babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. private _alignTangentsWithPath;
  4784. private readonly _pointAtData;
  4785. /**
  4786. * new Path3D(path, normal, raw)
  4787. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4788. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4789. * @param path an array of Vector3, the curve axis of the Path3D
  4790. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4791. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4792. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4793. */
  4794. constructor(
  4795. /**
  4796. * an array of Vector3, the curve axis of the Path3D
  4797. */
  4798. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4799. /**
  4800. * Returns the Path3D array of successive Vector3 designing its curve.
  4801. * @returns the Path3D array of successive Vector3 designing its curve.
  4802. */
  4803. getCurve(): Vector3[];
  4804. /**
  4805. * Returns the Path3D array of successive Vector3 designing its curve.
  4806. * @returns the Path3D array of successive Vector3 designing its curve.
  4807. */
  4808. getPoints(): Vector3[];
  4809. /**
  4810. * @returns the computed length (float) of the path.
  4811. */
  4812. length(): number;
  4813. /**
  4814. * Returns an array populated with tangent vectors on each Path3D curve point.
  4815. * @returns an array populated with tangent vectors on each Path3D curve point.
  4816. */
  4817. getTangents(): Vector3[];
  4818. /**
  4819. * Returns an array populated with normal vectors on each Path3D curve point.
  4820. * @returns an array populated with normal vectors on each Path3D curve point.
  4821. */
  4822. getNormals(): Vector3[];
  4823. /**
  4824. * Returns an array populated with binormal vectors on each Path3D curve point.
  4825. * @returns an array populated with binormal vectors on each Path3D curve point.
  4826. */
  4827. getBinormals(): Vector3[];
  4828. /**
  4829. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4830. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4831. */
  4832. getDistances(): number[];
  4833. /**
  4834. * Returns an interpolated point along this path
  4835. * @param position the position of the point along this path, from 0.0 to 1.0
  4836. * @returns a new Vector3 as the point
  4837. */
  4838. getPointAt(position: number): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4843. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4844. */
  4845. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4850. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4851. */
  4852. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4857. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4858. */
  4859. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4860. /**
  4861. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4864. */
  4865. getDistanceAt(position: number): number;
  4866. /**
  4867. * Returns the array index of the previous point of an interpolated point along this path
  4868. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4869. * @returns the array index
  4870. */
  4871. getPreviousPointIndexAt(position: number): number;
  4872. /**
  4873. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4874. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4875. * @returns the sub position
  4876. */
  4877. getSubPositionAt(position: number): number;
  4878. /**
  4879. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4880. * @param target the vector of which to get the closest position to
  4881. * @returns the position of the closest virtual point on this path to the target vector
  4882. */
  4883. getClosestPositionTo(target: Vector3): number;
  4884. /**
  4885. * Returns a sub path (slice) of this path
  4886. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4887. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4888. * @returns a sub path (slice) of this path
  4889. */
  4890. slice(start?: number, end?: number): Path3D;
  4891. /**
  4892. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4893. * @param path path which all values are copied into the curves points
  4894. * @param firstNormal which should be projected onto the curve
  4895. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4896. * @returns the same object updated.
  4897. */
  4898. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4899. private _compute;
  4900. private _getFirstNonNullVector;
  4901. private _getLastNonNullVector;
  4902. private _normalVector;
  4903. /**
  4904. * Updates the point at data for an interpolated point along this curve
  4905. * @param position the position of the point along this curve, from 0.0 to 1.0
  4906. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4907. * @returns the (updated) point at data
  4908. */
  4909. private _updatePointAtData;
  4910. /**
  4911. * Updates the point at data from the specified parameters
  4912. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4913. * @param point the interpolated point
  4914. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4915. */
  4916. private _setPointAtData;
  4917. /**
  4918. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4919. */
  4920. private _updateInterpolationMatrix;
  4921. }
  4922. /**
  4923. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4924. * A Curve3 is designed from a series of successive Vector3.
  4925. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4926. */
  4927. export class Curve3 {
  4928. private _points;
  4929. private _length;
  4930. /**
  4931. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4932. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4933. * @param v1 (Vector3) the control point
  4934. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4935. * @param nbPoints (integer) the wanted number of points in the curve
  4936. * @returns the created Curve3
  4937. */
  4938. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4939. /**
  4940. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4941. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4942. * @param v1 (Vector3) the first control point
  4943. * @param v2 (Vector3) the second control point
  4944. * @param v3 (Vector3) the end point of the Cubic Bezier
  4945. * @param nbPoints (integer) the wanted number of points in the curve
  4946. * @returns the created Curve3
  4947. */
  4948. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4949. /**
  4950. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4951. * @param p1 (Vector3) the origin point of the Hermite Spline
  4952. * @param t1 (Vector3) the tangent vector at the origin point
  4953. * @param p2 (Vector3) the end point of the Hermite Spline
  4954. * @param t2 (Vector3) the tangent vector at the end point
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a CatmullRom Spline curve :
  4961. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4962. * @param nbPoints (integer) the wanted number of points between each curve control points
  4963. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4964. * @returns the created Curve3
  4965. */
  4966. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4971. * @param points points which make up the curve
  4972. */
  4973. constructor(points: Vector3[]);
  4974. /**
  4975. * @returns the Curve3 stored array of successive Vector3
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the curve.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4984. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4985. * curveA and curveB keep unchanged.
  4986. * @param curve the curve to continue from this curve
  4987. * @returns the newly constructed curve
  4988. */
  4989. continue(curve: DeepImmutable<Curve3>): Curve3;
  4990. private _computeLength;
  4991. }
  4992. }
  4993. declare module "babylonjs/Animations/easing" {
  4994. /**
  4995. * This represents the main contract an easing function should follow.
  4996. * Easing functions are used throughout the animation system.
  4997. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4998. */
  4999. export interface IEasingFunction {
  5000. /**
  5001. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5002. * of the easing function.
  5003. * The link below provides some of the most common examples of easing functions.
  5004. * @see https://easings.net/
  5005. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5006. * @returns the corresponding value on the curve defined by the easing function
  5007. */
  5008. ease(gradient: number): number;
  5009. }
  5010. /**
  5011. * Base class used for every default easing function.
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class EasingFunction implements IEasingFunction {
  5015. /**
  5016. * Interpolation follows the mathematical formula associated with the easing function.
  5017. */
  5018. static readonly EASINGMODE_EASEIN: number;
  5019. /**
  5020. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5021. */
  5022. static readonly EASINGMODE_EASEOUT: number;
  5023. /**
  5024. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5025. */
  5026. static readonly EASINGMODE_EASEINOUT: number;
  5027. private _easingMode;
  5028. /**
  5029. * Sets the easing mode of the current function.
  5030. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5031. */
  5032. setEasingMode(easingMode: number): void;
  5033. /**
  5034. * Gets the current easing mode.
  5035. * @returns the easing mode
  5036. */
  5037. getEasingMode(): number;
  5038. /**
  5039. * @hidden
  5040. */
  5041. easeInCore(gradient: number): number;
  5042. /**
  5043. * Given an input gradient between 0 and 1, this returns the corresponding value
  5044. * of the easing function.
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Easing function with a circle shape (see link below).
  5052. * @see https://easings.net/#easeInCirc
  5053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5054. */
  5055. export class CircleEase extends EasingFunction implements IEasingFunction {
  5056. /** @hidden */
  5057. easeInCore(gradient: number): number;
  5058. }
  5059. /**
  5060. * Easing function with a ease back shape (see link below).
  5061. * @see https://easings.net/#easeInBack
  5062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5063. */
  5064. export class BackEase extends EasingFunction implements IEasingFunction {
  5065. /** Defines the amplitude of the function */
  5066. amplitude: number;
  5067. /**
  5068. * Instantiates a back ease easing
  5069. * @see https://easings.net/#easeInBack
  5070. * @param amplitude Defines the amplitude of the function
  5071. */
  5072. constructor(
  5073. /** Defines the amplitude of the function */
  5074. amplitude?: number);
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a bouncing shape (see link below).
  5080. * @see https://easings.net/#easeInBounce
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BounceEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the number of bounces */
  5085. bounces: number;
  5086. /** Defines the amplitude of the bounce */
  5087. bounciness: number;
  5088. /**
  5089. * Instantiates a bounce easing
  5090. * @see https://easings.net/#easeInBounce
  5091. * @param bounces Defines the number of bounces
  5092. * @param bounciness Defines the amplitude of the bounce
  5093. */
  5094. constructor(
  5095. /** Defines the number of bounces */
  5096. bounces?: number,
  5097. /** Defines the amplitude of the bounce */
  5098. bounciness?: number);
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 3 shape (see link below).
  5104. * @see https://easings.net/#easeInCubic
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class CubicEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with an elastic shape (see link below).
  5113. * @see https://easings.net/#easeInElastic
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5117. /** Defines the number of oscillations*/
  5118. oscillations: number;
  5119. /** Defines the amplitude of the oscillations*/
  5120. springiness: number;
  5121. /**
  5122. * Instantiates an elastic easing function
  5123. * @see https://easings.net/#easeInElastic
  5124. * @param oscillations Defines the number of oscillations
  5125. * @param springiness Defines the amplitude of the oscillations
  5126. */
  5127. constructor(
  5128. /** Defines the number of oscillations*/
  5129. oscillations?: number,
  5130. /** Defines the amplitude of the oscillations*/
  5131. springiness?: number);
  5132. /** @hidden */
  5133. easeInCore(gradient: number): number;
  5134. }
  5135. /**
  5136. * Easing function with an exponential shape (see link below).
  5137. * @see https://easings.net/#easeInExpo
  5138. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5139. */
  5140. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5141. /** Defines the exponent of the function */
  5142. exponent: number;
  5143. /**
  5144. * Instantiates an exponential easing function
  5145. * @see https://easings.net/#easeInExpo
  5146. * @param exponent Defines the exponent of the function
  5147. */
  5148. constructor(
  5149. /** Defines the exponent of the function */
  5150. exponent?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with a power shape (see link below).
  5156. * @see https://easings.net/#easeInQuad
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class PowerEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the power of the function */
  5161. power: number;
  5162. /**
  5163. * Instantiates an power base easing function
  5164. * @see https://easings.net/#easeInQuad
  5165. * @param power Defines the power of the function
  5166. */
  5167. constructor(
  5168. /** Defines the power of the function */
  5169. power?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 2 shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 4 shape (see link below).
  5184. * @see https://easings.net/#easeInQuart
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with a power of 5 shape (see link below).
  5193. * @see https://easings.net/#easeInQuint
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a sin shape (see link below).
  5202. * @see https://easings.net/#easeInSine
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class SineEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a bezier shape (see link below).
  5211. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the x component of the start tangent in the bezier curve */
  5216. x1: number;
  5217. /** Defines the y component of the start tangent in the bezier curve */
  5218. y1: number;
  5219. /** Defines the x component of the end tangent in the bezier curve */
  5220. x2: number;
  5221. /** Defines the y component of the end tangent in the bezier curve */
  5222. y2: number;
  5223. /**
  5224. * Instantiates a bezier function
  5225. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5226. * @param x1 Defines the x component of the start tangent in the bezier curve
  5227. * @param y1 Defines the y component of the start tangent in the bezier curve
  5228. * @param x2 Defines the x component of the end tangent in the bezier curve
  5229. * @param y2 Defines the y component of the end tangent in the bezier curve
  5230. */
  5231. constructor(
  5232. /** Defines the x component of the start tangent in the bezier curve */
  5233. x1?: number,
  5234. /** Defines the y component of the start tangent in the bezier curve */
  5235. y1?: number,
  5236. /** Defines the x component of the end tangent in the bezier curve */
  5237. x2?: number,
  5238. /** Defines the y component of the end tangent in the bezier curve */
  5239. y2?: number);
  5240. /** @hidden */
  5241. easeInCore(gradient: number): number;
  5242. }
  5243. }
  5244. declare module "babylonjs/Maths/math.color" {
  5245. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5246. /**
  5247. * Class used to hold a RBG color
  5248. */
  5249. export class Color3 {
  5250. /**
  5251. * Defines the red component (between 0 and 1, default is 0)
  5252. */
  5253. r: number;
  5254. /**
  5255. * Defines the green component (between 0 and 1, default is 0)
  5256. */
  5257. g: number;
  5258. /**
  5259. * Defines the blue component (between 0 and 1, default is 0)
  5260. */
  5261. b: number;
  5262. /**
  5263. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5264. * @param r defines the red component (between 0 and 1, default is 0)
  5265. * @param g defines the green component (between 0 and 1, default is 0)
  5266. * @param b defines the blue component (between 0 and 1, default is 0)
  5267. */
  5268. constructor(
  5269. /**
  5270. * Defines the red component (between 0 and 1, default is 0)
  5271. */
  5272. r?: number,
  5273. /**
  5274. * Defines the green component (between 0 and 1, default is 0)
  5275. */
  5276. g?: number,
  5277. /**
  5278. * Defines the blue component (between 0 and 1, default is 0)
  5279. */
  5280. b?: number);
  5281. /**
  5282. * Creates a string with the Color3 current values
  5283. * @returns the string representation of the Color3 object
  5284. */
  5285. toString(): string;
  5286. /**
  5287. * Returns the string "Color3"
  5288. * @returns "Color3"
  5289. */
  5290. getClassName(): string;
  5291. /**
  5292. * Compute the Color3 hash code
  5293. * @returns an unique number that can be used to hash Color3 objects
  5294. */
  5295. getHashCode(): number;
  5296. /**
  5297. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5298. * @param array defines the array where to store the r,g,b components
  5299. * @param index defines an optional index in the target array to define where to start storing values
  5300. * @returns the current Color3 object
  5301. */
  5302. toArray(array: FloatArray, index?: number): Color3;
  5303. /**
  5304. * Returns a new Color4 object from the current Color3 and the given alpha
  5305. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5306. * @returns a new Color4 object
  5307. */
  5308. toColor4(alpha?: number): Color4;
  5309. /**
  5310. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5311. * @returns the new array
  5312. */
  5313. asArray(): number[];
  5314. /**
  5315. * Returns the luminance value
  5316. * @returns a float value
  5317. */
  5318. toLuminance(): number;
  5319. /**
  5320. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5321. * @param otherColor defines the second operand
  5322. * @returns the new Color3 object
  5323. */
  5324. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5325. /**
  5326. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5327. * @param otherColor defines the second operand
  5328. * @param result defines the Color3 object where to store the result
  5329. * @returns the current Color3
  5330. */
  5331. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5332. /**
  5333. * Determines equality between Color3 objects
  5334. * @param otherColor defines the second operand
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equals(otherColor: DeepImmutable<Color3>): boolean;
  5338. /**
  5339. * Determines equality between the current Color3 object and a set of r,b,g values
  5340. * @param r defines the red component to check
  5341. * @param g defines the green component to check
  5342. * @param b defines the blue component to check
  5343. * @returns true if the rgb values are equal to the given ones
  5344. */
  5345. equalsFloats(r: number, g: number, b: number): boolean;
  5346. /**
  5347. * Multiplies in place each rgb value by scale
  5348. * @param scale defines the scaling factor
  5349. * @returns the updated Color3
  5350. */
  5351. scale(scale: number): Color3;
  5352. /**
  5353. * Multiplies the rgb values by scale and stores the result into "result"
  5354. * @param scale defines the scaling factor
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the unmodified current Color3
  5357. */
  5358. scaleToRef(scale: number, result: Color3): Color3;
  5359. /**
  5360. * Scale the current Color3 values by a factor and add the result to a given Color3
  5361. * @param scale defines the scale factor
  5362. * @param result defines color to store the result into
  5363. * @returns the unmodified current Color3
  5364. */
  5365. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5366. /**
  5367. * Clamps the rgb values by the min and max values and stores the result into "result"
  5368. * @param min defines minimum clamping value (default is 0)
  5369. * @param max defines maximum clamping value (default is 1)
  5370. * @param result defines color to store the result into
  5371. * @returns the original Color3
  5372. */
  5373. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5374. /**
  5375. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3
  5378. */
  5379. add(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines Color3 object to store the result into
  5384. * @returns the unmodified current Color3
  5385. */
  5386. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5389. * @param otherColor defines the second operand
  5390. * @returns the new Color3
  5391. */
  5392. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5393. /**
  5394. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5395. * @param otherColor defines the second operand
  5396. * @param result defines Color3 object to store the result into
  5397. * @returns the unmodified current Color3
  5398. */
  5399. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5400. /**
  5401. * Copy the current object
  5402. * @returns a new Color3 copied the current one
  5403. */
  5404. clone(): Color3;
  5405. /**
  5406. * Copies the rgb values from the source in the current Color3
  5407. * @param source defines the source Color3 object
  5408. * @returns the updated Color3 object
  5409. */
  5410. copyFrom(source: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. copyFromFloats(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Updates the Color3 rgb values from the given floats
  5421. * @param r defines the red component to read from
  5422. * @param g defines the green component to read from
  5423. * @param b defines the blue component to read from
  5424. * @returns the current Color3 object
  5425. */
  5426. set(r: number, g: number, b: number): Color3;
  5427. /**
  5428. * Compute the Color3 hexadecimal code as a string
  5429. * @returns a string containing the hexadecimal representation of the Color3 object
  5430. */
  5431. toHexString(): string;
  5432. /**
  5433. * Computes a new Color3 converted from the current one to linear space
  5434. * @returns a new Color3 object
  5435. */
  5436. toLinearSpace(): Color3;
  5437. /**
  5438. * Converts current color in rgb space to HSV values
  5439. * @returns a new color3 representing the HSV values
  5440. */
  5441. toHSV(): Color3;
  5442. /**
  5443. * Converts current color in rgb space to HSV values
  5444. * @param result defines the Color3 where to store the HSV values
  5445. */
  5446. toHSVToRef(result: Color3): void;
  5447. /**
  5448. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5449. * @param convertedColor defines the Color3 object where to store the linear space version
  5450. * @returns the unmodified Color3
  5451. */
  5452. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5453. /**
  5454. * Computes a new Color3 converted from the current one to gamma space
  5455. * @returns a new Color3 object
  5456. */
  5457. toGammaSpace(): Color3;
  5458. /**
  5459. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5460. * @param convertedColor defines the Color3 object where to store the gamma space version
  5461. * @returns the unmodified Color3
  5462. */
  5463. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5464. private static _BlackReadOnly;
  5465. /**
  5466. * Convert Hue, saturation and value to a Color3 (RGB)
  5467. * @param hue defines the hue
  5468. * @param saturation defines the saturation
  5469. * @param value defines the value
  5470. * @param result defines the Color3 where to store the RGB values
  5471. */
  5472. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5473. /**
  5474. * Creates a new Color3 from the string containing valid hexadecimal values
  5475. * @param hex defines a string containing valid hexadecimal values
  5476. * @returns a new Color3 object
  5477. */
  5478. static FromHexString(hex: string): Color3;
  5479. /**
  5480. * Creates a new Color3 from the starting index of the given array
  5481. * @param array defines the source array
  5482. * @param offset defines an offset in the source array
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5486. /**
  5487. * Creates a new Color3 from integer values (< 256)
  5488. * @param r defines the red component to read from (value between 0 and 255)
  5489. * @param g defines the green component to read from (value between 0 and 255)
  5490. * @param b defines the blue component to read from (value between 0 and 255)
  5491. * @returns a new Color3 object
  5492. */
  5493. static FromInts(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param start defines the start Color3 value
  5497. * @param end defines the end Color3 value
  5498. * @param amount defines the gradient value between start and end
  5499. * @returns a new Color3 object
  5500. */
  5501. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5502. /**
  5503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5504. * @param left defines the start value
  5505. * @param right defines the end value
  5506. * @param amount defines the gradient factor
  5507. * @param result defines the Color3 object where to store the result
  5508. */
  5509. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5510. /**
  5511. * Returns a Color3 value containing a red color
  5512. * @returns a new Color3 object
  5513. */
  5514. static Red(): Color3;
  5515. /**
  5516. * Returns a Color3 value containing a green color
  5517. * @returns a new Color3 object
  5518. */
  5519. static Green(): Color3;
  5520. /**
  5521. * Returns a Color3 value containing a blue color
  5522. * @returns a new Color3 object
  5523. */
  5524. static Blue(): Color3;
  5525. /**
  5526. * Returns a Color3 value containing a black color
  5527. * @returns a new Color3 object
  5528. */
  5529. static Black(): Color3;
  5530. /**
  5531. * Gets a Color3 value containing a black color that must not be updated
  5532. */
  5533. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5534. /**
  5535. * Returns a Color3 value containing a white color
  5536. * @returns a new Color3 object
  5537. */
  5538. static White(): Color3;
  5539. /**
  5540. * Returns a Color3 value containing a purple color
  5541. * @returns a new Color3 object
  5542. */
  5543. static Purple(): Color3;
  5544. /**
  5545. * Returns a Color3 value containing a magenta color
  5546. * @returns a new Color3 object
  5547. */
  5548. static Magenta(): Color3;
  5549. /**
  5550. * Returns a Color3 value containing a yellow color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Yellow(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a gray color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Gray(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a teal color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Teal(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a random color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Random(): Color3;
  5569. }
  5570. /**
  5571. * Class used to hold a RBGA color
  5572. */
  5573. export class Color4 {
  5574. /**
  5575. * Defines the red component (between 0 and 1, default is 0)
  5576. */
  5577. r: number;
  5578. /**
  5579. * Defines the green component (between 0 and 1, default is 0)
  5580. */
  5581. g: number;
  5582. /**
  5583. * Defines the blue component (between 0 and 1, default is 0)
  5584. */
  5585. b: number;
  5586. /**
  5587. * Defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. a: number;
  5590. /**
  5591. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5592. * @param r defines the red component (between 0 and 1, default is 0)
  5593. * @param g defines the green component (between 0 and 1, default is 0)
  5594. * @param b defines the blue component (between 0 and 1, default is 0)
  5595. * @param a defines the alpha component (between 0 and 1, default is 1)
  5596. */
  5597. constructor(
  5598. /**
  5599. * Defines the red component (between 0 and 1, default is 0)
  5600. */
  5601. r?: number,
  5602. /**
  5603. * Defines the green component (between 0 and 1, default is 0)
  5604. */
  5605. g?: number,
  5606. /**
  5607. * Defines the blue component (between 0 and 1, default is 0)
  5608. */
  5609. b?: number,
  5610. /**
  5611. * Defines the alpha component (between 0 and 1, default is 1)
  5612. */
  5613. a?: number);
  5614. /**
  5615. * Adds in place the given Color4 values to the current Color4 object
  5616. * @param right defines the second operand
  5617. * @returns the current updated Color4 object
  5618. */
  5619. addInPlace(right: DeepImmutable<Color4>): Color4;
  5620. /**
  5621. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5622. * @returns the new array
  5623. */
  5624. asArray(): number[];
  5625. /**
  5626. * Stores from the starting index in the given array the Color4 successive values
  5627. * @param array defines the array where to store the r,g,b components
  5628. * @param index defines an optional index in the target array to define where to start storing values
  5629. * @returns the current Color4 object
  5630. */
  5631. toArray(array: number[], index?: number): Color4;
  5632. /**
  5633. * Determines equality between Color4 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgba values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color4>): boolean;
  5638. /**
  5639. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5640. * @param right defines the second operand
  5641. * @returns a new Color4 object
  5642. */
  5643. add(right: DeepImmutable<Color4>): Color4;
  5644. /**
  5645. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5646. * @param right defines the second operand
  5647. * @returns a new Color4 object
  5648. */
  5649. subtract(right: DeepImmutable<Color4>): Color4;
  5650. /**
  5651. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5652. * @param right defines the second operand
  5653. * @param result defines the Color4 object where to store the result
  5654. * @returns the current Color4 object
  5655. */
  5656. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5657. /**
  5658. * Creates a new Color4 with the current Color4 values multiplied by scale
  5659. * @param scale defines the scaling factor to apply
  5660. * @returns a new Color4 object
  5661. */
  5662. scale(scale: number): Color4;
  5663. /**
  5664. * Multiplies the current Color4 values by scale and stores the result in "result"
  5665. * @param scale defines the scaling factor to apply
  5666. * @param result defines the Color4 object where to store the result
  5667. * @returns the current unmodified Color4
  5668. */
  5669. scaleToRef(scale: number, result: Color4): Color4;
  5670. /**
  5671. * Scale the current Color4 values by a factor and add the result to a given Color4
  5672. * @param scale defines the scale factor
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the unmodified current Color4
  5675. */
  5676. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5677. /**
  5678. * Clamps the rgb values by the min and max values and stores the result into "result"
  5679. * @param min defines minimum clamping value (default is 0)
  5680. * @param max defines maximum clamping value (default is 1)
  5681. * @param result defines color to store the result into.
  5682. * @returns the cuurent Color4
  5683. */
  5684. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5685. /**
  5686. * Multipy an Color4 value by another and return a new Color4 object
  5687. * @param color defines the Color4 value to multiply by
  5688. * @returns a new Color4 object
  5689. */
  5690. multiply(color: Color4): Color4;
  5691. /**
  5692. * Multipy a Color4 value by another and push the result in a reference value
  5693. * @param color defines the Color4 value to multiply by
  5694. * @param result defines the Color4 to fill the result in
  5695. * @returns the result Color4
  5696. */
  5697. multiplyToRef(color: Color4, result: Color4): Color4;
  5698. /**
  5699. * Creates a string with the Color4 current values
  5700. * @returns the string representation of the Color4 object
  5701. */
  5702. toString(): string;
  5703. /**
  5704. * Returns the string "Color4"
  5705. * @returns "Color4"
  5706. */
  5707. getClassName(): string;
  5708. /**
  5709. * Compute the Color4 hash code
  5710. * @returns an unique number that can be used to hash Color4 objects
  5711. */
  5712. getHashCode(): number;
  5713. /**
  5714. * Creates a new Color4 copied from the current one
  5715. * @returns a new Color4 object
  5716. */
  5717. clone(): Color4;
  5718. /**
  5719. * Copies the given Color4 values into the current one
  5720. * @param source defines the source Color4 object
  5721. * @returns the current updated Color4 object
  5722. */
  5723. copyFrom(source: Color4): Color4;
  5724. /**
  5725. * Copies the given float values into the current one
  5726. * @param r defines the red component to read from
  5727. * @param g defines the green component to read from
  5728. * @param b defines the blue component to read from
  5729. * @param a defines the alpha component to read from
  5730. * @returns the current updated Color4 object
  5731. */
  5732. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5733. /**
  5734. * Copies the given float values into the current one
  5735. * @param r defines the red component to read from
  5736. * @param g defines the green component to read from
  5737. * @param b defines the blue component to read from
  5738. * @param a defines the alpha component to read from
  5739. * @returns the current updated Color4 object
  5740. */
  5741. set(r: number, g: number, b: number, a: number): Color4;
  5742. /**
  5743. * Compute the Color4 hexadecimal code as a string
  5744. * @returns a string containing the hexadecimal representation of the Color4 object
  5745. */
  5746. toHexString(): string;
  5747. /**
  5748. * Computes a new Color4 converted from the current one to linear space
  5749. * @returns a new Color4 object
  5750. */
  5751. toLinearSpace(): Color4;
  5752. /**
  5753. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5754. * @param convertedColor defines the Color4 object where to store the linear space version
  5755. * @returns the unmodified Color4
  5756. */
  5757. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5758. /**
  5759. * Computes a new Color4 converted from the current one to gamma space
  5760. * @returns a new Color4 object
  5761. */
  5762. toGammaSpace(): Color4;
  5763. /**
  5764. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5765. * @param convertedColor defines the Color4 object where to store the gamma space version
  5766. * @returns the unmodified Color4
  5767. */
  5768. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5769. /**
  5770. * Creates a new Color4 from the string containing valid hexadecimal values
  5771. * @param hex defines a string containing valid hexadecimal values
  5772. * @returns a new Color4 object
  5773. */
  5774. static FromHexString(hex: string): Color4;
  5775. /**
  5776. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @returns a new Color4 object
  5781. */
  5782. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5783. /**
  5784. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5785. * @param left defines the start value
  5786. * @param right defines the end value
  5787. * @param amount defines the gradient factor
  5788. * @param result defines the Color4 object where to store data
  5789. */
  5790. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5791. /**
  5792. * Creates a new Color4 from a Color3 and an alpha value
  5793. * @param color3 defines the source Color3 to read from
  5794. * @param alpha defines the alpha component (1.0 by default)
  5795. * @returns a new Color4 object
  5796. */
  5797. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5798. /**
  5799. * Creates a new Color4 from the starting index element of the given array
  5800. * @param array defines the source array to read from
  5801. * @param offset defines the offset in the source array
  5802. * @returns a new Color4 object
  5803. */
  5804. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5805. /**
  5806. * Creates a new Color3 from integer values (< 256)
  5807. * @param r defines the red component to read from (value between 0 and 255)
  5808. * @param g defines the green component to read from (value between 0 and 255)
  5809. * @param b defines the blue component to read from (value between 0 and 255)
  5810. * @param a defines the alpha component to read from (value between 0 and 255)
  5811. * @returns a new Color3 object
  5812. */
  5813. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5814. /**
  5815. * Check the content of a given array and convert it to an array containing RGBA data
  5816. * If the original array was already containing count * 4 values then it is returned directly
  5817. * @param colors defines the array to check
  5818. * @param count defines the number of RGBA data to expect
  5819. * @returns an array containing count * 4 values (RGBA)
  5820. */
  5821. static CheckColors4(colors: number[], count: number): number[];
  5822. }
  5823. /**
  5824. * @hidden
  5825. */
  5826. export class TmpColors {
  5827. static Color3: Color3[];
  5828. static Color4: Color4[];
  5829. }
  5830. }
  5831. declare module "babylonjs/Animations/animationKey" {
  5832. /**
  5833. * Defines an interface which represents an animation key frame
  5834. */
  5835. export interface IAnimationKey {
  5836. /**
  5837. * Frame of the key frame
  5838. */
  5839. frame: number;
  5840. /**
  5841. * Value at the specifies key frame
  5842. */
  5843. value: any;
  5844. /**
  5845. * The input tangent for the cubic hermite spline
  5846. */
  5847. inTangent?: any;
  5848. /**
  5849. * The output tangent for the cubic hermite spline
  5850. */
  5851. outTangent?: any;
  5852. /**
  5853. * The animation interpolation type
  5854. */
  5855. interpolation?: AnimationKeyInterpolation;
  5856. }
  5857. /**
  5858. * Enum for the animation key frame interpolation type
  5859. */
  5860. export enum AnimationKeyInterpolation {
  5861. /**
  5862. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5863. */
  5864. STEP = 1
  5865. }
  5866. }
  5867. declare module "babylonjs/Animations/animationRange" {
  5868. /**
  5869. * Represents the range of an animation
  5870. */
  5871. export class AnimationRange {
  5872. /**The name of the animation range**/
  5873. name: string;
  5874. /**The starting frame of the animation */
  5875. from: number;
  5876. /**The ending frame of the animation*/
  5877. to: number;
  5878. /**
  5879. * Initializes the range of an animation
  5880. * @param name The name of the animation range
  5881. * @param from The starting frame of the animation
  5882. * @param to The ending frame of the animation
  5883. */
  5884. constructor(
  5885. /**The name of the animation range**/
  5886. name: string,
  5887. /**The starting frame of the animation */
  5888. from: number,
  5889. /**The ending frame of the animation*/
  5890. to: number);
  5891. /**
  5892. * Makes a copy of the animation range
  5893. * @returns A copy of the animation range
  5894. */
  5895. clone(): AnimationRange;
  5896. }
  5897. }
  5898. declare module "babylonjs/Animations/animationEvent" {
  5899. /**
  5900. * Composed of a frame, and an action function
  5901. */
  5902. export class AnimationEvent {
  5903. /** The frame for which the event is triggered **/
  5904. frame: number;
  5905. /** The event to perform when triggered **/
  5906. action: (currentFrame: number) => void;
  5907. /** Specifies if the event should be triggered only once**/
  5908. onlyOnce?: boolean | undefined;
  5909. /**
  5910. * Specifies if the animation event is done
  5911. */
  5912. isDone: boolean;
  5913. /**
  5914. * Initializes the animation event
  5915. * @param frame The frame for which the event is triggered
  5916. * @param action The event to perform when triggered
  5917. * @param onlyOnce Specifies if the event should be triggered only once
  5918. */
  5919. constructor(
  5920. /** The frame for which the event is triggered **/
  5921. frame: number,
  5922. /** The event to perform when triggered **/
  5923. action: (currentFrame: number) => void,
  5924. /** Specifies if the event should be triggered only once**/
  5925. onlyOnce?: boolean | undefined);
  5926. /** @hidden */
  5927. _clone(): AnimationEvent;
  5928. }
  5929. }
  5930. declare module "babylonjs/Behaviors/behavior" {
  5931. import { Nullable } from "babylonjs/types";
  5932. /**
  5933. * Interface used to define a behavior
  5934. */
  5935. export interface Behavior<T> {
  5936. /** gets or sets behavior's name */
  5937. name: string;
  5938. /**
  5939. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5940. */
  5941. init(): void;
  5942. /**
  5943. * Called when the behavior is attached to a target
  5944. * @param target defines the target where the behavior is attached to
  5945. */
  5946. attach(target: T): void;
  5947. /**
  5948. * Called when the behavior is detached from its target
  5949. */
  5950. detach(): void;
  5951. }
  5952. /**
  5953. * Interface implemented by classes supporting behaviors
  5954. */
  5955. export interface IBehaviorAware<T> {
  5956. /**
  5957. * Attach a behavior
  5958. * @param behavior defines the behavior to attach
  5959. * @returns the current host
  5960. */
  5961. addBehavior(behavior: Behavior<T>): T;
  5962. /**
  5963. * Remove a behavior from the current object
  5964. * @param behavior defines the behavior to detach
  5965. * @returns the current host
  5966. */
  5967. removeBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Gets a behavior using its name to search
  5970. * @param name defines the name to search
  5971. * @returns the behavior or null if not found
  5972. */
  5973. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5974. }
  5975. }
  5976. declare module "babylonjs/Misc/smartArray" {
  5977. /**
  5978. * Defines an array and its length.
  5979. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5980. */
  5981. export interface ISmartArrayLike<T> {
  5982. /**
  5983. * The data of the array.
  5984. */
  5985. data: Array<T>;
  5986. /**
  5987. * The active length of the array.
  5988. */
  5989. length: number;
  5990. }
  5991. /**
  5992. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5993. */
  5994. export class SmartArray<T> implements ISmartArrayLike<T> {
  5995. /**
  5996. * The full set of data from the array.
  5997. */
  5998. data: Array<T>;
  5999. /**
  6000. * The active length of the array.
  6001. */
  6002. length: number;
  6003. protected _id: number;
  6004. /**
  6005. * Instantiates a Smart Array.
  6006. * @param capacity defines the default capacity of the array.
  6007. */
  6008. constructor(capacity: number);
  6009. /**
  6010. * Pushes a value at the end of the active data.
  6011. * @param value defines the object to push in the array.
  6012. */
  6013. push(value: T): void;
  6014. /**
  6015. * Iterates over the active data and apply the lambda to them.
  6016. * @param func defines the action to apply on each value.
  6017. */
  6018. forEach(func: (content: T) => void): void;
  6019. /**
  6020. * Sorts the full sets of data.
  6021. * @param compareFn defines the comparison function to apply.
  6022. */
  6023. sort(compareFn: (a: T, b: T) => number): void;
  6024. /**
  6025. * Resets the active data to an empty array.
  6026. */
  6027. reset(): void;
  6028. /**
  6029. * Releases all the data from the array as well as the array.
  6030. */
  6031. dispose(): void;
  6032. /**
  6033. * Concats the active data with a given array.
  6034. * @param array defines the data to concatenate with.
  6035. */
  6036. concat(array: any): void;
  6037. /**
  6038. * Returns the position of a value in the active data.
  6039. * @param value defines the value to find the index for
  6040. * @returns the index if found in the active data otherwise -1
  6041. */
  6042. indexOf(value: T): number;
  6043. /**
  6044. * Returns whether an element is part of the active data.
  6045. * @param value defines the value to look for
  6046. * @returns true if found in the active data otherwise false
  6047. */
  6048. contains(value: T): boolean;
  6049. private static _GlobalId;
  6050. }
  6051. /**
  6052. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6053. * The data in this array can only be present once
  6054. */
  6055. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6056. private _duplicateId;
  6057. /**
  6058. * Pushes a value at the end of the active data.
  6059. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6060. * @param value defines the object to push in the array.
  6061. */
  6062. push(value: T): void;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * If the data is already present, it won t be added again
  6066. * @param value defines the object to push in the array.
  6067. * @returns true if added false if it was already present
  6068. */
  6069. pushNoDuplicate(value: T): boolean;
  6070. /**
  6071. * Resets the active data to an empty array.
  6072. */
  6073. reset(): void;
  6074. /**
  6075. * Concats the active data with a given array.
  6076. * This ensures no dupplicate will be present in the result.
  6077. * @param array defines the data to concatenate with.
  6078. */
  6079. concatWithNoDuplicate(array: any): void;
  6080. }
  6081. }
  6082. declare module "babylonjs/Cameras/cameraInputsManager" {
  6083. import { Nullable } from "babylonjs/types";
  6084. import { Camera } from "babylonjs/Cameras/camera";
  6085. /**
  6086. * @ignore
  6087. * This is a list of all the different input types that are available in the application.
  6088. * Fo instance: ArcRotateCameraGamepadInput...
  6089. */
  6090. export var CameraInputTypes: {};
  6091. /**
  6092. * This is the contract to implement in order to create a new input class.
  6093. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6094. */
  6095. export interface ICameraInput<TCamera extends Camera> {
  6096. /**
  6097. * Defines the camera the input is attached to.
  6098. */
  6099. camera: Nullable<TCamera>;
  6100. /**
  6101. * Gets the class name of the current intput.
  6102. * @returns the class name
  6103. */
  6104. getClassName(): string;
  6105. /**
  6106. * Get the friendly name associated with the input class.
  6107. * @returns the input friendly name
  6108. */
  6109. getSimpleName(): string;
  6110. /**
  6111. * Attach the input controls to a specific dom element to get the input from.
  6112. * @param element Defines the element the controls should be listened from
  6113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6114. */
  6115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6116. /**
  6117. * Detach the current controls from the specified dom element.
  6118. * @param element Defines the element to stop listening the inputs from
  6119. */
  6120. detachControl(element: Nullable<HTMLElement>): void;
  6121. /**
  6122. * Update the current camera state depending on the inputs that have been used this frame.
  6123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6124. */
  6125. checkInputs?: () => void;
  6126. }
  6127. /**
  6128. * Represents a map of input types to input instance or input index to input instance.
  6129. */
  6130. export interface CameraInputsMap<TCamera extends Camera> {
  6131. /**
  6132. * Accessor to the input by input type.
  6133. */
  6134. [name: string]: ICameraInput<TCamera>;
  6135. /**
  6136. * Accessor to the input by input index.
  6137. */
  6138. [idx: number]: ICameraInput<TCamera>;
  6139. }
  6140. /**
  6141. * This represents the input manager used within a camera.
  6142. * It helps dealing with all the different kind of input attached to a camera.
  6143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6144. */
  6145. export class CameraInputsManager<TCamera extends Camera> {
  6146. /**
  6147. * Defines the list of inputs attahed to the camera.
  6148. */
  6149. attached: CameraInputsMap<TCamera>;
  6150. /**
  6151. * Defines the dom element the camera is collecting inputs from.
  6152. * This is null if the controls have not been attached.
  6153. */
  6154. attachedElement: Nullable<HTMLElement>;
  6155. /**
  6156. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. noPreventDefault: boolean;
  6159. /**
  6160. * Defined the camera the input manager belongs to.
  6161. */
  6162. camera: TCamera;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs: () => void;
  6168. /**
  6169. * Instantiate a new Camera Input Manager.
  6170. * @param camera Defines the camera the input manager blongs to
  6171. */
  6172. constructor(camera: TCamera);
  6173. /**
  6174. * Add an input method to a camera
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. * @param input camera input method
  6177. */
  6178. add(input: ICameraInput<TCamera>): void;
  6179. /**
  6180. * Remove a specific input method from a camera
  6181. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6182. * @param inputToRemove camera input method
  6183. */
  6184. remove(inputToRemove: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input type from a camera
  6187. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6188. * @param inputType the type of the input to remove
  6189. */
  6190. removeByType(inputType: string): void;
  6191. private _addCheckInputs;
  6192. /**
  6193. * Attach the input controls to the currently attached dom element to listen the events from.
  6194. * @param input Defines the input to attach
  6195. */
  6196. attachInput(input: ICameraInput<TCamera>): void;
  6197. /**
  6198. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6199. * @param element Defines the dom element to collect the events from
  6200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6201. */
  6202. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6203. /**
  6204. * Detach the current manager inputs controls from a specific dom element.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6207. */
  6208. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6209. /**
  6210. * Rebuild the dynamic inputCheck function from the current list of
  6211. * defined inputs in the manager.
  6212. */
  6213. rebuildInputCheck(): void;
  6214. /**
  6215. * Remove all attached input methods from a camera
  6216. */
  6217. clear(): void;
  6218. /**
  6219. * Serialize the current input manager attached to a camera.
  6220. * This ensures than once parsed,
  6221. * the input associated to the camera will be identical to the current ones
  6222. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6223. */
  6224. serialize(serializedCamera: any): void;
  6225. /**
  6226. * Parses an input manager serialized JSON to restore the previous list of inputs
  6227. * and states associated to a camera.
  6228. * @param parsedCamera Defines the JSON to parse
  6229. */
  6230. parse(parsedCamera: any): void;
  6231. }
  6232. }
  6233. declare module "babylonjs/Meshes/buffer" {
  6234. import { Nullable, DataArray } from "babylonjs/types";
  6235. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6236. /**
  6237. * Class used to store data that will be store in GPU memory
  6238. */
  6239. export class Buffer {
  6240. private _engine;
  6241. private _buffer;
  6242. /** @hidden */
  6243. _data: Nullable<DataArray>;
  6244. private _updatable;
  6245. private _instanced;
  6246. private _divisor;
  6247. /**
  6248. * Gets the byte stride.
  6249. */
  6250. readonly byteStride: number;
  6251. /**
  6252. * Constructor
  6253. * @param engine the engine
  6254. * @param data the data to use for this buffer
  6255. * @param updatable whether the data is updatable
  6256. * @param stride the stride (optional)
  6257. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6258. * @param instanced whether the buffer is instanced (optional)
  6259. * @param useBytes set to true if the stride in in bytes (optional)
  6260. * @param divisor sets an optional divisor for instances (1 by default)
  6261. */
  6262. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6263. /**
  6264. * Create a new VertexBuffer based on the current buffer
  6265. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6266. * @param offset defines offset in the buffer (0 by default)
  6267. * @param size defines the size in floats of attributes (position is 3 for instance)
  6268. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6269. * @param instanced defines if the vertex buffer contains indexed data
  6270. * @param useBytes defines if the offset and stride are in bytes *
  6271. * @param divisor sets an optional divisor for instances (1 by default)
  6272. * @returns the new vertex buffer
  6273. */
  6274. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6275. /**
  6276. * Gets a boolean indicating if the Buffer is updatable?
  6277. * @returns true if the buffer is updatable
  6278. */
  6279. isUpdatable(): boolean;
  6280. /**
  6281. * Gets current buffer's data
  6282. * @returns a DataArray or null
  6283. */
  6284. getData(): Nullable<DataArray>;
  6285. /**
  6286. * Gets underlying native buffer
  6287. * @returns underlying native buffer
  6288. */
  6289. getBuffer(): Nullable<DataBuffer>;
  6290. /**
  6291. * Gets the stride in float32 units (i.e. byte stride / 4).
  6292. * May not be an integer if the byte stride is not divisible by 4.
  6293. * DEPRECATED. Use byteStride instead.
  6294. * @returns the stride in float32 units
  6295. */
  6296. getStrideSize(): number;
  6297. /**
  6298. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6299. * @param data defines the data to store
  6300. */
  6301. create(data?: Nullable<DataArray>): void;
  6302. /** @hidden */
  6303. _rebuild(): void;
  6304. /**
  6305. * Update current buffer data
  6306. * @param data defines the data to store
  6307. */
  6308. update(data: DataArray): void;
  6309. /**
  6310. * Updates the data directly.
  6311. * @param data the new data
  6312. * @param offset the new offset
  6313. * @param vertexCount the vertex count (optional)
  6314. * @param useBytes set to true if the offset is in bytes
  6315. */
  6316. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6317. /**
  6318. * Release all resources
  6319. */
  6320. dispose(): void;
  6321. }
  6322. /**
  6323. * Specialized buffer used to store vertex data
  6324. */
  6325. export class VertexBuffer {
  6326. /** @hidden */
  6327. _buffer: Buffer;
  6328. private _kind;
  6329. private _size;
  6330. private _ownsBuffer;
  6331. private _instanced;
  6332. private _instanceDivisor;
  6333. /**
  6334. * The byte type.
  6335. */
  6336. static readonly BYTE: number;
  6337. /**
  6338. * The unsigned byte type.
  6339. */
  6340. static readonly UNSIGNED_BYTE: number;
  6341. /**
  6342. * The short type.
  6343. */
  6344. static readonly SHORT: number;
  6345. /**
  6346. * The unsigned short type.
  6347. */
  6348. static readonly UNSIGNED_SHORT: number;
  6349. /**
  6350. * The integer type.
  6351. */
  6352. static readonly INT: number;
  6353. /**
  6354. * The unsigned integer type.
  6355. */
  6356. static readonly UNSIGNED_INT: number;
  6357. /**
  6358. * The float type.
  6359. */
  6360. static readonly FLOAT: number;
  6361. /**
  6362. * Gets or sets the instance divisor when in instanced mode
  6363. */
  6364. instanceDivisor: number;
  6365. /**
  6366. * Gets the byte stride.
  6367. */
  6368. readonly byteStride: number;
  6369. /**
  6370. * Gets the byte offset.
  6371. */
  6372. readonly byteOffset: number;
  6373. /**
  6374. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6375. */
  6376. readonly normalized: boolean;
  6377. /**
  6378. * Gets the data type of each component in the array.
  6379. */
  6380. readonly type: number;
  6381. /**
  6382. * Constructor
  6383. * @param engine the engine
  6384. * @param data the data to use for this vertex buffer
  6385. * @param kind the vertex buffer kind
  6386. * @param updatable whether the data is updatable
  6387. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6388. * @param stride the stride (optional)
  6389. * @param instanced whether the buffer is instanced (optional)
  6390. * @param offset the offset of the data (optional)
  6391. * @param size the number of components (optional)
  6392. * @param type the type of the component (optional)
  6393. * @param normalized whether the data contains normalized data (optional)
  6394. * @param useBytes set to true if stride and offset are in bytes (optional)
  6395. * @param divisor defines the instance divisor to use (1 by default)
  6396. */
  6397. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6398. /** @hidden */
  6399. _rebuild(): void;
  6400. /**
  6401. * Returns the kind of the VertexBuffer (string)
  6402. * @returns a string
  6403. */
  6404. getKind(): string;
  6405. /**
  6406. * Gets a boolean indicating if the VertexBuffer is updatable?
  6407. * @returns true if the buffer is updatable
  6408. */
  6409. isUpdatable(): boolean;
  6410. /**
  6411. * Gets current buffer's data
  6412. * @returns a DataArray or null
  6413. */
  6414. getData(): Nullable<DataArray>;
  6415. /**
  6416. * Gets underlying native buffer
  6417. * @returns underlying native buffer
  6418. */
  6419. getBuffer(): Nullable<DataBuffer>;
  6420. /**
  6421. * Gets the stride in float32 units (i.e. byte stride / 4).
  6422. * May not be an integer if the byte stride is not divisible by 4.
  6423. * DEPRECATED. Use byteStride instead.
  6424. * @returns the stride in float32 units
  6425. */
  6426. getStrideSize(): number;
  6427. /**
  6428. * Returns the offset as a multiple of the type byte length.
  6429. * DEPRECATED. Use byteOffset instead.
  6430. * @returns the offset in bytes
  6431. */
  6432. getOffset(): number;
  6433. /**
  6434. * Returns the number of components per vertex attribute (integer)
  6435. * @returns the size in float
  6436. */
  6437. getSize(): number;
  6438. /**
  6439. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6440. * @returns true if this buffer is instanced
  6441. */
  6442. getIsInstanced(): boolean;
  6443. /**
  6444. * Returns the instancing divisor, zero for non-instanced (integer).
  6445. * @returns a number
  6446. */
  6447. getInstanceDivisor(): number;
  6448. /**
  6449. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6450. * @param data defines the data to store
  6451. */
  6452. create(data?: DataArray): void;
  6453. /**
  6454. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6455. * This function will create a new buffer if the current one is not updatable
  6456. * @param data defines the data to store
  6457. */
  6458. update(data: DataArray): void;
  6459. /**
  6460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6461. * Returns the directly updated WebGLBuffer.
  6462. * @param data the new data
  6463. * @param offset the new offset
  6464. * @param useBytes set to true if the offset is in bytes
  6465. */
  6466. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6467. /**
  6468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6469. */
  6470. dispose(): void;
  6471. /**
  6472. * Enumerates each value of this vertex buffer as numbers.
  6473. * @param count the number of values to enumerate
  6474. * @param callback the callback function called for each value
  6475. */
  6476. forEach(count: number, callback: (value: number, index: number) => void): void;
  6477. /**
  6478. * Positions
  6479. */
  6480. static readonly PositionKind: string;
  6481. /**
  6482. * Normals
  6483. */
  6484. static readonly NormalKind: string;
  6485. /**
  6486. * Tangents
  6487. */
  6488. static readonly TangentKind: string;
  6489. /**
  6490. * Texture coordinates
  6491. */
  6492. static readonly UVKind: string;
  6493. /**
  6494. * Texture coordinates 2
  6495. */
  6496. static readonly UV2Kind: string;
  6497. /**
  6498. * Texture coordinates 3
  6499. */
  6500. static readonly UV3Kind: string;
  6501. /**
  6502. * Texture coordinates 4
  6503. */
  6504. static readonly UV4Kind: string;
  6505. /**
  6506. * Texture coordinates 5
  6507. */
  6508. static readonly UV5Kind: string;
  6509. /**
  6510. * Texture coordinates 6
  6511. */
  6512. static readonly UV6Kind: string;
  6513. /**
  6514. * Colors
  6515. */
  6516. static readonly ColorKind: string;
  6517. /**
  6518. * Matrix indices (for bones)
  6519. */
  6520. static readonly MatricesIndicesKind: string;
  6521. /**
  6522. * Matrix weights (for bones)
  6523. */
  6524. static readonly MatricesWeightsKind: string;
  6525. /**
  6526. * Additional matrix indices (for bones)
  6527. */
  6528. static readonly MatricesIndicesExtraKind: string;
  6529. /**
  6530. * Additional matrix weights (for bones)
  6531. */
  6532. static readonly MatricesWeightsExtraKind: string;
  6533. /**
  6534. * Deduces the stride given a kind.
  6535. * @param kind The kind string to deduce
  6536. * @returns The deduced stride
  6537. */
  6538. static DeduceStride(kind: string): number;
  6539. /**
  6540. * Gets the byte length of the given type.
  6541. * @param type the type
  6542. * @returns the number of bytes
  6543. */
  6544. static GetTypeByteLength(type: number): number;
  6545. /**
  6546. * Enumerates each value of the given parameters as numbers.
  6547. * @param data the data to enumerate
  6548. * @param byteOffset the byte offset of the data
  6549. * @param byteStride the byte stride of the data
  6550. * @param componentCount the number of components per element
  6551. * @param componentType the type of the component
  6552. * @param count the number of values to enumerate
  6553. * @param normalized whether the data is normalized
  6554. * @param callback the callback function called for each value
  6555. */
  6556. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6557. private static _GetFloatValue;
  6558. }
  6559. }
  6560. declare module "babylonjs/Collisions/intersectionInfo" {
  6561. import { Nullable } from "babylonjs/types";
  6562. /**
  6563. * @hidden
  6564. */
  6565. export class IntersectionInfo {
  6566. bu: Nullable<number>;
  6567. bv: Nullable<number>;
  6568. distance: number;
  6569. faceId: number;
  6570. subMeshId: number;
  6571. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6572. }
  6573. }
  6574. declare module "babylonjs/Maths/math.plane" {
  6575. import { DeepImmutable } from "babylonjs/types";
  6576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6577. /**
  6578. * Represens a plane by the equation ax + by + cz + d = 0
  6579. */
  6580. export class Plane {
  6581. private static _TmpMatrix;
  6582. /**
  6583. * Normal of the plane (a,b,c)
  6584. */
  6585. normal: Vector3;
  6586. /**
  6587. * d component of the plane
  6588. */
  6589. d: number;
  6590. /**
  6591. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6592. * @param a a component of the plane
  6593. * @param b b component of the plane
  6594. * @param c c component of the plane
  6595. * @param d d component of the plane
  6596. */
  6597. constructor(a: number, b: number, c: number, d: number);
  6598. /**
  6599. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6600. */
  6601. asArray(): number[];
  6602. /**
  6603. * @returns a new plane copied from the current Plane.
  6604. */
  6605. clone(): Plane;
  6606. /**
  6607. * @returns the string "Plane".
  6608. */
  6609. getClassName(): string;
  6610. /**
  6611. * @returns the Plane hash code.
  6612. */
  6613. getHashCode(): number;
  6614. /**
  6615. * Normalize the current Plane in place.
  6616. * @returns the updated Plane.
  6617. */
  6618. normalize(): Plane;
  6619. /**
  6620. * Applies a transformation the plane and returns the result
  6621. * @param transformation the transformation matrix to be applied to the plane
  6622. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6623. */
  6624. transform(transformation: DeepImmutable<Matrix>): Plane;
  6625. /**
  6626. * Calcualtte the dot product between the point and the plane normal
  6627. * @param point point to calculate the dot product with
  6628. * @returns the dot product (float) of the point coordinates and the plane normal.
  6629. */
  6630. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6631. /**
  6632. * Updates the current Plane from the plane defined by the three given points.
  6633. * @param point1 one of the points used to contruct the plane
  6634. * @param point2 one of the points used to contruct the plane
  6635. * @param point3 one of the points used to contruct the plane
  6636. * @returns the updated Plane.
  6637. */
  6638. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6639. /**
  6640. * Checks if the plane is facing a given direction
  6641. * @param direction the direction to check if the plane is facing
  6642. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6643. * @returns True is the vector "direction" is the same side than the plane normal.
  6644. */
  6645. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6646. /**
  6647. * Calculates the distance to a point
  6648. * @param point point to calculate distance to
  6649. * @returns the signed distance (float) from the given point to the Plane.
  6650. */
  6651. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6652. /**
  6653. * Creates a plane from an array
  6654. * @param array the array to create a plane from
  6655. * @returns a new Plane from the given array.
  6656. */
  6657. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6658. /**
  6659. * Creates a plane from three points
  6660. * @param point1 point used to create the plane
  6661. * @param point2 point used to create the plane
  6662. * @param point3 point used to create the plane
  6663. * @returns a new Plane defined by the three given points.
  6664. */
  6665. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6666. /**
  6667. * Creates a plane from an origin point and a normal
  6668. * @param origin origin of the plane to be constructed
  6669. * @param normal normal of the plane to be constructed
  6670. * @returns a new Plane the normal vector to this plane at the given origin point.
  6671. * Note : the vector "normal" is updated because normalized.
  6672. */
  6673. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6674. /**
  6675. * Calculates the distance from a plane and a point
  6676. * @param origin origin of the plane to be constructed
  6677. * @param normal normal of the plane to be constructed
  6678. * @param point point to calculate distance to
  6679. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6680. */
  6681. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingSphere" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { Plane } from "babylonjs/Maths/math.plane";
  6688. /**
  6689. * Class used to store bounding sphere information
  6690. */
  6691. export class BoundingSphere {
  6692. /**
  6693. * Gets the center of the bounding sphere in local space
  6694. */
  6695. readonly center: Vector3;
  6696. /**
  6697. * Radius of the bounding sphere in local space
  6698. */
  6699. radius: number;
  6700. /**
  6701. * Gets the center of the bounding sphere in world space
  6702. */
  6703. readonly centerWorld: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in world space
  6706. */
  6707. radiusWorld: number;
  6708. /**
  6709. * Gets the minimum vector in local space
  6710. */
  6711. readonly minimum: Vector3;
  6712. /**
  6713. * Gets the maximum vector in local space
  6714. */
  6715. readonly maximum: Vector3;
  6716. private _worldMatrix;
  6717. private static readonly TmpVector3;
  6718. /**
  6719. * Creates a new bounding sphere
  6720. * @param min defines the minimum vector (in local space)
  6721. * @param max defines the maximum vector (in local space)
  6722. * @param worldMatrix defines the new world matrix
  6723. */
  6724. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6725. /**
  6726. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6727. * @param min defines the new minimum vector (in local space)
  6728. * @param max defines the new maximum vector (in local space)
  6729. * @param worldMatrix defines the new world matrix
  6730. */
  6731. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6732. /**
  6733. * Scale the current bounding sphere by applying a scale factor
  6734. * @param factor defines the scale factor to apply
  6735. * @returns the current bounding box
  6736. */
  6737. scale(factor: number): BoundingSphere;
  6738. /**
  6739. * Gets the world matrix of the bounding box
  6740. * @returns a matrix
  6741. */
  6742. getWorldMatrix(): DeepImmutable<Matrix>;
  6743. /** @hidden */
  6744. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6745. /**
  6746. * Tests if the bounding sphere is intersecting the frustum planes
  6747. * @param frustumPlanes defines the frustum planes to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6751. /**
  6752. * Tests if the bounding sphere center is in between the frustum planes.
  6753. * Used for optimistic fast inclusion.
  6754. * @param frustumPlanes defines the frustum planes to test
  6755. * @returns true if the sphere center is in between the frustum planes
  6756. */
  6757. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6758. /**
  6759. * Tests if a point is inside the bounding sphere
  6760. * @param point defines the point to test
  6761. * @returns true if the point is inside the bounding sphere
  6762. */
  6763. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6764. /**
  6765. * Checks if two sphere intersct
  6766. * @param sphere0 sphere 0
  6767. * @param sphere1 sphere 1
  6768. * @returns true if the speres intersect
  6769. */
  6770. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6771. }
  6772. }
  6773. declare module "babylonjs/Culling/boundingBox" {
  6774. import { DeepImmutable } from "babylonjs/types";
  6775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6776. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6777. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /**
  6780. * Class used to store bounding box information
  6781. */
  6782. export class BoundingBox implements ICullable {
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in local space
  6785. */
  6786. readonly vectors: Vector3[];
  6787. /**
  6788. * Gets the center of the bounding box in local space
  6789. */
  6790. readonly center: Vector3;
  6791. /**
  6792. * Gets the center of the bounding box in world space
  6793. */
  6794. readonly centerWorld: Vector3;
  6795. /**
  6796. * Gets the extend size in local space
  6797. */
  6798. readonly extendSize: Vector3;
  6799. /**
  6800. * Gets the extend size in world space
  6801. */
  6802. readonly extendSizeWorld: Vector3;
  6803. /**
  6804. * Gets the OBB (object bounding box) directions
  6805. */
  6806. readonly directions: Vector3[];
  6807. /**
  6808. * Gets the 8 vectors representing the bounding box in world space
  6809. */
  6810. readonly vectorsWorld: Vector3[];
  6811. /**
  6812. * Gets the minimum vector in world space
  6813. */
  6814. readonly minimumWorld: Vector3;
  6815. /**
  6816. * Gets the maximum vector in world space
  6817. */
  6818. readonly maximumWorld: Vector3;
  6819. /**
  6820. * Gets the minimum vector in local space
  6821. */
  6822. readonly minimum: Vector3;
  6823. /**
  6824. * Gets the maximum vector in local space
  6825. */
  6826. readonly maximum: Vector3;
  6827. private _worldMatrix;
  6828. private static readonly TmpVector3;
  6829. /**
  6830. * @hidden
  6831. */
  6832. _tag: number;
  6833. /**
  6834. * Creates a new bounding box
  6835. * @param min defines the minimum vector (in local space)
  6836. * @param max defines the maximum vector (in local space)
  6837. * @param worldMatrix defines the new world matrix
  6838. */
  6839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6840. /**
  6841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6842. * @param min defines the new minimum vector (in local space)
  6843. * @param max defines the new maximum vector (in local space)
  6844. * @param worldMatrix defines the new world matrix
  6845. */
  6846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6847. /**
  6848. * Scale the current bounding box by applying a scale factor
  6849. * @param factor defines the scale factor to apply
  6850. * @returns the current bounding box
  6851. */
  6852. scale(factor: number): BoundingBox;
  6853. /**
  6854. * Gets the world matrix of the bounding box
  6855. * @returns a matrix
  6856. */
  6857. getWorldMatrix(): DeepImmutable<Matrix>;
  6858. /** @hidden */
  6859. _update(world: DeepImmutable<Matrix>): void;
  6860. /**
  6861. * Tests if the bounding box is intersecting the frustum planes
  6862. * @param frustumPlanes defines the frustum planes to test
  6863. * @returns true if there is an intersection
  6864. */
  6865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6866. /**
  6867. * Tests if the bounding box is entirely inside the frustum planes
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @returns true if there is an inclusion
  6870. */
  6871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. /**
  6873. * Tests if a point is inside the bounding box
  6874. * @param point defines the point to test
  6875. * @returns true if the point is inside the bounding box
  6876. */
  6877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6878. /**
  6879. * Tests if the bounding box intersects with a bounding sphere
  6880. * @param sphere defines the sphere to test
  6881. * @returns true if there is an intersection
  6882. */
  6883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6884. /**
  6885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6886. * @param min defines the min vector to use
  6887. * @param max defines the max vector to use
  6888. * @returns true if there is an intersection
  6889. */
  6890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6891. /**
  6892. * Tests if two bounding boxes are intersections
  6893. * @param box0 defines the first box to test
  6894. * @param box1 defines the second box to test
  6895. * @returns true if there is an intersection
  6896. */
  6897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6898. /**
  6899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6900. * @param minPoint defines the minimum vector of the bounding box
  6901. * @param maxPoint defines the maximum vector of the bounding box
  6902. * @param sphereCenter defines the sphere center
  6903. * @param sphereRadius defines the sphere radius
  6904. * @returns true if there is an intersection
  6905. */
  6906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6907. /**
  6908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6910. * @param frustumPlanes defines the frustum planes to test
  6911. * @return true if there is an inclusion
  6912. */
  6913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6914. /**
  6915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6917. * @param frustumPlanes defines the frustum planes to test
  6918. * @return true if there is an intersection
  6919. */
  6920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6921. }
  6922. }
  6923. declare module "babylonjs/Collisions/collider" {
  6924. import { Nullable, IndicesArray } from "babylonjs/types";
  6925. import { Vector3 } from "babylonjs/Maths/math.vector";
  6926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6927. import { Plane } from "babylonjs/Maths/math.plane";
  6928. /** @hidden */
  6929. export class Collider {
  6930. /** Define if a collision was found */
  6931. collisionFound: boolean;
  6932. /**
  6933. * Define last intersection point in local space
  6934. */
  6935. intersectionPoint: Vector3;
  6936. /**
  6937. * Define last collided mesh
  6938. */
  6939. collidedMesh: Nullable<AbstractMesh>;
  6940. private _collisionPoint;
  6941. private _planeIntersectionPoint;
  6942. private _tempVector;
  6943. private _tempVector2;
  6944. private _tempVector3;
  6945. private _tempVector4;
  6946. private _edge;
  6947. private _baseToVertex;
  6948. private _destinationPoint;
  6949. private _slidePlaneNormal;
  6950. private _displacementVector;
  6951. /** @hidden */
  6952. _radius: Vector3;
  6953. /** @hidden */
  6954. _retry: number;
  6955. private _velocity;
  6956. private _basePoint;
  6957. private _epsilon;
  6958. /** @hidden */
  6959. _velocityWorldLength: number;
  6960. /** @hidden */
  6961. _basePointWorld: Vector3;
  6962. private _velocityWorld;
  6963. private _normalizedVelocity;
  6964. /** @hidden */
  6965. _initialVelocity: Vector3;
  6966. /** @hidden */
  6967. _initialPosition: Vector3;
  6968. private _nearestDistance;
  6969. private _collisionMask;
  6970. collisionMask: number;
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. readonly slidePlaneNormal: Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module "babylonjs/Culling/boundingInfo" {
  6990. import { DeepImmutable } from "babylonjs/types";
  6991. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6992. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6993. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6994. import { Plane } from "babylonjs/Maths/math.plane";
  6995. import { Collider } from "babylonjs/Collisions/collider";
  6996. /**
  6997. * Interface for cullable objects
  6998. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6999. */
  7000. export interface ICullable {
  7001. /**
  7002. * Checks if the object or part of the object is in the frustum
  7003. * @param frustumPlanes Camera near/planes
  7004. * @returns true if the object is in frustum otherwise false
  7005. */
  7006. isInFrustum(frustumPlanes: Plane[]): boolean;
  7007. /**
  7008. * Checks if a cullable object (mesh...) is in the camera frustum
  7009. * Unlike isInFrustum this cheks the full bounding box
  7010. * @param frustumPlanes Camera near/planes
  7011. * @returns true if the object is in frustum otherwise false
  7012. */
  7013. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7014. }
  7015. /**
  7016. * Info for a bounding data of a mesh
  7017. */
  7018. export class BoundingInfo implements ICullable {
  7019. /**
  7020. * Bounding box for the mesh
  7021. */
  7022. readonly boundingBox: BoundingBox;
  7023. /**
  7024. * Bounding sphere for the mesh
  7025. */
  7026. readonly boundingSphere: BoundingSphere;
  7027. private _isLocked;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * Constructs bounding info
  7031. * @param minimum min vector of the bounding box/sphere
  7032. * @param maximum max vector of the bounding box/sphere
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * min vector of the bounding box/sphere
  7045. */
  7046. readonly minimum: Vector3;
  7047. /**
  7048. * max vector of the bounding box/sphere
  7049. */
  7050. readonly maximum: Vector3;
  7051. /**
  7052. * If the info is locked and won't be updated to avoid perf overhead
  7053. */
  7054. isLocked: boolean;
  7055. /**
  7056. * Updates the bounding sphere and box
  7057. * @param world world matrix to be used to update
  7058. */
  7059. update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7062. * @param center New center of the bounding info
  7063. * @param extend New extend of the bounding info
  7064. * @returns the current bounding info
  7065. */
  7066. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7067. /**
  7068. * Scale the current bounding info by applying a scale factor
  7069. * @param factor defines the scale factor to apply
  7070. * @returns the current bounding info
  7071. */
  7072. scale(factor: number): BoundingInfo;
  7073. /**
  7074. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7075. * @param frustumPlanes defines the frustum to test
  7076. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7077. * @returns true if the bounding info is in the frustum planes
  7078. */
  7079. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7080. /**
  7081. * Gets the world distance between the min and max points of the bounding box
  7082. */
  7083. readonly diagonalLength: number;
  7084. /**
  7085. * Checks if a cullable object (mesh...) is in the camera frustum
  7086. * Unlike isInFrustum this cheks the full bounding box
  7087. * @param frustumPlanes Camera near/planes
  7088. * @returns true if the object is in frustum otherwise false
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /** @hidden */
  7092. _checkCollision(collider: Collider): boolean;
  7093. /**
  7094. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7095. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7096. * @param point the point to check intersection with
  7097. * @returns if the point intersects
  7098. */
  7099. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7100. /**
  7101. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7102. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7103. * @param boundingInfo the bounding info to check intersection with
  7104. * @param precise if the intersection should be done using OBB
  7105. * @returns if the bounding info intersects
  7106. */
  7107. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7108. }
  7109. }
  7110. declare module "babylonjs/Maths/math.functions" {
  7111. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7112. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7113. /**
  7114. * Extracts minimum and maximum values from a list of indexed positions
  7115. * @param positions defines the positions to use
  7116. * @param indices defines the indices to the positions
  7117. * @param indexStart defines the start index
  7118. * @param indexCount defines the end index
  7119. * @param bias defines bias value to add to the result
  7120. * @return minimum and maximum values
  7121. */
  7122. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7123. minimum: Vector3;
  7124. maximum: Vector3;
  7125. };
  7126. /**
  7127. * Extracts minimum and maximum values from a list of positions
  7128. * @param positions defines the positions to use
  7129. * @param start defines the start index in the positions array
  7130. * @param count defines the number of positions to handle
  7131. * @param bias defines bias value to add to the result
  7132. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7133. * @return minimum and maximum values
  7134. */
  7135. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7136. minimum: Vector3;
  7137. maximum: Vector3;
  7138. };
  7139. }
  7140. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7141. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7142. /** @hidden */
  7143. export class WebGLDataBuffer extends DataBuffer {
  7144. private _buffer;
  7145. constructor(resource: WebGLBuffer);
  7146. readonly underlyingResource: any;
  7147. }
  7148. }
  7149. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7150. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7151. import { Nullable } from "babylonjs/types";
  7152. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7153. /** @hidden */
  7154. export class WebGLPipelineContext implements IPipelineContext {
  7155. engine: ThinEngine;
  7156. program: Nullable<WebGLProgram>;
  7157. context?: WebGLRenderingContext;
  7158. vertexShader?: WebGLShader;
  7159. fragmentShader?: WebGLShader;
  7160. isParallelCompiled: boolean;
  7161. onCompiled?: () => void;
  7162. transformFeedback?: WebGLTransformFeedback | null;
  7163. readonly isAsync: boolean;
  7164. readonly isReady: boolean;
  7165. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7166. }
  7167. }
  7168. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7169. import { FloatArray, Nullable } from "babylonjs/types";
  7170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7171. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7172. module "babylonjs/Engines/thinEngine" {
  7173. interface ThinEngine {
  7174. /**
  7175. * Create an uniform buffer
  7176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7177. * @param elements defines the content of the uniform buffer
  7178. * @returns the webGL uniform buffer
  7179. */
  7180. createUniformBuffer(elements: FloatArray): DataBuffer;
  7181. /**
  7182. * Create a dynamic uniform buffer
  7183. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7184. * @param elements defines the content of the uniform buffer
  7185. * @returns the webGL uniform buffer
  7186. */
  7187. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7188. /**
  7189. * Update an existing uniform buffer
  7190. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7191. * @param uniformBuffer defines the target uniform buffer
  7192. * @param elements defines the content to update
  7193. * @param offset defines the offset in the uniform buffer where update should start
  7194. * @param count defines the size of the data to update
  7195. */
  7196. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7197. /**
  7198. * Bind an uniform buffer to the current webGL context
  7199. * @param buffer defines the buffer to bind
  7200. */
  7201. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7202. /**
  7203. * Bind a buffer to the current webGL context at a given location
  7204. * @param buffer defines the buffer to bind
  7205. * @param location defines the index where to bind the buffer
  7206. */
  7207. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7208. /**
  7209. * Bind a specific block at a given index in a specific shader program
  7210. * @param pipelineContext defines the pipeline context to use
  7211. * @param blockName defines the block name
  7212. * @param index defines the index where to bind the block
  7213. */
  7214. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7215. }
  7216. }
  7217. }
  7218. declare module "babylonjs/Materials/uniformBuffer" {
  7219. import { Nullable, FloatArray } from "babylonjs/types";
  7220. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7221. import { Engine } from "babylonjs/Engines/engine";
  7222. import { Effect } from "babylonjs/Materials/effect";
  7223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7224. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7225. import { Color3 } from "babylonjs/Maths/math.color";
  7226. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7227. /**
  7228. * Uniform buffer objects.
  7229. *
  7230. * Handles blocks of uniform on the GPU.
  7231. *
  7232. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7233. *
  7234. * For more information, please refer to :
  7235. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7236. */
  7237. export class UniformBuffer {
  7238. private _engine;
  7239. private _buffer;
  7240. private _data;
  7241. private _bufferData;
  7242. private _dynamic?;
  7243. private _uniformLocations;
  7244. private _uniformSizes;
  7245. private _uniformLocationPointer;
  7246. private _needSync;
  7247. private _noUBO;
  7248. private _currentEffect;
  7249. /** @hidden */
  7250. _alreadyBound: boolean;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /**
  7672. * @hidden
  7673. */
  7674. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7675. }
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7679. import { Nullable } from "babylonjs/types";
  7680. import { Scene } from "babylonjs/scene";
  7681. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7683. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7684. /**
  7685. * Class for creating a cube texture
  7686. */
  7687. export class CubeTexture extends BaseTexture {
  7688. private _delayedOnLoad;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. /**
  7707. * Returns the bounding box size
  7708. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7709. */
  7710. boundingBoxSize: Vector3;
  7711. protected _rotationY: number;
  7712. /**
  7713. * Sets texture matrix rotation angle around Y axis in radians.
  7714. */
  7715. /**
  7716. * Gets texture matrix rotation angle around Y axis radians.
  7717. */
  7718. rotationY: number;
  7719. /**
  7720. * Are mip maps generated for this texture or not.
  7721. */
  7722. readonly noMipmap: boolean;
  7723. private _noMipmap;
  7724. private _files;
  7725. protected _forcedExtension: Nullable<string>;
  7726. private _extensions;
  7727. private _textureMatrix;
  7728. private _format;
  7729. private _createPolynomials;
  7730. /** @hidden */
  7731. _prefiltered: boolean;
  7732. /**
  7733. * Creates a cube texture from an array of image urls
  7734. * @param files defines an array of image urls
  7735. * @param scene defines the hosting scene
  7736. * @param noMipmap specifies if mip maps are not used
  7737. * @returns a cube texture
  7738. */
  7739. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7740. /**
  7741. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7742. * @param url defines the url of the prefiltered texture
  7743. * @param scene defines the scene the texture is attached to
  7744. * @param forcedExtension defines the extension of the file if different from the url
  7745. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7746. * @return the prefiltered texture
  7747. */
  7748. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7749. /**
  7750. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7751. * as prefiltered data.
  7752. * @param rootUrl defines the url of the texture or the root name of the six images
  7753. * @param scene defines the scene the texture is attached to
  7754. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7755. * @param noMipmap defines if mipmaps should be created or not
  7756. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7757. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7758. * @param onError defines a callback triggered in case of error during load
  7759. * @param format defines the internal format to use for the texture once loaded
  7760. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7761. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7762. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @return the cube texture
  7766. */
  7767. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7768. /**
  7769. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7770. */
  7771. readonly isPrefiltered: boolean;
  7772. /**
  7773. * Get the current class name of the texture useful for serialization or dynamic coding.
  7774. * @returns "CubeTexture"
  7775. */
  7776. getClassName(): string;
  7777. /**
  7778. * Update the url (and optional buffer) of this texture if url was null during construction.
  7779. * @param url the url of the texture
  7780. * @param forcedExtension defines the extension to use
  7781. * @param onLoad callback called when the texture is loaded (defaults to null)
  7782. */
  7783. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7784. /**
  7785. * Delays loading of the cube texture
  7786. * @param forcedExtension defines the extension to use
  7787. */
  7788. delayLoad(forcedExtension?: string): void;
  7789. /**
  7790. * Returns the reflection texture matrix
  7791. * @returns the reflection texture matrix
  7792. */
  7793. getReflectionTextureMatrix(): Matrix;
  7794. /**
  7795. * Sets the reflection texture matrix
  7796. * @param value Reflection texture matrix
  7797. */
  7798. setReflectionTextureMatrix(value: Matrix): void;
  7799. /**
  7800. * Parses text to create a cube texture
  7801. * @param parsedTexture define the serialized text to read from
  7802. * @param scene defines the hosting scene
  7803. * @param rootUrl defines the root url of the cube texture
  7804. * @returns a cube texture
  7805. */
  7806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7807. /**
  7808. * Makes a clone, or deep copy, of the cube texture
  7809. * @returns a new cube texture
  7810. */
  7811. clone(): CubeTexture;
  7812. }
  7813. }
  7814. declare module "babylonjs/Materials/materialDefines" {
  7815. /**
  7816. * Manages the defines for the Material
  7817. */
  7818. export class MaterialDefines {
  7819. /** @hidden */
  7820. protected _keys: string[];
  7821. private _isDirty;
  7822. /** @hidden */
  7823. _renderId: number;
  7824. /** @hidden */
  7825. _areLightsDirty: boolean;
  7826. /** @hidden */
  7827. _areLightsDisposed: boolean;
  7828. /** @hidden */
  7829. _areAttributesDirty: boolean;
  7830. /** @hidden */
  7831. _areTexturesDirty: boolean;
  7832. /** @hidden */
  7833. _areFresnelDirty: boolean;
  7834. /** @hidden */
  7835. _areMiscDirty: boolean;
  7836. /** @hidden */
  7837. _areImageProcessingDirty: boolean;
  7838. /** @hidden */
  7839. _normals: boolean;
  7840. /** @hidden */
  7841. _uvs: boolean;
  7842. /** @hidden */
  7843. _needNormals: boolean;
  7844. /** @hidden */
  7845. _needUVs: boolean;
  7846. [id: string]: any;
  7847. /**
  7848. * Specifies if the material needs to be re-calculated
  7849. */
  7850. readonly isDirty: boolean;
  7851. /**
  7852. * Marks the material to indicate that it has been re-calculated
  7853. */
  7854. markAsProcessed(): void;
  7855. /**
  7856. * Marks the material to indicate that it needs to be re-calculated
  7857. */
  7858. markAsUnprocessed(): void;
  7859. /**
  7860. * Marks the material to indicate all of its defines need to be re-calculated
  7861. */
  7862. markAllAsDirty(): void;
  7863. /**
  7864. * Marks the material to indicate that image processing needs to be re-calculated
  7865. */
  7866. markAsImageProcessingDirty(): void;
  7867. /**
  7868. * Marks the material to indicate the lights need to be re-calculated
  7869. * @param disposed Defines whether the light is dirty due to dispose or not
  7870. */
  7871. markAsLightDirty(disposed?: boolean): void;
  7872. /**
  7873. * Marks the attribute state as changed
  7874. */
  7875. markAsAttributesDirty(): void;
  7876. /**
  7877. * Marks the texture state as changed
  7878. */
  7879. markAsTexturesDirty(): void;
  7880. /**
  7881. * Marks the fresnel state as changed
  7882. */
  7883. markAsFresnelDirty(): void;
  7884. /**
  7885. * Marks the misc state as changed
  7886. */
  7887. markAsMiscDirty(): void;
  7888. /**
  7889. * Rebuilds the material defines
  7890. */
  7891. rebuild(): void;
  7892. /**
  7893. * Specifies if two material defines are equal
  7894. * @param other - A material define instance to compare to
  7895. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7896. */
  7897. isEqual(other: MaterialDefines): boolean;
  7898. /**
  7899. * Clones this instance's defines to another instance
  7900. * @param other - material defines to clone values to
  7901. */
  7902. cloneTo(other: MaterialDefines): void;
  7903. /**
  7904. * Resets the material define values
  7905. */
  7906. reset(): void;
  7907. /**
  7908. * Converts the material define values to a string
  7909. * @returns - String of material define information
  7910. */
  7911. toString(): string;
  7912. }
  7913. }
  7914. declare module "babylonjs/Materials/colorCurves" {
  7915. import { Effect } from "babylonjs/Materials/effect";
  7916. /**
  7917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7919. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7921. */
  7922. export class ColorCurves {
  7923. private _dirty;
  7924. private _tempColor;
  7925. private _globalCurve;
  7926. private _highlightsCurve;
  7927. private _midtonesCurve;
  7928. private _shadowsCurve;
  7929. private _positiveCurve;
  7930. private _negativeCurve;
  7931. private _globalHue;
  7932. private _globalDensity;
  7933. private _globalSaturation;
  7934. private _globalExposure;
  7935. /**
  7936. * Gets the global Hue value.
  7937. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7938. */
  7939. /**
  7940. * Sets the global Hue value.
  7941. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7942. */
  7943. globalHue: number;
  7944. /**
  7945. * Gets the global Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. /**
  7950. * Sets the global Density value.
  7951. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. globalDensity: number;
  7955. /**
  7956. * Gets the global Saturation value.
  7957. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7958. */
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. globalSaturation: number;
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. /**
  7969. * Sets the global Exposure value.
  7970. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7971. */
  7972. globalExposure: number;
  7973. private _highlightsHue;
  7974. private _highlightsDensity;
  7975. private _highlightsSaturation;
  7976. private _highlightsExposure;
  7977. /**
  7978. * Gets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. /**
  7982. * Sets the highlights Hue value.
  7983. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7984. */
  7985. highlightsHue: number;
  7986. /**
  7987. * Gets the highlights Density value.
  7988. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. /**
  7992. * Sets the highlights Density value.
  7993. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7994. * Values less than zero provide a filter of opposite hue.
  7995. */
  7996. highlightsDensity: number;
  7997. /**
  7998. * Gets the highlights Saturation value.
  7999. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8000. */
  8001. /**
  8002. * Sets the highlights Saturation value.
  8003. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8004. */
  8005. highlightsSaturation: number;
  8006. /**
  8007. * Gets the highlights Exposure value.
  8008. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8009. */
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. highlightsExposure: number;
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8022. */
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8026. */
  8027. midtonesHue: number;
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. /**
  8034. * Sets the midtones Density value.
  8035. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. midtonesDensity: number;
  8039. /**
  8040. * Gets the midtones Saturation value.
  8041. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8042. */
  8043. /**
  8044. * Sets the midtones Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. midtonesSaturation: number;
  8048. /**
  8049. * Gets the midtones Exposure value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8051. */
  8052. /**
  8053. * Sets the midtones Exposure value.
  8054. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8055. */
  8056. midtonesExposure: number;
  8057. private _shadowsHue;
  8058. private _shadowsDensity;
  8059. private _shadowsSaturation;
  8060. private _shadowsExposure;
  8061. /**
  8062. * Gets the shadows Hue value.
  8063. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8064. */
  8065. /**
  8066. * Sets the shadows Hue value.
  8067. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8068. */
  8069. shadowsHue: number;
  8070. /**
  8071. * Gets the shadows Density value.
  8072. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. /**
  8076. * Sets the shadows Density value.
  8077. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. shadowsDensity: number;
  8081. /**
  8082. * Gets the shadows Saturation value.
  8083. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8084. */
  8085. /**
  8086. * Sets the shadows Saturation value.
  8087. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8088. */
  8089. shadowsSaturation: number;
  8090. /**
  8091. * Gets the shadows Exposure value.
  8092. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8093. */
  8094. /**
  8095. * Sets the shadows Exposure value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8097. */
  8098. shadowsExposure: number;
  8099. /**
  8100. * Returns the class name
  8101. * @returns The class name
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Binds the color curves to the shader.
  8106. * @param colorCurves The color curve to bind
  8107. * @param effect The effect to bind to
  8108. * @param positiveUniform The positive uniform shader parameter
  8109. * @param neutralUniform The neutral uniform shader parameter
  8110. * @param negativeUniform The negative uniform shader parameter
  8111. */
  8112. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8113. /**
  8114. * Prepare the list of uniforms associated with the ColorCurves effects.
  8115. * @param uniformsList The list of uniforms used in the effect
  8116. */
  8117. static PrepareUniforms(uniformsList: string[]): void;
  8118. /**
  8119. * Returns color grading data based on a hue, density, saturation and exposure value.
  8120. * @param filterHue The hue of the color filter.
  8121. * @param filterDensity The density of the color filter.
  8122. * @param saturation The saturation.
  8123. * @param exposure The exposure.
  8124. * @param result The result data container.
  8125. */
  8126. private getColorGradingDataToRef;
  8127. /**
  8128. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8129. * @param value The input slider value in range [-100,100].
  8130. * @returns Adjusted value.
  8131. */
  8132. private static applyColorGradingSliderNonlinear;
  8133. /**
  8134. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8135. * @param hue The hue (H) input.
  8136. * @param saturation The saturation (S) input.
  8137. * @param brightness The brightness (B) input.
  8138. * @result An RGBA color represented as Vector4.
  8139. */
  8140. private static fromHSBToRef;
  8141. /**
  8142. * Returns a value clamped between min and max
  8143. * @param value The value to clamp
  8144. * @param min The minimum of value
  8145. * @param max The maximum of value
  8146. * @returns The clamped value.
  8147. */
  8148. private static clamp;
  8149. /**
  8150. * Clones the current color curve instance.
  8151. * @return The cloned curves
  8152. */
  8153. clone(): ColorCurves;
  8154. /**
  8155. * Serializes the current color curve instance to a json representation.
  8156. * @return a JSON representation
  8157. */
  8158. serialize(): any;
  8159. /**
  8160. * Parses the color curve from a json representation.
  8161. * @param source the JSON source to parse
  8162. * @return The parsed curves
  8163. */
  8164. static Parse(source: any): ColorCurves;
  8165. }
  8166. }
  8167. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8168. import { Observable } from "babylonjs/Misc/observable";
  8169. import { Nullable } from "babylonjs/types";
  8170. import { Color4 } from "babylonjs/Maths/math.color";
  8171. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8172. import { Effect } from "babylonjs/Materials/effect";
  8173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. /**
  8240. * Sets wether the color curves effect is enabled.
  8241. */
  8242. colorCurvesEnabled: boolean;
  8243. private _colorGradingTexture;
  8244. /**
  8245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8246. */
  8247. /**
  8248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8249. */
  8250. colorGradingTexture: Nullable<BaseTexture>;
  8251. private _colorGradingEnabled;
  8252. /**
  8253. * Gets wether the color grading effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color grading effect is enabled.
  8257. */
  8258. colorGradingEnabled: boolean;
  8259. private _colorGradingWithGreenDepth;
  8260. /**
  8261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8262. */
  8263. /**
  8264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. colorGradingWithGreenDepth: boolean;
  8267. private _colorGradingBGR;
  8268. /**
  8269. * Gets wether the color grading texture contains BGR values.
  8270. */
  8271. /**
  8272. * Sets wether the color grading texture contains BGR values.
  8273. */
  8274. colorGradingBGR: boolean;
  8275. /** @hidden */
  8276. _exposure: number;
  8277. /**
  8278. * Gets the Exposure used in the effect.
  8279. */
  8280. /**
  8281. * Sets the Exposure used in the effect.
  8282. */
  8283. exposure: number;
  8284. private _toneMappingEnabled;
  8285. /**
  8286. * Gets wether the tone mapping effect is enabled.
  8287. */
  8288. /**
  8289. * Sets wether the tone mapping effect is enabled.
  8290. */
  8291. toneMappingEnabled: boolean;
  8292. private _toneMappingType;
  8293. /**
  8294. * Gets the type of tone mapping effect.
  8295. */
  8296. /**
  8297. * Sets the type of tone mapping effect used in BabylonJS.
  8298. */
  8299. toneMappingType: number;
  8300. protected _contrast: number;
  8301. /**
  8302. * Gets the contrast used in the effect.
  8303. */
  8304. /**
  8305. * Sets the contrast used in the effect.
  8306. */
  8307. contrast: number;
  8308. /**
  8309. * Vignette stretch size.
  8310. */
  8311. vignetteStretch: number;
  8312. /**
  8313. * Vignette centre X Offset.
  8314. */
  8315. vignetteCentreX: number;
  8316. /**
  8317. * Vignette centre Y Offset.
  8318. */
  8319. vignetteCentreY: number;
  8320. /**
  8321. * Vignette weight or intensity of the vignette effect.
  8322. */
  8323. vignetteWeight: number;
  8324. /**
  8325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8326. * if vignetteEnabled is set to true.
  8327. */
  8328. vignetteColor: Color4;
  8329. /**
  8330. * Camera field of view used by the Vignette effect.
  8331. */
  8332. vignetteCameraFov: number;
  8333. private _vignetteBlendMode;
  8334. /**
  8335. * Gets the vignette blend mode allowing different kind of effect.
  8336. */
  8337. /**
  8338. * Sets the vignette blend mode allowing different kind of effect.
  8339. */
  8340. vignetteBlendMode: number;
  8341. private _vignetteEnabled;
  8342. /**
  8343. * Gets wether the vignette effect is enabled.
  8344. */
  8345. /**
  8346. * Sets wether the vignette effect is enabled.
  8347. */
  8348. vignetteEnabled: boolean;
  8349. private _applyByPostProcess;
  8350. /**
  8351. * Gets wether the image processing is applied through a post process or not.
  8352. */
  8353. /**
  8354. * Sets wether the image processing is applied through a post process or not.
  8355. */
  8356. applyByPostProcess: boolean;
  8357. private _isEnabled;
  8358. /**
  8359. * Gets wether the image processing is enabled or not.
  8360. */
  8361. /**
  8362. * Sets wether the image processing is enabled or not.
  8363. */
  8364. isEnabled: boolean;
  8365. /**
  8366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8367. */
  8368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8369. /**
  8370. * Method called each time the image processing information changes requires to recompile the effect.
  8371. */
  8372. protected _updateParameters(): void;
  8373. /**
  8374. * Gets the current class name.
  8375. * @return "ImageProcessingConfiguration"
  8376. */
  8377. getClassName(): string;
  8378. /**
  8379. * Prepare the list of uniforms associated with the Image Processing effects.
  8380. * @param uniforms The list of uniforms used in the effect
  8381. * @param defines the list of defines currently in use
  8382. */
  8383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8384. /**
  8385. * Prepare the list of samplers associated with the Image Processing effects.
  8386. * @param samplersList The list of uniforms used in the effect
  8387. * @param defines the list of defines currently in use
  8388. */
  8389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8390. /**
  8391. * Prepare the list of defines associated to the shader.
  8392. * @param defines the list of defines to complete
  8393. * @param forPostProcess Define if we are currently in post process mode or not
  8394. */
  8395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8396. /**
  8397. * Returns true if all the image processing information are ready.
  8398. * @returns True if ready, otherwise, false
  8399. */
  8400. isReady(): boolean;
  8401. /**
  8402. * Binds the image processing to the shader.
  8403. * @param effect The effect to bind to
  8404. * @param overrideAspectRatio Override the aspect ratio of the effect
  8405. */
  8406. bind(effect: Effect, overrideAspectRatio?: number): void;
  8407. /**
  8408. * Clones the current image processing instance.
  8409. * @return The cloned image processing
  8410. */
  8411. clone(): ImageProcessingConfiguration;
  8412. /**
  8413. * Serializes the current image processing instance to a json representation.
  8414. * @return a JSON representation
  8415. */
  8416. serialize(): any;
  8417. /**
  8418. * Parses the image processing from a json representation.
  8419. * @param source the JSON source to parse
  8420. * @return The parsed image processing
  8421. */
  8422. static Parse(source: any): ImageProcessingConfiguration;
  8423. private static _VIGNETTEMODE_MULTIPLY;
  8424. private static _VIGNETTEMODE_OPAQUE;
  8425. /**
  8426. * Used to apply the vignette as a mix with the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_MULTIPLY: number;
  8429. /**
  8430. * Used to apply the vignette as a replacement of the pixel color.
  8431. */
  8432. static readonly VIGNETTEMODE_OPAQUE: number;
  8433. }
  8434. }
  8435. declare module "babylonjs/Shaders/postprocess.vertex" {
  8436. /** @hidden */
  8437. export var postprocessVertexShader: {
  8438. name: string;
  8439. shader: string;
  8440. };
  8441. }
  8442. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8445. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8446. module "babylonjs/Engines/thinEngine" {
  8447. interface ThinEngine {
  8448. /**
  8449. * Creates a new render target texture
  8450. * @param size defines the size of the texture
  8451. * @param options defines the options used to create the texture
  8452. * @returns a new render target texture stored in an InternalTexture
  8453. */
  8454. createRenderTargetTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8458. /**
  8459. * Creates a depth stencil texture.
  8460. * This is only available in WebGL 2 or with the depth texture extension available.
  8461. * @param size The size of face edge in the texture.
  8462. * @param options The options defining the texture.
  8463. * @returns The texture
  8464. */
  8465. createDepthStencilTexture(size: number | {
  8466. width: number;
  8467. height: number;
  8468. }, options: DepthTextureCreationOptions): InternalTexture;
  8469. /** @hidden */
  8470. _createDepthStencilTexture(size: number | {
  8471. width: number;
  8472. height: number;
  8473. }, options: DepthTextureCreationOptions): InternalTexture;
  8474. }
  8475. }
  8476. }
  8477. declare module "babylonjs/Maths/math.axis" {
  8478. import { Vector3 } from "babylonjs/Maths/math.vector";
  8479. /** Defines supported spaces */
  8480. export enum Space {
  8481. /** Local (object) space */
  8482. LOCAL = 0,
  8483. /** World space */
  8484. WORLD = 1,
  8485. /** Bone space */
  8486. BONE = 2
  8487. }
  8488. /** Defines the 3 main axes */
  8489. export class Axis {
  8490. /** X axis */
  8491. static X: Vector3;
  8492. /** Y axis */
  8493. static Y: Vector3;
  8494. /** Z axis */
  8495. static Z: Vector3;
  8496. }
  8497. }
  8498. declare module "babylonjs/Cameras/targetCamera" {
  8499. import { Nullable } from "babylonjs/types";
  8500. import { Camera } from "babylonjs/Cameras/camera";
  8501. import { Scene } from "babylonjs/scene";
  8502. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8503. /**
  8504. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8505. * This is the base of the follow, arc rotate cameras and Free camera
  8506. * @see http://doc.babylonjs.com/features/cameras
  8507. */
  8508. export class TargetCamera extends Camera {
  8509. private static _RigCamTransformMatrix;
  8510. private static _TargetTransformMatrix;
  8511. private static _TargetFocalPoint;
  8512. /**
  8513. * Define the current direction the camera is moving to
  8514. */
  8515. cameraDirection: Vector3;
  8516. /**
  8517. * Define the current rotation the camera is rotating to
  8518. */
  8519. cameraRotation: Vector2;
  8520. /**
  8521. * When set, the up vector of the camera will be updated by the rotation of the camera
  8522. */
  8523. updateUpVectorFromRotation: boolean;
  8524. private _tmpQuaternion;
  8525. /**
  8526. * Define the current rotation of the camera
  8527. */
  8528. rotation: Vector3;
  8529. /**
  8530. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8531. */
  8532. rotationQuaternion: Quaternion;
  8533. /**
  8534. * Define the current speed of the camera
  8535. */
  8536. speed: number;
  8537. /**
  8538. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8539. * around all axis.
  8540. */
  8541. noRotationConstraint: boolean;
  8542. /**
  8543. * Define the current target of the camera as an object or a position.
  8544. */
  8545. lockedTarget: any;
  8546. /** @hidden */
  8547. _currentTarget: Vector3;
  8548. /** @hidden */
  8549. _initialFocalDistance: number;
  8550. /** @hidden */
  8551. _viewMatrix: Matrix;
  8552. /** @hidden */
  8553. _camMatrix: Matrix;
  8554. /** @hidden */
  8555. _cameraTransformMatrix: Matrix;
  8556. /** @hidden */
  8557. _cameraRotationMatrix: Matrix;
  8558. /** @hidden */
  8559. _referencePoint: Vector3;
  8560. /** @hidden */
  8561. _transformedReferencePoint: Vector3;
  8562. protected _globalCurrentTarget: Vector3;
  8563. protected _globalCurrentUpVector: Vector3;
  8564. /** @hidden */
  8565. _reset: () => void;
  8566. private _defaultUp;
  8567. /**
  8568. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8569. * This is the base of the follow, arc rotate cameras and Free camera
  8570. * @see http://doc.babylonjs.com/features/cameras
  8571. * @param name Defines the name of the camera in the scene
  8572. * @param position Defines the start position of the camera in the scene
  8573. * @param scene Defines the scene the camera belongs to
  8574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8575. */
  8576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8577. /**
  8578. * Gets the position in front of the camera at a given distance.
  8579. * @param distance The distance from the camera we want the position to be
  8580. * @returns the position
  8581. */
  8582. getFrontPosition(distance: number): Vector3;
  8583. /** @hidden */
  8584. _getLockedTargetPosition(): Nullable<Vector3>;
  8585. private _storedPosition;
  8586. private _storedRotation;
  8587. private _storedRotationQuaternion;
  8588. /**
  8589. * Store current camera state of the camera (fov, position, rotation, etc..)
  8590. * @returns the camera
  8591. */
  8592. storeState(): Camera;
  8593. /**
  8594. * Restored camera state. You must call storeState() first
  8595. * @returns whether it was successful or not
  8596. * @hidden
  8597. */
  8598. _restoreStateValues(): boolean;
  8599. /** @hidden */
  8600. _initCache(): void;
  8601. /** @hidden */
  8602. _updateCache(ignoreParentClass?: boolean): void;
  8603. /** @hidden */
  8604. _isSynchronizedViewMatrix(): boolean;
  8605. /** @hidden */
  8606. _computeLocalCameraSpeed(): number;
  8607. /**
  8608. * Defines the target the camera should look at.
  8609. * @param target Defines the new target as a Vector or a mesh
  8610. */
  8611. setTarget(target: Vector3): void;
  8612. /**
  8613. * Return the current target position of the camera. This value is expressed in local space.
  8614. * @returns the target position
  8615. */
  8616. getTarget(): Vector3;
  8617. /** @hidden */
  8618. _decideIfNeedsToMove(): boolean;
  8619. /** @hidden */
  8620. _updatePosition(): void;
  8621. /** @hidden */
  8622. _checkInputs(): void;
  8623. protected _updateCameraRotationMatrix(): void;
  8624. /**
  8625. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8626. * @returns the current camera
  8627. */
  8628. private _rotateUpVectorWithCameraRotationMatrix;
  8629. private _cachedRotationZ;
  8630. private _cachedQuaternionRotationZ;
  8631. /** @hidden */
  8632. _getViewMatrix(): Matrix;
  8633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8634. /**
  8635. * @hidden
  8636. */
  8637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8638. /**
  8639. * @hidden
  8640. */
  8641. _updateRigCameras(): void;
  8642. private _getRigCamPositionAndTarget;
  8643. /**
  8644. * Gets the current object class name.
  8645. * @return the class name
  8646. */
  8647. getClassName(): string;
  8648. }
  8649. }
  8650. declare module "babylonjs/Events/keyboardEvents" {
  8651. /**
  8652. * Gather the list of keyboard event types as constants.
  8653. */
  8654. export class KeyboardEventTypes {
  8655. /**
  8656. * The keydown event is fired when a key becomes active (pressed).
  8657. */
  8658. static readonly KEYDOWN: number;
  8659. /**
  8660. * The keyup event is fired when a key has been released.
  8661. */
  8662. static readonly KEYUP: number;
  8663. }
  8664. /**
  8665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8666. */
  8667. export class KeyboardInfo {
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number;
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent;
  8676. /**
  8677. * Instantiates a new keyboard info.
  8678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8679. * @param type Defines the type of event (KeyboardEventTypes)
  8680. * @param event Defines the related dom event
  8681. */
  8682. constructor(
  8683. /**
  8684. * Defines the type of event (KeyboardEventTypes)
  8685. */
  8686. type: number,
  8687. /**
  8688. * Defines the related dom event
  8689. */
  8690. event: KeyboardEvent);
  8691. }
  8692. /**
  8693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8695. */
  8696. export class KeyboardInfoPre extends KeyboardInfo {
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number;
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent;
  8705. /**
  8706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8707. */
  8708. skipOnPointerObservable: boolean;
  8709. /**
  8710. * Instantiates a new keyboard pre info.
  8711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8712. * @param type Defines the type of event (KeyboardEventTypes)
  8713. * @param event Defines the related dom event
  8714. */
  8715. constructor(
  8716. /**
  8717. * Defines the type of event (KeyboardEventTypes)
  8718. */
  8719. type: number,
  8720. /**
  8721. * Defines the related dom event
  8722. */
  8723. event: KeyboardEvent);
  8724. }
  8725. }
  8726. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8727. import { Nullable } from "babylonjs/types";
  8728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8730. /**
  8731. * Manage the keyboard inputs to control the movement of a free camera.
  8732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8733. */
  8734. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8735. /**
  8736. * Defines the camera the input is attached to.
  8737. */
  8738. camera: FreeCamera;
  8739. /**
  8740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8741. */
  8742. keysUp: number[];
  8743. /**
  8744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8745. */
  8746. keysDown: number[];
  8747. /**
  8748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8749. */
  8750. keysLeft: number[];
  8751. /**
  8752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8753. */
  8754. keysRight: number[];
  8755. private _keys;
  8756. private _onCanvasBlurObserver;
  8757. private _onKeyboardObserver;
  8758. private _engine;
  8759. private _scene;
  8760. /**
  8761. * Attach the input controls to a specific dom element to get the input from.
  8762. * @param element Defines the element the controls should be listened from
  8763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8764. */
  8765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8766. /**
  8767. * Detach the current controls from the specified dom element.
  8768. * @param element Defines the element to stop listening the inputs from
  8769. */
  8770. detachControl(element: Nullable<HTMLElement>): void;
  8771. /**
  8772. * Update the current camera state depending on the inputs that have been used this frame.
  8773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8774. */
  8775. checkInputs(): void;
  8776. /**
  8777. * Gets the class name of the current intput.
  8778. * @returns the class name
  8779. */
  8780. getClassName(): string;
  8781. /** @hidden */
  8782. _onLostFocus(): void;
  8783. /**
  8784. * Get the friendly name associated with the input class.
  8785. * @returns the input friendly name
  8786. */
  8787. getSimpleName(): string;
  8788. }
  8789. }
  8790. declare module "babylonjs/Lights/shadowLight" {
  8791. import { Camera } from "babylonjs/Cameras/camera";
  8792. import { Scene } from "babylonjs/scene";
  8793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8795. import { Light } from "babylonjs/Lights/light";
  8796. /**
  8797. * Interface describing all the common properties and methods a shadow light needs to implement.
  8798. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8799. * as well as binding the different shadow properties to the effects.
  8800. */
  8801. export interface IShadowLight extends Light {
  8802. /**
  8803. * The light id in the scene (used in scene.findLighById for instance)
  8804. */
  8805. id: string;
  8806. /**
  8807. * The position the shdow will be casted from.
  8808. */
  8809. position: Vector3;
  8810. /**
  8811. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8812. */
  8813. direction: Vector3;
  8814. /**
  8815. * The transformed position. Position of the light in world space taking parenting in account.
  8816. */
  8817. transformedPosition: Vector3;
  8818. /**
  8819. * The transformed direction. Direction of the light in world space taking parenting in account.
  8820. */
  8821. transformedDirection: Vector3;
  8822. /**
  8823. * The friendly name of the light in the scene.
  8824. */
  8825. name: string;
  8826. /**
  8827. * Defines the shadow projection clipping minimum z value.
  8828. */
  8829. shadowMinZ: number;
  8830. /**
  8831. * Defines the shadow projection clipping maximum z value.
  8832. */
  8833. shadowMaxZ: number;
  8834. /**
  8835. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8836. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8837. */
  8838. computeTransformedInformation(): boolean;
  8839. /**
  8840. * Gets the scene the light belongs to.
  8841. * @returns The scene
  8842. */
  8843. getScene(): Scene;
  8844. /**
  8845. * Callback defining a custom Projection Matrix Builder.
  8846. * This can be used to override the default projection matrix computation.
  8847. */
  8848. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. /**
  8858. * Gets the current depth scale used in ESM.
  8859. * @returns The scale
  8860. */
  8861. getDepthScale(): number;
  8862. /**
  8863. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8864. * @returns true if a cube texture needs to be use
  8865. */
  8866. needCube(): boolean;
  8867. /**
  8868. * Detects if the projection matrix requires to be recomputed this frame.
  8869. * @returns true if it requires to be recomputed otherwise, false.
  8870. */
  8871. needProjectionMatrixCompute(): boolean;
  8872. /**
  8873. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8874. */
  8875. forceProjectionMatrixCompute(): void;
  8876. /**
  8877. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8878. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8879. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8880. */
  8881. getShadowDirection(faceIndex?: number): Vector3;
  8882. /**
  8883. * Gets the minZ used for shadow according to both the scene and the light.
  8884. * @param activeCamera The camera we are returning the min for
  8885. * @returns the depth min z
  8886. */
  8887. getDepthMinZ(activeCamera: Camera): number;
  8888. /**
  8889. * Gets the maxZ used for shadow according to both the scene and the light.
  8890. * @param activeCamera The camera we are returning the max for
  8891. * @returns the depth max z
  8892. */
  8893. getDepthMaxZ(activeCamera: Camera): number;
  8894. }
  8895. /**
  8896. * Base implementation IShadowLight
  8897. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8898. */
  8899. export abstract class ShadowLight extends Light implements IShadowLight {
  8900. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8901. protected _position: Vector3;
  8902. protected _setPosition(value: Vector3): void;
  8903. /**
  8904. * Sets the position the shadow will be casted from. Also use as the light position for both
  8905. * point and spot lights.
  8906. */
  8907. /**
  8908. * Sets the position the shadow will be casted from. Also use as the light position for both
  8909. * point and spot lights.
  8910. */
  8911. position: Vector3;
  8912. protected _direction: Vector3;
  8913. protected _setDirection(value: Vector3): void;
  8914. /**
  8915. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8916. * Also use as the light direction on spot and directional lights.
  8917. */
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. direction: Vector3;
  8923. private _shadowMinZ;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. /**
  8928. * Sets the shadow projection clipping minimum z value.
  8929. */
  8930. shadowMinZ: number;
  8931. private _shadowMaxZ;
  8932. /**
  8933. * Sets the shadow projection clipping maximum z value.
  8934. */
  8935. /**
  8936. * Gets the shadow projection clipping maximum z value.
  8937. */
  8938. shadowMaxZ: number;
  8939. /**
  8940. * Callback defining a custom Projection Matrix Builder.
  8941. * This can be used to override the default projection matrix computation.
  8942. */
  8943. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8944. /**
  8945. * The transformed position. Position of the light in world space taking parenting in account.
  8946. */
  8947. transformedPosition: Vector3;
  8948. /**
  8949. * The transformed direction. Direction of the light in world space taking parenting in account.
  8950. */
  8951. transformedDirection: Vector3;
  8952. private _needProjectionMatrixCompute;
  8953. /**
  8954. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8955. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8956. */
  8957. computeTransformedInformation(): boolean;
  8958. /**
  8959. * Return the depth scale used for the shadow map.
  8960. * @returns the depth scale.
  8961. */
  8962. getDepthScale(): number;
  8963. /**
  8964. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8965. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8966. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8967. */
  8968. getShadowDirection(faceIndex?: number): Vector3;
  8969. /**
  8970. * Returns the ShadowLight absolute position in the World.
  8971. * @returns the position vector in world space
  8972. */
  8973. getAbsolutePosition(): Vector3;
  8974. /**
  8975. * Sets the ShadowLight direction toward the passed target.
  8976. * @param target The point to target in local space
  8977. * @returns the updated ShadowLight direction
  8978. */
  8979. setDirectionToTarget(target: Vector3): Vector3;
  8980. /**
  8981. * Returns the light rotation in euler definition.
  8982. * @returns the x y z rotation in local space.
  8983. */
  8984. getRotation(): Vector3;
  8985. /**
  8986. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8987. * @returns true if a cube texture needs to be use
  8988. */
  8989. needCube(): boolean;
  8990. /**
  8991. * Detects if the projection matrix requires to be recomputed this frame.
  8992. * @returns true if it requires to be recomputed otherwise, false.
  8993. */
  8994. needProjectionMatrixCompute(): boolean;
  8995. /**
  8996. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8997. */
  8998. forceProjectionMatrixCompute(): void;
  8999. /** @hidden */
  9000. _initCache(): void;
  9001. /** @hidden */
  9002. _isSynchronized(): boolean;
  9003. /**
  9004. * Computes the world matrix of the node
  9005. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9006. * @returns the world matrix
  9007. */
  9008. computeWorldMatrix(force?: boolean): Matrix;
  9009. /**
  9010. * Gets the minZ used for shadow according to both the scene and the light.
  9011. * @param activeCamera The camera we are returning the min for
  9012. * @returns the depth min z
  9013. */
  9014. getDepthMinZ(activeCamera: Camera): number;
  9015. /**
  9016. * Gets the maxZ used for shadow according to both the scene and the light.
  9017. * @param activeCamera The camera we are returning the max for
  9018. * @returns the depth max z
  9019. */
  9020. getDepthMaxZ(activeCamera: Camera): number;
  9021. /**
  9022. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9023. * @param matrix The materix to updated with the projection information
  9024. * @param viewMatrix The transform matrix of the light
  9025. * @param renderList The list of mesh to render in the map
  9026. * @returns The current light
  9027. */
  9028. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9029. }
  9030. }
  9031. declare module "babylonjs/Materials/effectFallbacks" {
  9032. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9033. import { Effect } from "babylonjs/Materials/effect";
  9034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9035. /**
  9036. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9037. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9038. */
  9039. export class EffectFallbacks implements IEffectFallbacks {
  9040. private _defines;
  9041. private _currentRank;
  9042. private _maxRank;
  9043. private _mesh;
  9044. /**
  9045. * Removes the fallback from the bound mesh.
  9046. */
  9047. unBindMesh(): void;
  9048. /**
  9049. * Adds a fallback on the specified property.
  9050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9051. * @param define The name of the define in the shader
  9052. */
  9053. addFallback(rank: number, define: string): void;
  9054. /**
  9055. * Sets the mesh to use CPU skinning when needing to fallback.
  9056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9057. * @param mesh The mesh to use the fallbacks.
  9058. */
  9059. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9060. /**
  9061. * Checks to see if more fallbacks are still availible.
  9062. */
  9063. readonly hasMoreFallbacks: boolean;
  9064. /**
  9065. * Removes the defines that should be removed when falling back.
  9066. * @param currentDefines defines the current define statements for the shader.
  9067. * @param effect defines the current effect we try to compile
  9068. * @returns The resulting defines with defines of the current rank removed.
  9069. */
  9070. reduce(currentDefines: string, effect: Effect): string;
  9071. }
  9072. }
  9073. declare module "babylonjs/Materials/materialHelper" {
  9074. import { Nullable } from "babylonjs/types";
  9075. import { Scene } from "babylonjs/scene";
  9076. import { Engine } from "babylonjs/Engines/engine";
  9077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9078. import { Light } from "babylonjs/Lights/light";
  9079. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9080. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9083. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9084. /**
  9085. * "Static Class" containing the most commonly used helper while dealing with material for
  9086. * rendering purpose.
  9087. *
  9088. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9089. *
  9090. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9091. */
  9092. export class MaterialHelper {
  9093. /**
  9094. * Bind the current view position to an effect.
  9095. * @param effect The effect to be bound
  9096. * @param scene The scene the eyes position is used from
  9097. */
  9098. static BindEyePosition(effect: Effect, scene: Scene): void;
  9099. /**
  9100. * Helps preparing the defines values about the UVs in used in the effect.
  9101. * UVs are shared as much as we can accross channels in the shaders.
  9102. * @param texture The texture we are preparing the UVs for
  9103. * @param defines The defines to update
  9104. * @param key The channel key "diffuse", "specular"... used in the shader
  9105. */
  9106. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9107. /**
  9108. * Binds a texture matrix value to its corrsponding uniform
  9109. * @param texture The texture to bind the matrix for
  9110. * @param uniformBuffer The uniform buffer receivin the data
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9114. /**
  9115. * Gets the current status of the fog (should it be enabled?)
  9116. * @param mesh defines the mesh to evaluate for fog support
  9117. * @param scene defines the hosting scene
  9118. * @returns true if fog must be enabled
  9119. */
  9120. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9123. * @param mesh defines the current mesh
  9124. * @param scene defines the current scene
  9125. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9126. * @param pointsCloud defines if point cloud rendering has to be turned on
  9127. * @param fogEnabled defines if fog has to be turned on
  9128. * @param alphaTest defines if alpha testing has to be turned on
  9129. * @param defines defines the current list of defines
  9130. */
  9131. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9132. /**
  9133. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9134. * @param scene defines the current scene
  9135. * @param engine defines the current engine
  9136. * @param defines specifies the list of active defines
  9137. * @param useInstances defines if instances have to be turned on
  9138. * @param useClipPlane defines if clip plane have to be turned on
  9139. */
  9140. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9141. /**
  9142. * Prepares the defines for bones
  9143. * @param mesh The mesh containing the geometry data we will draw
  9144. * @param defines The defines to update
  9145. */
  9146. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9147. /**
  9148. * Prepares the defines for morph targets
  9149. * @param mesh The mesh containing the geometry data we will draw
  9150. * @param defines The defines to update
  9151. */
  9152. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9153. /**
  9154. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9158. * @param useBones Precise whether bones should be used or not (override mesh info)
  9159. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9160. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9161. * @returns false if defines are considered not dirty and have not been checked
  9162. */
  9163. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9164. /**
  9165. * Prepares the defines related to multiview
  9166. * @param scene The scene we are intending to draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9170. /**
  9171. * Prepares the defines related to the light information passed in parameter
  9172. * @param scene The scene we are intending to draw
  9173. * @param mesh The mesh the effect is compiling for
  9174. * @param light The light the effect is compiling for
  9175. * @param lightIndex The index of the light
  9176. * @param defines The defines to update
  9177. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9178. * @param state Defines the current state regarding what is needed (normals, etc...)
  9179. */
  9180. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9181. needNormals: boolean;
  9182. needRebuild: boolean;
  9183. shadowEnabled: boolean;
  9184. specularEnabled: boolean;
  9185. lightmapMode: boolean;
  9186. }): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param defines The defines to update
  9192. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9193. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9194. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9195. * @returns true if normals will be required for the rest of the effect
  9196. */
  9197. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9198. /**
  9199. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9200. * @param lightIndex defines the light index
  9201. * @param uniformsList The uniform list
  9202. * @param samplersList The sampler list
  9203. * @param projectedLightTexture defines if projected texture must be used
  9204. * @param uniformBuffersList defines an optional list of uniform buffers
  9205. */
  9206. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The sampler list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. private static _TmpMorphInfluencers;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param influencers The number of influencers
  9230. */
  9231. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param defines The current Defines of the effect
  9237. */
  9238. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9239. /**
  9240. * Prepares the list of attributes required for bones according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the bones attributes for
  9243. * @param defines The current Defines of the effect
  9244. * @param fallbacks The current efffect fallback strategy
  9245. */
  9246. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9247. /**
  9248. * Check and prepare the list of attributes required for instances according to the effect defines.
  9249. * @param attribs The current list of supported attribs
  9250. * @param defines The current MaterialDefines of the effect
  9251. */
  9252. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9253. /**
  9254. * Add the list of attributes required for instances to the attribs array.
  9255. * @param attribs The current list of supported attribs
  9256. */
  9257. static PushAttributesForInstances(attribs: string[]): void;
  9258. /**
  9259. * Binds the light information to the effect.
  9260. * @param light The light containing the generator
  9261. * @param effect The effect we are binding the data to
  9262. * @param lightIndex The light index in the effect used to render
  9263. */
  9264. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9265. /**
  9266. * Binds the lights information from the scene to the effect for the given mesh.
  9267. * @param light Light to bind
  9268. * @param lightIndex Light index
  9269. * @param scene The scene where the light belongs to
  9270. * @param effect The effect we are binding the data to
  9271. * @param useSpecular Defines if specular is supported
  9272. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9273. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9274. */
  9275. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9276. /**
  9277. * Binds the lights information from the scene to the effect for the given mesh.
  9278. * @param scene The scene the lights belongs to
  9279. * @param mesh The mesh we are binding the information to render
  9280. * @param effect The effect we are binding the data to
  9281. * @param defines The generated defines for the effect
  9282. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9283. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9287. private static _tempFogColor;
  9288. /**
  9289. * Binds the fog information from the scene to the effect for the given mesh.
  9290. * @param scene The scene the lights belongs to
  9291. * @param mesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. * @param linearSpace Defines if the fog effect is applied in linear space
  9294. */
  9295. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9296. /**
  9297. * Binds the bones information from the mesh to the effect.
  9298. * @param mesh The mesh we are binding the information to render
  9299. * @param effect The effect we are binding the data to
  9300. */
  9301. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9302. /**
  9303. * Binds the morph targets information from the mesh to the effect.
  9304. * @param abstractMesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9308. /**
  9309. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9310. * @param defines The generated defines used in the effect
  9311. * @param effect The effect we are binding the data to
  9312. * @param scene The scene we are willing to render with logarithmic scale for
  9313. */
  9314. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9315. /**
  9316. * Binds the clip plane information from the scene to the effect.
  9317. * @param scene The scene the clip plane information are extracted from
  9318. * @param effect The effect we are binding the data to
  9319. */
  9320. static BindClipPlane(effect: Effect, scene: Scene): void;
  9321. }
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9324. /** @hidden */
  9325. export var packingFunctions: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9331. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9395. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9398. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9399. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9400. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9401. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9403. /** @hidden */
  9404. export var shadowMapVertexShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9410. /** @hidden */
  9411. export var depthBoxBlurPixelShader: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9417. import { Nullable } from "babylonjs/types";
  9418. import { Scene } from "babylonjs/scene";
  9419. import { Matrix } from "babylonjs/Maths/math.vector";
  9420. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9422. import { Mesh } from "babylonjs/Meshes/mesh";
  9423. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9424. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9425. import { Effect } from "babylonjs/Materials/effect";
  9426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9427. import "babylonjs/Shaders/shadowMap.fragment";
  9428. import "babylonjs/Shaders/shadowMap.vertex";
  9429. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9430. import { Observable } from "babylonjs/Misc/observable";
  9431. /**
  9432. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9433. */
  9434. export interface ICustomShaderOptions {
  9435. /**
  9436. * Gets or sets the custom shader name to use
  9437. */
  9438. shaderName: string;
  9439. /**
  9440. * The list of attribute names used in the shader
  9441. */
  9442. attributes?: string[];
  9443. /**
  9444. * The list of unifrom names used in the shader
  9445. */
  9446. uniforms?: string[];
  9447. /**
  9448. * The list of sampler names used in the shader
  9449. */
  9450. samplers?: string[];
  9451. /**
  9452. * The list of defines used in the shader
  9453. */
  9454. defines?: string[];
  9455. }
  9456. /**
  9457. * Interface to implement to create a shadow generator compatible with BJS.
  9458. */
  9459. export interface IShadowGenerator {
  9460. /**
  9461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9462. * @returns The render target texture if present otherwise, null
  9463. */
  9464. getShadowMap(): Nullable<RenderTargetTexture>;
  9465. /**
  9466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9467. * @returns The render target texture if the shadow map is present otherwise, null
  9468. */
  9469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9470. /**
  9471. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9472. * @param subMesh The submesh we want to render in the shadow map
  9473. * @param useInstances Defines wether will draw in the map using instances
  9474. * @returns true if ready otherwise, false
  9475. */
  9476. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9477. /**
  9478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9479. * @param defines Defines of the material we want to update
  9480. * @param lightIndex Index of the light in the enabled light list of the material
  9481. */
  9482. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9483. /**
  9484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9485. * defined in the generator but impacting the effect).
  9486. * It implies the unifroms available on the materials are the standard BJS ones.
  9487. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9488. * @param effect The effect we are binfing the information for
  9489. */
  9490. bindShadowLight(lightIndex: string, effect: Effect): void;
  9491. /**
  9492. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9493. * (eq to shadow prjection matrix * light transform matrix)
  9494. * @returns The transform matrix used to create the shadow map
  9495. */
  9496. getTransformMatrix(): Matrix;
  9497. /**
  9498. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9499. * Cube and 2D textures for instance.
  9500. */
  9501. recreateShadowMap(): void;
  9502. /**
  9503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9504. * @param onCompiled Callback triggered at the and of the effects compilation
  9505. * @param options Sets of optional options forcing the compilation with different modes
  9506. */
  9507. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9508. useInstances: boolean;
  9509. }>): void;
  9510. /**
  9511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9512. * @param options Sets of optional options forcing the compilation with different modes
  9513. * @returns A promise that resolves when the compilation completes
  9514. */
  9515. forceCompilationAsync(options?: Partial<{
  9516. useInstances: boolean;
  9517. }>): Promise<void>;
  9518. /**
  9519. * Serializes the shadow generator setup to a json object.
  9520. * @returns The serialized JSON object
  9521. */
  9522. serialize(): any;
  9523. /**
  9524. * Disposes the Shadow map and related Textures and effects.
  9525. */
  9526. dispose(): void;
  9527. }
  9528. /**
  9529. * Default implementation IShadowGenerator.
  9530. * This is the main object responsible of generating shadows in the framework.
  9531. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9532. */
  9533. export class ShadowGenerator implements IShadowGenerator {
  9534. /**
  9535. * Shadow generator mode None: no filtering applied.
  9536. */
  9537. static readonly FILTER_NONE: number;
  9538. /**
  9539. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9540. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9541. */
  9542. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9543. /**
  9544. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9545. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9546. */
  9547. static readonly FILTER_POISSONSAMPLING: number;
  9548. /**
  9549. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9550. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9551. */
  9552. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9553. /**
  9554. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9555. * edge artifacts on steep falloff.
  9556. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9557. */
  9558. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9559. /**
  9560. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9561. * edge artifacts on steep falloff.
  9562. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9563. */
  9564. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9565. /**
  9566. * Shadow generator mode PCF: Percentage Closer Filtering
  9567. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9568. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9569. */
  9570. static readonly FILTER_PCF: number;
  9571. /**
  9572. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9573. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9574. * Contact Hardening
  9575. */
  9576. static readonly FILTER_PCSS: number;
  9577. /**
  9578. * Reserved for PCF and PCSS
  9579. * Highest Quality.
  9580. *
  9581. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9582. *
  9583. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9584. */
  9585. static readonly QUALITY_HIGH: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * Good tradeoff for quality/perf cross devices
  9589. *
  9590. * Execute PCF on a 3*3 kernel.
  9591. *
  9592. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9593. */
  9594. static readonly QUALITY_MEDIUM: number;
  9595. /**
  9596. * Reserved for PCF and PCSS
  9597. * The lowest quality but the fastest.
  9598. *
  9599. * Execute PCF on a 1*1 kernel.
  9600. *
  9601. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9602. */
  9603. static readonly QUALITY_LOW: number;
  9604. /** Gets or sets the custom shader name to use */
  9605. customShaderOptions: ICustomShaderOptions;
  9606. /**
  9607. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9608. */
  9609. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9610. /**
  9611. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9612. */
  9613. onAfterShadowMapRenderObservable: Observable<Effect>;
  9614. /**
  9615. * Observable triggered before a mesh is rendered in the shadow map.
  9616. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9617. */
  9618. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9619. /**
  9620. * Observable triggered after a mesh is rendered in the shadow map.
  9621. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9622. */
  9623. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9624. private _bias;
  9625. /**
  9626. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9627. */
  9628. /**
  9629. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9630. */
  9631. bias: number;
  9632. private _normalBias;
  9633. /**
  9634. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9635. */
  9636. /**
  9637. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9638. */
  9639. normalBias: number;
  9640. private _blurBoxOffset;
  9641. /**
  9642. * Gets the blur box offset: offset applied during the blur pass.
  9643. * Only useful if useKernelBlur = false
  9644. */
  9645. /**
  9646. * Sets the blur box offset: offset applied during the blur pass.
  9647. * Only useful if useKernelBlur = false
  9648. */
  9649. blurBoxOffset: number;
  9650. private _blurScale;
  9651. /**
  9652. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9653. * 2 means half of the size.
  9654. */
  9655. /**
  9656. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9657. * 2 means half of the size.
  9658. */
  9659. blurScale: number;
  9660. private _blurKernel;
  9661. /**
  9662. * Gets the blur kernel: kernel size of the blur pass.
  9663. * Only useful if useKernelBlur = true
  9664. */
  9665. /**
  9666. * Sets the blur kernel: kernel size of the blur pass.
  9667. * Only useful if useKernelBlur = true
  9668. */
  9669. blurKernel: number;
  9670. private _useKernelBlur;
  9671. /**
  9672. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9673. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9674. */
  9675. /**
  9676. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9677. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9678. */
  9679. useKernelBlur: boolean;
  9680. private _depthScale;
  9681. /**
  9682. * Gets the depth scale used in ESM mode.
  9683. */
  9684. /**
  9685. * Sets the depth scale used in ESM mode.
  9686. * This can override the scale stored on the light.
  9687. */
  9688. depthScale: number;
  9689. private _filter;
  9690. /**
  9691. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9692. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9693. */
  9694. /**
  9695. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9696. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9697. */
  9698. filter: number;
  9699. /**
  9700. * Gets if the current filter is set to Poisson Sampling.
  9701. */
  9702. /**
  9703. * Sets the current filter to Poisson Sampling.
  9704. */
  9705. usePoissonSampling: boolean;
  9706. /**
  9707. * Gets if the current filter is set to ESM.
  9708. */
  9709. /**
  9710. * Sets the current filter is to ESM.
  9711. */
  9712. useExponentialShadowMap: boolean;
  9713. /**
  9714. * Gets if the current filter is set to filtered ESM.
  9715. */
  9716. /**
  9717. * Gets if the current filter is set to filtered ESM.
  9718. */
  9719. useBlurExponentialShadowMap: boolean;
  9720. /**
  9721. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9722. * exponential to prevent steep falloff artifacts).
  9723. */
  9724. /**
  9725. * Sets the current filter to "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. useCloseExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. /**
  9734. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9735. * exponential to prevent steep falloff artifacts).
  9736. */
  9737. useBlurCloseExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9740. */
  9741. /**
  9742. * Sets the current filter to "PCF" (percentage closer filtering).
  9743. */
  9744. usePercentageCloserFiltering: boolean;
  9745. private _filteringQuality;
  9746. /**
  9747. * Gets the PCF or PCSS Quality.
  9748. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9749. */
  9750. /**
  9751. * Sets the PCF or PCSS Quality.
  9752. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9753. */
  9754. filteringQuality: number;
  9755. /**
  9756. * Gets if the current filter is set to "PCSS" (contact hardening).
  9757. */
  9758. /**
  9759. * Sets the current filter to "PCSS" (contact hardening).
  9760. */
  9761. useContactHardeningShadow: boolean;
  9762. private _contactHardeningLightSizeUVRatio;
  9763. /**
  9764. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9765. * Using a ratio helps keeping shape stability independently of the map size.
  9766. *
  9767. * It does not account for the light projection as it was having too much
  9768. * instability during the light setup or during light position changes.
  9769. *
  9770. * Only valid if useContactHardeningShadow is true.
  9771. */
  9772. /**
  9773. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9774. * Using a ratio helps keeping shape stability independently of the map size.
  9775. *
  9776. * It does not account for the light projection as it was having too much
  9777. * instability during the light setup or during light position changes.
  9778. *
  9779. * Only valid if useContactHardeningShadow is true.
  9780. */
  9781. contactHardeningLightSizeUVRatio: number;
  9782. private _darkness;
  9783. /** Gets or sets the actual darkness of a shadow */
  9784. darkness: number;
  9785. /**
  9786. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9787. * 0 means strongest and 1 would means no shadow.
  9788. * @returns the darkness.
  9789. */
  9790. getDarkness(): number;
  9791. /**
  9792. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9793. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9794. * @returns the shadow generator allowing fluent coding.
  9795. */
  9796. setDarkness(darkness: number): ShadowGenerator;
  9797. private _transparencyShadow;
  9798. /** Gets or sets the ability to have transparent shadow */
  9799. transparencyShadow: boolean;
  9800. /**
  9801. * Sets the ability to have transparent shadow (boolean).
  9802. * @param transparent True if transparent else False
  9803. * @returns the shadow generator allowing fluent coding
  9804. */
  9805. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9806. private _shadowMap;
  9807. private _shadowMap2;
  9808. /**
  9809. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9810. * @returns The render target texture if present otherwise, null
  9811. */
  9812. getShadowMap(): Nullable<RenderTargetTexture>;
  9813. /**
  9814. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9815. * @returns The render target texture if the shadow map is present otherwise, null
  9816. */
  9817. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9818. /**
  9819. * Gets the class name of that object
  9820. * @returns "ShadowGenerator"
  9821. */
  9822. getClassName(): string;
  9823. /**
  9824. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9825. * @param mesh Mesh to add
  9826. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9827. * @returns the Shadow Generator itself
  9828. */
  9829. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9830. /**
  9831. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9832. * @param mesh Mesh to remove
  9833. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9834. * @returns the Shadow Generator itself
  9835. */
  9836. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9837. /**
  9838. * Controls the extent to which the shadows fade out at the edge of the frustum
  9839. * Used only by directionals and spots
  9840. */
  9841. frustumEdgeFalloff: number;
  9842. private _light;
  9843. /**
  9844. * Returns the associated light object.
  9845. * @returns the light generating the shadow
  9846. */
  9847. getLight(): IShadowLight;
  9848. /**
  9849. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9850. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9851. * It might on the other hand introduce peter panning.
  9852. */
  9853. forceBackFacesOnly: boolean;
  9854. private _scene;
  9855. private _lightDirection;
  9856. private _effect;
  9857. private _viewMatrix;
  9858. private _projectionMatrix;
  9859. private _transformMatrix;
  9860. private _cachedPosition;
  9861. private _cachedDirection;
  9862. private _cachedDefines;
  9863. private _currentRenderID;
  9864. private _boxBlurPostprocess;
  9865. private _kernelBlurXPostprocess;
  9866. private _kernelBlurYPostprocess;
  9867. private _blurPostProcesses;
  9868. private _mapSize;
  9869. private _currentFaceIndex;
  9870. private _currentFaceIndexCache;
  9871. private _textureType;
  9872. private _defaultTextureMatrix;
  9873. private _storedUniqueId;
  9874. /** @hidden */
  9875. static _SceneComponentInitialization: (scene: Scene) => void;
  9876. /**
  9877. * Creates a ShadowGenerator object.
  9878. * A ShadowGenerator is the required tool to use the shadows.
  9879. * Each light casting shadows needs to use its own ShadowGenerator.
  9880. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9881. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9882. * @param light The light object generating the shadows.
  9883. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9884. */
  9885. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9886. private _initializeGenerator;
  9887. private _initializeShadowMap;
  9888. private _initializeBlurRTTAndPostProcesses;
  9889. private _renderForShadowMap;
  9890. private _renderSubMeshForShadowMap;
  9891. private _applyFilterValues;
  9892. /**
  9893. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9894. * @param onCompiled Callback triggered at the and of the effects compilation
  9895. * @param options Sets of optional options forcing the compilation with different modes
  9896. */
  9897. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9898. useInstances: boolean;
  9899. }>): void;
  9900. /**
  9901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9902. * @param options Sets of optional options forcing the compilation with different modes
  9903. * @returns A promise that resolves when the compilation completes
  9904. */
  9905. forceCompilationAsync(options?: Partial<{
  9906. useInstances: boolean;
  9907. }>): Promise<void>;
  9908. /**
  9909. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9910. * @param subMesh The submesh we want to render in the shadow map
  9911. * @param useInstances Defines wether will draw in the map using instances
  9912. * @returns true if ready otherwise, false
  9913. */
  9914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9915. /**
  9916. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9917. * @param defines Defines of the material we want to update
  9918. * @param lightIndex Index of the light in the enabled light list of the material
  9919. */
  9920. prepareDefines(defines: any, lightIndex: number): void;
  9921. /**
  9922. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9923. * defined in the generator but impacting the effect).
  9924. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9925. * @param effect The effect we are binfing the information for
  9926. */
  9927. bindShadowLight(lightIndex: string, effect: Effect): void;
  9928. /**
  9929. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9930. * (eq to shadow prjection matrix * light transform matrix)
  9931. * @returns The transform matrix used to create the shadow map
  9932. */
  9933. getTransformMatrix(): Matrix;
  9934. /**
  9935. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9936. * Cube and 2D textures for instance.
  9937. */
  9938. recreateShadowMap(): void;
  9939. private _disposeBlurPostProcesses;
  9940. private _disposeRTTandPostProcesses;
  9941. /**
  9942. * Disposes the ShadowGenerator.
  9943. * Returns nothing.
  9944. */
  9945. dispose(): void;
  9946. /**
  9947. * Serializes the shadow generator setup to a json object.
  9948. * @returns The serialized JSON object
  9949. */
  9950. serialize(): any;
  9951. /**
  9952. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9953. * @param parsedShadowGenerator The JSON object to parse
  9954. * @param scene The scene to create the shadow map for
  9955. * @returns The parsed shadow generator
  9956. */
  9957. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9958. }
  9959. }
  9960. declare module "babylonjs/Lights/light" {
  9961. import { Nullable } from "babylonjs/types";
  9962. import { Scene } from "babylonjs/scene";
  9963. import { Vector3 } from "babylonjs/Maths/math.vector";
  9964. import { Color3 } from "babylonjs/Maths/math.color";
  9965. import { Node } from "babylonjs/node";
  9966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9967. import { Effect } from "babylonjs/Materials/effect";
  9968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9969. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9970. /**
  9971. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9972. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9973. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9974. */
  9975. export abstract class Light extends Node {
  9976. /**
  9977. * Falloff Default: light is falling off following the material specification:
  9978. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9979. */
  9980. static readonly FALLOFF_DEFAULT: number;
  9981. /**
  9982. * Falloff Physical: light is falling off following the inverse squared distance law.
  9983. */
  9984. static readonly FALLOFF_PHYSICAL: number;
  9985. /**
  9986. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9987. * to enhance interoperability with other engines.
  9988. */
  9989. static readonly FALLOFF_GLTF: number;
  9990. /**
  9991. * Falloff Standard: light is falling off like in the standard material
  9992. * to enhance interoperability with other materials.
  9993. */
  9994. static readonly FALLOFF_STANDARD: number;
  9995. /**
  9996. * If every light affecting the material is in this lightmapMode,
  9997. * material.lightmapTexture adds or multiplies
  9998. * (depends on material.useLightmapAsShadowmap)
  9999. * after every other light calculations.
  10000. */
  10001. static readonly LIGHTMAP_DEFAULT: number;
  10002. /**
  10003. * material.lightmapTexture as only diffuse lighting from this light
  10004. * adds only specular lighting from this light
  10005. * adds dynamic shadows
  10006. */
  10007. static readonly LIGHTMAP_SPECULAR: number;
  10008. /**
  10009. * material.lightmapTexture as only lighting
  10010. * no light calculation from this light
  10011. * only adds dynamic shadows from this light
  10012. */
  10013. static readonly LIGHTMAP_SHADOWSONLY: number;
  10014. /**
  10015. * Each light type uses the default quantity according to its type:
  10016. * point/spot lights use luminous intensity
  10017. * directional lights use illuminance
  10018. */
  10019. static readonly INTENSITYMODE_AUTOMATIC: number;
  10020. /**
  10021. * lumen (lm)
  10022. */
  10023. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10024. /**
  10025. * candela (lm/sr)
  10026. */
  10027. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10028. /**
  10029. * lux (lm/m^2)
  10030. */
  10031. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10032. /**
  10033. * nit (cd/m^2)
  10034. */
  10035. static readonly INTENSITYMODE_LUMINANCE: number;
  10036. /**
  10037. * Light type const id of the point light.
  10038. */
  10039. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10040. /**
  10041. * Light type const id of the directional light.
  10042. */
  10043. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10044. /**
  10045. * Light type const id of the spot light.
  10046. */
  10047. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10048. /**
  10049. * Light type const id of the hemispheric light.
  10050. */
  10051. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10052. /**
  10053. * Diffuse gives the basic color to an object.
  10054. */
  10055. diffuse: Color3;
  10056. /**
  10057. * Specular produces a highlight color on an object.
  10058. * Note: This is note affecting PBR materials.
  10059. */
  10060. specular: Color3;
  10061. /**
  10062. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10063. * falling off base on range or angle.
  10064. * This can be set to any values in Light.FALLOFF_x.
  10065. *
  10066. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10067. * other types of materials.
  10068. */
  10069. falloffType: number;
  10070. /**
  10071. * Strength of the light.
  10072. * Note: By default it is define in the framework own unit.
  10073. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10074. */
  10075. intensity: number;
  10076. private _range;
  10077. protected _inverseSquaredRange: number;
  10078. /**
  10079. * Defines how far from the source the light is impacting in scene units.
  10080. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10081. */
  10082. /**
  10083. * Defines how far from the source the light is impacting in scene units.
  10084. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10085. */
  10086. range: number;
  10087. /**
  10088. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10089. * of light.
  10090. */
  10091. private _photometricScale;
  10092. private _intensityMode;
  10093. /**
  10094. * Gets the photometric scale used to interpret the intensity.
  10095. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10096. */
  10097. /**
  10098. * Sets the photometric scale used to interpret the intensity.
  10099. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10100. */
  10101. intensityMode: number;
  10102. private _radius;
  10103. /**
  10104. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10105. */
  10106. /**
  10107. * sets the light radius used by PBR Materials to simulate soft area lights.
  10108. */
  10109. radius: number;
  10110. private _renderPriority;
  10111. /**
  10112. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10113. * exceeding the number allowed of the materials.
  10114. */
  10115. renderPriority: number;
  10116. private _shadowEnabled;
  10117. /**
  10118. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10119. * the current shadow generator.
  10120. */
  10121. /**
  10122. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10123. * the current shadow generator.
  10124. */
  10125. shadowEnabled: boolean;
  10126. private _includedOnlyMeshes;
  10127. /**
  10128. * Gets the only meshes impacted by this light.
  10129. */
  10130. /**
  10131. * Sets the only meshes impacted by this light.
  10132. */
  10133. includedOnlyMeshes: AbstractMesh[];
  10134. private _excludedMeshes;
  10135. /**
  10136. * Gets the meshes not impacted by this light.
  10137. */
  10138. /**
  10139. * Sets the meshes not impacted by this light.
  10140. */
  10141. excludedMeshes: AbstractMesh[];
  10142. private _excludeWithLayerMask;
  10143. /**
  10144. * Gets the layer id use to find what meshes are not impacted by the light.
  10145. * Inactive if 0
  10146. */
  10147. /**
  10148. * Sets the layer id use to find what meshes are not impacted by the light.
  10149. * Inactive if 0
  10150. */
  10151. excludeWithLayerMask: number;
  10152. private _includeOnlyWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. includeOnlyWithLayerMask: number;
  10162. private _lightmapMode;
  10163. /**
  10164. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10165. */
  10166. /**
  10167. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10168. */
  10169. lightmapMode: number;
  10170. /**
  10171. * Shadow generator associted to the light.
  10172. * @hidden Internal use only.
  10173. */
  10174. _shadowGenerator: Nullable<IShadowGenerator>;
  10175. /**
  10176. * @hidden Internal use only.
  10177. */
  10178. _excludedMeshesIds: string[];
  10179. /**
  10180. * @hidden Internal use only.
  10181. */
  10182. _includedOnlyMeshesIds: string[];
  10183. /**
  10184. * The current light unifom buffer.
  10185. * @hidden Internal use only.
  10186. */
  10187. _uniformBuffer: UniformBuffer;
  10188. /** @hidden */
  10189. _renderId: number;
  10190. /**
  10191. * Creates a Light object in the scene.
  10192. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10193. * @param name The firendly name of the light
  10194. * @param scene The scene the light belongs too
  10195. */
  10196. constructor(name: string, scene: Scene);
  10197. protected abstract _buildUniformLayout(): void;
  10198. /**
  10199. * Sets the passed Effect "effect" with the Light information.
  10200. * @param effect The effect to update
  10201. * @param lightIndex The index of the light in the effect to update
  10202. * @returns The light
  10203. */
  10204. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10205. /**
  10206. * Sets the passed Effect "effect" with the Light information.
  10207. * @param effect The effect to update
  10208. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10209. * @returns The light
  10210. */
  10211. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10212. /**
  10213. * Returns the string "Light".
  10214. * @returns the class name
  10215. */
  10216. getClassName(): string;
  10217. /** @hidden */
  10218. readonly _isLight: boolean;
  10219. /**
  10220. * Converts the light information to a readable string for debug purpose.
  10221. * @param fullDetails Supports for multiple levels of logging within scene loading
  10222. * @returns the human readable light info
  10223. */
  10224. toString(fullDetails?: boolean): string;
  10225. /** @hidden */
  10226. protected _syncParentEnabledState(): void;
  10227. /**
  10228. * Set the enabled state of this node.
  10229. * @param value - the new enabled state
  10230. */
  10231. setEnabled(value: boolean): void;
  10232. /**
  10233. * Returns the Light associated shadow generator if any.
  10234. * @return the associated shadow generator.
  10235. */
  10236. getShadowGenerator(): Nullable<IShadowGenerator>;
  10237. /**
  10238. * Returns a Vector3, the absolute light position in the World.
  10239. * @returns the world space position of the light
  10240. */
  10241. getAbsolutePosition(): Vector3;
  10242. /**
  10243. * Specifies if the light will affect the passed mesh.
  10244. * @param mesh The mesh to test against the light
  10245. * @return true the mesh is affected otherwise, false.
  10246. */
  10247. canAffectMesh(mesh: AbstractMesh): boolean;
  10248. /**
  10249. * Sort function to order lights for rendering.
  10250. * @param a First Light object to compare to second.
  10251. * @param b Second Light object to compare first.
  10252. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10253. */
  10254. static CompareLightsPriority(a: Light, b: Light): number;
  10255. /**
  10256. * Releases resources associated with this node.
  10257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10259. */
  10260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10261. /**
  10262. * Returns the light type ID (integer).
  10263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10264. */
  10265. getTypeID(): number;
  10266. /**
  10267. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10268. * @returns the scaled intensity in intensity mode unit
  10269. */
  10270. getScaledIntensity(): number;
  10271. /**
  10272. * Returns a new Light object, named "name", from the current one.
  10273. * @param name The name of the cloned light
  10274. * @returns the new created light
  10275. */
  10276. clone(name: string): Nullable<Light>;
  10277. /**
  10278. * Serializes the current light into a Serialization object.
  10279. * @returns the serialized object.
  10280. */
  10281. serialize(): any;
  10282. /**
  10283. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10284. * This new light is named "name" and added to the passed scene.
  10285. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10286. * @param name The friendly name of the light
  10287. * @param scene The scene the new light will belong to
  10288. * @returns the constructor function
  10289. */
  10290. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10291. /**
  10292. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10293. * @param parsedLight The JSON representation of the light
  10294. * @param scene The scene to create the parsed light in
  10295. * @returns the created light after parsing
  10296. */
  10297. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10298. private _hookArrayForExcluded;
  10299. private _hookArrayForIncludedOnly;
  10300. private _resyncMeshes;
  10301. /**
  10302. * Forces the meshes to update their light related information in their rendering used effects
  10303. * @hidden Internal Use Only
  10304. */
  10305. _markMeshesAsLightDirty(): void;
  10306. /**
  10307. * Recomputes the cached photometric scale if needed.
  10308. */
  10309. private _computePhotometricScale;
  10310. /**
  10311. * Returns the Photometric Scale according to the light type and intensity mode.
  10312. */
  10313. private _getPhotometricScale;
  10314. /**
  10315. * Reorder the light in the scene according to their defined priority.
  10316. * @hidden Internal Use Only
  10317. */
  10318. _reorderLightsInScene(): void;
  10319. /**
  10320. * Prepares the list of defines specific to the light type.
  10321. * @param defines the list of defines
  10322. * @param lightIndex defines the index of the light for the effect
  10323. */
  10324. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Actions/action" {
  10328. import { Observable } from "babylonjs/Misc/observable";
  10329. import { Condition } from "babylonjs/Actions/condition";
  10330. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. _prepare(): void;
  10364. /**
  10365. * Internal only - manager for action
  10366. * @hidden
  10367. */
  10368. _actionManager: AbstractActionManager;
  10369. /**
  10370. * Adds action to chain of actions, may be a DoNothingAction
  10371. * @param action defines the next action to execute
  10372. * @returns The action passed in
  10373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10374. */
  10375. then(action: IAction): IAction;
  10376. }
  10377. /**
  10378. * The action to be carried out following a trigger
  10379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10380. */
  10381. export class Action implements IAction {
  10382. /** the trigger, with or without parameters, for the action */
  10383. triggerOptions: any;
  10384. /**
  10385. * Trigger for the action
  10386. */
  10387. trigger: number;
  10388. /**
  10389. * Internal only - manager for action
  10390. * @hidden
  10391. */
  10392. _actionManager: ActionManager;
  10393. private _nextActiveAction;
  10394. private _child;
  10395. private _condition?;
  10396. private _triggerParameter;
  10397. /**
  10398. * An event triggered prior to action being executed.
  10399. */
  10400. onBeforeExecuteObservable: Observable<Action>;
  10401. /**
  10402. * Creates a new Action
  10403. * @param triggerOptions the trigger, with or without parameters, for the action
  10404. * @param condition an optional determinant of action
  10405. */
  10406. constructor(
  10407. /** the trigger, with or without parameters, for the action */
  10408. triggerOptions: any, condition?: Condition);
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. _prepare(): void;
  10414. /**
  10415. * Gets the trigger parameters
  10416. * @returns the trigger parameters
  10417. */
  10418. getTriggerParameter(): any;
  10419. /**
  10420. * Internal only - executes current action event
  10421. * @hidden
  10422. */
  10423. _executeCurrent(evt?: ActionEvent): void;
  10424. /**
  10425. * Execute placeholder for child classes
  10426. * @param evt optional action event
  10427. */
  10428. execute(evt?: ActionEvent): void;
  10429. /**
  10430. * Skips to next active action
  10431. */
  10432. skipToNextActiveAction(): void;
  10433. /**
  10434. * Adds action to chain of actions, may be a DoNothingAction
  10435. * @param action defines the next action to execute
  10436. * @returns The action passed in
  10437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10438. */
  10439. then(action: Action): Action;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. _getProperty(propertyPath: string): string;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. _getEffectiveTarget(target: any, propertyPath: string): any;
  10450. /**
  10451. * Serialize placeholder for child classes
  10452. * @param parent of child
  10453. * @returns the serialized object
  10454. */
  10455. serialize(parent: any): any;
  10456. /**
  10457. * Internal only called by serialize
  10458. * @hidden
  10459. */
  10460. protected _serialize(serializedAction: any, parent?: any): any;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. static _SerializeValueAsString: (value: any) => string;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10471. name: string;
  10472. targetType: string;
  10473. value: string;
  10474. };
  10475. }
  10476. }
  10477. declare module "babylonjs/Actions/condition" {
  10478. import { ActionManager } from "babylonjs/Actions/actionManager";
  10479. /**
  10480. * A Condition applied to an Action
  10481. */
  10482. export class Condition {
  10483. /**
  10484. * Internal only - manager for action
  10485. * @hidden
  10486. */
  10487. _actionManager: ActionManager;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. _evaluationId: number;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. _currentResult: boolean;
  10498. /**
  10499. * Creates a new Condition
  10500. * @param actionManager the manager of the action the condition is applied to
  10501. */
  10502. constructor(actionManager: ActionManager);
  10503. /**
  10504. * Check if the current condition is valid
  10505. * @returns a boolean
  10506. */
  10507. isValid(): boolean;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _getProperty(propertyPath: string): string;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _getEffectiveTarget(target: any, propertyPath: string): any;
  10518. /**
  10519. * Serialize placeholder for child classes
  10520. * @returns the serialized object
  10521. */
  10522. serialize(): any;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. protected _serialize(serializedCondition: any): any;
  10528. }
  10529. /**
  10530. * Defines specific conditional operators as extensions of Condition
  10531. */
  10532. export class ValueCondition extends Condition {
  10533. /** path to specify the property of the target the conditional operator uses */
  10534. propertyPath: string;
  10535. /** the value compared by the conditional operator against the current value of the property */
  10536. value: any;
  10537. /** the conditional operator, default ValueCondition.IsEqual */
  10538. operator: number;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. private static _IsEqual;
  10544. /**
  10545. * Internal only
  10546. * @hidden
  10547. */
  10548. private static _IsDifferent;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private static _IsGreater;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsLesser;
  10559. /**
  10560. * returns the number for IsEqual
  10561. */
  10562. static readonly IsEqual: number;
  10563. /**
  10564. * Returns the number for IsDifferent
  10565. */
  10566. static readonly IsDifferent: number;
  10567. /**
  10568. * Returns the number for IsGreater
  10569. */
  10570. static readonly IsGreater: number;
  10571. /**
  10572. * Returns the number for IsLesser
  10573. */
  10574. static readonly IsLesser: number;
  10575. /**
  10576. * Internal only The action manager for the condition
  10577. * @hidden
  10578. */
  10579. _actionManager: ActionManager;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private _target;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. private _effectiveTarget;
  10590. /**
  10591. * Internal only
  10592. * @hidden
  10593. */
  10594. private _property;
  10595. /**
  10596. * Creates a new ValueCondition
  10597. * @param actionManager manager for the action the condition applies to
  10598. * @param target for the action
  10599. * @param propertyPath path to specify the property of the target the conditional operator uses
  10600. * @param value the value compared by the conditional operator against the current value of the property
  10601. * @param operator the conditional operator, default ValueCondition.IsEqual
  10602. */
  10603. constructor(actionManager: ActionManager, target: any,
  10604. /** path to specify the property of the target the conditional operator uses */
  10605. propertyPath: string,
  10606. /** the value compared by the conditional operator against the current value of the property */
  10607. value: any,
  10608. /** the conditional operator, default ValueCondition.IsEqual */
  10609. operator?: number);
  10610. /**
  10611. * Compares the given value with the property value for the specified conditional operator
  10612. * @returns the result of the comparison
  10613. */
  10614. isValid(): boolean;
  10615. /**
  10616. * Serialize the ValueCondition into a JSON compatible object
  10617. * @returns serialization object
  10618. */
  10619. serialize(): any;
  10620. /**
  10621. * Gets the name of the conditional operator for the ValueCondition
  10622. * @param operator the conditional operator
  10623. * @returns the name
  10624. */
  10625. static GetOperatorName(operator: number): string;
  10626. }
  10627. /**
  10628. * Defines a predicate condition as an extension of Condition
  10629. */
  10630. export class PredicateCondition extends Condition {
  10631. /** defines the predicate function used to validate the condition */
  10632. predicate: () => boolean;
  10633. /**
  10634. * Internal only - manager for action
  10635. * @hidden
  10636. */
  10637. _actionManager: ActionManager;
  10638. /**
  10639. * Creates a new PredicateCondition
  10640. * @param actionManager manager for the action the condition applies to
  10641. * @param predicate defines the predicate function used to validate the condition
  10642. */
  10643. constructor(actionManager: ActionManager,
  10644. /** defines the predicate function used to validate the condition */
  10645. predicate: () => boolean);
  10646. /**
  10647. * @returns the validity of the predicate condition
  10648. */
  10649. isValid(): boolean;
  10650. }
  10651. /**
  10652. * Defines a state condition as an extension of Condition
  10653. */
  10654. export class StateCondition extends Condition {
  10655. /** Value to compare with target state */
  10656. value: string;
  10657. /**
  10658. * Internal only - manager for action
  10659. * @hidden
  10660. */
  10661. _actionManager: ActionManager;
  10662. /**
  10663. * Internal only
  10664. * @hidden
  10665. */
  10666. private _target;
  10667. /**
  10668. * Creates a new StateCondition
  10669. * @param actionManager manager for the action the condition applies to
  10670. * @param target of the condition
  10671. * @param value to compare with target state
  10672. */
  10673. constructor(actionManager: ActionManager, target: any,
  10674. /** Value to compare with target state */
  10675. value: string);
  10676. /**
  10677. * Gets a boolean indicating if the current condition is met
  10678. * @returns the validity of the state
  10679. */
  10680. isValid(): boolean;
  10681. /**
  10682. * Serialize the StateCondition into a JSON compatible object
  10683. * @returns serialization object
  10684. */
  10685. serialize(): any;
  10686. }
  10687. }
  10688. declare module "babylonjs/Actions/directActions" {
  10689. import { Action } from "babylonjs/Actions/action";
  10690. import { Condition } from "babylonjs/Actions/condition";
  10691. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10692. /**
  10693. * This defines an action responsible to toggle a boolean once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SwitchBooleanAction extends Action {
  10697. /**
  10698. * The path to the boolean property in the target object
  10699. */
  10700. propertyPath: string;
  10701. private _target;
  10702. private _effectiveTarget;
  10703. private _property;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the boolean
  10708. * @param propertyPath defines the path to the boolean property in the target object
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10712. /** @hidden */
  10713. _prepare(): void;
  10714. /**
  10715. * Execute the action toggle the boolean value.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to set a the state field of the target
  10727. * to a desired value once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class SetStateAction extends Action {
  10731. /**
  10732. * The value to store in the state field.
  10733. */
  10734. value: string;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the state property
  10740. * @param value defines the value to store in the state field
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10744. /**
  10745. * Execute the action and store the value on the target state property.
  10746. */
  10747. execute(): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to set a property of the target
  10757. * to a desired value once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class SetValueAction extends Action {
  10761. /**
  10762. * The path of the property to set in the target.
  10763. */
  10764. propertyPath: string;
  10765. /**
  10766. * The value to set in the property
  10767. */
  10768. value: any;
  10769. private _target;
  10770. private _effectiveTarget;
  10771. private _property;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the property
  10776. * @param propertyPath defines the path of the property to set in the target
  10777. * @param value defines the value to set in the property
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10781. /** @hidden */
  10782. _prepare(): void;
  10783. /**
  10784. * Execute the action and set the targetted property to the desired value.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to increment the target value
  10796. * to a desired value once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class IncrementValueAction extends Action {
  10800. /**
  10801. * The path of the property to increment in the target.
  10802. */
  10803. propertyPath: string;
  10804. /**
  10805. * The value we should increment the property by.
  10806. */
  10807. value: any;
  10808. private _target;
  10809. private _effectiveTarget;
  10810. private _property;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the object containing the property
  10815. * @param propertyPath defines the path of the property to increment in the target
  10816. * @param value defines the value value we should increment the property by
  10817. * @param condition defines the trigger related conditions
  10818. */
  10819. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10820. /** @hidden */
  10821. _prepare(): void;
  10822. /**
  10823. * Execute the action and increment the target of the value amount.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to start an animation once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class PlayAnimationAction extends Action {
  10838. /**
  10839. * Where the animation should start (animation frame)
  10840. */
  10841. from: number;
  10842. /**
  10843. * Where the animation should stop (animation frame)
  10844. */
  10845. to: number;
  10846. /**
  10847. * Define if the animation should loop or stop after the first play.
  10848. */
  10849. loop?: boolean;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target animation or animation name
  10855. * @param from defines from where the animation should start (animation frame)
  10856. * @param end defines where the animation should stop (animation frame)
  10857. * @param loop defines if the animation should loop or stop after the first play
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10861. /** @hidden */
  10862. _prepare(): void;
  10863. /**
  10864. * Execute the action and play the animation.
  10865. */
  10866. execute(): void;
  10867. /**
  10868. * Serializes the actions and its related information.
  10869. * @param parent defines the object to serialize in
  10870. * @returns the serialized object
  10871. */
  10872. serialize(parent: any): any;
  10873. }
  10874. /**
  10875. * This defines an action responsible to stop an animation once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class StopAnimationAction extends Action {
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action and stop the animation.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible that does nothing once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class DoNothingAction extends Action {
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions?: any, condition?: Condition);
  10911. /**
  10912. * Execute the action and do nothing.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to trigger several actions once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class CombineAction extends Action {
  10927. /**
  10928. * The list of aggregated animations to run.
  10929. */
  10930. children: Action[];
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param children defines the list of aggregated animations to run
  10935. * @param condition defines the trigger related conditions
  10936. */
  10937. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10938. /** @hidden */
  10939. _prepare(): void;
  10940. /**
  10941. * Execute the action and executes all the aggregated actions.
  10942. */
  10943. execute(evt: ActionEvent): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to run code (external event) once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class ExecuteCodeAction extends Action {
  10956. /**
  10957. * The callback function to run.
  10958. */
  10959. func: (evt: ActionEvent) => void;
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param func defines the callback function to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10967. /**
  10968. * Execute the action and run the attached code.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. }
  10972. /**
  10973. * This defines an action responsible to set the parent property of the target once triggered.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class SetParentAction extends Action {
  10977. private _parent;
  10978. private _target;
  10979. /**
  10980. * Instantiate the action
  10981. * @param triggerOptions defines the trigger options
  10982. * @param target defines the target containing the parent property
  10983. * @param parent defines from where the animation should start (animation frame)
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10987. /** @hidden */
  10988. _prepare(): void;
  10989. /**
  10990. * Execute the action and set the parent property.
  10991. */
  10992. execute(): void;
  10993. /**
  10994. * Serializes the actions and its related information.
  10995. * @param parent defines the object to serialize in
  10996. * @returns the serialized object
  10997. */
  10998. serialize(parent: any): any;
  10999. }
  11000. }
  11001. declare module "babylonjs/Actions/actionManager" {
  11002. import { Nullable } from "babylonjs/types";
  11003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11004. import { Scene } from "babylonjs/scene";
  11005. import { IAction } from "babylonjs/Actions/action";
  11006. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11007. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11008. /**
  11009. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11010. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class ActionManager extends AbstractActionManager {
  11014. /**
  11015. * Nothing
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11017. */
  11018. static readonly NothingTrigger: number;
  11019. /**
  11020. * On pick
  11021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11022. */
  11023. static readonly OnPickTrigger: number;
  11024. /**
  11025. * On left pick
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnLeftPickTrigger: number;
  11029. /**
  11030. * On right pick
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnRightPickTrigger: number;
  11034. /**
  11035. * On center pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnCenterPickTrigger: number;
  11039. /**
  11040. * On pick down
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickDownTrigger: number;
  11044. /**
  11045. * On double pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnDoublePickTrigger: number;
  11049. /**
  11050. * On pick up
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnPickUpTrigger: number;
  11054. /**
  11055. * On pick out.
  11056. * This trigger will only be raised if you also declared a OnPickDown
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickOutTrigger: number;
  11060. /**
  11061. * On long press
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnLongPressTrigger: number;
  11065. /**
  11066. * On pointer over
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPointerOverTrigger: number;
  11070. /**
  11071. * On pointer out
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPointerOutTrigger: number;
  11075. /**
  11076. * On every frame
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnEveryFrameTrigger: number;
  11080. /**
  11081. * On intersection enter
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnIntersectionEnterTrigger: number;
  11085. /**
  11086. * On intersection exit
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnIntersectionExitTrigger: number;
  11090. /**
  11091. * On key down
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnKeyDownTrigger: number;
  11095. /**
  11096. * On key up
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnKeyUpTrigger: number;
  11100. private _scene;
  11101. /**
  11102. * Creates a new action manager
  11103. * @param scene defines the hosting scene
  11104. */
  11105. constructor(scene: Scene);
  11106. /**
  11107. * Releases all associated resources
  11108. */
  11109. dispose(): void;
  11110. /**
  11111. * Gets hosting scene
  11112. * @returns the hosting scene
  11113. */
  11114. getScene(): Scene;
  11115. /**
  11116. * Does this action manager handles actions of any of the given triggers
  11117. * @param triggers defines the triggers to be tested
  11118. * @return a boolean indicating whether one (or more) of the triggers is handled
  11119. */
  11120. hasSpecificTriggers(triggers: number[]): boolean;
  11121. /**
  11122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11123. * speed.
  11124. * @param triggerA defines the trigger to be tested
  11125. * @param triggerB defines the trigger to be tested
  11126. * @return a boolean indicating whether one (or more) of the triggers is handled
  11127. */
  11128. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11129. /**
  11130. * Does this action manager handles actions of a given trigger
  11131. * @param trigger defines the trigger to be tested
  11132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11133. * @return whether the trigger is handled
  11134. */
  11135. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11136. /**
  11137. * Does this action manager has pointer triggers
  11138. */
  11139. readonly hasPointerTriggers: boolean;
  11140. /**
  11141. * Does this action manager has pick triggers
  11142. */
  11143. readonly hasPickTriggers: boolean;
  11144. /**
  11145. * Registers an action to this action manager
  11146. * @param action defines the action to be registered
  11147. * @return the action amended (prepared) after registration
  11148. */
  11149. registerAction(action: IAction): Nullable<IAction>;
  11150. /**
  11151. * Unregisters an action to this action manager
  11152. * @param action defines the action to be unregistered
  11153. * @return a boolean indicating whether the action has been unregistered
  11154. */
  11155. unregisterAction(action: IAction): Boolean;
  11156. /**
  11157. * Process a specific trigger
  11158. * @param trigger defines the trigger to process
  11159. * @param evt defines the event details to be processed
  11160. */
  11161. processTrigger(trigger: number, evt?: IActionEvent): void;
  11162. /** @hidden */
  11163. _getEffectiveTarget(target: any, propertyPath: string): any;
  11164. /** @hidden */
  11165. _getProperty(propertyPath: string): string;
  11166. /**
  11167. * Serialize this manager to a JSON object
  11168. * @param name defines the property name to store this manager
  11169. * @returns a JSON representation of this manager
  11170. */
  11171. serialize(name: string): any;
  11172. /**
  11173. * Creates a new ActionManager from a JSON data
  11174. * @param parsedActions defines the JSON data to read from
  11175. * @param object defines the hosting mesh
  11176. * @param scene defines the hosting scene
  11177. */
  11178. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11179. /**
  11180. * Get a trigger name by index
  11181. * @param trigger defines the trigger index
  11182. * @returns a trigger name
  11183. */
  11184. static GetTriggerName(trigger: number): string;
  11185. }
  11186. }
  11187. declare module "babylonjs/Culling/ray" {
  11188. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11192. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11193. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11194. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11195. import { Plane } from "babylonjs/Maths/math.plane";
  11196. /**
  11197. * Class representing a ray with position and direction
  11198. */
  11199. export class Ray {
  11200. /** origin point */
  11201. origin: Vector3;
  11202. /** direction */
  11203. direction: Vector3;
  11204. /** length of the ray */
  11205. length: number;
  11206. private static readonly TmpVector3;
  11207. private _tmpRay;
  11208. /**
  11209. * Creates a new ray
  11210. * @param origin origin point
  11211. * @param direction direction
  11212. * @param length length of the ray
  11213. */
  11214. constructor(
  11215. /** origin point */
  11216. origin: Vector3,
  11217. /** direction */
  11218. direction: Vector3,
  11219. /** length of the ray */
  11220. length?: number);
  11221. /**
  11222. * Checks if the ray intersects a box
  11223. * @param minimum bound of the box
  11224. * @param maximum bound of the box
  11225. * @param intersectionTreshold extra extend to be added to the box in all direction
  11226. * @returns if the box was hit
  11227. */
  11228. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param box the bounding box to check
  11232. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * If the ray hits a sphere
  11238. * @param sphere the bounding sphere to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11240. * @returns true if it hits the sphere
  11241. */
  11242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a triange
  11245. * @param vertex0 triangle vertex
  11246. * @param vertex1 triangle vertex
  11247. * @param vertex2 triangle vertex
  11248. * @returns intersection information if hit
  11249. */
  11250. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11251. /**
  11252. * Checks if ray intersects a plane
  11253. * @param plane the plane to check
  11254. * @returns the distance away it was hit
  11255. */
  11256. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11257. /**
  11258. * Calculate the intercept of a ray on a given axis
  11259. * @param axis to check 'x' | 'y' | 'z'
  11260. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11261. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11262. */
  11263. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11264. /**
  11265. * Checks if ray intersects a mesh
  11266. * @param mesh the mesh to check
  11267. * @param fastCheck if only the bounding box should checked
  11268. * @returns picking info of the intersecton
  11269. */
  11270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param meshes the meshes to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @param results array to store result in
  11276. * @returns Array of picking infos
  11277. */
  11278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11279. private _comparePickingInfo;
  11280. private static smallnum;
  11281. private static rayl;
  11282. /**
  11283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11284. * @param sega the first point of the segment to test the intersection against
  11285. * @param segb the second point of the segment to test the intersection against
  11286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11288. */
  11289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11290. /**
  11291. * Update the ray from viewport position
  11292. * @param x position
  11293. * @param y y position
  11294. * @param viewportWidth viewport width
  11295. * @param viewportHeight viewport height
  11296. * @param world world matrix
  11297. * @param view view matrix
  11298. * @param projection projection matrix
  11299. * @returns this ray updated
  11300. */
  11301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Creates a ray with origin and direction of 0,0,0
  11304. * @returns the new ray
  11305. */
  11306. static Zero(): Ray;
  11307. /**
  11308. * Creates a new ray from screen space and viewport
  11309. * @param x position
  11310. * @param y y position
  11311. * @param viewportWidth viewport width
  11312. * @param viewportHeight viewport height
  11313. * @param world world matrix
  11314. * @param view view matrix
  11315. * @param projection projection matrix
  11316. * @returns new ray
  11317. */
  11318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11319. /**
  11320. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11321. * transformed to the given world matrix.
  11322. * @param origin The origin point
  11323. * @param end The end point
  11324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11325. * @returns the new ray
  11326. */
  11327. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11328. /**
  11329. * Transforms a ray by a matrix
  11330. * @param ray ray to transform
  11331. * @param matrix matrix to apply
  11332. * @returns the resulting new ray
  11333. */
  11334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @param result ray to store result in
  11340. */
  11341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11342. /**
  11343. * Unproject a ray from screen space to object space
  11344. * @param sourceX defines the screen space x coordinate to use
  11345. * @param sourceY defines the screen space y coordinate to use
  11346. * @param viewportWidth defines the current width of the viewport
  11347. * @param viewportHeight defines the current height of the viewport
  11348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11349. * @param view defines the view matrix to use
  11350. * @param projection defines the projection matrix to use
  11351. */
  11352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11353. }
  11354. /**
  11355. * Type used to define predicate used to select faces when a mesh intersection is detected
  11356. */
  11357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11358. module "babylonjs/scene" {
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. }
  11373. declare module "babylonjs/sceneComponent" {
  11374. import { Scene } from "babylonjs/scene";
  11375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11377. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11378. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11382. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11383. import { AbstractScene } from "babylonjs/abstractScene";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. /**
  11386. * Groups all the scene component constants in one place to ease maintenance.
  11387. * @hidden
  11388. */
  11389. export class SceneComponentConstants {
  11390. static readonly NAME_EFFECTLAYER: string;
  11391. static readonly NAME_LAYER: string;
  11392. static readonly NAME_LENSFLARESYSTEM: string;
  11393. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11394. static readonly NAME_PARTICLESYSTEM: string;
  11395. static readonly NAME_GAMEPAD: string;
  11396. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11397. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11398. static readonly NAME_DEPTHRENDERER: string;
  11399. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11400. static readonly NAME_SPRITE: string;
  11401. static readonly NAME_OUTLINERENDERER: string;
  11402. static readonly NAME_PROCEDURALTEXTURE: string;
  11403. static readonly NAME_SHADOWGENERATOR: string;
  11404. static readonly NAME_OCTREE: string;
  11405. static readonly NAME_PHYSICSENGINE: string;
  11406. static readonly NAME_AUDIO: string;
  11407. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11408. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11409. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11410. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11411. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11412. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11414. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11415. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11416. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11417. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11418. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11419. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11420. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11421. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11422. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11423. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11424. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11425. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11426. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11427. static readonly STEP_AFTERRENDER_AUDIO: number;
  11428. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11429. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11430. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11431. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11432. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11433. static readonly STEP_POINTERMOVE_SPRITE: number;
  11434. static readonly STEP_POINTERDOWN_SPRITE: number;
  11435. static readonly STEP_POINTERUP_SPRITE: number;
  11436. }
  11437. /**
  11438. * This represents a scene component.
  11439. *
  11440. * This is used to decouple the dependency the scene is having on the different workloads like
  11441. * layers, post processes...
  11442. */
  11443. export interface ISceneComponent {
  11444. /**
  11445. * The name of the component. Each component must have a unique name.
  11446. */
  11447. name: string;
  11448. /**
  11449. * The scene the component belongs to.
  11450. */
  11451. scene: Scene;
  11452. /**
  11453. * Register the component to one instance of a scene.
  11454. */
  11455. register(): void;
  11456. /**
  11457. * Rebuilds the elements related to this component in case of
  11458. * context lost for instance.
  11459. */
  11460. rebuild(): void;
  11461. /**
  11462. * Disposes the component and the associated ressources.
  11463. */
  11464. dispose(): void;
  11465. }
  11466. /**
  11467. * This represents a SERIALIZABLE scene component.
  11468. *
  11469. * This extends Scene Component to add Serialization methods on top.
  11470. */
  11471. export interface ISceneSerializableComponent extends ISceneComponent {
  11472. /**
  11473. * Adds all the elements from the container to the scene
  11474. * @param container the container holding the elements
  11475. */
  11476. addFromContainer(container: AbstractScene): void;
  11477. /**
  11478. * Removes all the elements in the container from the scene
  11479. * @param container contains the elements to remove
  11480. * @param dispose if the removed element should be disposed (default: false)
  11481. */
  11482. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11483. /**
  11484. * Serializes the component data to the specified json object
  11485. * @param serializationObject The object to serialize to
  11486. */
  11487. serialize(serializationObject: any): void;
  11488. }
  11489. /**
  11490. * Strong typing of a Mesh related stage step action
  11491. */
  11492. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11493. /**
  11494. * Strong typing of a Evaluate Sub Mesh related stage step action
  11495. */
  11496. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11497. /**
  11498. * Strong typing of a Active Mesh related stage step action
  11499. */
  11500. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11501. /**
  11502. * Strong typing of a Camera related stage step action
  11503. */
  11504. export type CameraStageAction = (camera: Camera) => void;
  11505. /**
  11506. * Strong typing of a Camera Frame buffer related stage step action
  11507. */
  11508. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Representation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Scene } from "babylonjs/scene";
  11573. import { Sprite } from "babylonjs/Sprites/sprite";
  11574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11575. import { Ray } from "babylonjs/Culling/ray";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11578. import { ISceneComponent } from "babylonjs/sceneComponent";
  11579. module "babylonjs/scene" {
  11580. interface Scene {
  11581. /** @hidden */
  11582. _pointerOverSprite: Nullable<Sprite>;
  11583. /** @hidden */
  11584. _pickedDownSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _tempSpritePickingRay: Nullable<Ray>;
  11587. /**
  11588. * All of the sprite managers added to this scene
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. spriteManagers: Array<ISpriteManager>;
  11592. /**
  11593. * An event triggered when sprites rendering is about to start
  11594. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11595. */
  11596. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11597. /**
  11598. * An event triggered when sprites rendering is done
  11599. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11600. */
  11601. onAfterSpritesRenderingObservable: Observable<Scene>;
  11602. /** @hidden */
  11603. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Launch a ray to try to pick a sprite in the scene
  11605. * @param x position on screen
  11606. * @param y position on screen
  11607. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11610. * @returns a PickingInfo
  11611. */
  11612. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11613. /** Use the given ray to pick a sprite in the scene
  11614. * @param ray The ray (in world space) to use to pick meshes
  11615. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11617. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11618. * @returns a PickingInfo
  11619. */
  11620. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11621. /** @hidden */
  11622. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11623. /** Launch a ray to try to pick sprites in the scene
  11624. * @param x position on screen
  11625. * @param y position on screen
  11626. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11627. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11628. * @returns a PickingInfo array
  11629. */
  11630. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11631. /** Use the given ray to pick sprites in the scene
  11632. * @param ray The ray (in world space) to use to pick meshes
  11633. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11634. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11635. * @returns a PickingInfo array
  11636. */
  11637. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11638. /**
  11639. * Force the sprite under the pointer
  11640. * @param sprite defines the sprite to use
  11641. */
  11642. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11643. /**
  11644. * Gets the sprite under the pointer
  11645. * @returns a Sprite or null if no sprite is under the pointer
  11646. */
  11647. getPointerOverSprite(): Nullable<Sprite>;
  11648. }
  11649. }
  11650. /**
  11651. * Defines the sprite scene component responsible to manage sprites
  11652. * in a given scene.
  11653. */
  11654. export class SpriteSceneComponent implements ISceneComponent {
  11655. /**
  11656. * The component name helpfull to identify the component in the list of scene components.
  11657. */
  11658. readonly name: string;
  11659. /**
  11660. * The scene the component belongs to.
  11661. */
  11662. scene: Scene;
  11663. /** @hidden */
  11664. private _spritePredicate;
  11665. /**
  11666. * Creates a new instance of the component for the given scene
  11667. * @param scene Defines the scene to register the component in
  11668. */
  11669. constructor(scene: Scene);
  11670. /**
  11671. * Registers the component in a given scene
  11672. */
  11673. register(): void;
  11674. /**
  11675. * Rebuilds the elements related to this component in case of
  11676. * context lost for instance.
  11677. */
  11678. rebuild(): void;
  11679. /**
  11680. * Disposes the component and the associated ressources.
  11681. */
  11682. dispose(): void;
  11683. private _pickSpriteButKeepRay;
  11684. private _pointerMove;
  11685. private _pointerDown;
  11686. private _pointerUp;
  11687. }
  11688. }
  11689. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11690. /** @hidden */
  11691. export var fogFragmentDeclaration: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11697. /** @hidden */
  11698. export var fogFragment: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.fragment" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11705. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11706. /** @hidden */
  11707. export var spritesPixelShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11713. /** @hidden */
  11714. export var fogVertexDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/sprites.vertex" {
  11720. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11721. /** @hidden */
  11722. export var spritesVertexShader: {
  11723. name: string;
  11724. shader: string;
  11725. };
  11726. }
  11727. declare module "babylonjs/Sprites/spriteManager" {
  11728. import { IDisposable, Scene } from "babylonjs/scene";
  11729. import { Nullable } from "babylonjs/types";
  11730. import { Observable } from "babylonjs/Misc/observable";
  11731. import { Sprite } from "babylonjs/Sprites/sprite";
  11732. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11733. import { Camera } from "babylonjs/Cameras/camera";
  11734. import { Texture } from "babylonjs/Materials/Textures/texture";
  11735. import "babylonjs/Shaders/sprites.fragment";
  11736. import "babylonjs/Shaders/sprites.vertex";
  11737. import { Ray } from "babylonjs/Culling/ray";
  11738. /**
  11739. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11740. */
  11741. export interface ISpriteManager extends IDisposable {
  11742. /**
  11743. * Restricts the camera to viewing objects with the same layerMask.
  11744. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11745. */
  11746. layerMask: number;
  11747. /**
  11748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11749. */
  11750. isPickable: boolean;
  11751. /**
  11752. * Specifies the rendering group id for this mesh (0 by default)
  11753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11754. */
  11755. renderingGroupId: number;
  11756. /**
  11757. * Defines the list of sprites managed by the manager.
  11758. */
  11759. sprites: Array<Sprite>;
  11760. /**
  11761. * Tests the intersection of a sprite with a specific ray.
  11762. * @param ray The ray we are sending to test the collision
  11763. * @param camera The camera space we are sending rays in
  11764. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11765. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11766. * @returns picking info or null.
  11767. */
  11768. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11769. /**
  11770. * Intersects the sprites with a ray
  11771. * @param ray defines the ray to intersect with
  11772. * @param camera defines the current active camera
  11773. * @param predicate defines a predicate used to select candidate sprites
  11774. * @returns null if no hit or a PickingInfo array
  11775. */
  11776. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11777. /**
  11778. * Renders the list of sprites on screen.
  11779. */
  11780. render(): void;
  11781. }
  11782. /**
  11783. * Class used to manage multiple sprites on the same spritesheet
  11784. * @see http://doc.babylonjs.com/babylon101/sprites
  11785. */
  11786. export class SpriteManager implements ISpriteManager {
  11787. /** defines the manager's name */
  11788. name: string;
  11789. /** Gets the list of sprites */
  11790. sprites: Sprite[];
  11791. /** Gets or sets the rendering group id (0 by default) */
  11792. renderingGroupId: number;
  11793. /** Gets or sets camera layer mask */
  11794. layerMask: number;
  11795. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11796. fogEnabled: boolean;
  11797. /** Gets or sets a boolean indicating if the sprites are pickable */
  11798. isPickable: boolean;
  11799. /** Defines the default width of a cell in the spritesheet */
  11800. cellWidth: number;
  11801. /** Defines the default height of a cell in the spritesheet */
  11802. cellHeight: number;
  11803. /** Associative array from JSON sprite data file */
  11804. private _cellData;
  11805. /** Array of sprite names from JSON sprite data file */
  11806. private _spriteMap;
  11807. /** True when packed cell data from JSON file is ready*/
  11808. private _packedAndReady;
  11809. /**
  11810. * An event triggered when the manager is disposed.
  11811. */
  11812. onDisposeObservable: Observable<SpriteManager>;
  11813. private _onDisposeObserver;
  11814. /**
  11815. * Callback called when the manager is disposed
  11816. */
  11817. onDispose: () => void;
  11818. private _capacity;
  11819. private _fromPacked;
  11820. private _spriteTexture;
  11821. private _epsilon;
  11822. private _scene;
  11823. private _vertexData;
  11824. private _buffer;
  11825. private _vertexBuffers;
  11826. private _indexBuffer;
  11827. private _effectBase;
  11828. private _effectFog;
  11829. /**
  11830. * Gets or sets the spritesheet texture
  11831. */
  11832. texture: Texture;
  11833. /**
  11834. * Creates a new sprite manager
  11835. * @param name defines the manager's name
  11836. * @param imgUrl defines the sprite sheet url
  11837. * @param capacity defines the maximum allowed number of sprites
  11838. * @param cellSize defines the size of a sprite cell
  11839. * @param scene defines the hosting scene
  11840. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11841. * @param samplingMode defines the smapling mode to use with spritesheet
  11842. * @param fromPacked set to false; do not alter
  11843. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11844. */
  11845. constructor(
  11846. /** defines the manager's name */
  11847. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11848. private _makePacked;
  11849. private _appendSpriteVertex;
  11850. /**
  11851. * Intersects the sprites with a ray
  11852. * @param ray defines the ray to intersect with
  11853. * @param camera defines the current active camera
  11854. * @param predicate defines a predicate used to select candidate sprites
  11855. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11856. * @returns null if no hit or a PickingInfo
  11857. */
  11858. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11859. /**
  11860. * Intersects the sprites with a ray
  11861. * @param ray defines the ray to intersect with
  11862. * @param camera defines the current active camera
  11863. * @param predicate defines a predicate used to select candidate sprites
  11864. * @returns null if no hit or a PickingInfo array
  11865. */
  11866. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11867. /**
  11868. * Render all child sprites
  11869. */
  11870. render(): void;
  11871. /**
  11872. * Release associated resources
  11873. */
  11874. dispose(): void;
  11875. }
  11876. }
  11877. declare module "babylonjs/Sprites/sprite" {
  11878. import { Vector3 } from "babylonjs/Maths/math.vector";
  11879. import { Nullable } from "babylonjs/types";
  11880. import { ActionManager } from "babylonjs/Actions/actionManager";
  11881. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11882. import { Color4 } from "babylonjs/Maths/math.color";
  11883. /**
  11884. * Class used to represent a sprite
  11885. * @see http://doc.babylonjs.com/babylon101/sprites
  11886. */
  11887. export class Sprite {
  11888. /** defines the name */
  11889. name: string;
  11890. /** Gets or sets the current world position */
  11891. position: Vector3;
  11892. /** Gets or sets the main color */
  11893. color: Color4;
  11894. /** Gets or sets the width */
  11895. width: number;
  11896. /** Gets or sets the height */
  11897. height: number;
  11898. /** Gets or sets rotation angle */
  11899. angle: number;
  11900. /** Gets or sets the cell index in the sprite sheet */
  11901. cellIndex: number;
  11902. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11903. cellRef: string;
  11904. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11905. invertU: number;
  11906. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11907. invertV: number;
  11908. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11909. disposeWhenFinishedAnimating: boolean;
  11910. /** Gets the list of attached animations */
  11911. animations: Animation[];
  11912. /** Gets or sets a boolean indicating if the sprite can be picked */
  11913. isPickable: boolean;
  11914. /**
  11915. * Gets or sets the associated action manager
  11916. */
  11917. actionManager: Nullable<ActionManager>;
  11918. private _animationStarted;
  11919. private _loopAnimation;
  11920. private _fromIndex;
  11921. private _toIndex;
  11922. private _delay;
  11923. private _direction;
  11924. private _manager;
  11925. private _time;
  11926. private _onAnimationEnd;
  11927. /**
  11928. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11929. */
  11930. isVisible: boolean;
  11931. /**
  11932. * Gets or sets the sprite size
  11933. */
  11934. size: number;
  11935. /**
  11936. * Creates a new Sprite
  11937. * @param name defines the name
  11938. * @param manager defines the manager
  11939. */
  11940. constructor(
  11941. /** defines the name */
  11942. name: string, manager: ISpriteManager);
  11943. /**
  11944. * Starts an animation
  11945. * @param from defines the initial key
  11946. * @param to defines the end key
  11947. * @param loop defines if the animation must loop
  11948. * @param delay defines the start delay (in ms)
  11949. * @param onAnimationEnd defines a callback to call when animation ends
  11950. */
  11951. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11952. /** Stops current animation (if any) */
  11953. stopAnimation(): void;
  11954. /** @hidden */
  11955. _animate(deltaTime: number): void;
  11956. /** Release associated resources */
  11957. dispose(): void;
  11958. }
  11959. }
  11960. declare module "babylonjs/Collisions/pickingInfo" {
  11961. import { Nullable } from "babylonjs/types";
  11962. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11964. import { Sprite } from "babylonjs/Sprites/sprite";
  11965. import { Ray } from "babylonjs/Culling/ray";
  11966. /**
  11967. * Information about the result of picking within a scene
  11968. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11969. */
  11970. export class PickingInfo {
  11971. /** @hidden */
  11972. _pickingUnavailable: boolean;
  11973. /**
  11974. * If the pick collided with an object
  11975. */
  11976. hit: boolean;
  11977. /**
  11978. * Distance away where the pick collided
  11979. */
  11980. distance: number;
  11981. /**
  11982. * The location of pick collision
  11983. */
  11984. pickedPoint: Nullable<Vector3>;
  11985. /**
  11986. * The mesh corresponding the the pick collision
  11987. */
  11988. pickedMesh: Nullable<AbstractMesh>;
  11989. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11990. bu: number;
  11991. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11992. bv: number;
  11993. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11994. faceId: number;
  11995. /** Id of the the submesh that was picked */
  11996. subMeshId: number;
  11997. /** If a sprite was picked, this will be the sprite the pick collided with */
  11998. pickedSprite: Nullable<Sprite>;
  11999. /**
  12000. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12001. */
  12002. originMesh: Nullable<AbstractMesh>;
  12003. /**
  12004. * The ray that was used to perform the picking.
  12005. */
  12006. ray: Nullable<Ray>;
  12007. /**
  12008. * Gets the normal correspodning to the face the pick collided with
  12009. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12010. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12011. * @returns The normal correspodning to the face the pick collided with
  12012. */
  12013. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12014. /**
  12015. * Gets the texture coordinates of where the pick occured
  12016. * @returns the vector containing the coordnates of the texture
  12017. */
  12018. getTextureCoordinates(): Nullable<Vector2>;
  12019. }
  12020. }
  12021. declare module "babylonjs/Events/pointerEvents" {
  12022. import { Nullable } from "babylonjs/types";
  12023. import { Vector2 } from "babylonjs/Maths/math.vector";
  12024. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12025. import { Ray } from "babylonjs/Culling/ray";
  12026. /**
  12027. * Gather the list of pointer event types as constants.
  12028. */
  12029. export class PointerEventTypes {
  12030. /**
  12031. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12032. */
  12033. static readonly POINTERDOWN: number;
  12034. /**
  12035. * The pointerup event is fired when a pointer is no longer active.
  12036. */
  12037. static readonly POINTERUP: number;
  12038. /**
  12039. * The pointermove event is fired when a pointer changes coordinates.
  12040. */
  12041. static readonly POINTERMOVE: number;
  12042. /**
  12043. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12044. */
  12045. static readonly POINTERWHEEL: number;
  12046. /**
  12047. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12048. */
  12049. static readonly POINTERPICK: number;
  12050. /**
  12051. * The pointertap event is fired when a the object has been touched and released without drag.
  12052. */
  12053. static readonly POINTERTAP: number;
  12054. /**
  12055. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12056. */
  12057. static readonly POINTERDOUBLETAP: number;
  12058. }
  12059. /**
  12060. * Base class of pointer info types.
  12061. */
  12062. export class PointerInfoBase {
  12063. /**
  12064. * Defines the type of event (PointerEventTypes)
  12065. */
  12066. type: number;
  12067. /**
  12068. * Defines the related dom event
  12069. */
  12070. event: PointerEvent | MouseWheelEvent;
  12071. /**
  12072. * Instantiates the base class of pointers info.
  12073. * @param type Defines the type of event (PointerEventTypes)
  12074. * @param event Defines the related dom event
  12075. */
  12076. constructor(
  12077. /**
  12078. * Defines the type of event (PointerEventTypes)
  12079. */
  12080. type: number,
  12081. /**
  12082. * Defines the related dom event
  12083. */
  12084. event: PointerEvent | MouseWheelEvent);
  12085. }
  12086. /**
  12087. * This class is used to store pointer related info for the onPrePointerObservable event.
  12088. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12089. */
  12090. export class PointerInfoPre extends PointerInfoBase {
  12091. /**
  12092. * Ray from a pointer if availible (eg. 6dof controller)
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Defines the local position of the pointer on the canvas.
  12097. */
  12098. localPosition: Vector2;
  12099. /**
  12100. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12101. */
  12102. skipOnPointerObservable: boolean;
  12103. /**
  12104. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12105. * @param type Defines the type of event (PointerEventTypes)
  12106. * @param event Defines the related dom event
  12107. * @param localX Defines the local x coordinates of the pointer when the event occured
  12108. * @param localY Defines the local y coordinates of the pointer when the event occured
  12109. */
  12110. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12111. }
  12112. /**
  12113. * This type contains all the data related to a pointer event in Babylon.js.
  12114. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12115. */
  12116. export class PointerInfo extends PointerInfoBase {
  12117. /**
  12118. * Defines the picking info associated to the info (if any)\
  12119. */
  12120. pickInfo: Nullable<PickingInfo>;
  12121. /**
  12122. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12123. * @param type Defines the type of event (PointerEventTypes)
  12124. * @param event Defines the related dom event
  12125. * @param pickInfo Defines the picking info associated to the info (if any)\
  12126. */
  12127. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12128. /**
  12129. * Defines the picking info associated to the info (if any)\
  12130. */
  12131. pickInfo: Nullable<PickingInfo>);
  12132. }
  12133. /**
  12134. * Data relating to a touch event on the screen.
  12135. */
  12136. export interface PointerTouch {
  12137. /**
  12138. * X coordinate of touch.
  12139. */
  12140. x: number;
  12141. /**
  12142. * Y coordinate of touch.
  12143. */
  12144. y: number;
  12145. /**
  12146. * Id of touch. Unique for each finger.
  12147. */
  12148. pointerId: number;
  12149. /**
  12150. * Event type passed from DOM.
  12151. */
  12152. type: any;
  12153. }
  12154. }
  12155. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12156. import { Observable } from "babylonjs/Misc/observable";
  12157. import { Nullable } from "babylonjs/types";
  12158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12159. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12160. /**
  12161. * Manage the mouse inputs to control the movement of a free camera.
  12162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12163. */
  12164. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12165. /**
  12166. * Define if touch is enabled in the mouse input
  12167. */
  12168. touchEnabled: boolean;
  12169. /**
  12170. * Defines the camera the input is attached to.
  12171. */
  12172. camera: FreeCamera;
  12173. /**
  12174. * Defines the buttons associated with the input to handle camera move.
  12175. */
  12176. buttons: number[];
  12177. /**
  12178. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12179. */
  12180. angularSensibility: number;
  12181. private _pointerInput;
  12182. private _onMouseMove;
  12183. private _observer;
  12184. private previousPosition;
  12185. /**
  12186. * Observable for when a pointer move event occurs containing the move offset
  12187. */
  12188. onPointerMovedObservable: Observable<{
  12189. offsetX: number;
  12190. offsetY: number;
  12191. }>;
  12192. /**
  12193. * @hidden
  12194. * If the camera should be rotated automatically based on pointer movement
  12195. */
  12196. _allowCameraRotation: boolean;
  12197. /**
  12198. * Manage the mouse inputs to control the movement of a free camera.
  12199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12200. * @param touchEnabled Defines if touch is enabled or not
  12201. */
  12202. constructor(
  12203. /**
  12204. * Define if touch is enabled in the mouse input
  12205. */
  12206. touchEnabled?: boolean);
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Called on JS contextmenu event.
  12215. * Override this method to provide functionality.
  12216. */
  12217. protected onContextMenu(evt: PointerEvent): void;
  12218. /**
  12219. * Detach the current controls from the specified dom element.
  12220. * @param element Defines the element to stop listening the inputs from
  12221. */
  12222. detachControl(element: Nullable<HTMLElement>): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12236. import { Nullable } from "babylonjs/types";
  12237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12239. /**
  12240. * Manage the touch inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12244. /**
  12245. * Defines the camera the input is attached to.
  12246. */
  12247. camera: FreeCamera;
  12248. /**
  12249. * Defines the touch sensibility for rotation.
  12250. * The higher the faster.
  12251. */
  12252. touchAngularSensibility: number;
  12253. /**
  12254. * Defines the touch sensibility for move.
  12255. * The higher the faster.
  12256. */
  12257. touchMoveSensibility: number;
  12258. private _offsetX;
  12259. private _offsetY;
  12260. private _pointerPressed;
  12261. private _pointerInput;
  12262. private _observer;
  12263. private _onLostFocus;
  12264. /**
  12265. * Attach the input controls to a specific dom element to get the input from.
  12266. * @param element Defines the element the controls should be listened from
  12267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12268. */
  12269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12270. /**
  12271. * Detach the current controls from the specified dom element.
  12272. * @param element Defines the element to stop listening the inputs from
  12273. */
  12274. detachControl(element: Nullable<HTMLElement>): void;
  12275. /**
  12276. * Update the current camera state depending on the inputs that have been used this frame.
  12277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12278. */
  12279. checkInputs(): void;
  12280. /**
  12281. * Gets the class name of the current intput.
  12282. * @returns the class name
  12283. */
  12284. getClassName(): string;
  12285. /**
  12286. * Get the friendly name associated with the input class.
  12287. * @returns the input friendly name
  12288. */
  12289. getSimpleName(): string;
  12290. }
  12291. }
  12292. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12294. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12295. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12296. import { Nullable } from "babylonjs/types";
  12297. /**
  12298. * Default Inputs manager for the FreeCamera.
  12299. * It groups all the default supported inputs for ease of use.
  12300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12301. */
  12302. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12303. /**
  12304. * @hidden
  12305. */
  12306. _mouseInput: Nullable<FreeCameraMouseInput>;
  12307. /**
  12308. * Instantiates a new FreeCameraInputsManager.
  12309. * @param camera Defines the camera the inputs belong to
  12310. */
  12311. constructor(camera: FreeCamera);
  12312. /**
  12313. * Add keyboard input support to the input manager.
  12314. * @returns the current input manager
  12315. */
  12316. addKeyboard(): FreeCameraInputsManager;
  12317. /**
  12318. * Add mouse input support to the input manager.
  12319. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12320. * @returns the current input manager
  12321. */
  12322. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12323. /**
  12324. * Removes the mouse input support from the manager
  12325. * @returns the current input manager
  12326. */
  12327. removeMouse(): FreeCameraInputsManager;
  12328. /**
  12329. * Add touch input support to the input manager.
  12330. * @returns the current input manager
  12331. */
  12332. addTouch(): FreeCameraInputsManager;
  12333. /**
  12334. * Remove all attached input methods from a camera
  12335. */
  12336. clear(): void;
  12337. }
  12338. }
  12339. declare module "babylonjs/Cameras/freeCamera" {
  12340. import { Vector3 } from "babylonjs/Maths/math.vector";
  12341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12342. import { Scene } from "babylonjs/scene";
  12343. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12344. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12345. /**
  12346. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12347. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12349. */
  12350. export class FreeCamera extends TargetCamera {
  12351. /**
  12352. * Define the collision ellipsoid of the camera.
  12353. * This is helpful to simulate a camera body like the player body around the camera
  12354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12355. */
  12356. ellipsoid: Vector3;
  12357. /**
  12358. * Define an offset for the position of the ellipsoid around the camera.
  12359. * This can be helpful to determine the center of the body near the gravity center of the body
  12360. * instead of its head.
  12361. */
  12362. ellipsoidOffset: Vector3;
  12363. /**
  12364. * Enable or disable collisions of the camera with the rest of the scene objects.
  12365. */
  12366. checkCollisions: boolean;
  12367. /**
  12368. * Enable or disable gravity on the camera.
  12369. */
  12370. applyGravity: boolean;
  12371. /**
  12372. * Define the input manager associated to the camera.
  12373. */
  12374. inputs: FreeCameraInputsManager;
  12375. /**
  12376. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12377. * Higher values reduce sensitivity.
  12378. */
  12379. /**
  12380. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12381. * Higher values reduce sensitivity.
  12382. */
  12383. angularSensibility: number;
  12384. /**
  12385. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12386. */
  12387. keysUp: number[];
  12388. /**
  12389. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12390. */
  12391. keysDown: number[];
  12392. /**
  12393. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12394. */
  12395. keysLeft: number[];
  12396. /**
  12397. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12398. */
  12399. keysRight: number[];
  12400. /**
  12401. * Event raised when the camera collide with a mesh in the scene.
  12402. */
  12403. onCollide: (collidedMesh: AbstractMesh) => void;
  12404. private _collider;
  12405. private _needMoveForGravity;
  12406. private _oldPosition;
  12407. private _diffPosition;
  12408. private _newPosition;
  12409. /** @hidden */
  12410. _localDirection: Vector3;
  12411. /** @hidden */
  12412. _transformedDirection: Vector3;
  12413. /**
  12414. * Instantiates a Free Camera.
  12415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12416. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12417. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12418. * @param name Define the name of the camera in the scene
  12419. * @param position Define the start position of the camera in the scene
  12420. * @param scene Define the scene the camera belongs to
  12421. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12422. */
  12423. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12424. /**
  12425. * Attached controls to the current camera.
  12426. * @param element Defines the element the controls should be listened from
  12427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12428. */
  12429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12430. /**
  12431. * Detach the current controls from the camera.
  12432. * The camera will stop reacting to inputs.
  12433. * @param element Defines the element to stop listening the inputs from
  12434. */
  12435. detachControl(element: HTMLElement): void;
  12436. private _collisionMask;
  12437. /**
  12438. * Define a collision mask to limit the list of object the camera can collide with
  12439. */
  12440. collisionMask: number;
  12441. /** @hidden */
  12442. _collideWithWorld(displacement: Vector3): void;
  12443. private _onCollisionPositionChange;
  12444. /** @hidden */
  12445. _checkInputs(): void;
  12446. /** @hidden */
  12447. _decideIfNeedsToMove(): boolean;
  12448. /** @hidden */
  12449. _updatePosition(): void;
  12450. /**
  12451. * Destroy the camera and release the current resources hold by it.
  12452. */
  12453. dispose(): void;
  12454. /**
  12455. * Gets the current object class name.
  12456. * @return the class name
  12457. */
  12458. getClassName(): string;
  12459. }
  12460. }
  12461. declare module "babylonjs/Gamepads/gamepad" {
  12462. import { Observable } from "babylonjs/Misc/observable";
  12463. /**
  12464. * Represents a gamepad control stick position
  12465. */
  12466. export class StickValues {
  12467. /**
  12468. * The x component of the control stick
  12469. */
  12470. x: number;
  12471. /**
  12472. * The y component of the control stick
  12473. */
  12474. y: number;
  12475. /**
  12476. * Initializes the gamepad x and y control stick values
  12477. * @param x The x component of the gamepad control stick value
  12478. * @param y The y component of the gamepad control stick value
  12479. */
  12480. constructor(
  12481. /**
  12482. * The x component of the control stick
  12483. */
  12484. x: number,
  12485. /**
  12486. * The y component of the control stick
  12487. */
  12488. y: number);
  12489. }
  12490. /**
  12491. * An interface which manages callbacks for gamepad button changes
  12492. */
  12493. export interface GamepadButtonChanges {
  12494. /**
  12495. * Called when a gamepad has been changed
  12496. */
  12497. changed: boolean;
  12498. /**
  12499. * Called when a gamepad press event has been triggered
  12500. */
  12501. pressChanged: boolean;
  12502. /**
  12503. * Called when a touch event has been triggered
  12504. */
  12505. touchChanged: boolean;
  12506. /**
  12507. * Called when a value has changed
  12508. */
  12509. valueChanged: boolean;
  12510. }
  12511. /**
  12512. * Represents a gamepad
  12513. */
  12514. export class Gamepad {
  12515. /**
  12516. * The id of the gamepad
  12517. */
  12518. id: string;
  12519. /**
  12520. * The index of the gamepad
  12521. */
  12522. index: number;
  12523. /**
  12524. * The browser gamepad
  12525. */
  12526. browserGamepad: any;
  12527. /**
  12528. * Specifies what type of gamepad this represents
  12529. */
  12530. type: number;
  12531. private _leftStick;
  12532. private _rightStick;
  12533. /** @hidden */
  12534. _isConnected: boolean;
  12535. private _leftStickAxisX;
  12536. private _leftStickAxisY;
  12537. private _rightStickAxisX;
  12538. private _rightStickAxisY;
  12539. /**
  12540. * Triggered when the left control stick has been changed
  12541. */
  12542. private _onleftstickchanged;
  12543. /**
  12544. * Triggered when the right control stick has been changed
  12545. */
  12546. private _onrightstickchanged;
  12547. /**
  12548. * Represents a gamepad controller
  12549. */
  12550. static GAMEPAD: number;
  12551. /**
  12552. * Represents a generic controller
  12553. */
  12554. static GENERIC: number;
  12555. /**
  12556. * Represents an XBox controller
  12557. */
  12558. static XBOX: number;
  12559. /**
  12560. * Represents a pose-enabled controller
  12561. */
  12562. static POSE_ENABLED: number;
  12563. /**
  12564. * Represents an Dual Shock controller
  12565. */
  12566. static DUALSHOCK: number;
  12567. /**
  12568. * Specifies whether the left control stick should be Y-inverted
  12569. */
  12570. protected _invertLeftStickY: boolean;
  12571. /**
  12572. * Specifies if the gamepad has been connected
  12573. */
  12574. readonly isConnected: boolean;
  12575. /**
  12576. * Initializes the gamepad
  12577. * @param id The id of the gamepad
  12578. * @param index The index of the gamepad
  12579. * @param browserGamepad The browser gamepad
  12580. * @param leftStickX The x component of the left joystick
  12581. * @param leftStickY The y component of the left joystick
  12582. * @param rightStickX The x component of the right joystick
  12583. * @param rightStickY The y component of the right joystick
  12584. */
  12585. constructor(
  12586. /**
  12587. * The id of the gamepad
  12588. */
  12589. id: string,
  12590. /**
  12591. * The index of the gamepad
  12592. */
  12593. index: number,
  12594. /**
  12595. * The browser gamepad
  12596. */
  12597. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12598. /**
  12599. * Callback triggered when the left joystick has changed
  12600. * @param callback
  12601. */
  12602. onleftstickchanged(callback: (values: StickValues) => void): void;
  12603. /**
  12604. * Callback triggered when the right joystick has changed
  12605. * @param callback
  12606. */
  12607. onrightstickchanged(callback: (values: StickValues) => void): void;
  12608. /**
  12609. * Gets the left joystick
  12610. */
  12611. /**
  12612. * Sets the left joystick values
  12613. */
  12614. leftStick: StickValues;
  12615. /**
  12616. * Gets the right joystick
  12617. */
  12618. /**
  12619. * Sets the right joystick value
  12620. */
  12621. rightStick: StickValues;
  12622. /**
  12623. * Updates the gamepad joystick positions
  12624. */
  12625. update(): void;
  12626. /**
  12627. * Disposes the gamepad
  12628. */
  12629. dispose(): void;
  12630. }
  12631. /**
  12632. * Represents a generic gamepad
  12633. */
  12634. export class GenericPad extends Gamepad {
  12635. private _buttons;
  12636. private _onbuttondown;
  12637. private _onbuttonup;
  12638. /**
  12639. * Observable triggered when a button has been pressed
  12640. */
  12641. onButtonDownObservable: Observable<number>;
  12642. /**
  12643. * Observable triggered when a button has been released
  12644. */
  12645. onButtonUpObservable: Observable<number>;
  12646. /**
  12647. * Callback triggered when a button has been pressed
  12648. * @param callback Called when a button has been pressed
  12649. */
  12650. onbuttondown(callback: (buttonPressed: number) => void): void;
  12651. /**
  12652. * Callback triggered when a button has been released
  12653. * @param callback Called when a button has been released
  12654. */
  12655. onbuttonup(callback: (buttonReleased: number) => void): void;
  12656. /**
  12657. * Initializes the generic gamepad
  12658. * @param id The id of the generic gamepad
  12659. * @param index The index of the generic gamepad
  12660. * @param browserGamepad The browser gamepad
  12661. */
  12662. constructor(id: string, index: number, browserGamepad: any);
  12663. private _setButtonValue;
  12664. /**
  12665. * Updates the generic gamepad
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the generic gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. }
  12674. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12675. import { Nullable } from "babylonjs/types";
  12676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12677. import { Scene } from "babylonjs/scene";
  12678. module "babylonjs/Engines/engine" {
  12679. interface Engine {
  12680. /**
  12681. * Creates a raw texture
  12682. * @param data defines the data to store in the texture
  12683. * @param width defines the width of the texture
  12684. * @param height defines the height of the texture
  12685. * @param format defines the format of the data
  12686. * @param generateMipMaps defines if the engine should generate the mip levels
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12689. * @param compression defines the compression used (null by default)
  12690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12691. * @returns the raw texture inside an InternalTexture
  12692. */
  12693. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12694. /**
  12695. * Update a raw texture
  12696. * @param texture defines the texture to update
  12697. * @param data defines the data to store in the texture
  12698. * @param format defines the format of the data
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. */
  12701. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12702. /**
  12703. * Update a raw texture
  12704. * @param texture defines the texture to update
  12705. * @param data defines the data to store in the texture
  12706. * @param format defines the format of the data
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param compression defines the compression used (null by default)
  12709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12710. */
  12711. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12712. /**
  12713. * Creates a new raw cube texture
  12714. * @param data defines the array of data to use to create each face
  12715. * @param size defines the size of the textures
  12716. * @param format defines the format of the data
  12717. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12718. * @param generateMipMaps defines if the engine should generate the mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compression used (null by default)
  12722. * @returns the cube texture as an InternalTexture
  12723. */
  12724. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12725. /**
  12726. * Update a raw cube texture
  12727. * @param texture defines the texture to udpdate
  12728. * @param data defines the data to store
  12729. * @param format defines the data format
  12730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw cube texture
  12736. * @param texture defines the texture to udpdate
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12740. * @param invertY defines if data must be stored with Y axis inverted
  12741. * @param compression defines the compression used (null by default)
  12742. */
  12743. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12744. /**
  12745. * Update a raw cube texture
  12746. * @param texture defines the texture to udpdate
  12747. * @param data defines the data to store
  12748. * @param format defines the data format
  12749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12750. * @param invertY defines if data must be stored with Y axis inverted
  12751. * @param compression defines the compression used (null by default)
  12752. * @param level defines which level of the texture to update
  12753. */
  12754. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12755. /**
  12756. * Creates a new raw cube texture from a specified url
  12757. * @param url defines the url where the data is located
  12758. * @param scene defines the current scene
  12759. * @param size defines the size of the textures
  12760. * @param format defines the format of the data
  12761. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12762. * @param noMipmap defines if the engine should avoid generating the mip levels
  12763. * @param callback defines a callback used to extract texture data from loaded data
  12764. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12765. * @param onLoad defines a callback called when texture is loaded
  12766. * @param onError defines a callback called if there is an error
  12767. * @returns the cube texture as an InternalTexture
  12768. */
  12769. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12770. /**
  12771. * Creates a new raw cube texture from a specified url
  12772. * @param url defines the url where the data is located
  12773. * @param scene defines the current scene
  12774. * @param size defines the size of the textures
  12775. * @param format defines the format of the data
  12776. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12777. * @param noMipmap defines if the engine should avoid generating the mip levels
  12778. * @param callback defines a callback used to extract texture data from loaded data
  12779. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12780. * @param onLoad defines a callback called when texture is loaded
  12781. * @param onError defines a callback called if there is an error
  12782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @returns the cube texture as an InternalTexture
  12785. */
  12786. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12787. /**
  12788. * Creates a new raw 3D texture
  12789. * @param data defines the data used to create the texture
  12790. * @param width defines the width of the texture
  12791. * @param height defines the height of the texture
  12792. * @param depth defines the depth of the texture
  12793. * @param format defines the format of the texture
  12794. * @param generateMipMaps defines if the engine must generate mip levels
  12795. * @param invertY defines if data must be stored with Y axis inverted
  12796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12797. * @param compression defines the compressed used (can be null)
  12798. * @param textureType defines the compressed used (can be null)
  12799. * @returns a new raw 3D texture (stored in an InternalTexture)
  12800. */
  12801. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12802. /**
  12803. * Update a raw 3D texture
  12804. * @param texture defines the texture to update
  12805. * @param data defines the data to store
  12806. * @param format defines the data format
  12807. * @param invertY defines if data must be stored with Y axis inverted
  12808. */
  12809. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12810. /**
  12811. * Update a raw 3D texture
  12812. * @param texture defines the texture to update
  12813. * @param data defines the data to store
  12814. * @param format defines the data format
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param compression defines the used compression (can be null)
  12817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12818. */
  12819. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12820. /**
  12821. * Creates a new raw 2D array texture
  12822. * @param data defines the data used to create the texture
  12823. * @param width defines the width of the texture
  12824. * @param height defines the height of the texture
  12825. * @param depth defines the number of layers of the texture
  12826. * @param format defines the format of the texture
  12827. * @param generateMipMaps defines if the engine must generate mip levels
  12828. * @param invertY defines if data must be stored with Y axis inverted
  12829. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12830. * @param compression defines the compressed used (can be null)
  12831. * @param textureType defines the compressed used (can be null)
  12832. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12833. */
  12834. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12835. /**
  12836. * Update a raw 2D array texture
  12837. * @param texture defines the texture to update
  12838. * @param data defines the data to store
  12839. * @param format defines the data format
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. */
  12842. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12843. /**
  12844. * Update a raw 2D array texture
  12845. * @param texture defines the texture to update
  12846. * @param data defines the data to store
  12847. * @param format defines the data format
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param compression defines the used compression (can be null)
  12850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12851. */
  12852. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12853. }
  12854. }
  12855. }
  12856. declare module "babylonjs/Materials/Textures/rawTexture" {
  12857. import { Scene } from "babylonjs/scene";
  12858. import { Texture } from "babylonjs/Materials/Textures/texture";
  12859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12860. /**
  12861. * Raw texture can help creating a texture directly from an array of data.
  12862. * This can be super useful if you either get the data from an uncompressed source or
  12863. * if you wish to create your texture pixel by pixel.
  12864. */
  12865. export class RawTexture extends Texture {
  12866. /**
  12867. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12868. */
  12869. format: number;
  12870. private _engine;
  12871. /**
  12872. * Instantiates a new RawTexture.
  12873. * Raw texture can help creating a texture directly from an array of data.
  12874. * This can be super useful if you either get the data from an uncompressed source or
  12875. * if you wish to create your texture pixel by pixel.
  12876. * @param data define the array of data to use to create the texture
  12877. * @param width define the width of the texture
  12878. * @param height define the height of the texture
  12879. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12880. * @param scene define the scene the texture belongs to
  12881. * @param generateMipMaps define whether mip maps should be generated or not
  12882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12884. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12885. */
  12886. constructor(data: ArrayBufferView, width: number, height: number,
  12887. /**
  12888. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12889. */
  12890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12891. /**
  12892. * Updates the texture underlying data.
  12893. * @param data Define the new data of the texture
  12894. */
  12895. update(data: ArrayBufferView): void;
  12896. /**
  12897. * Creates a luminance texture from some data.
  12898. * @param data Define the texture data
  12899. * @param width Define the width of the texture
  12900. * @param height Define the height of the texture
  12901. * @param scene Define the scene the texture belongs to
  12902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12905. * @returns the luminance texture
  12906. */
  12907. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12908. /**
  12909. * Creates a luminance alpha texture from some data.
  12910. * @param data Define the texture data
  12911. * @param width Define the width of the texture
  12912. * @param height Define the height of the texture
  12913. * @param scene Define the scene the texture belongs to
  12914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12917. * @returns the luminance alpha texture
  12918. */
  12919. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12920. /**
  12921. * Creates an alpha texture from some data.
  12922. * @param data Define the texture data
  12923. * @param width Define the width of the texture
  12924. * @param height Define the height of the texture
  12925. * @param scene Define the scene the texture belongs to
  12926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12929. * @returns the alpha texture
  12930. */
  12931. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12932. /**
  12933. * Creates a RGB texture from some data.
  12934. * @param data Define the texture data
  12935. * @param width Define the width of the texture
  12936. * @param height Define the height of the texture
  12937. * @param scene Define the scene the texture belongs to
  12938. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12939. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12940. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12941. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12942. * @returns the RGB alpha texture
  12943. */
  12944. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12945. /**
  12946. * Creates a RGBA texture from some data.
  12947. * @param data Define the texture data
  12948. * @param width Define the width of the texture
  12949. * @param height Define the height of the texture
  12950. * @param scene Define the scene the texture belongs to
  12951. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12952. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12953. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12954. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12955. * @returns the RGBA texture
  12956. */
  12957. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12958. /**
  12959. * Creates a R texture from some data.
  12960. * @param data Define the texture data
  12961. * @param width Define the width of the texture
  12962. * @param height Define the height of the texture
  12963. * @param scene Define the scene the texture belongs to
  12964. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12965. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12966. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12967. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12968. * @returns the R texture
  12969. */
  12970. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12971. }
  12972. }
  12973. declare module "babylonjs/Maths/math.size" {
  12974. /**
  12975. * Interface for the size containing width and height
  12976. */
  12977. export interface ISize {
  12978. /**
  12979. * Width
  12980. */
  12981. width: number;
  12982. /**
  12983. * Heighht
  12984. */
  12985. height: number;
  12986. }
  12987. /**
  12988. * Size containing widht and height
  12989. */
  12990. export class Size implements ISize {
  12991. /**
  12992. * Width
  12993. */
  12994. width: number;
  12995. /**
  12996. * Height
  12997. */
  12998. height: number;
  12999. /**
  13000. * Creates a Size object from the given width and height (floats).
  13001. * @param width width of the new size
  13002. * @param height height of the new size
  13003. */
  13004. constructor(width: number, height: number);
  13005. /**
  13006. * Returns a string with the Size width and height
  13007. * @returns a string with the Size width and height
  13008. */
  13009. toString(): string;
  13010. /**
  13011. * "Size"
  13012. * @returns the string "Size"
  13013. */
  13014. getClassName(): string;
  13015. /**
  13016. * Returns the Size hash code.
  13017. * @returns a hash code for a unique width and height
  13018. */
  13019. getHashCode(): number;
  13020. /**
  13021. * Updates the current size from the given one.
  13022. * @param src the given size
  13023. */
  13024. copyFrom(src: Size): void;
  13025. /**
  13026. * Updates in place the current Size from the given floats.
  13027. * @param width width of the new size
  13028. * @param height height of the new size
  13029. * @returns the updated Size.
  13030. */
  13031. copyFromFloats(width: number, height: number): Size;
  13032. /**
  13033. * Updates in place the current Size from the given floats.
  13034. * @param width width to set
  13035. * @param height height to set
  13036. * @returns the updated Size.
  13037. */
  13038. set(width: number, height: number): Size;
  13039. /**
  13040. * Multiplies the width and height by numbers
  13041. * @param w factor to multiple the width by
  13042. * @param h factor to multiple the height by
  13043. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13044. */
  13045. multiplyByFloats(w: number, h: number): Size;
  13046. /**
  13047. * Clones the size
  13048. * @returns a new Size copied from the given one.
  13049. */
  13050. clone(): Size;
  13051. /**
  13052. * True if the current Size and the given one width and height are strictly equal.
  13053. * @param other the other size to compare against
  13054. * @returns True if the current Size and the given one width and height are strictly equal.
  13055. */
  13056. equals(other: Size): boolean;
  13057. /**
  13058. * The surface of the Size : width * height (float).
  13059. */
  13060. readonly surface: number;
  13061. /**
  13062. * Create a new size of zero
  13063. * @returns a new Size set to (0.0, 0.0)
  13064. */
  13065. static Zero(): Size;
  13066. /**
  13067. * Sums the width and height of two sizes
  13068. * @param otherSize size to add to this size
  13069. * @returns a new Size set as the addition result of the current Size and the given one.
  13070. */
  13071. add(otherSize: Size): Size;
  13072. /**
  13073. * Subtracts the width and height of two
  13074. * @param otherSize size to subtract to this size
  13075. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13076. */
  13077. subtract(otherSize: Size): Size;
  13078. /**
  13079. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13080. * @param start starting size to lerp between
  13081. * @param end end size to lerp between
  13082. * @param amount amount to lerp between the start and end values
  13083. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13084. */
  13085. static Lerp(start: Size, end: Size, amount: number): Size;
  13086. }
  13087. }
  13088. declare module "babylonjs/Animations/runtimeAnimation" {
  13089. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13090. import { Animatable } from "babylonjs/Animations/animatable";
  13091. import { Scene } from "babylonjs/scene";
  13092. /**
  13093. * Defines a runtime animation
  13094. */
  13095. export class RuntimeAnimation {
  13096. private _events;
  13097. /**
  13098. * The current frame of the runtime animation
  13099. */
  13100. private _currentFrame;
  13101. /**
  13102. * The animation used by the runtime animation
  13103. */
  13104. private _animation;
  13105. /**
  13106. * The target of the runtime animation
  13107. */
  13108. private _target;
  13109. /**
  13110. * The initiating animatable
  13111. */
  13112. private _host;
  13113. /**
  13114. * The original value of the runtime animation
  13115. */
  13116. private _originalValue;
  13117. /**
  13118. * The original blend value of the runtime animation
  13119. */
  13120. private _originalBlendValue;
  13121. /**
  13122. * The offsets cache of the runtime animation
  13123. */
  13124. private _offsetsCache;
  13125. /**
  13126. * The high limits cache of the runtime animation
  13127. */
  13128. private _highLimitsCache;
  13129. /**
  13130. * Specifies if the runtime animation has been stopped
  13131. */
  13132. private _stopped;
  13133. /**
  13134. * The blending factor of the runtime animation
  13135. */
  13136. private _blendingFactor;
  13137. /**
  13138. * The BabylonJS scene
  13139. */
  13140. private _scene;
  13141. /**
  13142. * The current value of the runtime animation
  13143. */
  13144. private _currentValue;
  13145. /** @hidden */
  13146. _animationState: _IAnimationState;
  13147. /**
  13148. * The active target of the runtime animation
  13149. */
  13150. private _activeTargets;
  13151. private _currentActiveTarget;
  13152. private _directTarget;
  13153. /**
  13154. * The target path of the runtime animation
  13155. */
  13156. private _targetPath;
  13157. /**
  13158. * The weight of the runtime animation
  13159. */
  13160. private _weight;
  13161. /**
  13162. * The ratio offset of the runtime animation
  13163. */
  13164. private _ratioOffset;
  13165. /**
  13166. * The previous delay of the runtime animation
  13167. */
  13168. private _previousDelay;
  13169. /**
  13170. * The previous ratio of the runtime animation
  13171. */
  13172. private _previousRatio;
  13173. private _enableBlending;
  13174. private _keys;
  13175. private _minFrame;
  13176. private _maxFrame;
  13177. private _minValue;
  13178. private _maxValue;
  13179. private _targetIsArray;
  13180. /**
  13181. * Gets the current frame of the runtime animation
  13182. */
  13183. readonly currentFrame: number;
  13184. /**
  13185. * Gets the weight of the runtime animation
  13186. */
  13187. readonly weight: number;
  13188. /**
  13189. * Gets the current value of the runtime animation
  13190. */
  13191. readonly currentValue: any;
  13192. /**
  13193. * Gets the target path of the runtime animation
  13194. */
  13195. readonly targetPath: string;
  13196. /**
  13197. * Gets the actual target of the runtime animation
  13198. */
  13199. readonly target: any;
  13200. /** @hidden */
  13201. _onLoop: () => void;
  13202. /**
  13203. * Create a new RuntimeAnimation object
  13204. * @param target defines the target of the animation
  13205. * @param animation defines the source animation object
  13206. * @param scene defines the hosting scene
  13207. * @param host defines the initiating Animatable
  13208. */
  13209. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13210. private _preparePath;
  13211. /**
  13212. * Gets the animation from the runtime animation
  13213. */
  13214. readonly animation: Animation;
  13215. /**
  13216. * Resets the runtime animation to the beginning
  13217. * @param restoreOriginal defines whether to restore the target property to the original value
  13218. */
  13219. reset(restoreOriginal?: boolean): void;
  13220. /**
  13221. * Specifies if the runtime animation is stopped
  13222. * @returns Boolean specifying if the runtime animation is stopped
  13223. */
  13224. isStopped(): boolean;
  13225. /**
  13226. * Disposes of the runtime animation
  13227. */
  13228. dispose(): void;
  13229. /**
  13230. * Apply the interpolated value to the target
  13231. * @param currentValue defines the value computed by the animation
  13232. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13233. */
  13234. setValue(currentValue: any, weight: number): void;
  13235. private _getOriginalValues;
  13236. private _setValue;
  13237. /**
  13238. * Gets the loop pmode of the runtime animation
  13239. * @returns Loop Mode
  13240. */
  13241. private _getCorrectLoopMode;
  13242. /**
  13243. * Move the current animation to a given frame
  13244. * @param frame defines the frame to move to
  13245. */
  13246. goToFrame(frame: number): void;
  13247. /**
  13248. * @hidden Internal use only
  13249. */
  13250. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13251. /**
  13252. * Execute the current animation
  13253. * @param delay defines the delay to add to the current frame
  13254. * @param from defines the lower bound of the animation range
  13255. * @param to defines the upper bound of the animation range
  13256. * @param loop defines if the current animation must loop
  13257. * @param speedRatio defines the current speed ratio
  13258. * @param weight defines the weight of the animation (default is -1 so no weight)
  13259. * @param onLoop optional callback called when animation loops
  13260. * @returns a boolean indicating if the animation is running
  13261. */
  13262. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13263. }
  13264. }
  13265. declare module "babylonjs/Animations/animatable" {
  13266. import { Animation } from "babylonjs/Animations/animation";
  13267. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13268. import { Nullable } from "babylonjs/types";
  13269. import { Observable } from "babylonjs/Misc/observable";
  13270. import { Scene } from "babylonjs/scene";
  13271. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13272. import { Node } from "babylonjs/node";
  13273. /**
  13274. * Class used to store an actual running animation
  13275. */
  13276. export class Animatable {
  13277. /** defines the target object */
  13278. target: any;
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame: number;
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame: number;
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation: boolean;
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined;
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined;
  13289. private _localDelayOffset;
  13290. private _pausedDelay;
  13291. private _runtimeAnimations;
  13292. private _paused;
  13293. private _scene;
  13294. private _speedRatio;
  13295. private _weight;
  13296. private _syncRoot;
  13297. /**
  13298. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13299. * This will only apply for non looping animation (default is true)
  13300. */
  13301. disposeOnEnd: boolean;
  13302. /**
  13303. * Gets a boolean indicating if the animation has started
  13304. */
  13305. animationStarted: boolean;
  13306. /**
  13307. * Observer raised when the animation ends
  13308. */
  13309. onAnimationEndObservable: Observable<Animatable>;
  13310. /**
  13311. * Observer raised when the animation loops
  13312. */
  13313. onAnimationLoopObservable: Observable<Animatable>;
  13314. /**
  13315. * Gets the root Animatable used to synchronize and normalize animations
  13316. */
  13317. readonly syncRoot: Nullable<Animatable>;
  13318. /**
  13319. * Gets the current frame of the first RuntimeAnimation
  13320. * Used to synchronize Animatables
  13321. */
  13322. readonly masterFrame: number;
  13323. /**
  13324. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13325. */
  13326. weight: number;
  13327. /**
  13328. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13329. */
  13330. speedRatio: number;
  13331. /**
  13332. * Creates a new Animatable
  13333. * @param scene defines the hosting scene
  13334. * @param target defines the target object
  13335. * @param fromFrame defines the starting frame number (default is 0)
  13336. * @param toFrame defines the ending frame number (default is 100)
  13337. * @param loopAnimation defines if the animation must loop (default is false)
  13338. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13339. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13340. * @param animations defines a group of animation to add to the new Animatable
  13341. * @param onAnimationLoop defines a callback to call when animation loops
  13342. */
  13343. constructor(scene: Scene,
  13344. /** defines the target object */
  13345. target: any,
  13346. /** defines the starting frame number (default is 0) */
  13347. fromFrame?: number,
  13348. /** defines the ending frame number (default is 100) */
  13349. toFrame?: number,
  13350. /** defines if the animation must loop (default is false) */
  13351. loopAnimation?: boolean, speedRatio?: number,
  13352. /** defines a callback to call when animation ends if it is not looping */
  13353. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13354. /** defines a callback to call when animation loops */
  13355. onAnimationLoop?: (() => void) | null | undefined);
  13356. /**
  13357. * Synchronize and normalize current Animatable with a source Animatable
  13358. * This is useful when using animation weights and when animations are not of the same length
  13359. * @param root defines the root Animatable to synchronize with
  13360. * @returns the current Animatable
  13361. */
  13362. syncWith(root: Animatable): Animatable;
  13363. /**
  13364. * Gets the list of runtime animations
  13365. * @returns an array of RuntimeAnimation
  13366. */
  13367. getAnimations(): RuntimeAnimation[];
  13368. /**
  13369. * Adds more animations to the current animatable
  13370. * @param target defines the target of the animations
  13371. * @param animations defines the new animations to add
  13372. */
  13373. appendAnimations(target: any, animations: Animation[]): void;
  13374. /**
  13375. * Gets the source animation for a specific property
  13376. * @param property defines the propertyu to look for
  13377. * @returns null or the source animation for the given property
  13378. */
  13379. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13380. /**
  13381. * Gets the runtime animation for a specific property
  13382. * @param property defines the propertyu to look for
  13383. * @returns null or the runtime animation for the given property
  13384. */
  13385. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13386. /**
  13387. * Resets the animatable to its original state
  13388. */
  13389. reset(): void;
  13390. /**
  13391. * Allows the animatable to blend with current running animations
  13392. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13393. * @param blendingSpeed defines the blending speed to use
  13394. */
  13395. enableBlending(blendingSpeed: number): void;
  13396. /**
  13397. * Disable animation blending
  13398. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13399. */
  13400. disableBlending(): void;
  13401. /**
  13402. * Jump directly to a given frame
  13403. * @param frame defines the frame to jump to
  13404. */
  13405. goToFrame(frame: number): void;
  13406. /**
  13407. * Pause the animation
  13408. */
  13409. pause(): void;
  13410. /**
  13411. * Restart the animation
  13412. */
  13413. restart(): void;
  13414. private _raiseOnAnimationEnd;
  13415. /**
  13416. * Stop and delete the current animation
  13417. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13418. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13419. */
  13420. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13421. /**
  13422. * Wait asynchronously for the animation to end
  13423. * @returns a promise which will be fullfilled when the animation ends
  13424. */
  13425. waitAsync(): Promise<Animatable>;
  13426. /** @hidden */
  13427. _animate(delay: number): boolean;
  13428. }
  13429. module "babylonjs/scene" {
  13430. interface Scene {
  13431. /** @hidden */
  13432. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13433. /** @hidden */
  13434. _processLateAnimationBindingsForMatrices(holder: {
  13435. totalWeight: number;
  13436. animations: RuntimeAnimation[];
  13437. originalValue: Matrix;
  13438. }): any;
  13439. /** @hidden */
  13440. _processLateAnimationBindingsForQuaternions(holder: {
  13441. totalWeight: number;
  13442. animations: RuntimeAnimation[];
  13443. originalValue: Quaternion;
  13444. }, refQuaternion: Quaternion): Quaternion;
  13445. /** @hidden */
  13446. _processLateAnimationBindings(): void;
  13447. /**
  13448. * Will start the animation sequence of a given target
  13449. * @param target defines the target
  13450. * @param from defines from which frame should animation start
  13451. * @param to defines until which frame should animation run.
  13452. * @param weight defines the weight to apply to the animation (1.0 by default)
  13453. * @param loop defines if the animation loops
  13454. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13455. * @param onAnimationEnd defines the function to be executed when the animation ends
  13456. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13457. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13458. * @param onAnimationLoop defines the callback to call when an animation loops
  13459. * @returns the animatable object created for this animation
  13460. */
  13461. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13462. /**
  13463. * Will start the animation sequence of a given target
  13464. * @param target defines the target
  13465. * @param from defines from which frame should animation start
  13466. * @param to defines until which frame should animation run.
  13467. * @param loop defines if the animation loops
  13468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13469. * @param onAnimationEnd defines the function to be executed when the animation ends
  13470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13471. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13472. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13473. * @param onAnimationLoop defines the callback to call when an animation loops
  13474. * @returns the animatable object created for this animation
  13475. */
  13476. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13477. /**
  13478. * Will start the animation sequence of a given target and its hierarchy
  13479. * @param target defines the target
  13480. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13481. * @param from defines from which frame should animation start
  13482. * @param to defines until which frame should animation run.
  13483. * @param loop defines if the animation loops
  13484. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13485. * @param onAnimationEnd defines the function to be executed when the animation ends
  13486. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13487. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13488. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13489. * @param onAnimationLoop defines the callback to call when an animation loops
  13490. * @returns the list of created animatables
  13491. */
  13492. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13493. /**
  13494. * Begin a new animation on a given node
  13495. * @param target defines the target where the animation will take place
  13496. * @param animations defines the list of animations to start
  13497. * @param from defines the initial value
  13498. * @param to defines the final value
  13499. * @param loop defines if you want animation to loop (off by default)
  13500. * @param speedRatio defines the speed ratio to apply to all animations
  13501. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13502. * @param onAnimationLoop defines the callback to call when an animation loops
  13503. * @returns the list of created animatables
  13504. */
  13505. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13506. /**
  13507. * Begin a new animation on a given node and its hierarchy
  13508. * @param target defines the root node where the animation will take place
  13509. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13510. * @param animations defines the list of animations to start
  13511. * @param from defines the initial value
  13512. * @param to defines the final value
  13513. * @param loop defines if you want animation to loop (off by default)
  13514. * @param speedRatio defines the speed ratio to apply to all animations
  13515. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13516. * @param onAnimationLoop defines the callback to call when an animation loops
  13517. * @returns the list of animatables created for all nodes
  13518. */
  13519. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13520. /**
  13521. * Gets the animatable associated with a specific target
  13522. * @param target defines the target of the animatable
  13523. * @returns the required animatable if found
  13524. */
  13525. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13526. /**
  13527. * Gets all animatables associated with a given target
  13528. * @param target defines the target to look animatables for
  13529. * @returns an array of Animatables
  13530. */
  13531. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13532. /**
  13533. * Stops and removes all animations that have been applied to the scene
  13534. */
  13535. stopAllAnimations(): void;
  13536. /**
  13537. * Gets the current delta time used by animation engine
  13538. */
  13539. deltaTime: number;
  13540. }
  13541. }
  13542. module "babylonjs/Bones/bone" {
  13543. interface Bone {
  13544. /**
  13545. * Copy an animation range from another bone
  13546. * @param source defines the source bone
  13547. * @param rangeName defines the range name to copy
  13548. * @param frameOffset defines the frame offset
  13549. * @param rescaleAsRequired defines if rescaling must be applied if required
  13550. * @param skelDimensionsRatio defines the scaling ratio
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13554. }
  13555. }
  13556. }
  13557. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13558. /**
  13559. * Class used to override all child animations of a given target
  13560. */
  13561. export class AnimationPropertiesOverride {
  13562. /**
  13563. * Gets or sets a value indicating if animation blending must be used
  13564. */
  13565. enableBlending: boolean;
  13566. /**
  13567. * Gets or sets the blending speed to use when enableBlending is true
  13568. */
  13569. blendingSpeed: number;
  13570. /**
  13571. * Gets or sets the default loop mode to use
  13572. */
  13573. loopMode: number;
  13574. }
  13575. }
  13576. declare module "babylonjs/Bones/skeleton" {
  13577. import { Bone } from "babylonjs/Bones/bone";
  13578. import { Observable } from "babylonjs/Misc/observable";
  13579. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13580. import { Scene } from "babylonjs/scene";
  13581. import { Nullable } from "babylonjs/types";
  13582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13583. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13584. import { Animatable } from "babylonjs/Animations/animatable";
  13585. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13586. import { Animation } from "babylonjs/Animations/animation";
  13587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13588. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13590. /**
  13591. * Class used to handle skinning animations
  13592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13593. */
  13594. export class Skeleton implements IAnimatable {
  13595. /** defines the skeleton name */
  13596. name: string;
  13597. /** defines the skeleton Id */
  13598. id: string;
  13599. /**
  13600. * Defines the list of child bones
  13601. */
  13602. bones: Bone[];
  13603. /**
  13604. * Defines an estimate of the dimension of the skeleton at rest
  13605. */
  13606. dimensionsAtRest: Vector3;
  13607. /**
  13608. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13609. */
  13610. needInitialSkinMatrix: boolean;
  13611. /**
  13612. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13613. */
  13614. overrideMesh: Nullable<AbstractMesh>;
  13615. /**
  13616. * Gets the list of animations attached to this skeleton
  13617. */
  13618. animations: Array<Animation>;
  13619. private _scene;
  13620. private _isDirty;
  13621. private _transformMatrices;
  13622. private _transformMatrixTexture;
  13623. private _meshesWithPoseMatrix;
  13624. private _animatables;
  13625. private _identity;
  13626. private _synchronizedWithMesh;
  13627. private _ranges;
  13628. private _lastAbsoluteTransformsUpdateId;
  13629. private _canUseTextureForBones;
  13630. private _uniqueId;
  13631. /** @hidden */
  13632. _numBonesWithLinkedTransformNode: number;
  13633. /** @hidden */
  13634. _hasWaitingData: Nullable<boolean>;
  13635. /**
  13636. * Specifies if the skeleton should be serialized
  13637. */
  13638. doNotSerialize: boolean;
  13639. private _useTextureToStoreBoneMatrices;
  13640. /**
  13641. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13642. * Please note that this option is not available if the hardware does not support it
  13643. */
  13644. useTextureToStoreBoneMatrices: boolean;
  13645. private _animationPropertiesOverride;
  13646. /**
  13647. * Gets or sets the animation properties override
  13648. */
  13649. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * An observable triggered before computing the skeleton's matrices
  13657. */
  13658. onBeforeComputeObservable: Observable<Skeleton>;
  13659. /**
  13660. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13661. */
  13662. readonly isUsingTextureForMatrices: boolean;
  13663. /**
  13664. * Gets the unique ID of this skeleton
  13665. */
  13666. readonly uniqueId: number;
  13667. /**
  13668. * Creates a new skeleton
  13669. * @param name defines the skeleton name
  13670. * @param id defines the skeleton Id
  13671. * @param scene defines the hosting scene
  13672. */
  13673. constructor(
  13674. /** defines the skeleton name */
  13675. name: string,
  13676. /** defines the skeleton Id */
  13677. id: string, scene: Scene);
  13678. /**
  13679. * Gets the current object class name.
  13680. * @return the class name
  13681. */
  13682. getClassName(): string;
  13683. /**
  13684. * Returns an array containing the root bones
  13685. * @returns an array containing the root bones
  13686. */
  13687. getChildren(): Array<Bone>;
  13688. /**
  13689. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13690. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13691. * @returns a Float32Array containing matrices data
  13692. */
  13693. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13694. /**
  13695. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13696. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13697. * @returns a raw texture containing the data
  13698. */
  13699. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13700. /**
  13701. * Gets the current hosting scene
  13702. * @returns a scene object
  13703. */
  13704. getScene(): Scene;
  13705. /**
  13706. * Gets a string representing the current skeleton data
  13707. * @param fullDetails defines a boolean indicating if we want a verbose version
  13708. * @returns a string representing the current skeleton data
  13709. */
  13710. toString(fullDetails?: boolean): string;
  13711. /**
  13712. * Get bone's index searching by name
  13713. * @param name defines bone's name to search for
  13714. * @return the indice of the bone. Returns -1 if not found
  13715. */
  13716. getBoneIndexByName(name: string): number;
  13717. /**
  13718. * Creater a new animation range
  13719. * @param name defines the name of the range
  13720. * @param from defines the start key
  13721. * @param to defines the end key
  13722. */
  13723. createAnimationRange(name: string, from: number, to: number): void;
  13724. /**
  13725. * Delete a specific animation range
  13726. * @param name defines the name of the range
  13727. * @param deleteFrames defines if frames must be removed as well
  13728. */
  13729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13730. /**
  13731. * Gets a specific animation range
  13732. * @param name defines the name of the range to look for
  13733. * @returns the requested animation range or null if not found
  13734. */
  13735. getAnimationRange(name: string): Nullable<AnimationRange>;
  13736. /**
  13737. * Gets the list of all animation ranges defined on this skeleton
  13738. * @returns an array
  13739. */
  13740. getAnimationRanges(): Nullable<AnimationRange>[];
  13741. /**
  13742. * Copy animation range from a source skeleton.
  13743. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13744. * @param source defines the source skeleton
  13745. * @param name defines the name of the range to copy
  13746. * @param rescaleAsRequired defines if rescaling must be applied if required
  13747. * @returns true if operation was successful
  13748. */
  13749. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13750. /**
  13751. * Forces the skeleton to go to rest pose
  13752. */
  13753. returnToRest(): void;
  13754. private _getHighestAnimationFrame;
  13755. /**
  13756. * Begin a specific animation range
  13757. * @param name defines the name of the range to start
  13758. * @param loop defines if looping must be turned on (false by default)
  13759. * @param speedRatio defines the speed ratio to apply (1 by default)
  13760. * @param onAnimationEnd defines a callback which will be called when animation will end
  13761. * @returns a new animatable
  13762. */
  13763. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13764. /** @hidden */
  13765. _markAsDirty(): void;
  13766. /** @hidden */
  13767. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13768. /** @hidden */
  13769. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13770. private _computeTransformMatrices;
  13771. /**
  13772. * Build all resources required to render a skeleton
  13773. */
  13774. prepare(): void;
  13775. /**
  13776. * Gets the list of animatables currently running for this skeleton
  13777. * @returns an array of animatables
  13778. */
  13779. getAnimatables(): IAnimatable[];
  13780. /**
  13781. * Clone the current skeleton
  13782. * @param name defines the name of the new skeleton
  13783. * @param id defines the id of the new skeleton
  13784. * @returns the new skeleton
  13785. */
  13786. clone(name: string, id?: string): Skeleton;
  13787. /**
  13788. * Enable animation blending for this skeleton
  13789. * @param blendingSpeed defines the blending speed to apply
  13790. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13791. */
  13792. enableBlending(blendingSpeed?: number): void;
  13793. /**
  13794. * Releases all resources associated with the current skeleton
  13795. */
  13796. dispose(): void;
  13797. /**
  13798. * Serialize the skeleton in a JSON object
  13799. * @returns a JSON object
  13800. */
  13801. serialize(): any;
  13802. /**
  13803. * Creates a new skeleton from serialized data
  13804. * @param parsedSkeleton defines the serialized data
  13805. * @param scene defines the hosting scene
  13806. * @returns a new skeleton
  13807. */
  13808. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13809. /**
  13810. * Compute all node absolute transforms
  13811. * @param forceUpdate defines if computation must be done even if cache is up to date
  13812. */
  13813. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13814. /**
  13815. * Gets the root pose matrix
  13816. * @returns a matrix
  13817. */
  13818. getPoseMatrix(): Nullable<Matrix>;
  13819. /**
  13820. * Sorts bones per internal index
  13821. */
  13822. sortBones(): void;
  13823. private _sortBones;
  13824. }
  13825. }
  13826. declare module "babylonjs/Bones/bone" {
  13827. import { Skeleton } from "babylonjs/Bones/skeleton";
  13828. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13829. import { Nullable } from "babylonjs/types";
  13830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13832. import { Node } from "babylonjs/node";
  13833. import { Space } from "babylonjs/Maths/math.axis";
  13834. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13835. /**
  13836. * Class used to store bone information
  13837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13838. */
  13839. export class Bone extends Node {
  13840. /**
  13841. * defines the bone name
  13842. */
  13843. name: string;
  13844. private static _tmpVecs;
  13845. private static _tmpQuat;
  13846. private static _tmpMats;
  13847. /**
  13848. * Gets the list of child bones
  13849. */
  13850. children: Bone[];
  13851. /** Gets the animations associated with this bone */
  13852. animations: import("babylonjs/Animations/animation").Animation[];
  13853. /**
  13854. * Gets or sets bone length
  13855. */
  13856. length: number;
  13857. /**
  13858. * @hidden Internal only
  13859. * Set this value to map this bone to a different index in the transform matrices
  13860. * Set this value to -1 to exclude the bone from the transform matrices
  13861. */
  13862. _index: Nullable<number>;
  13863. private _skeleton;
  13864. private _localMatrix;
  13865. private _restPose;
  13866. private _baseMatrix;
  13867. private _absoluteTransform;
  13868. private _invertedAbsoluteTransform;
  13869. private _parent;
  13870. private _scalingDeterminant;
  13871. private _worldTransform;
  13872. private _localScaling;
  13873. private _localRotation;
  13874. private _localPosition;
  13875. private _needToDecompose;
  13876. private _needToCompose;
  13877. /** @hidden */
  13878. _linkedTransformNode: Nullable<TransformNode>;
  13879. /** @hidden */
  13880. _waitingTransformNodeId: Nullable<string>;
  13881. /** @hidden */
  13882. /** @hidden */
  13883. _matrix: Matrix;
  13884. /**
  13885. * Create a new bone
  13886. * @param name defines the bone name
  13887. * @param skeleton defines the parent skeleton
  13888. * @param parentBone defines the parent (can be null if the bone is the root)
  13889. * @param localMatrix defines the local matrix
  13890. * @param restPose defines the rest pose matrix
  13891. * @param baseMatrix defines the base matrix
  13892. * @param index defines index of the bone in the hiearchy
  13893. */
  13894. constructor(
  13895. /**
  13896. * defines the bone name
  13897. */
  13898. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13899. /**
  13900. * Gets the current object class name.
  13901. * @return the class name
  13902. */
  13903. getClassName(): string;
  13904. /**
  13905. * Gets the parent skeleton
  13906. * @returns a skeleton
  13907. */
  13908. getSkeleton(): Skeleton;
  13909. /**
  13910. * Gets parent bone
  13911. * @returns a bone or null if the bone is the root of the bone hierarchy
  13912. */
  13913. getParent(): Nullable<Bone>;
  13914. /**
  13915. * Returns an array containing the root bones
  13916. * @returns an array containing the root bones
  13917. */
  13918. getChildren(): Array<Bone>;
  13919. /**
  13920. * Gets the node index in matrix array generated for rendering
  13921. * @returns the node index
  13922. */
  13923. getIndex(): number;
  13924. /**
  13925. * Sets the parent bone
  13926. * @param parent defines the parent (can be null if the bone is the root)
  13927. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13928. */
  13929. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13930. /**
  13931. * Gets the local matrix
  13932. * @returns a matrix
  13933. */
  13934. getLocalMatrix(): Matrix;
  13935. /**
  13936. * Gets the base matrix (initial matrix which remains unchanged)
  13937. * @returns a matrix
  13938. */
  13939. getBaseMatrix(): Matrix;
  13940. /**
  13941. * Gets the rest pose matrix
  13942. * @returns a matrix
  13943. */
  13944. getRestPose(): Matrix;
  13945. /**
  13946. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13947. */
  13948. getWorldMatrix(): Matrix;
  13949. /**
  13950. * Sets the local matrix to rest pose matrix
  13951. */
  13952. returnToRest(): void;
  13953. /**
  13954. * Gets the inverse of the absolute transform matrix.
  13955. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13956. * @returns a matrix
  13957. */
  13958. getInvertedAbsoluteTransform(): Matrix;
  13959. /**
  13960. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13961. * @returns a matrix
  13962. */
  13963. getAbsoluteTransform(): Matrix;
  13964. /**
  13965. * Links with the given transform node.
  13966. * The local matrix of this bone is copied from the transform node every frame.
  13967. * @param transformNode defines the transform node to link to
  13968. */
  13969. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13970. /**
  13971. * Gets the node used to drive the bone's transformation
  13972. * @returns a transform node or null
  13973. */
  13974. getTransformNode(): Nullable<TransformNode>;
  13975. /** Gets or sets current position (in local space) */
  13976. position: Vector3;
  13977. /** Gets or sets current rotation (in local space) */
  13978. rotation: Vector3;
  13979. /** Gets or sets current rotation quaternion (in local space) */
  13980. rotationQuaternion: Quaternion;
  13981. /** Gets or sets current scaling (in local space) */
  13982. scaling: Vector3;
  13983. /**
  13984. * Gets the animation properties override
  13985. */
  13986. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13987. private _decompose;
  13988. private _compose;
  13989. /**
  13990. * Update the base and local matrices
  13991. * @param matrix defines the new base or local matrix
  13992. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13993. * @param updateLocalMatrix defines if the local matrix should be updated
  13994. */
  13995. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13996. /** @hidden */
  13997. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13998. /**
  13999. * Flag the bone as dirty (Forcing it to update everything)
  14000. */
  14001. markAsDirty(): void;
  14002. /** @hidden */
  14003. _markAsDirtyAndCompose(): void;
  14004. private _markAsDirtyAndDecompose;
  14005. /**
  14006. * Translate the bone in local or world space
  14007. * @param vec The amount to translate the bone
  14008. * @param space The space that the translation is in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. */
  14011. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14012. /**
  14013. * Set the postion of the bone in local or world space
  14014. * @param position The position to set the bone
  14015. * @param space The space that the position is in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. */
  14018. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14019. /**
  14020. * Set the absolute position of the bone (world space)
  14021. * @param position The position to set the bone
  14022. * @param mesh The mesh that this bone is attached to
  14023. */
  14024. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14025. /**
  14026. * Scale the bone on the x, y and z axes (in local space)
  14027. * @param x The amount to scale the bone on the x axis
  14028. * @param y The amount to scale the bone on the y axis
  14029. * @param z The amount to scale the bone on the z axis
  14030. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14031. */
  14032. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14033. /**
  14034. * Set the bone scaling in local space
  14035. * @param scale defines the scaling vector
  14036. */
  14037. setScale(scale: Vector3): void;
  14038. /**
  14039. * Gets the current scaling in local space
  14040. * @returns the current scaling vector
  14041. */
  14042. getScale(): Vector3;
  14043. /**
  14044. * Gets the current scaling in local space and stores it in a target vector
  14045. * @param result defines the target vector
  14046. */
  14047. getScaleToRef(result: Vector3): void;
  14048. /**
  14049. * Set the yaw, pitch, and roll of the bone in local or world space
  14050. * @param yaw The rotation of the bone on the y axis
  14051. * @param pitch The rotation of the bone on the x axis
  14052. * @param roll The rotation of the bone on the z axis
  14053. * @param space The space that the axes of rotation are in
  14054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14055. */
  14056. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14057. /**
  14058. * Add a rotation to the bone on an axis in local or world space
  14059. * @param axis The axis to rotate the bone on
  14060. * @param amount The amount to rotate the bone
  14061. * @param space The space that the axis is in
  14062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14063. */
  14064. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14065. /**
  14066. * Set the rotation of the bone to a particular axis angle in local or world space
  14067. * @param axis The axis to rotate the bone on
  14068. * @param angle The angle that the bone should be rotated to
  14069. * @param space The space that the axis is in
  14070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14071. */
  14072. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14073. /**
  14074. * Set the euler rotation of the bone in local of world space
  14075. * @param rotation The euler rotation that the bone should be set to
  14076. * @param space The space that the rotation is in
  14077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14078. */
  14079. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14080. /**
  14081. * Set the quaternion rotation of the bone in local of world space
  14082. * @param quat The quaternion rotation that the bone should be set to
  14083. * @param space The space that the rotation is in
  14084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14085. */
  14086. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14087. /**
  14088. * Set the rotation matrix of the bone in local of world space
  14089. * @param rotMat The rotation matrix that the bone should be set to
  14090. * @param space The space that the rotation is in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14094. private _rotateWithMatrix;
  14095. private _getNegativeRotationToRef;
  14096. /**
  14097. * Get the position of the bone in local or world space
  14098. * @param space The space that the returned position is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The position of the bone
  14101. */
  14102. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14103. /**
  14104. * Copy the position of the bone to a vector3 in local or world space
  14105. * @param space The space that the returned position is in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The vector3 to copy the position to
  14108. */
  14109. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14110. /**
  14111. * Get the absolute position of the bone (world space)
  14112. * @param mesh The mesh that this bone is attached to
  14113. * @returns The absolute position of the bone
  14114. */
  14115. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14116. /**
  14117. * Copy the absolute position of the bone (world space) to the result param
  14118. * @param mesh The mesh that this bone is attached to
  14119. * @param result The vector3 to copy the absolute position to
  14120. */
  14121. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14122. /**
  14123. * Compute the absolute transforms of this bone and its children
  14124. */
  14125. computeAbsoluteTransforms(): void;
  14126. /**
  14127. * Get the world direction from an axis that is in the local space of the bone
  14128. * @param localAxis The local direction that is used to compute the world direction
  14129. * @param mesh The mesh that this bone is attached to
  14130. * @returns The world direction
  14131. */
  14132. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14133. /**
  14134. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14135. * @param localAxis The local direction that is used to compute the world direction
  14136. * @param mesh The mesh that this bone is attached to
  14137. * @param result The vector3 that the world direction will be copied to
  14138. */
  14139. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14140. /**
  14141. * Get the euler rotation of the bone in local or world space
  14142. * @param space The space that the rotation should be in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @returns The euler rotation
  14145. */
  14146. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14147. /**
  14148. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14149. * @param space The space that the rotation should be in
  14150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14151. * @param result The vector3 that the rotation should be copied to
  14152. */
  14153. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14154. /**
  14155. * Get the quaternion rotation of the bone in either local or world space
  14156. * @param space The space that the rotation should be in
  14157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14158. * @returns The quaternion rotation
  14159. */
  14160. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14161. /**
  14162. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14163. * @param space The space that the rotation should be in
  14164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14165. * @param result The quaternion that the rotation should be copied to
  14166. */
  14167. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14168. /**
  14169. * Get the rotation matrix of the bone in local or world space
  14170. * @param space The space that the rotation should be in
  14171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14172. * @returns The rotation matrix
  14173. */
  14174. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14175. /**
  14176. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14177. * @param space The space that the rotation should be in
  14178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14179. * @param result The quaternion that the rotation should be copied to
  14180. */
  14181. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14182. /**
  14183. * Get the world position of a point that is in the local space of the bone
  14184. * @param position The local position
  14185. * @param mesh The mesh that this bone is attached to
  14186. * @returns The world position
  14187. */
  14188. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14191. * @param position The local position
  14192. * @param mesh The mesh that this bone is attached to
  14193. * @param result The vector3 that the world position should be copied to
  14194. */
  14195. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the local position of a point that is in world space
  14198. * @param position The world position
  14199. * @param mesh The mesh that this bone is attached to
  14200. * @returns The local position
  14201. */
  14202. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14203. /**
  14204. * Get the local position of a point that is in world space and copy it to the result param
  14205. * @param position The world position
  14206. * @param mesh The mesh that this bone is attached to
  14207. * @param result The vector3 that the local position should be copied to
  14208. */
  14209. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14210. }
  14211. }
  14212. declare module "babylonjs/Meshes/transformNode" {
  14213. import { DeepImmutable } from "babylonjs/types";
  14214. import { Observable } from "babylonjs/Misc/observable";
  14215. import { Nullable } from "babylonjs/types";
  14216. import { Camera } from "babylonjs/Cameras/camera";
  14217. import { Scene } from "babylonjs/scene";
  14218. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14219. import { Node } from "babylonjs/node";
  14220. import { Bone } from "babylonjs/Bones/bone";
  14221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14222. import { Space } from "babylonjs/Maths/math.axis";
  14223. /**
  14224. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14225. * @see https://doc.babylonjs.com/how_to/transformnode
  14226. */
  14227. export class TransformNode extends Node {
  14228. /**
  14229. * Object will not rotate to face the camera
  14230. */
  14231. static BILLBOARDMODE_NONE: number;
  14232. /**
  14233. * Object will rotate to face the camera but only on the x axis
  14234. */
  14235. static BILLBOARDMODE_X: number;
  14236. /**
  14237. * Object will rotate to face the camera but only on the y axis
  14238. */
  14239. static BILLBOARDMODE_Y: number;
  14240. /**
  14241. * Object will rotate to face the camera but only on the z axis
  14242. */
  14243. static BILLBOARDMODE_Z: number;
  14244. /**
  14245. * Object will rotate to face the camera
  14246. */
  14247. static BILLBOARDMODE_ALL: number;
  14248. /**
  14249. * Object will rotate to face the camera's position instead of orientation
  14250. */
  14251. static BILLBOARDMODE_USE_POSITION: number;
  14252. private _forward;
  14253. private _forwardInverted;
  14254. private _up;
  14255. private _right;
  14256. private _rightInverted;
  14257. private _position;
  14258. private _rotation;
  14259. private _rotationQuaternion;
  14260. protected _scaling: Vector3;
  14261. protected _isDirty: boolean;
  14262. private _transformToBoneReferal;
  14263. private _isAbsoluteSynced;
  14264. private _billboardMode;
  14265. /**
  14266. * Gets or sets the billboard mode. Default is 0.
  14267. *
  14268. * | Value | Type | Description |
  14269. * | --- | --- | --- |
  14270. * | 0 | BILLBOARDMODE_NONE | |
  14271. * | 1 | BILLBOARDMODE_X | |
  14272. * | 2 | BILLBOARDMODE_Y | |
  14273. * | 4 | BILLBOARDMODE_Z | |
  14274. * | 7 | BILLBOARDMODE_ALL | |
  14275. *
  14276. */
  14277. billboardMode: number;
  14278. private _preserveParentRotationForBillboard;
  14279. /**
  14280. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14281. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14282. */
  14283. preserveParentRotationForBillboard: boolean;
  14284. /**
  14285. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14286. */
  14287. scalingDeterminant: number;
  14288. private _infiniteDistance;
  14289. /**
  14290. * Gets or sets the distance of the object to max, often used by skybox
  14291. */
  14292. infiniteDistance: boolean;
  14293. /**
  14294. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14295. * By default the system will update normals to compensate
  14296. */
  14297. ignoreNonUniformScaling: boolean;
  14298. /**
  14299. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14300. */
  14301. reIntegrateRotationIntoRotationQuaternion: boolean;
  14302. /** @hidden */
  14303. _poseMatrix: Nullable<Matrix>;
  14304. /** @hidden */
  14305. _localMatrix: Matrix;
  14306. private _usePivotMatrix;
  14307. private _absolutePosition;
  14308. private _absoluteScaling;
  14309. private _absoluteRotationQuaternion;
  14310. private _pivotMatrix;
  14311. private _pivotMatrixInverse;
  14312. protected _postMultiplyPivotMatrix: boolean;
  14313. protected _isWorldMatrixFrozen: boolean;
  14314. /** @hidden */
  14315. _indexInSceneTransformNodesArray: number;
  14316. /**
  14317. * An event triggered after the world matrix is updated
  14318. */
  14319. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14320. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14321. /**
  14322. * Gets a string identifying the name of the class
  14323. * @returns "TransformNode" string
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14328. */
  14329. position: Vector3;
  14330. /**
  14331. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14332. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14333. */
  14334. rotation: Vector3;
  14335. /**
  14336. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14337. */
  14338. scaling: Vector3;
  14339. /**
  14340. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14341. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14342. */
  14343. rotationQuaternion: Nullable<Quaternion>;
  14344. /**
  14345. * The forward direction of that transform in world space.
  14346. */
  14347. readonly forward: Vector3;
  14348. /**
  14349. * The up direction of that transform in world space.
  14350. */
  14351. readonly up: Vector3;
  14352. /**
  14353. * The right direction of that transform in world space.
  14354. */
  14355. readonly right: Vector3;
  14356. /**
  14357. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14358. * @param matrix the matrix to copy the pose from
  14359. * @returns this TransformNode.
  14360. */
  14361. updatePoseMatrix(matrix: Matrix): TransformNode;
  14362. /**
  14363. * Returns the mesh Pose matrix.
  14364. * @returns the pose matrix
  14365. */
  14366. getPoseMatrix(): Matrix;
  14367. /** @hidden */
  14368. _isSynchronized(): boolean;
  14369. /** @hidden */
  14370. _initCache(): void;
  14371. /**
  14372. * Flag the transform node as dirty (Forcing it to update everything)
  14373. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14374. * @returns this transform node
  14375. */
  14376. markAsDirty(property: string): TransformNode;
  14377. /**
  14378. * Returns the current mesh absolute position.
  14379. * Returns a Vector3.
  14380. */
  14381. readonly absolutePosition: Vector3;
  14382. /**
  14383. * Returns the current mesh absolute scaling.
  14384. * Returns a Vector3.
  14385. */
  14386. readonly absoluteScaling: Vector3;
  14387. /**
  14388. * Returns the current mesh absolute rotation.
  14389. * Returns a Quaternion.
  14390. */
  14391. readonly absoluteRotationQuaternion: Quaternion;
  14392. /**
  14393. * Sets a new matrix to apply before all other transformation
  14394. * @param matrix defines the transform matrix
  14395. * @returns the current TransformNode
  14396. */
  14397. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14398. /**
  14399. * Sets a new pivot matrix to the current node
  14400. * @param matrix defines the new pivot matrix to use
  14401. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14402. * @returns the current TransformNode
  14403. */
  14404. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14405. /**
  14406. * Returns the mesh pivot matrix.
  14407. * Default : Identity.
  14408. * @returns the matrix
  14409. */
  14410. getPivotMatrix(): Matrix;
  14411. /**
  14412. * Instantiate (when possible) or clone that node with its hierarchy
  14413. * @param newParent defines the new parent to use for the instance (or clone)
  14414. * @param options defines options to configure how copy is done
  14415. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14416. * @returns an instance (or a clone) of the current node with its hiearchy
  14417. */
  14418. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14419. doNotInstantiate: boolean;
  14420. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14421. /**
  14422. * Prevents the World matrix to be computed any longer
  14423. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14424. * @returns the TransformNode.
  14425. */
  14426. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14427. /**
  14428. * Allows back the World matrix computation.
  14429. * @returns the TransformNode.
  14430. */
  14431. unfreezeWorldMatrix(): this;
  14432. /**
  14433. * True if the World matrix has been frozen.
  14434. */
  14435. readonly isWorldMatrixFrozen: boolean;
  14436. /**
  14437. * Retuns the mesh absolute position in the World.
  14438. * @returns a Vector3.
  14439. */
  14440. getAbsolutePosition(): Vector3;
  14441. /**
  14442. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14443. * @param absolutePosition the absolute position to set
  14444. * @returns the TransformNode.
  14445. */
  14446. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14447. /**
  14448. * Sets the mesh position in its local space.
  14449. * @param vector3 the position to set in localspace
  14450. * @returns the TransformNode.
  14451. */
  14452. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14453. /**
  14454. * Returns the mesh position in the local space from the current World matrix values.
  14455. * @returns a new Vector3.
  14456. */
  14457. getPositionExpressedInLocalSpace(): Vector3;
  14458. /**
  14459. * Translates the mesh along the passed Vector3 in its local space.
  14460. * @param vector3 the distance to translate in localspace
  14461. * @returns the TransformNode.
  14462. */
  14463. locallyTranslate(vector3: Vector3): TransformNode;
  14464. private static _lookAtVectorCache;
  14465. /**
  14466. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14467. * @param targetPoint the position (must be in same space as current mesh) to look at
  14468. * @param yawCor optional yaw (y-axis) correction in radians
  14469. * @param pitchCor optional pitch (x-axis) correction in radians
  14470. * @param rollCor optional roll (z-axis) correction in radians
  14471. * @param space the choosen space of the target
  14472. * @returns the TransformNode.
  14473. */
  14474. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14475. /**
  14476. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14477. * This Vector3 is expressed in the World space.
  14478. * @param localAxis axis to rotate
  14479. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14480. */
  14481. getDirection(localAxis: Vector3): Vector3;
  14482. /**
  14483. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14484. * localAxis is expressed in the mesh local space.
  14485. * result is computed in the Wordl space from the mesh World matrix.
  14486. * @param localAxis axis to rotate
  14487. * @param result the resulting transformnode
  14488. * @returns this TransformNode.
  14489. */
  14490. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14491. /**
  14492. * Sets this transform node rotation to the given local axis.
  14493. * @param localAxis the axis in local space
  14494. * @param yawCor optional yaw (y-axis) correction in radians
  14495. * @param pitchCor optional pitch (x-axis) correction in radians
  14496. * @param rollCor optional roll (z-axis) correction in radians
  14497. * @returns this TransformNode
  14498. */
  14499. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14500. /**
  14501. * Sets a new pivot point to the current node
  14502. * @param point defines the new pivot point to use
  14503. * @param space defines if the point is in world or local space (local by default)
  14504. * @returns the current TransformNode
  14505. */
  14506. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14507. /**
  14508. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14509. * @returns the pivot point
  14510. */
  14511. getPivotPoint(): Vector3;
  14512. /**
  14513. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14514. * @param result the vector3 to store the result
  14515. * @returns this TransformNode.
  14516. */
  14517. getPivotPointToRef(result: Vector3): TransformNode;
  14518. /**
  14519. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14520. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14521. */
  14522. getAbsolutePivotPoint(): Vector3;
  14523. /**
  14524. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14525. * @param result vector3 to store the result
  14526. * @returns this TransformNode.
  14527. */
  14528. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14529. /**
  14530. * Defines the passed node as the parent of the current node.
  14531. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14532. * @see https://doc.babylonjs.com/how_to/parenting
  14533. * @param node the node ot set as the parent
  14534. * @returns this TransformNode.
  14535. */
  14536. setParent(node: Nullable<Node>): TransformNode;
  14537. private _nonUniformScaling;
  14538. /**
  14539. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14540. */
  14541. readonly nonUniformScaling: boolean;
  14542. /** @hidden */
  14543. _updateNonUniformScalingState(value: boolean): boolean;
  14544. /**
  14545. * Attach the current TransformNode to another TransformNode associated with a bone
  14546. * @param bone Bone affecting the TransformNode
  14547. * @param affectedTransformNode TransformNode associated with the bone
  14548. * @returns this object
  14549. */
  14550. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14551. /**
  14552. * Detach the transform node if its associated with a bone
  14553. * @returns this object
  14554. */
  14555. detachFromBone(): TransformNode;
  14556. private static _rotationAxisCache;
  14557. /**
  14558. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14559. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14560. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14561. * The passed axis is also normalized.
  14562. * @param axis the axis to rotate around
  14563. * @param amount the amount to rotate in radians
  14564. * @param space Space to rotate in (Default: local)
  14565. * @returns the TransformNode.
  14566. */
  14567. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14568. /**
  14569. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14570. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14571. * The passed axis is also normalized. .
  14572. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14573. * @param point the point to rotate around
  14574. * @param axis the axis to rotate around
  14575. * @param amount the amount to rotate in radians
  14576. * @returns the TransformNode
  14577. */
  14578. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14579. /**
  14580. * Translates the mesh along the axis vector for the passed distance in the given space.
  14581. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14582. * @param axis the axis to translate in
  14583. * @param distance the distance to translate
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14588. /**
  14589. * Adds a rotation step to the mesh current rotation.
  14590. * x, y, z are Euler angles expressed in radians.
  14591. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14592. * This means this rotation is made in the mesh local space only.
  14593. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14594. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14595. * ```javascript
  14596. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14597. * ```
  14598. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14599. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14600. * @param x Rotation to add
  14601. * @param y Rotation to add
  14602. * @param z Rotation to add
  14603. * @returns the TransformNode.
  14604. */
  14605. addRotation(x: number, y: number, z: number): TransformNode;
  14606. /**
  14607. * @hidden
  14608. */
  14609. protected _getEffectiveParent(): Nullable<Node>;
  14610. /**
  14611. * Computes the world matrix of the node
  14612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14613. * @returns the world matrix
  14614. */
  14615. computeWorldMatrix(force?: boolean): Matrix;
  14616. protected _afterComputeWorldMatrix(): void;
  14617. /**
  14618. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14619. * @param func callback function to add
  14620. *
  14621. * @returns the TransformNode.
  14622. */
  14623. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14624. /**
  14625. * Removes a registered callback function.
  14626. * @param func callback function to remove
  14627. * @returns the TransformNode.
  14628. */
  14629. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14630. /**
  14631. * Gets the position of the current mesh in camera space
  14632. * @param camera defines the camera to use
  14633. * @returns a position
  14634. */
  14635. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14636. /**
  14637. * Returns the distance from the mesh to the active camera
  14638. * @param camera defines the camera to use
  14639. * @returns the distance
  14640. */
  14641. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14642. /**
  14643. * Clone the current transform node
  14644. * @param name Name of the new clone
  14645. * @param newParent New parent for the clone
  14646. * @param doNotCloneChildren Do not clone children hierarchy
  14647. * @returns the new transform node
  14648. */
  14649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14650. /**
  14651. * Serializes the objects information.
  14652. * @param currentSerializationObject defines the object to serialize in
  14653. * @returns the serialized object
  14654. */
  14655. serialize(currentSerializationObject?: any): any;
  14656. /**
  14657. * Returns a new TransformNode object parsed from the source provided.
  14658. * @param parsedTransformNode is the source.
  14659. * @param scene the scne the object belongs to
  14660. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14661. * @returns a new TransformNode object parsed from the source provided.
  14662. */
  14663. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14664. /**
  14665. * Get all child-transformNodes of this node
  14666. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14667. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14668. * @returns an array of TransformNode
  14669. */
  14670. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14671. /**
  14672. * Releases resources associated with this transform node.
  14673. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14674. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14675. */
  14676. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14677. /**
  14678. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14679. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14680. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14681. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14682. * @returns the current mesh
  14683. */
  14684. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14685. private _syncAbsoluteScalingAndRotation;
  14686. }
  14687. }
  14688. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14689. import { Observable } from "babylonjs/Misc/observable";
  14690. import { Nullable } from "babylonjs/types";
  14691. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14694. import { Ray } from "babylonjs/Culling/ray";
  14695. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14696. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14697. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14698. /**
  14699. * Defines the types of pose enabled controllers that are supported
  14700. */
  14701. export enum PoseEnabledControllerType {
  14702. /**
  14703. * HTC Vive
  14704. */
  14705. VIVE = 0,
  14706. /**
  14707. * Oculus Rift
  14708. */
  14709. OCULUS = 1,
  14710. /**
  14711. * Windows mixed reality
  14712. */
  14713. WINDOWS = 2,
  14714. /**
  14715. * Samsung gear VR
  14716. */
  14717. GEAR_VR = 3,
  14718. /**
  14719. * Google Daydream
  14720. */
  14721. DAYDREAM = 4,
  14722. /**
  14723. * Generic
  14724. */
  14725. GENERIC = 5
  14726. }
  14727. /**
  14728. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14729. */
  14730. export interface MutableGamepadButton {
  14731. /**
  14732. * Value of the button/trigger
  14733. */
  14734. value: number;
  14735. /**
  14736. * If the button/trigger is currently touched
  14737. */
  14738. touched: boolean;
  14739. /**
  14740. * If the button/trigger is currently pressed
  14741. */
  14742. pressed: boolean;
  14743. }
  14744. /**
  14745. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14746. * @hidden
  14747. */
  14748. export interface ExtendedGamepadButton extends GamepadButton {
  14749. /**
  14750. * If the button/trigger is currently pressed
  14751. */
  14752. readonly pressed: boolean;
  14753. /**
  14754. * If the button/trigger is currently touched
  14755. */
  14756. readonly touched: boolean;
  14757. /**
  14758. * Value of the button/trigger
  14759. */
  14760. readonly value: number;
  14761. }
  14762. /** @hidden */
  14763. export interface _GamePadFactory {
  14764. /**
  14765. * Returns wether or not the current gamepad can be created for this type of controller.
  14766. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14767. * @returns true if it can be created, otherwise false
  14768. */
  14769. canCreate(gamepadInfo: any): boolean;
  14770. /**
  14771. * Creates a new instance of the Gamepad.
  14772. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14773. * @returns the new gamepad instance
  14774. */
  14775. create(gamepadInfo: any): Gamepad;
  14776. }
  14777. /**
  14778. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14779. */
  14780. export class PoseEnabledControllerHelper {
  14781. /** @hidden */
  14782. static _ControllerFactories: _GamePadFactory[];
  14783. /** @hidden */
  14784. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14785. /**
  14786. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14787. * @param vrGamepad the gamepad to initialized
  14788. * @returns a vr controller of the type the gamepad identified as
  14789. */
  14790. static InitiateController(vrGamepad: any): Gamepad;
  14791. }
  14792. /**
  14793. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14794. */
  14795. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14796. /**
  14797. * If the controller is used in a webXR session
  14798. */
  14799. isXR: boolean;
  14800. private _deviceRoomPosition;
  14801. private _deviceRoomRotationQuaternion;
  14802. /**
  14803. * The device position in babylon space
  14804. */
  14805. devicePosition: Vector3;
  14806. /**
  14807. * The device rotation in babylon space
  14808. */
  14809. deviceRotationQuaternion: Quaternion;
  14810. /**
  14811. * The scale factor of the device in babylon space
  14812. */
  14813. deviceScaleFactor: number;
  14814. /**
  14815. * (Likely devicePosition should be used instead) The device position in its room space
  14816. */
  14817. position: Vector3;
  14818. /**
  14819. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14820. */
  14821. rotationQuaternion: Quaternion;
  14822. /**
  14823. * The type of controller (Eg. Windows mixed reality)
  14824. */
  14825. controllerType: PoseEnabledControllerType;
  14826. protected _calculatedPosition: Vector3;
  14827. private _calculatedRotation;
  14828. /**
  14829. * The raw pose from the device
  14830. */
  14831. rawPose: DevicePose;
  14832. private _trackPosition;
  14833. private _maxRotationDistFromHeadset;
  14834. private _draggedRoomRotation;
  14835. /**
  14836. * @hidden
  14837. */
  14838. _disableTrackPosition(fixedPosition: Vector3): void;
  14839. /**
  14840. * Internal, the mesh attached to the controller
  14841. * @hidden
  14842. */
  14843. _mesh: Nullable<AbstractMesh>;
  14844. private _poseControlledCamera;
  14845. private _leftHandSystemQuaternion;
  14846. /**
  14847. * Internal, matrix used to convert room space to babylon space
  14848. * @hidden
  14849. */
  14850. _deviceToWorld: Matrix;
  14851. /**
  14852. * Node to be used when casting a ray from the controller
  14853. * @hidden
  14854. */
  14855. _pointingPoseNode: Nullable<TransformNode>;
  14856. /**
  14857. * Name of the child mesh that can be used to cast a ray from the controller
  14858. */
  14859. static readonly POINTING_POSE: string;
  14860. /**
  14861. * Creates a new PoseEnabledController from a gamepad
  14862. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14863. */
  14864. constructor(browserGamepad: any);
  14865. private _workingMatrix;
  14866. /**
  14867. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14868. */
  14869. update(): void;
  14870. /**
  14871. * Updates only the pose device and mesh without doing any button event checking
  14872. */
  14873. protected _updatePoseAndMesh(): void;
  14874. /**
  14875. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14876. * @param poseData raw pose fromthe device
  14877. */
  14878. updateFromDevice(poseData: DevicePose): void;
  14879. /**
  14880. * @hidden
  14881. */
  14882. _meshAttachedObservable: Observable<AbstractMesh>;
  14883. /**
  14884. * Attaches a mesh to the controller
  14885. * @param mesh the mesh to be attached
  14886. */
  14887. attachToMesh(mesh: AbstractMesh): void;
  14888. /**
  14889. * Attaches the controllers mesh to a camera
  14890. * @param camera the camera the mesh should be attached to
  14891. */
  14892. attachToPoseControlledCamera(camera: TargetCamera): void;
  14893. /**
  14894. * Disposes of the controller
  14895. */
  14896. dispose(): void;
  14897. /**
  14898. * The mesh that is attached to the controller
  14899. */
  14900. readonly mesh: Nullable<AbstractMesh>;
  14901. /**
  14902. * Gets the ray of the controller in the direction the controller is pointing
  14903. * @param length the length the resulting ray should be
  14904. * @returns a ray in the direction the controller is pointing
  14905. */
  14906. getForwardRay(length?: number): Ray;
  14907. }
  14908. }
  14909. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14910. import { Observable } from "babylonjs/Misc/observable";
  14911. import { Scene } from "babylonjs/scene";
  14912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14913. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14914. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14915. import { Nullable } from "babylonjs/types";
  14916. /**
  14917. * Defines the WebVRController object that represents controllers tracked in 3D space
  14918. */
  14919. export abstract class WebVRController extends PoseEnabledController {
  14920. /**
  14921. * Internal, the default controller model for the controller
  14922. */
  14923. protected _defaultModel: Nullable<AbstractMesh>;
  14924. /**
  14925. * Fired when the trigger state has changed
  14926. */
  14927. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14928. /**
  14929. * Fired when the main button state has changed
  14930. */
  14931. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14932. /**
  14933. * Fired when the secondary button state has changed
  14934. */
  14935. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14936. /**
  14937. * Fired when the pad state has changed
  14938. */
  14939. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14940. /**
  14941. * Fired when controllers stick values have changed
  14942. */
  14943. onPadValuesChangedObservable: Observable<StickValues>;
  14944. /**
  14945. * Array of button availible on the controller
  14946. */
  14947. protected _buttons: Array<MutableGamepadButton>;
  14948. private _onButtonStateChange;
  14949. /**
  14950. * Fired when a controller button's state has changed
  14951. * @param callback the callback containing the button that was modified
  14952. */
  14953. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14954. /**
  14955. * X and Y axis corresponding to the controllers joystick
  14956. */
  14957. pad: StickValues;
  14958. /**
  14959. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14960. */
  14961. hand: string;
  14962. /**
  14963. * The default controller model for the controller
  14964. */
  14965. readonly defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Creates a new WebVRController from a gamepad
  14968. * @param vrGamepad the gamepad that the WebVRController should be created from
  14969. */
  14970. constructor(vrGamepad: any);
  14971. /**
  14972. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14973. */
  14974. update(): void;
  14975. /**
  14976. * Function to be called when a button is modified
  14977. */
  14978. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14979. /**
  14980. * Loads a mesh and attaches it to the controller
  14981. * @param scene the scene the mesh should be added to
  14982. * @param meshLoaded callback for when the mesh has been loaded
  14983. */
  14984. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14985. private _setButtonValue;
  14986. private _changes;
  14987. private _checkChanges;
  14988. /**
  14989. * Disposes of th webVRCOntroller
  14990. */
  14991. dispose(): void;
  14992. }
  14993. }
  14994. declare module "babylonjs/Lights/hemisphericLight" {
  14995. import { Nullable } from "babylonjs/types";
  14996. import { Scene } from "babylonjs/scene";
  14997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14998. import { Color3 } from "babylonjs/Maths/math.color";
  14999. import { Effect } from "babylonjs/Materials/effect";
  15000. import { Light } from "babylonjs/Lights/light";
  15001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15002. /**
  15003. * The HemisphericLight simulates the ambient environment light,
  15004. * so the passed direction is the light reflection direction, not the incoming direction.
  15005. */
  15006. export class HemisphericLight extends Light {
  15007. /**
  15008. * The groundColor is the light in the opposite direction to the one specified during creation.
  15009. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15010. */
  15011. groundColor: Color3;
  15012. /**
  15013. * The light reflection direction, not the incoming direction.
  15014. */
  15015. direction: Vector3;
  15016. /**
  15017. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15018. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15019. * The HemisphericLight can't cast shadows.
  15020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15021. * @param name The friendly name of the light
  15022. * @param direction The direction of the light reflection
  15023. * @param scene The scene the light belongs to
  15024. */
  15025. constructor(name: string, direction: Vector3, scene: Scene);
  15026. protected _buildUniformLayout(): void;
  15027. /**
  15028. * Returns the string "HemisphericLight".
  15029. * @return The class name
  15030. */
  15031. getClassName(): string;
  15032. /**
  15033. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15034. * Returns the updated direction.
  15035. * @param target The target the direction should point to
  15036. * @return The computed direction
  15037. */
  15038. setDirectionToTarget(target: Vector3): Vector3;
  15039. /**
  15040. * Returns the shadow generator associated to the light.
  15041. * @returns Always null for hemispheric lights because it does not support shadows.
  15042. */
  15043. getShadowGenerator(): Nullable<IShadowGenerator>;
  15044. /**
  15045. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15046. * @param effect The effect to update
  15047. * @param lightIndex The index of the light in the effect to update
  15048. * @returns The hemispheric light
  15049. */
  15050. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15051. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15052. /**
  15053. * Computes the world matrix of the node
  15054. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15055. * @param useWasUpdatedFlag defines a reserved property
  15056. * @returns the world matrix
  15057. */
  15058. computeWorldMatrix(): Matrix;
  15059. /**
  15060. * Returns the integer 3.
  15061. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15062. */
  15063. getTypeID(): number;
  15064. /**
  15065. * Prepares the list of defines specific to the light type.
  15066. * @param defines the list of defines
  15067. * @param lightIndex defines the index of the light for the effect
  15068. */
  15069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15070. }
  15071. }
  15072. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15073. /** @hidden */
  15074. export var vrMultiviewToSingleviewPixelShader: {
  15075. name: string;
  15076. shader: string;
  15077. };
  15078. }
  15079. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15080. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15081. import { Scene } from "babylonjs/scene";
  15082. /**
  15083. * Renders to multiple views with a single draw call
  15084. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15085. */
  15086. export class MultiviewRenderTarget extends RenderTargetTexture {
  15087. /**
  15088. * Creates a multiview render target
  15089. * @param scene scene used with the render target
  15090. * @param size the size of the render target (used for each view)
  15091. */
  15092. constructor(scene: Scene, size?: number | {
  15093. width: number;
  15094. height: number;
  15095. } | {
  15096. ratio: number;
  15097. });
  15098. /**
  15099. * @hidden
  15100. * @param faceIndex the face index, if its a cube texture
  15101. */
  15102. _bindFrameBuffer(faceIndex?: number): void;
  15103. /**
  15104. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15105. * @returns the view count
  15106. */
  15107. getViewCount(): number;
  15108. }
  15109. }
  15110. declare module "babylonjs/Maths/math.frustum" {
  15111. import { Matrix } from "babylonjs/Maths/math.vector";
  15112. import { DeepImmutable } from "babylonjs/types";
  15113. import { Plane } from "babylonjs/Maths/math.plane";
  15114. /**
  15115. * Represents a camera frustum
  15116. */
  15117. export class Frustum {
  15118. /**
  15119. * Gets the planes representing the frustum
  15120. * @param transform matrix to be applied to the returned planes
  15121. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15122. */
  15123. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15124. /**
  15125. * Gets the near frustum plane transformed by the transform matrix
  15126. * @param transform transformation matrix to be applied to the resulting frustum plane
  15127. * @param frustumPlane the resuling frustum plane
  15128. */
  15129. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15130. /**
  15131. * Gets the far frustum plane transformed by the transform matrix
  15132. * @param transform transformation matrix to be applied to the resulting frustum plane
  15133. * @param frustumPlane the resuling frustum plane
  15134. */
  15135. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15136. /**
  15137. * Gets the left frustum plane transformed by the transform matrix
  15138. * @param transform transformation matrix to be applied to the resulting frustum plane
  15139. * @param frustumPlane the resuling frustum plane
  15140. */
  15141. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15142. /**
  15143. * Gets the right frustum plane transformed by the transform matrix
  15144. * @param transform transformation matrix to be applied to the resulting frustum plane
  15145. * @param frustumPlane the resuling frustum plane
  15146. */
  15147. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15148. /**
  15149. * Gets the top frustum plane transformed by the transform matrix
  15150. * @param transform transformation matrix to be applied to the resulting frustum plane
  15151. * @param frustumPlane the resuling frustum plane
  15152. */
  15153. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15154. /**
  15155. * Gets the bottom frustum plane transformed by the transform matrix
  15156. * @param transform transformation matrix to be applied to the resulting frustum plane
  15157. * @param frustumPlane the resuling frustum plane
  15158. */
  15159. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15160. /**
  15161. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15162. * @param transform transformation matrix to be applied to the resulting frustum planes
  15163. * @param frustumPlanes the resuling frustum planes
  15164. */
  15165. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15166. }
  15167. }
  15168. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15169. import { Camera } from "babylonjs/Cameras/camera";
  15170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15171. import { Nullable } from "babylonjs/types";
  15172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15173. import { Matrix } from "babylonjs/Maths/math.vector";
  15174. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /**
  15178. * Creates a new multiview render target
  15179. * @param width defines the width of the texture
  15180. * @param height defines the height of the texture
  15181. * @returns the created multiview texture
  15182. */
  15183. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15184. /**
  15185. * Binds a multiview framebuffer to be drawn to
  15186. * @param multiviewTexture texture to bind
  15187. */
  15188. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15189. }
  15190. }
  15191. module "babylonjs/Cameras/camera" {
  15192. interface Camera {
  15193. /**
  15194. * @hidden
  15195. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15196. */
  15197. _useMultiviewToSingleView: boolean;
  15198. /**
  15199. * @hidden
  15200. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15201. */
  15202. _multiviewTexture: Nullable<RenderTargetTexture>;
  15203. /**
  15204. * @hidden
  15205. * ensures the multiview texture of the camera exists and has the specified width/height
  15206. * @param width height to set on the multiview texture
  15207. * @param height width to set on the multiview texture
  15208. */
  15209. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15210. }
  15211. }
  15212. module "babylonjs/scene" {
  15213. interface Scene {
  15214. /** @hidden */
  15215. _transformMatrixR: Matrix;
  15216. /** @hidden */
  15217. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15218. /** @hidden */
  15219. _createMultiviewUbo(): void;
  15220. /** @hidden */
  15221. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15222. /** @hidden */
  15223. _renderMultiviewToSingleView(camera: Camera): void;
  15224. }
  15225. }
  15226. }
  15227. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15228. import { Camera } from "babylonjs/Cameras/camera";
  15229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15230. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15231. import "babylonjs/Engines/Extensions/engine.multiview";
  15232. /**
  15233. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15234. * This will not be used for webXR as it supports displaying texture arrays directly
  15235. */
  15236. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15237. /**
  15238. * Initializes a VRMultiviewToSingleview
  15239. * @param name name of the post process
  15240. * @param camera camera to be applied to
  15241. * @param scaleFactor scaling factor to the size of the output texture
  15242. */
  15243. constructor(name: string, camera: Camera, scaleFactor: number);
  15244. }
  15245. }
  15246. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15247. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15248. import { Nullable } from "babylonjs/types";
  15249. import { Size } from "babylonjs/Maths/math.size";
  15250. import { Observable } from "babylonjs/Misc/observable";
  15251. /**
  15252. * Interface used to define additional presentation attributes
  15253. */
  15254. export interface IVRPresentationAttributes {
  15255. /**
  15256. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15257. */
  15258. highRefreshRate: boolean;
  15259. /**
  15260. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15261. */
  15262. foveationLevel: number;
  15263. }
  15264. module "babylonjs/Engines/engine" {
  15265. interface Engine {
  15266. /** @hidden */
  15267. _vrDisplay: any;
  15268. /** @hidden */
  15269. _vrSupported: boolean;
  15270. /** @hidden */
  15271. _oldSize: Size;
  15272. /** @hidden */
  15273. _oldHardwareScaleFactor: number;
  15274. /** @hidden */
  15275. _vrExclusivePointerMode: boolean;
  15276. /** @hidden */
  15277. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15278. /** @hidden */
  15279. _onVRDisplayPointerRestricted: () => void;
  15280. /** @hidden */
  15281. _onVRDisplayPointerUnrestricted: () => void;
  15282. /** @hidden */
  15283. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15284. /** @hidden */
  15285. _onVrDisplayDisconnect: Nullable<() => void>;
  15286. /** @hidden */
  15287. _onVrDisplayPresentChange: Nullable<() => void>;
  15288. /**
  15289. * Observable signaled when VR display mode changes
  15290. */
  15291. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15292. /**
  15293. * Observable signaled when VR request present is complete
  15294. */
  15295. onVRRequestPresentComplete: Observable<boolean>;
  15296. /**
  15297. * Observable signaled when VR request present starts
  15298. */
  15299. onVRRequestPresentStart: Observable<Engine>;
  15300. /**
  15301. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15302. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15303. */
  15304. isInVRExclusivePointerMode: boolean;
  15305. /**
  15306. * Gets a boolean indicating if a webVR device was detected
  15307. * @returns true if a webVR device was detected
  15308. */
  15309. isVRDevicePresent(): boolean;
  15310. /**
  15311. * Gets the current webVR device
  15312. * @returns the current webVR device (or null)
  15313. */
  15314. getVRDevice(): any;
  15315. /**
  15316. * Initializes a webVR display and starts listening to display change events
  15317. * The onVRDisplayChangedObservable will be notified upon these changes
  15318. * @returns A promise containing a VRDisplay and if vr is supported
  15319. */
  15320. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15321. /** @hidden */
  15322. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15323. /**
  15324. * Gets or sets the presentation attributes used to configure VR rendering
  15325. */
  15326. vrPresentationAttributes?: IVRPresentationAttributes;
  15327. /**
  15328. * Call this function to switch to webVR mode
  15329. * Will do nothing if webVR is not supported or if there is no webVR device
  15330. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15331. */
  15332. enableVR(): void;
  15333. /** @hidden */
  15334. _onVRFullScreenTriggered(): void;
  15335. }
  15336. }
  15337. }
  15338. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15339. import { Nullable } from "babylonjs/types";
  15340. import { Observable } from "babylonjs/Misc/observable";
  15341. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15342. import { Scene } from "babylonjs/scene";
  15343. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15344. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15345. import { Node } from "babylonjs/node";
  15346. import { Ray } from "babylonjs/Culling/ray";
  15347. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15348. import "babylonjs/Engines/Extensions/engine.webVR";
  15349. /**
  15350. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15351. * IMPORTANT!! The data is right-hand data.
  15352. * @export
  15353. * @interface DevicePose
  15354. */
  15355. export interface DevicePose {
  15356. /**
  15357. * The position of the device, values in array are [x,y,z].
  15358. */
  15359. readonly position: Nullable<Float32Array>;
  15360. /**
  15361. * The linearVelocity of the device, values in array are [x,y,z].
  15362. */
  15363. readonly linearVelocity: Nullable<Float32Array>;
  15364. /**
  15365. * The linearAcceleration of the device, values in array are [x,y,z].
  15366. */
  15367. readonly linearAcceleration: Nullable<Float32Array>;
  15368. /**
  15369. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15370. */
  15371. readonly orientation: Nullable<Float32Array>;
  15372. /**
  15373. * The angularVelocity of the device, values in array are [x,y,z].
  15374. */
  15375. readonly angularVelocity: Nullable<Float32Array>;
  15376. /**
  15377. * The angularAcceleration of the device, values in array are [x,y,z].
  15378. */
  15379. readonly angularAcceleration: Nullable<Float32Array>;
  15380. }
  15381. /**
  15382. * Interface representing a pose controlled object in Babylon.
  15383. * A pose controlled object has both regular pose values as well as pose values
  15384. * from an external device such as a VR head mounted display
  15385. */
  15386. export interface PoseControlled {
  15387. /**
  15388. * The position of the object in babylon space.
  15389. */
  15390. position: Vector3;
  15391. /**
  15392. * The rotation quaternion of the object in babylon space.
  15393. */
  15394. rotationQuaternion: Quaternion;
  15395. /**
  15396. * The position of the device in babylon space.
  15397. */
  15398. devicePosition?: Vector3;
  15399. /**
  15400. * The rotation quaternion of the device in babylon space.
  15401. */
  15402. deviceRotationQuaternion: Quaternion;
  15403. /**
  15404. * The raw pose coming from the device.
  15405. */
  15406. rawPose: Nullable<DevicePose>;
  15407. /**
  15408. * The scale of the device to be used when translating from device space to babylon space.
  15409. */
  15410. deviceScaleFactor: number;
  15411. /**
  15412. * Updates the poseControlled values based on the input device pose.
  15413. * @param poseData the pose data to update the object with
  15414. */
  15415. updateFromDevice(poseData: DevicePose): void;
  15416. }
  15417. /**
  15418. * Set of options to customize the webVRCamera
  15419. */
  15420. export interface WebVROptions {
  15421. /**
  15422. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15423. */
  15424. trackPosition?: boolean;
  15425. /**
  15426. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15427. */
  15428. positionScale?: number;
  15429. /**
  15430. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15431. */
  15432. displayName?: string;
  15433. /**
  15434. * Should the native controller meshes be initialized. (default: true)
  15435. */
  15436. controllerMeshes?: boolean;
  15437. /**
  15438. * Creating a default HemiLight only on controllers. (default: true)
  15439. */
  15440. defaultLightingOnControllers?: boolean;
  15441. /**
  15442. * If you don't want to use the default VR button of the helper. (default: false)
  15443. */
  15444. useCustomVRButton?: boolean;
  15445. /**
  15446. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15447. */
  15448. customVRButton?: HTMLButtonElement;
  15449. /**
  15450. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15451. */
  15452. rayLength?: number;
  15453. /**
  15454. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15455. */
  15456. defaultHeight?: number;
  15457. /**
  15458. * If multiview should be used if availible (default: false)
  15459. */
  15460. useMultiview?: boolean;
  15461. }
  15462. /**
  15463. * This represents a WebVR camera.
  15464. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15465. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15466. */
  15467. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15468. private webVROptions;
  15469. /**
  15470. * @hidden
  15471. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15472. */
  15473. _vrDevice: any;
  15474. /**
  15475. * The rawPose of the vrDevice.
  15476. */
  15477. rawPose: Nullable<DevicePose>;
  15478. private _onVREnabled;
  15479. private _specsVersion;
  15480. private _attached;
  15481. private _frameData;
  15482. protected _descendants: Array<Node>;
  15483. private _deviceRoomPosition;
  15484. /** @hidden */
  15485. _deviceRoomRotationQuaternion: Quaternion;
  15486. private _standingMatrix;
  15487. /**
  15488. * Represents device position in babylon space.
  15489. */
  15490. devicePosition: Vector3;
  15491. /**
  15492. * Represents device rotation in babylon space.
  15493. */
  15494. deviceRotationQuaternion: Quaternion;
  15495. /**
  15496. * The scale of the device to be used when translating from device space to babylon space.
  15497. */
  15498. deviceScaleFactor: number;
  15499. private _deviceToWorld;
  15500. private _worldToDevice;
  15501. /**
  15502. * References to the webVR controllers for the vrDevice.
  15503. */
  15504. controllers: Array<WebVRController>;
  15505. /**
  15506. * Emits an event when a controller is attached.
  15507. */
  15508. onControllersAttachedObservable: Observable<WebVRController[]>;
  15509. /**
  15510. * Emits an event when a controller's mesh has been loaded;
  15511. */
  15512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15513. /**
  15514. * Emits an event when the HMD's pose has been updated.
  15515. */
  15516. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15517. private _poseSet;
  15518. /**
  15519. * If the rig cameras be used as parent instead of this camera.
  15520. */
  15521. rigParenting: boolean;
  15522. private _lightOnControllers;
  15523. private _defaultHeight?;
  15524. /**
  15525. * Instantiates a WebVRFreeCamera.
  15526. * @param name The name of the WebVRFreeCamera
  15527. * @param position The starting anchor position for the camera
  15528. * @param scene The scene the camera belongs to
  15529. * @param webVROptions a set of customizable options for the webVRCamera
  15530. */
  15531. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15532. /**
  15533. * Gets the device distance from the ground in meters.
  15534. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15535. */
  15536. deviceDistanceToRoomGround(): number;
  15537. /**
  15538. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15539. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15540. */
  15541. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15542. /**
  15543. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15544. * @returns A promise with a boolean set to if the standing matrix is supported.
  15545. */
  15546. useStandingMatrixAsync(): Promise<boolean>;
  15547. /**
  15548. * Disposes the camera
  15549. */
  15550. dispose(): void;
  15551. /**
  15552. * Gets a vrController by name.
  15553. * @param name The name of the controller to retreive
  15554. * @returns the controller matching the name specified or null if not found
  15555. */
  15556. getControllerByName(name: string): Nullable<WebVRController>;
  15557. private _leftController;
  15558. /**
  15559. * The controller corresponding to the users left hand.
  15560. */
  15561. readonly leftController: Nullable<WebVRController>;
  15562. private _rightController;
  15563. /**
  15564. * The controller corresponding to the users right hand.
  15565. */
  15566. readonly rightController: Nullable<WebVRController>;
  15567. /**
  15568. * Casts a ray forward from the vrCamera's gaze.
  15569. * @param length Length of the ray (default: 100)
  15570. * @returns the ray corresponding to the gaze
  15571. */
  15572. getForwardRay(length?: number): Ray;
  15573. /**
  15574. * @hidden
  15575. * Updates the camera based on device's frame data
  15576. */
  15577. _checkInputs(): void;
  15578. /**
  15579. * Updates the poseControlled values based on the input device pose.
  15580. * @param poseData Pose coming from the device
  15581. */
  15582. updateFromDevice(poseData: DevicePose): void;
  15583. private _htmlElementAttached;
  15584. private _detachIfAttached;
  15585. /**
  15586. * WebVR's attach control will start broadcasting frames to the device.
  15587. * Note that in certain browsers (chrome for example) this function must be called
  15588. * within a user-interaction callback. Example:
  15589. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15590. *
  15591. * @param element html element to attach the vrDevice to
  15592. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15593. */
  15594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15595. /**
  15596. * Detaches the camera from the html element and disables VR
  15597. *
  15598. * @param element html element to detach from
  15599. */
  15600. detachControl(element: HTMLElement): void;
  15601. /**
  15602. * @returns the name of this class
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Calls resetPose on the vrDisplay
  15607. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15608. */
  15609. resetToCurrentRotation(): void;
  15610. /**
  15611. * @hidden
  15612. * Updates the rig cameras (left and right eye)
  15613. */
  15614. _updateRigCameras(): void;
  15615. private _workingVector;
  15616. private _oneVector;
  15617. private _workingMatrix;
  15618. private updateCacheCalled;
  15619. private _correctPositionIfNotTrackPosition;
  15620. /**
  15621. * @hidden
  15622. * Updates the cached values of the camera
  15623. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15624. */
  15625. _updateCache(ignoreParentClass?: boolean): void;
  15626. /**
  15627. * @hidden
  15628. * Get current device position in babylon world
  15629. */
  15630. _computeDevicePosition(): void;
  15631. /**
  15632. * Updates the current device position and rotation in the babylon world
  15633. */
  15634. update(): void;
  15635. /**
  15636. * @hidden
  15637. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15638. * @returns an identity matrix
  15639. */
  15640. _getViewMatrix(): Matrix;
  15641. private _tmpMatrix;
  15642. /**
  15643. * This function is called by the two RIG cameras.
  15644. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15645. * @hidden
  15646. */
  15647. _getWebVRViewMatrix(): Matrix;
  15648. /** @hidden */
  15649. _getWebVRProjectionMatrix(): Matrix;
  15650. private _onGamepadConnectedObserver;
  15651. private _onGamepadDisconnectedObserver;
  15652. private _updateCacheWhenTrackingDisabledObserver;
  15653. /**
  15654. * Initializes the controllers and their meshes
  15655. */
  15656. initControllers(): void;
  15657. }
  15658. }
  15659. declare module "babylonjs/PostProcesses/postProcess" {
  15660. import { Nullable } from "babylonjs/types";
  15661. import { SmartArray } from "babylonjs/Misc/smartArray";
  15662. import { Observable } from "babylonjs/Misc/observable";
  15663. import { Vector2 } from "babylonjs/Maths/math.vector";
  15664. import { Camera } from "babylonjs/Cameras/camera";
  15665. import { Effect } from "babylonjs/Materials/effect";
  15666. import "babylonjs/Shaders/postprocess.vertex";
  15667. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15668. import { Engine } from "babylonjs/Engines/engine";
  15669. import { Color4 } from "babylonjs/Maths/math.color";
  15670. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15672. /**
  15673. * Size options for a post process
  15674. */
  15675. export type PostProcessOptions = {
  15676. width: number;
  15677. height: number;
  15678. };
  15679. /**
  15680. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15681. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15682. */
  15683. export class PostProcess {
  15684. /** Name of the PostProcess. */
  15685. name: string;
  15686. /**
  15687. * Gets or sets the unique id of the post process
  15688. */
  15689. uniqueId: number;
  15690. /**
  15691. * Width of the texture to apply the post process on
  15692. */
  15693. width: number;
  15694. /**
  15695. * Height of the texture to apply the post process on
  15696. */
  15697. height: number;
  15698. /**
  15699. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15700. * @hidden
  15701. */
  15702. _outputTexture: Nullable<InternalTexture>;
  15703. /**
  15704. * Sampling mode used by the shader
  15705. * See https://doc.babylonjs.com/classes/3.1/texture
  15706. */
  15707. renderTargetSamplingMode: number;
  15708. /**
  15709. * Clear color to use when screen clearing
  15710. */
  15711. clearColor: Color4;
  15712. /**
  15713. * If the buffer needs to be cleared before applying the post process. (default: true)
  15714. * Should be set to false if shader will overwrite all previous pixels.
  15715. */
  15716. autoClear: boolean;
  15717. /**
  15718. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15719. */
  15720. alphaMode: number;
  15721. /**
  15722. * Sets the setAlphaBlendConstants of the babylon engine
  15723. */
  15724. alphaConstants: Color4;
  15725. /**
  15726. * Animations to be used for the post processing
  15727. */
  15728. animations: import("babylonjs/Animations/animation").Animation[];
  15729. /**
  15730. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15731. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15732. */
  15733. enablePixelPerfectMode: boolean;
  15734. /**
  15735. * Force the postprocess to be applied without taking in account viewport
  15736. */
  15737. forceFullscreenViewport: boolean;
  15738. /**
  15739. * List of inspectable custom properties (used by the Inspector)
  15740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15741. */
  15742. inspectableCustomProperties: IInspectable[];
  15743. /**
  15744. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15745. *
  15746. * | Value | Type | Description |
  15747. * | ----- | ----------------------------------- | ----------- |
  15748. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15749. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15750. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15751. *
  15752. */
  15753. scaleMode: number;
  15754. /**
  15755. * Force textures to be a power of two (default: false)
  15756. */
  15757. alwaysForcePOT: boolean;
  15758. private _samples;
  15759. /**
  15760. * Number of sample textures (default: 1)
  15761. */
  15762. samples: number;
  15763. /**
  15764. * Modify the scale of the post process to be the same as the viewport (default: false)
  15765. */
  15766. adaptScaleToCurrentViewport: boolean;
  15767. private _camera;
  15768. private _scene;
  15769. private _engine;
  15770. private _options;
  15771. private _reusable;
  15772. private _textureType;
  15773. /**
  15774. * Smart array of input and output textures for the post process.
  15775. * @hidden
  15776. */
  15777. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15778. /**
  15779. * The index in _textures that corresponds to the output texture.
  15780. * @hidden
  15781. */
  15782. _currentRenderTextureInd: number;
  15783. private _effect;
  15784. private _samplers;
  15785. private _fragmentUrl;
  15786. private _vertexUrl;
  15787. private _parameters;
  15788. private _scaleRatio;
  15789. protected _indexParameters: any;
  15790. private _shareOutputWithPostProcess;
  15791. private _texelSize;
  15792. private _forcedOutputTexture;
  15793. /**
  15794. * Returns the fragment url or shader name used in the post process.
  15795. * @returns the fragment url or name in the shader store.
  15796. */
  15797. getEffectName(): string;
  15798. /**
  15799. * An event triggered when the postprocess is activated.
  15800. */
  15801. onActivateObservable: Observable<Camera>;
  15802. private _onActivateObserver;
  15803. /**
  15804. * A function that is added to the onActivateObservable
  15805. */
  15806. onActivate: Nullable<(camera: Camera) => void>;
  15807. /**
  15808. * An event triggered when the postprocess changes its size.
  15809. */
  15810. onSizeChangedObservable: Observable<PostProcess>;
  15811. private _onSizeChangedObserver;
  15812. /**
  15813. * A function that is added to the onSizeChangedObservable
  15814. */
  15815. onSizeChanged: (postProcess: PostProcess) => void;
  15816. /**
  15817. * An event triggered when the postprocess applies its effect.
  15818. */
  15819. onApplyObservable: Observable<Effect>;
  15820. private _onApplyObserver;
  15821. /**
  15822. * A function that is added to the onApplyObservable
  15823. */
  15824. onApply: (effect: Effect) => void;
  15825. /**
  15826. * An event triggered before rendering the postprocess
  15827. */
  15828. onBeforeRenderObservable: Observable<Effect>;
  15829. private _onBeforeRenderObserver;
  15830. /**
  15831. * A function that is added to the onBeforeRenderObservable
  15832. */
  15833. onBeforeRender: (effect: Effect) => void;
  15834. /**
  15835. * An event triggered after rendering the postprocess
  15836. */
  15837. onAfterRenderObservable: Observable<Effect>;
  15838. private _onAfterRenderObserver;
  15839. /**
  15840. * A function that is added to the onAfterRenderObservable
  15841. */
  15842. onAfterRender: (efect: Effect) => void;
  15843. /**
  15844. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15845. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15846. */
  15847. inputTexture: InternalTexture;
  15848. /**
  15849. * Gets the camera which post process is applied to.
  15850. * @returns The camera the post process is applied to.
  15851. */
  15852. getCamera(): Camera;
  15853. /**
  15854. * Gets the texel size of the postprocess.
  15855. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15856. */
  15857. readonly texelSize: Vector2;
  15858. /**
  15859. * Creates a new instance PostProcess
  15860. * @param name The name of the PostProcess.
  15861. * @param fragmentUrl The url of the fragment shader to be used.
  15862. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15863. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15864. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15865. * @param camera The camera to apply the render pass to.
  15866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15867. * @param engine The engine which the post process will be applied. (default: current engine)
  15868. * @param reusable If the post process can be reused on the same frame. (default: false)
  15869. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15870. * @param textureType Type of textures used when performing the post process. (default: 0)
  15871. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15872. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15873. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15874. */
  15875. constructor(
  15876. /** Name of the PostProcess. */
  15877. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15878. /**
  15879. * Gets a string idenfifying the name of the class
  15880. * @returns "PostProcess" string
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Gets the engine which this post process belongs to.
  15885. * @returns The engine the post process was enabled with.
  15886. */
  15887. getEngine(): Engine;
  15888. /**
  15889. * The effect that is created when initializing the post process.
  15890. * @returns The created effect corresponding the the postprocess.
  15891. */
  15892. getEffect(): Effect;
  15893. /**
  15894. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15895. * @param postProcess The post process to share the output with.
  15896. * @returns This post process.
  15897. */
  15898. shareOutputWith(postProcess: PostProcess): PostProcess;
  15899. /**
  15900. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15901. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15902. */
  15903. useOwnOutput(): void;
  15904. /**
  15905. * Updates the effect with the current post process compile time values and recompiles the shader.
  15906. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15907. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15908. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15909. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15910. * @param onCompiled Called when the shader has been compiled.
  15911. * @param onError Called if there is an error when compiling a shader.
  15912. */
  15913. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15914. /**
  15915. * The post process is reusable if it can be used multiple times within one frame.
  15916. * @returns If the post process is reusable
  15917. */
  15918. isReusable(): boolean;
  15919. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15920. markTextureDirty(): void;
  15921. /**
  15922. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15923. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15924. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15925. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15926. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15927. * @returns The target texture that was bound to be written to.
  15928. */
  15929. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15930. /**
  15931. * If the post process is supported.
  15932. */
  15933. readonly isSupported: boolean;
  15934. /**
  15935. * The aspect ratio of the output texture.
  15936. */
  15937. readonly aspectRatio: number;
  15938. /**
  15939. * Get a value indicating if the post-process is ready to be used
  15940. * @returns true if the post-process is ready (shader is compiled)
  15941. */
  15942. isReady(): boolean;
  15943. /**
  15944. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15945. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15946. */
  15947. apply(): Nullable<Effect>;
  15948. private _disposeTextures;
  15949. /**
  15950. * Disposes the post process.
  15951. * @param camera The camera to dispose the post process on.
  15952. */
  15953. dispose(camera?: Camera): void;
  15954. }
  15955. }
  15956. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15957. /** @hidden */
  15958. export var kernelBlurVaryingDeclaration: {
  15959. name: string;
  15960. shader: string;
  15961. };
  15962. }
  15963. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15964. /** @hidden */
  15965. export var kernelBlurFragment: {
  15966. name: string;
  15967. shader: string;
  15968. };
  15969. }
  15970. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15971. /** @hidden */
  15972. export var kernelBlurFragment2: {
  15973. name: string;
  15974. shader: string;
  15975. };
  15976. }
  15977. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15978. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15979. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15980. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15981. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15982. /** @hidden */
  15983. export var kernelBlurPixelShader: {
  15984. name: string;
  15985. shader: string;
  15986. };
  15987. }
  15988. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15989. /** @hidden */
  15990. export var kernelBlurVertex: {
  15991. name: string;
  15992. shader: string;
  15993. };
  15994. }
  15995. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15996. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15997. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15998. /** @hidden */
  15999. export var kernelBlurVertexShader: {
  16000. name: string;
  16001. shader: string;
  16002. };
  16003. }
  16004. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16005. import { Vector2 } from "babylonjs/Maths/math.vector";
  16006. import { Nullable } from "babylonjs/types";
  16007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16008. import { Camera } from "babylonjs/Cameras/camera";
  16009. import { Effect } from "babylonjs/Materials/effect";
  16010. import { Engine } from "babylonjs/Engines/engine";
  16011. import "babylonjs/Shaders/kernelBlur.fragment";
  16012. import "babylonjs/Shaders/kernelBlur.vertex";
  16013. /**
  16014. * The Blur Post Process which blurs an image based on a kernel and direction.
  16015. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16016. */
  16017. export class BlurPostProcess extends PostProcess {
  16018. /** The direction in which to blur the image. */
  16019. direction: Vector2;
  16020. private blockCompilation;
  16021. protected _kernel: number;
  16022. protected _idealKernel: number;
  16023. protected _packedFloat: boolean;
  16024. private _staticDefines;
  16025. /**
  16026. * Sets the length in pixels of the blur sample region
  16027. */
  16028. /**
  16029. * Gets the length in pixels of the blur sample region
  16030. */
  16031. kernel: number;
  16032. /**
  16033. * Sets wether or not the blur needs to unpack/repack floats
  16034. */
  16035. /**
  16036. * Gets wether or not the blur is unpacking/repacking floats
  16037. */
  16038. packedFloat: boolean;
  16039. /**
  16040. * Creates a new instance BlurPostProcess
  16041. * @param name The name of the effect.
  16042. * @param direction The direction in which to blur the image.
  16043. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  16044. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16045. * @param camera The camera to apply the render pass to.
  16046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16047. * @param engine The engine which the post process will be applied. (default: current engine)
  16048. * @param reusable If the post process can be reused on the same frame. (default: false)
  16049. * @param textureType Type of textures used when performing the post process. (default: 0)
  16050. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  16051. */
  16052. constructor(name: string,
  16053. /** The direction in which to blur the image. */
  16054. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16055. /**
  16056. * Updates the effect with the current post process compile time values and recompiles the shader.
  16057. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16058. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16059. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16060. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  16061. * @param onCompiled Called when the shader has been compiled.
  16062. * @param onError Called if there is an error when compiling a shader.
  16063. */
  16064. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16065. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16066. /**
  16067. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16068. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16069. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16070. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16071. * The gaps between physical kernels are compensated for in the weighting of the samples
  16072. * @param idealKernel Ideal blur kernel.
  16073. * @return Nearest best kernel.
  16074. */
  16075. protected _nearestBestKernel(idealKernel: number): number;
  16076. /**
  16077. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16078. * @param x The point on the Gaussian distribution to sample.
  16079. * @return the value of the Gaussian function at x.
  16080. */
  16081. protected _gaussianWeight(x: number): number;
  16082. /**
  16083. * Generates a string that can be used as a floating point number in GLSL.
  16084. * @param x Value to print.
  16085. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16086. * @return GLSL float string.
  16087. */
  16088. protected _glslFloat(x: number, decimalFigures?: number): string;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16092. import { Scene } from "babylonjs/scene";
  16093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16094. import { Plane } from "babylonjs/Maths/math.plane";
  16095. /**
  16096. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16097. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16098. * You can then easily use it as a reflectionTexture on a flat surface.
  16099. * In case the surface is not a plane, please consider relying on reflection probes.
  16100. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16101. */
  16102. export class MirrorTexture extends RenderTargetTexture {
  16103. private scene;
  16104. /**
  16105. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16106. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  16107. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16108. */
  16109. mirrorPlane: Plane;
  16110. /**
  16111. * Define the blur ratio used to blur the reflection if needed.
  16112. */
  16113. blurRatio: number;
  16114. /**
  16115. * Define the adaptive blur kernel used to blur the reflection if needed.
  16116. * This will autocompute the closest best match for the `blurKernel`
  16117. */
  16118. adaptiveBlurKernel: number;
  16119. /**
  16120. * Define the blur kernel used to blur the reflection if needed.
  16121. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16122. */
  16123. blurKernel: number;
  16124. /**
  16125. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16126. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16127. */
  16128. blurKernelX: number;
  16129. /**
  16130. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16131. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16132. */
  16133. blurKernelY: number;
  16134. private _autoComputeBlurKernel;
  16135. protected _onRatioRescale(): void;
  16136. private _updateGammaSpace;
  16137. private _imageProcessingConfigChangeObserver;
  16138. private _transformMatrix;
  16139. private _mirrorMatrix;
  16140. private _savedViewMatrix;
  16141. private _blurX;
  16142. private _blurY;
  16143. private _adaptiveBlurKernel;
  16144. private _blurKernelX;
  16145. private _blurKernelY;
  16146. private _blurRatio;
  16147. /**
  16148. * Instantiates a Mirror Texture.
  16149. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16150. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16151. * You can then easily use it as a reflectionTexture on a flat surface.
  16152. * In case the surface is not a plane, please consider relying on reflection probes.
  16153. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16154. * @param name
  16155. * @param size
  16156. * @param scene
  16157. * @param generateMipMaps
  16158. * @param type
  16159. * @param samplingMode
  16160. * @param generateDepthBuffer
  16161. */
  16162. constructor(name: string, size: number | {
  16163. width: number;
  16164. height: number;
  16165. } | {
  16166. ratio: number;
  16167. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16168. private _preparePostProcesses;
  16169. /**
  16170. * Clone the mirror texture.
  16171. * @returns the cloned texture
  16172. */
  16173. clone(): MirrorTexture;
  16174. /**
  16175. * Serialize the texture to a JSON representation you could use in Parse later on
  16176. * @returns the serialized JSON representation
  16177. */
  16178. serialize(): any;
  16179. /**
  16180. * Dispose the texture and release its associated resources.
  16181. */
  16182. dispose(): void;
  16183. }
  16184. }
  16185. declare module "babylonjs/Materials/Textures/texture" {
  16186. import { Observable } from "babylonjs/Misc/observable";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Matrix } from "babylonjs/Maths/math.vector";
  16189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16190. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16191. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16192. import { Scene } from "babylonjs/scene";
  16193. /**
  16194. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16195. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16196. */
  16197. export class Texture extends BaseTexture {
  16198. /**
  16199. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16200. */
  16201. static SerializeBuffers: boolean;
  16202. /** @hidden */
  16203. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16204. /** @hidden */
  16205. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16206. /** @hidden */
  16207. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16208. /** nearest is mag = nearest and min = nearest and mip = linear */
  16209. static readonly NEAREST_SAMPLINGMODE: number;
  16210. /** nearest is mag = nearest and min = nearest and mip = linear */
  16211. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16213. static readonly BILINEAR_SAMPLINGMODE: number;
  16214. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16215. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16216. /** Trilinear is mag = linear and min = linear and mip = linear */
  16217. static readonly TRILINEAR_SAMPLINGMODE: number;
  16218. /** Trilinear is mag = linear and min = linear and mip = linear */
  16219. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16220. /** mag = nearest and min = nearest and mip = nearest */
  16221. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16222. /** mag = nearest and min = linear and mip = nearest */
  16223. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16224. /** mag = nearest and min = linear and mip = linear */
  16225. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16226. /** mag = nearest and min = linear and mip = none */
  16227. static readonly NEAREST_LINEAR: number;
  16228. /** mag = nearest and min = nearest and mip = none */
  16229. static readonly NEAREST_NEAREST: number;
  16230. /** mag = linear and min = nearest and mip = nearest */
  16231. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16232. /** mag = linear and min = nearest and mip = linear */
  16233. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16234. /** mag = linear and min = linear and mip = none */
  16235. static readonly LINEAR_LINEAR: number;
  16236. /** mag = linear and min = nearest and mip = none */
  16237. static readonly LINEAR_NEAREST: number;
  16238. /** Explicit coordinates mode */
  16239. static readonly EXPLICIT_MODE: number;
  16240. /** Spherical coordinates mode */
  16241. static readonly SPHERICAL_MODE: number;
  16242. /** Planar coordinates mode */
  16243. static readonly PLANAR_MODE: number;
  16244. /** Cubic coordinates mode */
  16245. static readonly CUBIC_MODE: number;
  16246. /** Projection coordinates mode */
  16247. static readonly PROJECTION_MODE: number;
  16248. /** Inverse Cubic coordinates mode */
  16249. static readonly SKYBOX_MODE: number;
  16250. /** Inverse Cubic coordinates mode */
  16251. static readonly INVCUBIC_MODE: number;
  16252. /** Equirectangular coordinates mode */
  16253. static readonly EQUIRECTANGULAR_MODE: number;
  16254. /** Equirectangular Fixed coordinates mode */
  16255. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16256. /** Equirectangular Fixed Mirrored coordinates mode */
  16257. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16258. /** Texture is not repeating outside of 0..1 UVs */
  16259. static readonly CLAMP_ADDRESSMODE: number;
  16260. /** Texture is repeating outside of 0..1 UVs */
  16261. static readonly WRAP_ADDRESSMODE: number;
  16262. /** Texture is repeating and mirrored */
  16263. static readonly MIRROR_ADDRESSMODE: number;
  16264. /**
  16265. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16266. */
  16267. static UseSerializedUrlIfAny: boolean;
  16268. /**
  16269. * Define the url of the texture.
  16270. */
  16271. url: Nullable<string>;
  16272. /**
  16273. * Define an offset on the texture to offset the u coordinates of the UVs
  16274. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16275. */
  16276. uOffset: number;
  16277. /**
  16278. * Define an offset on the texture to offset the v coordinates of the UVs
  16279. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16280. */
  16281. vOffset: number;
  16282. /**
  16283. * Define an offset on the texture to scale the u coordinates of the UVs
  16284. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16285. */
  16286. uScale: number;
  16287. /**
  16288. * Define an offset on the texture to scale the v coordinates of the UVs
  16289. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16290. */
  16291. vScale: number;
  16292. /**
  16293. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16294. * @see http://doc.babylonjs.com/how_to/more_materials
  16295. */
  16296. uAng: number;
  16297. /**
  16298. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16299. * @see http://doc.babylonjs.com/how_to/more_materials
  16300. */
  16301. vAng: number;
  16302. /**
  16303. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16304. * @see http://doc.babylonjs.com/how_to/more_materials
  16305. */
  16306. wAng: number;
  16307. /**
  16308. * Defines the center of rotation (U)
  16309. */
  16310. uRotationCenter: number;
  16311. /**
  16312. * Defines the center of rotation (V)
  16313. */
  16314. vRotationCenter: number;
  16315. /**
  16316. * Defines the center of rotation (W)
  16317. */
  16318. wRotationCenter: number;
  16319. /**
  16320. * Are mip maps generated for this texture or not.
  16321. */
  16322. readonly noMipmap: boolean;
  16323. /**
  16324. * List of inspectable custom properties (used by the Inspector)
  16325. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16326. */
  16327. inspectableCustomProperties: Nullable<IInspectable[]>;
  16328. private _noMipmap;
  16329. /** @hidden */
  16330. _invertY: boolean;
  16331. private _rowGenerationMatrix;
  16332. private _cachedTextureMatrix;
  16333. private _projectionModeMatrix;
  16334. private _t0;
  16335. private _t1;
  16336. private _t2;
  16337. private _cachedUOffset;
  16338. private _cachedVOffset;
  16339. private _cachedUScale;
  16340. private _cachedVScale;
  16341. private _cachedUAng;
  16342. private _cachedVAng;
  16343. private _cachedWAng;
  16344. private _cachedProjectionMatrixId;
  16345. private _cachedCoordinatesMode;
  16346. /** @hidden */
  16347. protected _initialSamplingMode: number;
  16348. /** @hidden */
  16349. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16350. private _deleteBuffer;
  16351. protected _format: Nullable<number>;
  16352. private _delayedOnLoad;
  16353. private _delayedOnError;
  16354. private _mimeType?;
  16355. /**
  16356. * Observable triggered once the texture has been loaded.
  16357. */
  16358. onLoadObservable: Observable<Texture>;
  16359. protected _isBlocking: boolean;
  16360. /**
  16361. * Is the texture preventing material to render while loading.
  16362. * If false, a default texture will be used instead of the loading one during the preparation step.
  16363. */
  16364. isBlocking: boolean;
  16365. /**
  16366. * Get the current sampling mode associated with the texture.
  16367. */
  16368. readonly samplingMode: number;
  16369. /**
  16370. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16371. */
  16372. readonly invertY: boolean;
  16373. /**
  16374. * Instantiates a new texture.
  16375. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16376. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16377. * @param url defines the url of the picture to load as a texture
  16378. * @param scene defines the scene or engine the texture will belong to
  16379. * @param noMipmap defines if the texture will require mip maps or not
  16380. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16381. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16382. * @param onLoad defines a callback triggered when the texture has been loaded
  16383. * @param onError defines a callback triggered when an error occurred during the loading session
  16384. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16385. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16386. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16387. * @param mimeType defines an optional mime type information
  16388. */
  16389. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16390. /**
  16391. * Update the url (and optional buffer) of this texture if url was null during construction.
  16392. * @param url the url of the texture
  16393. * @param buffer the buffer of the texture (defaults to null)
  16394. * @param onLoad callback called when the texture is loaded (defaults to null)
  16395. */
  16396. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16397. /**
  16398. * Finish the loading sequence of a texture flagged as delayed load.
  16399. * @hidden
  16400. */
  16401. delayLoad(): void;
  16402. private _prepareRowForTextureGeneration;
  16403. /**
  16404. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16405. * @returns the transform matrix of the texture.
  16406. */
  16407. getTextureMatrix(): Matrix;
  16408. /**
  16409. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16410. * @returns The reflection texture transform
  16411. */
  16412. getReflectionTextureMatrix(): Matrix;
  16413. /**
  16414. * Clones the texture.
  16415. * @returns the cloned texture
  16416. */
  16417. clone(): Texture;
  16418. /**
  16419. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16420. * @returns The JSON representation of the texture
  16421. */
  16422. serialize(): any;
  16423. /**
  16424. * Get the current class name of the texture useful for serialization or dynamic coding.
  16425. * @returns "Texture"
  16426. */
  16427. getClassName(): string;
  16428. /**
  16429. * Dispose the texture and release its associated resources.
  16430. */
  16431. dispose(): void;
  16432. /**
  16433. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16434. * @param parsedTexture Define the JSON representation of the texture
  16435. * @param scene Define the scene the parsed texture should be instantiated in
  16436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16437. * @returns The parsed texture if successful
  16438. */
  16439. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16440. /**
  16441. * Creates a texture from its base 64 representation.
  16442. * @param data Define the base64 payload without the data: prefix
  16443. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16444. * @param scene Define the scene the texture should belong to
  16445. * @param noMipmap Forces the texture to not create mip map information if true
  16446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16448. * @param onLoad define a callback triggered when the texture has been loaded
  16449. * @param onError define a callback triggered when an error occurred during the loading session
  16450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16451. * @returns the created texture
  16452. */
  16453. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16454. /**
  16455. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16456. * @param data Define the base64 payload without the data: prefix
  16457. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16458. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16459. * @param scene Define the scene the texture should belong to
  16460. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16461. * @param noMipmap Forces the texture to not create mip map information if true
  16462. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16463. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16464. * @param onLoad define a callback triggered when the texture has been loaded
  16465. * @param onError define a callback triggered when an error occurred during the loading session
  16466. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16467. * @returns the created texture
  16468. */
  16469. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16470. }
  16471. }
  16472. declare module "babylonjs/PostProcesses/postProcessManager" {
  16473. import { Nullable } from "babylonjs/types";
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16476. import { Scene } from "babylonjs/scene";
  16477. /**
  16478. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16479. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16480. */
  16481. export class PostProcessManager {
  16482. private _scene;
  16483. private _indexBuffer;
  16484. private _vertexBuffers;
  16485. /**
  16486. * Creates a new instance PostProcess
  16487. * @param scene The scene that the post process is associated with.
  16488. */
  16489. constructor(scene: Scene);
  16490. private _prepareBuffers;
  16491. private _buildIndexBuffer;
  16492. /**
  16493. * Rebuilds the vertex buffers of the manager.
  16494. * @hidden
  16495. */
  16496. _rebuild(): void;
  16497. /**
  16498. * Prepares a frame to be run through a post process.
  16499. * @param sourceTexture The input texture to the post procesess. (default: null)
  16500. * @param postProcesses An array of post processes to be run. (default: null)
  16501. * @returns True if the post processes were able to be run.
  16502. * @hidden
  16503. */
  16504. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16505. /**
  16506. * Manually render a set of post processes to a texture.
  16507. * @param postProcesses An array of post processes to be run.
  16508. * @param targetTexture The target texture to render to.
  16509. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16510. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16511. * @param lodLevel defines which lod of the texture to render to
  16512. */
  16513. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16514. /**
  16515. * Finalize the result of the output of the postprocesses.
  16516. * @param doNotPresent If true the result will not be displayed to the screen.
  16517. * @param targetTexture The target texture to render to.
  16518. * @param faceIndex The index of the face to bind the target texture to.
  16519. * @param postProcesses The array of post processes to render.
  16520. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16521. * @hidden
  16522. */
  16523. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16524. /**
  16525. * Disposes of the post process manager.
  16526. */
  16527. dispose(): void;
  16528. }
  16529. }
  16530. declare module "babylonjs/Misc/gradients" {
  16531. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16532. /** Interface used by value gradients (color, factor, ...) */
  16533. export interface IValueGradient {
  16534. /**
  16535. * Gets or sets the gradient value (between 0 and 1)
  16536. */
  16537. gradient: number;
  16538. }
  16539. /** Class used to store color4 gradient */
  16540. export class ColorGradient implements IValueGradient {
  16541. /**
  16542. * Gets or sets the gradient value (between 0 and 1)
  16543. */
  16544. gradient: number;
  16545. /**
  16546. * Gets or sets first associated color
  16547. */
  16548. color1: Color4;
  16549. /**
  16550. * Gets or sets second associated color
  16551. */
  16552. color2?: Color4;
  16553. /**
  16554. * Will get a color picked randomly between color1 and color2.
  16555. * If color2 is undefined then color1 will be used
  16556. * @param result defines the target Color4 to store the result in
  16557. */
  16558. getColorToRef(result: Color4): void;
  16559. }
  16560. /** Class used to store color 3 gradient */
  16561. export class Color3Gradient implements IValueGradient {
  16562. /**
  16563. * Gets or sets the gradient value (between 0 and 1)
  16564. */
  16565. gradient: number;
  16566. /**
  16567. * Gets or sets the associated color
  16568. */
  16569. color: Color3;
  16570. }
  16571. /** Class used to store factor gradient */
  16572. export class FactorGradient implements IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. /**
  16578. * Gets or sets first associated factor
  16579. */
  16580. factor1: number;
  16581. /**
  16582. * Gets or sets second associated factor
  16583. */
  16584. factor2?: number;
  16585. /**
  16586. * Will get a number picked randomly between factor1 and factor2.
  16587. * If factor2 is undefined then factor1 will be used
  16588. * @returns the picked number
  16589. */
  16590. getFactor(): number;
  16591. }
  16592. /**
  16593. * Helper used to simplify some generic gradient tasks
  16594. */
  16595. export class GradientHelper {
  16596. /**
  16597. * Gets the current gradient from an array of IValueGradient
  16598. * @param ratio defines the current ratio to get
  16599. * @param gradients defines the array of IValueGradient
  16600. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16601. */
  16602. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16603. }
  16604. }
  16605. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16607. import { Nullable } from "babylonjs/types";
  16608. module "babylonjs/Engines/thinEngine" {
  16609. interface ThinEngine {
  16610. /**
  16611. * Creates a dynamic texture
  16612. * @param width defines the width of the texture
  16613. * @param height defines the height of the texture
  16614. * @param generateMipMaps defines if the engine should generate the mip levels
  16615. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16616. * @returns the dynamic texture inside an InternalTexture
  16617. */
  16618. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16619. /**
  16620. * Update the content of a dynamic texture
  16621. * @param texture defines the texture to update
  16622. * @param canvas defines the canvas containing the source
  16623. * @param invertY defines if data must be stored with Y axis inverted
  16624. * @param premulAlpha defines if alpha is stored as premultiplied
  16625. * @param format defines the format of the data
  16626. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16627. */
  16628. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16629. }
  16630. }
  16631. }
  16632. declare module "babylonjs/Misc/canvasGenerator" {
  16633. /**
  16634. * Helper class used to generate a canvas to manipulate images
  16635. */
  16636. export class CanvasGenerator {
  16637. /**
  16638. * Create a new canvas (or offscreen canvas depending on the context)
  16639. * @param width defines the expected width
  16640. * @param height defines the expected height
  16641. * @return a new canvas or offscreen canvas
  16642. */
  16643. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16644. }
  16645. }
  16646. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16647. import { Scene } from "babylonjs/scene";
  16648. import { Texture } from "babylonjs/Materials/Textures/texture";
  16649. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16650. /**
  16651. * A class extending Texture allowing drawing on a texture
  16652. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16653. */
  16654. export class DynamicTexture extends Texture {
  16655. private _generateMipMaps;
  16656. private _canvas;
  16657. private _context;
  16658. private _engine;
  16659. /**
  16660. * Creates a DynamicTexture
  16661. * @param name defines the name of the texture
  16662. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16663. * @param scene defines the scene where you want the texture
  16664. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16665. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16666. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16667. */
  16668. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16669. /**
  16670. * Get the current class name of the texture useful for serialization or dynamic coding.
  16671. * @returns "DynamicTexture"
  16672. */
  16673. getClassName(): string;
  16674. /**
  16675. * Gets the current state of canRescale
  16676. */
  16677. readonly canRescale: boolean;
  16678. private _recreate;
  16679. /**
  16680. * Scales the texture
  16681. * @param ratio the scale factor to apply to both width and height
  16682. */
  16683. scale(ratio: number): void;
  16684. /**
  16685. * Resizes the texture
  16686. * @param width the new width
  16687. * @param height the new height
  16688. */
  16689. scaleTo(width: number, height: number): void;
  16690. /**
  16691. * Gets the context of the canvas used by the texture
  16692. * @returns the canvas context of the dynamic texture
  16693. */
  16694. getContext(): CanvasRenderingContext2D;
  16695. /**
  16696. * Clears the texture
  16697. */
  16698. clear(): void;
  16699. /**
  16700. * Updates the texture
  16701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16702. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16703. */
  16704. update(invertY?: boolean, premulAlpha?: boolean): void;
  16705. /**
  16706. * Draws text onto the texture
  16707. * @param text defines the text to be drawn
  16708. * @param x defines the placement of the text from the left
  16709. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16710. * @param font defines the font to be used with font-style, font-size, font-name
  16711. * @param color defines the color used for the text
  16712. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16713. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16714. * @param update defines whether texture is immediately update (default is true)
  16715. */
  16716. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16717. /**
  16718. * Clones the texture
  16719. * @returns the clone of the texture.
  16720. */
  16721. clone(): DynamicTexture;
  16722. /**
  16723. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16724. * @returns a serialized dynamic texture object
  16725. */
  16726. serialize(): any;
  16727. /** @hidden */
  16728. _rebuild(): void;
  16729. }
  16730. }
  16731. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16732. import { Scene } from "babylonjs/scene";
  16733. import { ISceneComponent } from "babylonjs/sceneComponent";
  16734. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16735. module "babylonjs/abstractScene" {
  16736. interface AbstractScene {
  16737. /**
  16738. * The list of procedural textures added to the scene
  16739. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16740. */
  16741. proceduralTextures: Array<ProceduralTexture>;
  16742. }
  16743. }
  16744. /**
  16745. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16746. * in a given scene.
  16747. */
  16748. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16749. /**
  16750. * The component name helpfull to identify the component in the list of scene components.
  16751. */
  16752. readonly name: string;
  16753. /**
  16754. * The scene the component belongs to.
  16755. */
  16756. scene: Scene;
  16757. /**
  16758. * Creates a new instance of the component for the given scene
  16759. * @param scene Defines the scene to register the component in
  16760. */
  16761. constructor(scene: Scene);
  16762. /**
  16763. * Registers the component in a given scene
  16764. */
  16765. register(): void;
  16766. /**
  16767. * Rebuilds the elements related to this component in case of
  16768. * context lost for instance.
  16769. */
  16770. rebuild(): void;
  16771. /**
  16772. * Disposes the component and the associated ressources.
  16773. */
  16774. dispose(): void;
  16775. private _beforeClear;
  16776. }
  16777. }
  16778. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16780. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16781. module "babylonjs/Engines/thinEngine" {
  16782. interface ThinEngine {
  16783. /**
  16784. * Creates a new render target cube texture
  16785. * @param size defines the size of the texture
  16786. * @param options defines the options used to create the texture
  16787. * @returns a new render target cube texture stored in an InternalTexture
  16788. */
  16789. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16790. }
  16791. }
  16792. }
  16793. declare module "babylonjs/Shaders/procedural.vertex" {
  16794. /** @hidden */
  16795. export var proceduralVertexShader: {
  16796. name: string;
  16797. shader: string;
  16798. };
  16799. }
  16800. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16801. import { Observable } from "babylonjs/Misc/observable";
  16802. import { Nullable } from "babylonjs/types";
  16803. import { Scene } from "babylonjs/scene";
  16804. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16805. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16806. import { Effect } from "babylonjs/Materials/effect";
  16807. import { Texture } from "babylonjs/Materials/Textures/texture";
  16808. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16809. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16810. import "babylonjs/Shaders/procedural.vertex";
  16811. /**
  16812. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16813. * This is the base class of any Procedural texture and contains most of the shareable code.
  16814. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16815. */
  16816. export class ProceduralTexture extends Texture {
  16817. isCube: boolean;
  16818. /**
  16819. * Define if the texture is enabled or not (disabled texture will not render)
  16820. */
  16821. isEnabled: boolean;
  16822. /**
  16823. * Define if the texture must be cleared before rendering (default is true)
  16824. */
  16825. autoClear: boolean;
  16826. /**
  16827. * Callback called when the texture is generated
  16828. */
  16829. onGenerated: () => void;
  16830. /**
  16831. * Event raised when the texture is generated
  16832. */
  16833. onGeneratedObservable: Observable<ProceduralTexture>;
  16834. /** @hidden */
  16835. _generateMipMaps: boolean;
  16836. /** @hidden **/
  16837. _effect: Effect;
  16838. /** @hidden */
  16839. _textures: {
  16840. [key: string]: Texture;
  16841. };
  16842. private _size;
  16843. private _currentRefreshId;
  16844. private _refreshRate;
  16845. private _vertexBuffers;
  16846. private _indexBuffer;
  16847. private _uniforms;
  16848. private _samplers;
  16849. private _fragment;
  16850. private _floats;
  16851. private _ints;
  16852. private _floatsArrays;
  16853. private _colors3;
  16854. private _colors4;
  16855. private _vectors2;
  16856. private _vectors3;
  16857. private _matrices;
  16858. private _fallbackTexture;
  16859. private _fallbackTextureUsed;
  16860. private _engine;
  16861. private _cachedDefines;
  16862. private _contentUpdateId;
  16863. private _contentData;
  16864. /**
  16865. * Instantiates a new procedural texture.
  16866. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16867. * This is the base class of any Procedural texture and contains most of the shareable code.
  16868. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16869. * @param name Define the name of the texture
  16870. * @param size Define the size of the texture to create
  16871. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16872. * @param scene Define the scene the texture belongs to
  16873. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16874. * @param generateMipMaps Define if the texture should creates mip maps or not
  16875. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16876. */
  16877. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16878. /**
  16879. * The effect that is created when initializing the post process.
  16880. * @returns The created effect corresponding the the postprocess.
  16881. */
  16882. getEffect(): Effect;
  16883. /**
  16884. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16885. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16886. */
  16887. getContent(): Nullable<ArrayBufferView>;
  16888. private _createIndexBuffer;
  16889. /** @hidden */
  16890. _rebuild(): void;
  16891. /**
  16892. * Resets the texture in order to recreate its associated resources.
  16893. * This can be called in case of context loss
  16894. */
  16895. reset(): void;
  16896. protected _getDefines(): string;
  16897. /**
  16898. * Is the texture ready to be used ? (rendered at least once)
  16899. * @returns true if ready, otherwise, false.
  16900. */
  16901. isReady(): boolean;
  16902. /**
  16903. * Resets the refresh counter of the texture and start bak from scratch.
  16904. * Could be useful to regenerate the texture if it is setup to render only once.
  16905. */
  16906. resetRefreshCounter(): void;
  16907. /**
  16908. * Set the fragment shader to use in order to render the texture.
  16909. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16910. */
  16911. setFragment(fragment: any): void;
  16912. /**
  16913. * Define the refresh rate of the texture or the rendering frequency.
  16914. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16915. */
  16916. refreshRate: number;
  16917. /** @hidden */
  16918. _shouldRender(): boolean;
  16919. /**
  16920. * Get the size the texture is rendering at.
  16921. * @returns the size (texture is always squared)
  16922. */
  16923. getRenderSize(): number;
  16924. /**
  16925. * Resize the texture to new value.
  16926. * @param size Define the new size the texture should have
  16927. * @param generateMipMaps Define whether the new texture should create mip maps
  16928. */
  16929. resize(size: number, generateMipMaps: boolean): void;
  16930. private _checkUniform;
  16931. /**
  16932. * Set a texture in the shader program used to render.
  16933. * @param name Define the name of the uniform samplers as defined in the shader
  16934. * @param texture Define the texture to bind to this sampler
  16935. * @return the texture itself allowing "fluent" like uniform updates
  16936. */
  16937. setTexture(name: string, texture: Texture): ProceduralTexture;
  16938. /**
  16939. * Set a float in the shader.
  16940. * @param name Define the name of the uniform as defined in the shader
  16941. * @param value Define the value to give to the uniform
  16942. * @return the texture itself allowing "fluent" like uniform updates
  16943. */
  16944. setFloat(name: string, value: number): ProceduralTexture;
  16945. /**
  16946. * Set a int in the shader.
  16947. * @param name Define the name of the uniform as defined in the shader
  16948. * @param value Define the value to give to the uniform
  16949. * @return the texture itself allowing "fluent" like uniform updates
  16950. */
  16951. setInt(name: string, value: number): ProceduralTexture;
  16952. /**
  16953. * Set an array of floats in the shader.
  16954. * @param name Define the name of the uniform as defined in the shader
  16955. * @param value Define the value to give to the uniform
  16956. * @return the texture itself allowing "fluent" like uniform updates
  16957. */
  16958. setFloats(name: string, value: number[]): ProceduralTexture;
  16959. /**
  16960. * Set a vec3 in the shader from a Color3.
  16961. * @param name Define the name of the uniform as defined in the shader
  16962. * @param value Define the value to give to the uniform
  16963. * @return the texture itself allowing "fluent" like uniform updates
  16964. */
  16965. setColor3(name: string, value: Color3): ProceduralTexture;
  16966. /**
  16967. * Set a vec4 in the shader from a Color4.
  16968. * @param name Define the name of the uniform as defined in the shader
  16969. * @param value Define the value to give to the uniform
  16970. * @return the texture itself allowing "fluent" like uniform updates
  16971. */
  16972. setColor4(name: string, value: Color4): ProceduralTexture;
  16973. /**
  16974. * Set a vec2 in the shader from a Vector2.
  16975. * @param name Define the name of the uniform as defined in the shader
  16976. * @param value Define the value to give to the uniform
  16977. * @return the texture itself allowing "fluent" like uniform updates
  16978. */
  16979. setVector2(name: string, value: Vector2): ProceduralTexture;
  16980. /**
  16981. * Set a vec3 in the shader from a Vector3.
  16982. * @param name Define the name of the uniform as defined in the shader
  16983. * @param value Define the value to give to the uniform
  16984. * @return the texture itself allowing "fluent" like uniform updates
  16985. */
  16986. setVector3(name: string, value: Vector3): ProceduralTexture;
  16987. /**
  16988. * Set a mat4 in the shader from a MAtrix.
  16989. * @param name Define the name of the uniform as defined in the shader
  16990. * @param value Define the value to give to the uniform
  16991. * @return the texture itself allowing "fluent" like uniform updates
  16992. */
  16993. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16994. /**
  16995. * Render the texture to its associated render target.
  16996. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16997. */
  16998. render(useCameraPostProcess?: boolean): void;
  16999. /**
  17000. * Clone the texture.
  17001. * @returns the cloned texture
  17002. */
  17003. clone(): ProceduralTexture;
  17004. /**
  17005. * Dispose the texture and release its asoociated resources.
  17006. */
  17007. dispose(): void;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/baseParticleSystem" {
  17011. import { Nullable } from "babylonjs/types";
  17012. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17014. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17015. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17016. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17017. import { Scene } from "babylonjs/scene";
  17018. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17019. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17020. import { Texture } from "babylonjs/Materials/Textures/texture";
  17021. import { Color4 } from "babylonjs/Maths/math.color";
  17022. import { Animation } from "babylonjs/Animations/animation";
  17023. /**
  17024. * This represents the base class for particle system in Babylon.
  17025. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17027. * @example https://doc.babylonjs.com/babylon101/particles
  17028. */
  17029. export class BaseParticleSystem {
  17030. /**
  17031. * Source color is added to the destination color without alpha affecting the result
  17032. */
  17033. static BLENDMODE_ONEONE: number;
  17034. /**
  17035. * Blend current color and particle color using particle’s alpha
  17036. */
  17037. static BLENDMODE_STANDARD: number;
  17038. /**
  17039. * Add current color and particle color multiplied by particle’s alpha
  17040. */
  17041. static BLENDMODE_ADD: number;
  17042. /**
  17043. * Multiply current color with particle color
  17044. */
  17045. static BLENDMODE_MULTIPLY: number;
  17046. /**
  17047. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17048. */
  17049. static BLENDMODE_MULTIPLYADD: number;
  17050. /**
  17051. * List of animations used by the particle system.
  17052. */
  17053. animations: Animation[];
  17054. /**
  17055. * The id of the Particle system.
  17056. */
  17057. id: string;
  17058. /**
  17059. * The friendly name of the Particle system.
  17060. */
  17061. name: string;
  17062. /**
  17063. * The rendering group used by the Particle system to chose when to render.
  17064. */
  17065. renderingGroupId: number;
  17066. /**
  17067. * The emitter represents the Mesh or position we are attaching the particle system to.
  17068. */
  17069. emitter: Nullable<AbstractMesh | Vector3>;
  17070. /**
  17071. * The maximum number of particles to emit per frame
  17072. */
  17073. emitRate: number;
  17074. /**
  17075. * If you want to launch only a few particles at once, that can be done, as well.
  17076. */
  17077. manualEmitCount: number;
  17078. /**
  17079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17080. */
  17081. updateSpeed: number;
  17082. /**
  17083. * The amount of time the particle system is running (depends of the overall update speed).
  17084. */
  17085. targetStopDuration: number;
  17086. /**
  17087. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17088. */
  17089. disposeOnStop: boolean;
  17090. /**
  17091. * Minimum power of emitting particles.
  17092. */
  17093. minEmitPower: number;
  17094. /**
  17095. * Maximum power of emitting particles.
  17096. */
  17097. maxEmitPower: number;
  17098. /**
  17099. * Minimum life time of emitting particles.
  17100. */
  17101. minLifeTime: number;
  17102. /**
  17103. * Maximum life time of emitting particles.
  17104. */
  17105. maxLifeTime: number;
  17106. /**
  17107. * Minimum Size of emitting particles.
  17108. */
  17109. minSize: number;
  17110. /**
  17111. * Maximum Size of emitting particles.
  17112. */
  17113. maxSize: number;
  17114. /**
  17115. * Minimum scale of emitting particles on X axis.
  17116. */
  17117. minScaleX: number;
  17118. /**
  17119. * Maximum scale of emitting particles on X axis.
  17120. */
  17121. maxScaleX: number;
  17122. /**
  17123. * Minimum scale of emitting particles on Y axis.
  17124. */
  17125. minScaleY: number;
  17126. /**
  17127. * Maximum scale of emitting particles on Y axis.
  17128. */
  17129. maxScaleY: number;
  17130. /**
  17131. * Gets or sets the minimal initial rotation in radians.
  17132. */
  17133. minInitialRotation: number;
  17134. /**
  17135. * Gets or sets the maximal initial rotation in radians.
  17136. */
  17137. maxInitialRotation: number;
  17138. /**
  17139. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17140. */
  17141. minAngularSpeed: number;
  17142. /**
  17143. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17144. */
  17145. maxAngularSpeed: number;
  17146. /**
  17147. * The texture used to render each particle. (this can be a spritesheet)
  17148. */
  17149. particleTexture: Nullable<Texture>;
  17150. /**
  17151. * The layer mask we are rendering the particles through.
  17152. */
  17153. layerMask: number;
  17154. /**
  17155. * This can help using your own shader to render the particle system.
  17156. * The according effect will be created
  17157. */
  17158. customShader: any;
  17159. /**
  17160. * By default particle system starts as soon as they are created. This prevents the
  17161. * automatic start to happen and let you decide when to start emitting particles.
  17162. */
  17163. preventAutoStart: boolean;
  17164. private _noiseTexture;
  17165. /**
  17166. * Gets or sets a texture used to add random noise to particle positions
  17167. */
  17168. noiseTexture: Nullable<ProceduralTexture>;
  17169. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17170. noiseStrength: Vector3;
  17171. /**
  17172. * Callback triggered when the particle animation is ending.
  17173. */
  17174. onAnimationEnd: Nullable<() => void>;
  17175. /**
  17176. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17177. */
  17178. blendMode: number;
  17179. /**
  17180. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17181. * to override the particles.
  17182. */
  17183. forceDepthWrite: boolean;
  17184. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  17185. preWarmCycles: number;
  17186. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17187. preWarmStepOffset: number;
  17188. /**
  17189. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17190. */
  17191. spriteCellChangeSpeed: number;
  17192. /**
  17193. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17194. */
  17195. startSpriteCellID: number;
  17196. /**
  17197. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17198. */
  17199. endSpriteCellID: number;
  17200. /**
  17201. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17202. */
  17203. spriteCellWidth: number;
  17204. /**
  17205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17206. */
  17207. spriteCellHeight: number;
  17208. /**
  17209. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17210. */
  17211. spriteRandomStartCell: boolean;
  17212. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17213. translationPivot: Vector2;
  17214. /** @hidden */
  17215. protected _isAnimationSheetEnabled: boolean;
  17216. /**
  17217. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17218. */
  17219. beginAnimationOnStart: boolean;
  17220. /**
  17221. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17222. */
  17223. beginAnimationFrom: number;
  17224. /**
  17225. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17226. */
  17227. beginAnimationTo: number;
  17228. /**
  17229. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17230. */
  17231. beginAnimationLoop: boolean;
  17232. /**
  17233. * Gets or sets a world offset applied to all particles
  17234. */
  17235. worldOffset: Vector3;
  17236. /**
  17237. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17238. */
  17239. isAnimationSheetEnabled: boolean;
  17240. /**
  17241. * Get hosting scene
  17242. * @returns the scene
  17243. */
  17244. getScene(): Scene;
  17245. /**
  17246. * You can use gravity if you want to give an orientation to your particles.
  17247. */
  17248. gravity: Vector3;
  17249. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17250. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17251. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17252. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17253. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17254. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17255. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17256. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17257. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17258. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17259. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17260. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17261. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17262. /**
  17263. * Defines the delay in milliseconds before starting the system (0 by default)
  17264. */
  17265. startDelay: number;
  17266. /**
  17267. * Gets the current list of drag gradients.
  17268. * You must use addDragGradient and removeDragGradient to udpate this list
  17269. * @returns the list of drag gradients
  17270. */
  17271. getDragGradients(): Nullable<Array<FactorGradient>>;
  17272. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17273. limitVelocityDamping: number;
  17274. /**
  17275. * Gets the current list of limit velocity gradients.
  17276. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17277. * @returns the list of limit velocity gradients
  17278. */
  17279. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17280. /**
  17281. * Gets the current list of color gradients.
  17282. * You must use addColorGradient and removeColorGradient to udpate this list
  17283. * @returns the list of color gradients
  17284. */
  17285. getColorGradients(): Nullable<Array<ColorGradient>>;
  17286. /**
  17287. * Gets the current list of size gradients.
  17288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17289. * @returns the list of size gradients
  17290. */
  17291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17292. /**
  17293. * Gets the current list of color remap gradients.
  17294. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17295. * @returns the list of color remap gradients
  17296. */
  17297. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17298. /**
  17299. * Gets the current list of alpha remap gradients.
  17300. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17301. * @returns the list of alpha remap gradients
  17302. */
  17303. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17304. /**
  17305. * Gets the current list of life time gradients.
  17306. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17307. * @returns the list of life time gradients
  17308. */
  17309. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17310. /**
  17311. * Gets the current list of angular speed gradients.
  17312. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17313. * @returns the list of angular speed gradients
  17314. */
  17315. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17316. /**
  17317. * Gets the current list of velocity gradients.
  17318. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17319. * @returns the list of velocity gradients
  17320. */
  17321. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17322. /**
  17323. * Gets the current list of start size gradients.
  17324. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17325. * @returns the list of start size gradients
  17326. */
  17327. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17328. /**
  17329. * Gets the current list of emit rate gradients.
  17330. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17331. * @returns the list of emit rate gradients
  17332. */
  17333. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17334. /**
  17335. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17337. */
  17338. direction1: Vector3;
  17339. /**
  17340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17341. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17342. */
  17343. direction2: Vector3;
  17344. /**
  17345. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17346. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17347. */
  17348. minEmitBox: Vector3;
  17349. /**
  17350. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17352. */
  17353. maxEmitBox: Vector3;
  17354. /**
  17355. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17356. */
  17357. color1: Color4;
  17358. /**
  17359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17360. */
  17361. color2: Color4;
  17362. /**
  17363. * Color the particle will have at the end of its lifetime
  17364. */
  17365. colorDead: Color4;
  17366. /**
  17367. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17368. */
  17369. textureMask: Color4;
  17370. /**
  17371. * The particle emitter type defines the emitter used by the particle system.
  17372. * It can be for example box, sphere, or cone...
  17373. */
  17374. particleEmitterType: IParticleEmitterType;
  17375. /** @hidden */
  17376. _isSubEmitter: boolean;
  17377. /**
  17378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17380. */
  17381. billboardMode: number;
  17382. protected _isBillboardBased: boolean;
  17383. /**
  17384. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17385. */
  17386. isBillboardBased: boolean;
  17387. /**
  17388. * The scene the particle system belongs to.
  17389. */
  17390. protected _scene: Scene;
  17391. /**
  17392. * Local cache of defines for image processing.
  17393. */
  17394. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17395. /**
  17396. * Default configuration related to image processing available in the standard Material.
  17397. */
  17398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17399. /**
  17400. * Gets the image processing configuration used either in this material.
  17401. */
  17402. /**
  17403. * Sets the Default image processing configuration used either in the this material.
  17404. *
  17405. * If sets to null, the scene one is in use.
  17406. */
  17407. imageProcessingConfiguration: ImageProcessingConfiguration;
  17408. /**
  17409. * Attaches a new image processing configuration to the Standard Material.
  17410. * @param configuration
  17411. */
  17412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17413. /** @hidden */
  17414. protected _reset(): void;
  17415. /** @hidden */
  17416. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17417. /**
  17418. * Instantiates a particle system.
  17419. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17420. * @param name The name of the particle system
  17421. */
  17422. constructor(name: string);
  17423. /**
  17424. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17427. * @returns the emitter
  17428. */
  17429. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17430. /**
  17431. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17432. * @param radius The radius of the hemisphere to emit from
  17433. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17434. * @returns the emitter
  17435. */
  17436. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17437. /**
  17438. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17439. * @param radius The radius of the sphere to emit from
  17440. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17441. * @returns the emitter
  17442. */
  17443. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17444. /**
  17445. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17446. * @param radius The radius of the sphere to emit from
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17449. * @returns the emitter
  17450. */
  17451. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17452. /**
  17453. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17454. * @param radius The radius of the emission cylinder
  17455. * @param height The height of the emission cylinder
  17456. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17457. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17458. * @returns the emitter
  17459. */
  17460. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17461. /**
  17462. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17463. * @param radius The radius of the cylinder to emit from
  17464. * @param height The height of the emission cylinder
  17465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17468. * @returns the emitter
  17469. */
  17470. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17471. /**
  17472. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17473. * @param radius The radius of the cone to emit from
  17474. * @param angle The base angle of the cone
  17475. * @returns the emitter
  17476. */
  17477. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17478. /**
  17479. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17482. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17483. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17484. * @returns the emitter
  17485. */
  17486. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17487. }
  17488. }
  17489. declare module "babylonjs/Particles/subEmitter" {
  17490. import { Scene } from "babylonjs/scene";
  17491. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17492. /**
  17493. * Type of sub emitter
  17494. */
  17495. export enum SubEmitterType {
  17496. /**
  17497. * Attached to the particle over it's lifetime
  17498. */
  17499. ATTACHED = 0,
  17500. /**
  17501. * Created when the particle dies
  17502. */
  17503. END = 1
  17504. }
  17505. /**
  17506. * Sub emitter class used to emit particles from an existing particle
  17507. */
  17508. export class SubEmitter {
  17509. /**
  17510. * the particle system to be used by the sub emitter
  17511. */
  17512. particleSystem: ParticleSystem;
  17513. /**
  17514. * Type of the submitter (Default: END)
  17515. */
  17516. type: SubEmitterType;
  17517. /**
  17518. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17519. * Note: This only is supported when using an emitter of type Mesh
  17520. */
  17521. inheritDirection: boolean;
  17522. /**
  17523. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17524. */
  17525. inheritedVelocityAmount: number;
  17526. /**
  17527. * Creates a sub emitter
  17528. * @param particleSystem the particle system to be used by the sub emitter
  17529. */
  17530. constructor(
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem);
  17535. /**
  17536. * Clones the sub emitter
  17537. * @returns the cloned sub emitter
  17538. */
  17539. clone(): SubEmitter;
  17540. /**
  17541. * Serialize current object to a JSON object
  17542. * @returns the serialized object
  17543. */
  17544. serialize(): any;
  17545. /** @hidden */
  17546. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17547. /**
  17548. * Creates a new SubEmitter from a serialized JSON version
  17549. * @param serializationObject defines the JSON object to read from
  17550. * @param scene defines the hosting scene
  17551. * @param rootUrl defines the rootUrl for data loading
  17552. * @returns a new SubEmitter
  17553. */
  17554. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17555. /** Release associated resources */
  17556. dispose(): void;
  17557. }
  17558. }
  17559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17560. /** @hidden */
  17561. export var clipPlaneFragmentDeclaration: {
  17562. name: string;
  17563. shader: string;
  17564. };
  17565. }
  17566. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17567. /** @hidden */
  17568. export var imageProcessingDeclaration: {
  17569. name: string;
  17570. shader: string;
  17571. };
  17572. }
  17573. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17574. /** @hidden */
  17575. export var imageProcessingFunctions: {
  17576. name: string;
  17577. shader: string;
  17578. };
  17579. }
  17580. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17581. /** @hidden */
  17582. export var clipPlaneFragment: {
  17583. name: string;
  17584. shader: string;
  17585. };
  17586. }
  17587. declare module "babylonjs/Shaders/particles.fragment" {
  17588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17589. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17591. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17592. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17593. /** @hidden */
  17594. export var particlesPixelShader: {
  17595. name: string;
  17596. shader: string;
  17597. };
  17598. }
  17599. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17600. /** @hidden */
  17601. export var clipPlaneVertexDeclaration: {
  17602. name: string;
  17603. shader: string;
  17604. };
  17605. }
  17606. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17607. /** @hidden */
  17608. export var clipPlaneVertex: {
  17609. name: string;
  17610. shader: string;
  17611. };
  17612. }
  17613. declare module "babylonjs/Shaders/particles.vertex" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17616. /** @hidden */
  17617. export var particlesVertexShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Particles/particleSystem" {
  17623. import { Nullable } from "babylonjs/types";
  17624. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17625. import { Observable } from "babylonjs/Misc/observable";
  17626. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17627. import { Effect } from "babylonjs/Materials/effect";
  17628. import { Scene, IDisposable } from "babylonjs/scene";
  17629. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17630. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17631. import { Particle } from "babylonjs/Particles/particle";
  17632. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17633. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17634. import "babylonjs/Shaders/particles.fragment";
  17635. import "babylonjs/Shaders/particles.vertex";
  17636. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17637. /**
  17638. * This represents a particle system in Babylon.
  17639. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17640. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17641. * @example https://doc.babylonjs.com/babylon101/particles
  17642. */
  17643. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17644. /**
  17645. * Billboard mode will only apply to Y axis
  17646. */
  17647. static readonly BILLBOARDMODE_Y: number;
  17648. /**
  17649. * Billboard mode will apply to all axes
  17650. */
  17651. static readonly BILLBOARDMODE_ALL: number;
  17652. /**
  17653. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17654. */
  17655. static readonly BILLBOARDMODE_STRETCHED: number;
  17656. /**
  17657. * This function can be defined to provide custom update for active particles.
  17658. * This function will be called instead of regular update (age, position, color, etc.).
  17659. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17660. */
  17661. updateFunction: (particles: Particle[]) => void;
  17662. private _emitterWorldMatrix;
  17663. /**
  17664. * This function can be defined to specify initial direction for every new particle.
  17665. * It by default use the emitterType defined function
  17666. */
  17667. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17668. /**
  17669. * This function can be defined to specify initial position for every new particle.
  17670. * It by default use the emitterType defined function
  17671. */
  17672. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17673. /**
  17674. * @hidden
  17675. */
  17676. _inheritedVelocityOffset: Vector3;
  17677. /**
  17678. * An event triggered when the system is disposed
  17679. */
  17680. onDisposeObservable: Observable<ParticleSystem>;
  17681. private _onDisposeObserver;
  17682. /**
  17683. * Sets a callback that will be triggered when the system is disposed
  17684. */
  17685. onDispose: () => void;
  17686. private _particles;
  17687. private _epsilon;
  17688. private _capacity;
  17689. private _stockParticles;
  17690. private _newPartsExcess;
  17691. private _vertexData;
  17692. private _vertexBuffer;
  17693. private _vertexBuffers;
  17694. private _spriteBuffer;
  17695. private _indexBuffer;
  17696. private _effect;
  17697. private _customEffect;
  17698. private _cachedDefines;
  17699. private _scaledColorStep;
  17700. private _colorDiff;
  17701. private _scaledDirection;
  17702. private _scaledGravity;
  17703. private _currentRenderId;
  17704. private _alive;
  17705. private _useInstancing;
  17706. private _started;
  17707. private _stopped;
  17708. private _actualFrame;
  17709. private _scaledUpdateSpeed;
  17710. private _vertexBufferSize;
  17711. /** @hidden */
  17712. _currentEmitRateGradient: Nullable<FactorGradient>;
  17713. /** @hidden */
  17714. _currentEmitRate1: number;
  17715. /** @hidden */
  17716. _currentEmitRate2: number;
  17717. /** @hidden */
  17718. _currentStartSizeGradient: Nullable<FactorGradient>;
  17719. /** @hidden */
  17720. _currentStartSize1: number;
  17721. /** @hidden */
  17722. _currentStartSize2: number;
  17723. private readonly _rawTextureWidth;
  17724. private _rampGradientsTexture;
  17725. private _useRampGradients;
  17726. /** Gets or sets a boolean indicating that ramp gradients must be used
  17727. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17728. */
  17729. useRampGradients: boolean;
  17730. /**
  17731. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17732. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17733. */
  17734. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17735. private _subEmitters;
  17736. /**
  17737. * @hidden
  17738. * If the particle systems emitter should be disposed when the particle system is disposed
  17739. */
  17740. _disposeEmitterOnDispose: boolean;
  17741. /**
  17742. * The current active Sub-systems, this property is used by the root particle system only.
  17743. */
  17744. activeSubSystems: Array<ParticleSystem>;
  17745. private _rootParticleSystem;
  17746. /**
  17747. * Gets the current list of active particles
  17748. */
  17749. readonly particles: Particle[];
  17750. /**
  17751. * Returns the string "ParticleSystem"
  17752. * @returns a string containing the class name
  17753. */
  17754. getClassName(): string;
  17755. /**
  17756. * Instantiates a particle system.
  17757. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17758. * @param name The name of the particle system
  17759. * @param capacity The max number of particles alive at the same time
  17760. * @param scene The scene the particle system belongs to
  17761. * @param customEffect a custom effect used to change the way particles are rendered by default
  17762. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17763. * @param epsilon Offset used to render the particles
  17764. */
  17765. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17766. private _addFactorGradient;
  17767. private _removeFactorGradient;
  17768. /**
  17769. * Adds a new life time gradient
  17770. * @param gradient defines the gradient to use (between 0 and 1)
  17771. * @param factor defines the life time factor to affect to the specified gradient
  17772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17773. * @returns the current particle system
  17774. */
  17775. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17776. /**
  17777. * Remove a specific life time gradient
  17778. * @param gradient defines the gradient to remove
  17779. * @returns the current particle system
  17780. */
  17781. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17782. /**
  17783. * Adds a new size gradient
  17784. * @param gradient defines the gradient to use (between 0 and 1)
  17785. * @param factor defines the size factor to affect to the specified gradient
  17786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17787. * @returns the current particle system
  17788. */
  17789. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17790. /**
  17791. * Remove a specific size gradient
  17792. * @param gradient defines the gradient to remove
  17793. * @returns the current particle system
  17794. */
  17795. removeSizeGradient(gradient: number): IParticleSystem;
  17796. /**
  17797. * Adds a new color remap gradient
  17798. * @param gradient defines the gradient to use (between 0 and 1)
  17799. * @param min defines the color remap minimal range
  17800. * @param max defines the color remap maximal range
  17801. * @returns the current particle system
  17802. */
  17803. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17804. /**
  17805. * Remove a specific color remap gradient
  17806. * @param gradient defines the gradient to remove
  17807. * @returns the current particle system
  17808. */
  17809. removeColorRemapGradient(gradient: number): IParticleSystem;
  17810. /**
  17811. * Adds a new alpha remap gradient
  17812. * @param gradient defines the gradient to use (between 0 and 1)
  17813. * @param min defines the alpha remap minimal range
  17814. * @param max defines the alpha remap maximal range
  17815. * @returns the current particle system
  17816. */
  17817. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17818. /**
  17819. * Remove a specific alpha remap gradient
  17820. * @param gradient defines the gradient to remove
  17821. * @returns the current particle system
  17822. */
  17823. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17824. /**
  17825. * Adds a new angular speed gradient
  17826. * @param gradient defines the gradient to use (between 0 and 1)
  17827. * @param factor defines the angular speed to affect to the specified gradient
  17828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17829. * @returns the current particle system
  17830. */
  17831. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17832. /**
  17833. * Remove a specific angular speed gradient
  17834. * @param gradient defines the gradient to remove
  17835. * @returns the current particle system
  17836. */
  17837. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17838. /**
  17839. * Adds a new velocity gradient
  17840. * @param gradient defines the gradient to use (between 0 and 1)
  17841. * @param factor defines the velocity to affect to the specified gradient
  17842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17843. * @returns the current particle system
  17844. */
  17845. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17846. /**
  17847. * Remove a specific velocity gradient
  17848. * @param gradient defines the gradient to remove
  17849. * @returns the current particle system
  17850. */
  17851. removeVelocityGradient(gradient: number): IParticleSystem;
  17852. /**
  17853. * Adds a new limit velocity gradient
  17854. * @param gradient defines the gradient to use (between 0 and 1)
  17855. * @param factor defines the limit velocity value to affect to the specified gradient
  17856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17857. * @returns the current particle system
  17858. */
  17859. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17860. /**
  17861. * Remove a specific limit velocity gradient
  17862. * @param gradient defines the gradient to remove
  17863. * @returns the current particle system
  17864. */
  17865. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17866. /**
  17867. * Adds a new drag gradient
  17868. * @param gradient defines the gradient to use (between 0 and 1)
  17869. * @param factor defines the drag value to affect to the specified gradient
  17870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17871. * @returns the current particle system
  17872. */
  17873. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17874. /**
  17875. * Remove a specific drag gradient
  17876. * @param gradient defines the gradient to remove
  17877. * @returns the current particle system
  17878. */
  17879. removeDragGradient(gradient: number): IParticleSystem;
  17880. /**
  17881. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17882. * @param gradient defines the gradient to use (between 0 and 1)
  17883. * @param factor defines the emit rate value to affect to the specified gradient
  17884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17885. * @returns the current particle system
  17886. */
  17887. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17888. /**
  17889. * Remove a specific emit rate gradient
  17890. * @param gradient defines the gradient to remove
  17891. * @returns the current particle system
  17892. */
  17893. removeEmitRateGradient(gradient: number): IParticleSystem;
  17894. /**
  17895. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17896. * @param gradient defines the gradient to use (between 0 and 1)
  17897. * @param factor defines the start size value to affect to the specified gradient
  17898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17899. * @returns the current particle system
  17900. */
  17901. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17902. /**
  17903. * Remove a specific start size gradient
  17904. * @param gradient defines the gradient to remove
  17905. * @returns the current particle system
  17906. */
  17907. removeStartSizeGradient(gradient: number): IParticleSystem;
  17908. private _createRampGradientTexture;
  17909. /**
  17910. * Gets the current list of ramp gradients.
  17911. * You must use addRampGradient and removeRampGradient to udpate this list
  17912. * @returns the list of ramp gradients
  17913. */
  17914. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17915. /**
  17916. * Adds a new ramp gradient used to remap particle colors
  17917. * @param gradient defines the gradient to use (between 0 and 1)
  17918. * @param color defines the color to affect to the specified gradient
  17919. * @returns the current particle system
  17920. */
  17921. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17922. /**
  17923. * Remove a specific ramp gradient
  17924. * @param gradient defines the gradient to remove
  17925. * @returns the current particle system
  17926. */
  17927. removeRampGradient(gradient: number): ParticleSystem;
  17928. /**
  17929. * Adds a new color gradient
  17930. * @param gradient defines the gradient to use (between 0 and 1)
  17931. * @param color1 defines the color to affect to the specified gradient
  17932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17933. * @returns this particle system
  17934. */
  17935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17936. /**
  17937. * Remove a specific color gradient
  17938. * @param gradient defines the gradient to remove
  17939. * @returns this particle system
  17940. */
  17941. removeColorGradient(gradient: number): IParticleSystem;
  17942. private _fetchR;
  17943. protected _reset(): void;
  17944. private _resetEffect;
  17945. private _createVertexBuffers;
  17946. private _createIndexBuffer;
  17947. /**
  17948. * Gets the maximum number of particles active at the same time.
  17949. * @returns The max number of active particles.
  17950. */
  17951. getCapacity(): number;
  17952. /**
  17953. * Gets whether there are still active particles in the system.
  17954. * @returns True if it is alive, otherwise false.
  17955. */
  17956. isAlive(): boolean;
  17957. /**
  17958. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17959. * @returns True if it has been started, otherwise false.
  17960. */
  17961. isStarted(): boolean;
  17962. private _prepareSubEmitterInternalArray;
  17963. /**
  17964. * Starts the particle system and begins to emit
  17965. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17966. */
  17967. start(delay?: number): void;
  17968. /**
  17969. * Stops the particle system.
  17970. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17971. */
  17972. stop(stopSubEmitters?: boolean): void;
  17973. /**
  17974. * Remove all active particles
  17975. */
  17976. reset(): void;
  17977. /**
  17978. * @hidden (for internal use only)
  17979. */
  17980. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17981. /**
  17982. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17983. * Its lifetime will start back at 0.
  17984. */
  17985. recycleParticle: (particle: Particle) => void;
  17986. private _stopSubEmitters;
  17987. private _createParticle;
  17988. private _removeFromRoot;
  17989. private _emitFromParticle;
  17990. private _update;
  17991. /** @hidden */
  17992. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17993. /** @hidden */
  17994. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17995. /** @hidden */
  17996. private _getEffect;
  17997. /**
  17998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17999. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18000. */
  18001. animate(preWarmOnly?: boolean): void;
  18002. private _appendParticleVertices;
  18003. /**
  18004. * Rebuilds the particle system.
  18005. */
  18006. rebuild(): void;
  18007. /**
  18008. * Is this system ready to be used/rendered
  18009. * @return true if the system is ready
  18010. */
  18011. isReady(): boolean;
  18012. private _render;
  18013. /**
  18014. * Renders the particle system in its current state.
  18015. * @returns the current number of particles
  18016. */
  18017. render(): number;
  18018. /**
  18019. * Disposes the particle system and free the associated resources
  18020. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18021. */
  18022. dispose(disposeTexture?: boolean): void;
  18023. /**
  18024. * Clones the particle system.
  18025. * @param name The name of the cloned object
  18026. * @param newEmitter The new emitter to use
  18027. * @returns the cloned particle system
  18028. */
  18029. clone(name: string, newEmitter: any): ParticleSystem;
  18030. /**
  18031. * Serializes the particle system to a JSON object.
  18032. * @returns the JSON object
  18033. */
  18034. serialize(): any;
  18035. /** @hidden */
  18036. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18037. /** @hidden */
  18038. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18039. /**
  18040. * Parses a JSON object to create a particle system.
  18041. * @param parsedParticleSystem The JSON object to parse
  18042. * @param scene The scene to create the particle system in
  18043. * @param rootUrl The root url to use to load external dependencies like texture
  18044. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18045. * @returns the Parsed particle system
  18046. */
  18047. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18048. }
  18049. }
  18050. declare module "babylonjs/Particles/particle" {
  18051. import { Nullable } from "babylonjs/types";
  18052. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18053. import { Color4 } from "babylonjs/Maths/math.color";
  18054. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18055. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18056. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18057. /**
  18058. * A particle represents one of the element emitted by a particle system.
  18059. * This is mainly define by its coordinates, direction, velocity and age.
  18060. */
  18061. export class Particle {
  18062. /**
  18063. * The particle system the particle belongs to.
  18064. */
  18065. particleSystem: ParticleSystem;
  18066. private static _Count;
  18067. /**
  18068. * Unique ID of the particle
  18069. */
  18070. id: number;
  18071. /**
  18072. * The world position of the particle in the scene.
  18073. */
  18074. position: Vector3;
  18075. /**
  18076. * The world direction of the particle in the scene.
  18077. */
  18078. direction: Vector3;
  18079. /**
  18080. * The color of the particle.
  18081. */
  18082. color: Color4;
  18083. /**
  18084. * The color change of the particle per step.
  18085. */
  18086. colorStep: Color4;
  18087. /**
  18088. * Defines how long will the life of the particle be.
  18089. */
  18090. lifeTime: number;
  18091. /**
  18092. * The current age of the particle.
  18093. */
  18094. age: number;
  18095. /**
  18096. * The current size of the particle.
  18097. */
  18098. size: number;
  18099. /**
  18100. * The current scale of the particle.
  18101. */
  18102. scale: Vector2;
  18103. /**
  18104. * The current angle of the particle.
  18105. */
  18106. angle: number;
  18107. /**
  18108. * Defines how fast is the angle changing.
  18109. */
  18110. angularSpeed: number;
  18111. /**
  18112. * Defines the cell index used by the particle to be rendered from a sprite.
  18113. */
  18114. cellIndex: number;
  18115. /**
  18116. * The information required to support color remapping
  18117. */
  18118. remapData: Vector4;
  18119. /** @hidden */
  18120. _randomCellOffset?: number;
  18121. /** @hidden */
  18122. _initialDirection: Nullable<Vector3>;
  18123. /** @hidden */
  18124. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18125. /** @hidden */
  18126. _initialStartSpriteCellID: number;
  18127. /** @hidden */
  18128. _initialEndSpriteCellID: number;
  18129. /** @hidden */
  18130. _currentColorGradient: Nullable<ColorGradient>;
  18131. /** @hidden */
  18132. _currentColor1: Color4;
  18133. /** @hidden */
  18134. _currentColor2: Color4;
  18135. /** @hidden */
  18136. _currentSizeGradient: Nullable<FactorGradient>;
  18137. /** @hidden */
  18138. _currentSize1: number;
  18139. /** @hidden */
  18140. _currentSize2: number;
  18141. /** @hidden */
  18142. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18143. /** @hidden */
  18144. _currentAngularSpeed1: number;
  18145. /** @hidden */
  18146. _currentAngularSpeed2: number;
  18147. /** @hidden */
  18148. _currentVelocityGradient: Nullable<FactorGradient>;
  18149. /** @hidden */
  18150. _currentVelocity1: number;
  18151. /** @hidden */
  18152. _currentVelocity2: number;
  18153. /** @hidden */
  18154. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18155. /** @hidden */
  18156. _currentLimitVelocity1: number;
  18157. /** @hidden */
  18158. _currentLimitVelocity2: number;
  18159. /** @hidden */
  18160. _currentDragGradient: Nullable<FactorGradient>;
  18161. /** @hidden */
  18162. _currentDrag1: number;
  18163. /** @hidden */
  18164. _currentDrag2: number;
  18165. /** @hidden */
  18166. _randomNoiseCoordinates1: Vector3;
  18167. /** @hidden */
  18168. _randomNoiseCoordinates2: Vector3;
  18169. /**
  18170. * Creates a new instance Particle
  18171. * @param particleSystem the particle system the particle belongs to
  18172. */
  18173. constructor(
  18174. /**
  18175. * The particle system the particle belongs to.
  18176. */
  18177. particleSystem: ParticleSystem);
  18178. private updateCellInfoFromSystem;
  18179. /**
  18180. * Defines how the sprite cell index is updated for the particle
  18181. */
  18182. updateCellIndex(): void;
  18183. /** @hidden */
  18184. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18185. /** @hidden */
  18186. _inheritParticleInfoToSubEmitters(): void;
  18187. /** @hidden */
  18188. _reset(): void;
  18189. /**
  18190. * Copy the properties of particle to another one.
  18191. * @param other the particle to copy the information to.
  18192. */
  18193. copyTo(other: Particle): void;
  18194. }
  18195. }
  18196. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18197. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18198. import { Effect } from "babylonjs/Materials/effect";
  18199. import { Particle } from "babylonjs/Particles/particle";
  18200. /**
  18201. * Particle emitter represents a volume emitting particles.
  18202. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18203. */
  18204. export interface IParticleEmitterType {
  18205. /**
  18206. * Called by the particle System when the direction is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param directionToUpdate is the direction vector to update with the result
  18209. * @param particle is the particle we are computed the direction for
  18210. */
  18211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Called by the particle System when the position is computed for the created particle.
  18214. * @param worldMatrix is the world matrix of the particle system
  18215. * @param positionToUpdate is the position vector to update with the result
  18216. * @param particle is the particle we are computed the position for
  18217. */
  18218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18219. /**
  18220. * Clones the current emitter and returns a copy of it
  18221. * @returns the new emitter
  18222. */
  18223. clone(): IParticleEmitterType;
  18224. /**
  18225. * Called by the GPUParticleSystem to setup the update shader
  18226. * @param effect defines the update shader
  18227. */
  18228. applyToShader(effect: Effect): void;
  18229. /**
  18230. * Returns a string to use to update the GPU particles update shader
  18231. * @returns the effect defines string
  18232. */
  18233. getEffectDefines(): string;
  18234. /**
  18235. * Returns a string representing the class name
  18236. * @returns a string containing the class name
  18237. */
  18238. getClassName(): string;
  18239. /**
  18240. * Serializes the particle system to a JSON object.
  18241. * @returns the JSON object
  18242. */
  18243. serialize(): any;
  18244. /**
  18245. * Parse properties from a JSON object
  18246. * @param serializationObject defines the JSON object
  18247. */
  18248. parse(serializationObject: any): void;
  18249. }
  18250. }
  18251. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18252. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import { Particle } from "babylonjs/Particles/particle";
  18255. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18256. /**
  18257. * Particle emitter emitting particles from the inside of a box.
  18258. * It emits the particles randomly between 2 given directions.
  18259. */
  18260. export class BoxParticleEmitter implements IParticleEmitterType {
  18261. /**
  18262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18263. */
  18264. direction1: Vector3;
  18265. /**
  18266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18267. */
  18268. direction2: Vector3;
  18269. /**
  18270. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18271. */
  18272. minEmitBox: Vector3;
  18273. /**
  18274. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18275. */
  18276. maxEmitBox: Vector3;
  18277. /**
  18278. * Creates a new instance BoxParticleEmitter
  18279. */
  18280. constructor();
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): BoxParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "BoxParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. }
  18327. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18328. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18329. import { Effect } from "babylonjs/Materials/effect";
  18330. import { Particle } from "babylonjs/Particles/particle";
  18331. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18332. /**
  18333. * Particle emitter emitting particles from the inside of a cone.
  18334. * It emits the particles alongside the cone volume from the base to the particle.
  18335. * The emission direction might be randomized.
  18336. */
  18337. export class ConeParticleEmitter implements IParticleEmitterType {
  18338. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18339. directionRandomizer: number;
  18340. private _radius;
  18341. private _angle;
  18342. private _height;
  18343. /**
  18344. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18345. */
  18346. radiusRange: number;
  18347. /**
  18348. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18349. */
  18350. heightRange: number;
  18351. /**
  18352. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18353. */
  18354. emitFromSpawnPointOnly: boolean;
  18355. /**
  18356. * Gets or sets the radius of the emission cone
  18357. */
  18358. radius: number;
  18359. /**
  18360. * Gets or sets the angle of the emission cone
  18361. */
  18362. angle: number;
  18363. private _buildHeight;
  18364. /**
  18365. * Creates a new instance ConeParticleEmitter
  18366. * @param radius the radius of the emission cone (1 by default)
  18367. * @param angle the cone base angle (PI by default)
  18368. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18369. */
  18370. constructor(radius?: number, angle?: number,
  18371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18372. directionRandomizer?: number);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Called by the particle System when the position is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param positionToUpdate is the position vector to update with the result
  18384. * @param particle is the particle we are computed the position for
  18385. */
  18386. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Clones the current emitter and returns a copy of it
  18389. * @returns the new emitter
  18390. */
  18391. clone(): ConeParticleEmitter;
  18392. /**
  18393. * Called by the GPUParticleSystem to setup the update shader
  18394. * @param effect defines the update shader
  18395. */
  18396. applyToShader(effect: Effect): void;
  18397. /**
  18398. * Returns a string to use to update the GPU particles update shader
  18399. * @returns a string containng the defines string
  18400. */
  18401. getEffectDefines(): string;
  18402. /**
  18403. * Returns the string "ConeParticleEmitter"
  18404. * @returns a string containing the class name
  18405. */
  18406. getClassName(): string;
  18407. /**
  18408. * Serializes the particle system to a JSON object.
  18409. * @returns the JSON object
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * Parse properties from a JSON object
  18414. * @param serializationObject defines the JSON object
  18415. */
  18416. parse(serializationObject: any): void;
  18417. }
  18418. }
  18419. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18420. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18421. import { Effect } from "babylonjs/Materials/effect";
  18422. import { Particle } from "babylonjs/Particles/particle";
  18423. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18424. /**
  18425. * Particle emitter emitting particles from the inside of a cylinder.
  18426. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18427. */
  18428. export class CylinderParticleEmitter implements IParticleEmitterType {
  18429. /**
  18430. * The radius of the emission cylinder.
  18431. */
  18432. radius: number;
  18433. /**
  18434. * The height of the emission cylinder.
  18435. */
  18436. height: number;
  18437. /**
  18438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18439. */
  18440. radiusRange: number;
  18441. /**
  18442. * How much to randomize the particle direction [0-1].
  18443. */
  18444. directionRandomizer: number;
  18445. /**
  18446. * Creates a new instance CylinderParticleEmitter
  18447. * @param radius the radius of the emission cylinder (1 by default)
  18448. * @param height the height of the emission cylinder (1 by default)
  18449. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18450. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18451. */
  18452. constructor(
  18453. /**
  18454. * The radius of the emission cylinder.
  18455. */
  18456. radius?: number,
  18457. /**
  18458. * The height of the emission cylinder.
  18459. */
  18460. height?: number,
  18461. /**
  18462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18463. */
  18464. radiusRange?: number,
  18465. /**
  18466. * How much to randomize the particle direction [0-1].
  18467. */
  18468. directionRandomizer?: number);
  18469. /**
  18470. * Called by the particle System when the direction is computed for the created particle.
  18471. * @param worldMatrix is the world matrix of the particle system
  18472. * @param directionToUpdate is the direction vector to update with the result
  18473. * @param particle is the particle we are computed the direction for
  18474. */
  18475. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18476. /**
  18477. * Called by the particle System when the position is computed for the created particle.
  18478. * @param worldMatrix is the world matrix of the particle system
  18479. * @param positionToUpdate is the position vector to update with the result
  18480. * @param particle is the particle we are computed the position for
  18481. */
  18482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18483. /**
  18484. * Clones the current emitter and returns a copy of it
  18485. * @returns the new emitter
  18486. */
  18487. clone(): CylinderParticleEmitter;
  18488. /**
  18489. * Called by the GPUParticleSystem to setup the update shader
  18490. * @param effect defines the update shader
  18491. */
  18492. applyToShader(effect: Effect): void;
  18493. /**
  18494. * Returns a string to use to update the GPU particles update shader
  18495. * @returns a string containng the defines string
  18496. */
  18497. getEffectDefines(): string;
  18498. /**
  18499. * Returns the string "CylinderParticleEmitter"
  18500. * @returns a string containing the class name
  18501. */
  18502. getClassName(): string;
  18503. /**
  18504. * Serializes the particle system to a JSON object.
  18505. * @returns the JSON object
  18506. */
  18507. serialize(): any;
  18508. /**
  18509. * Parse properties from a JSON object
  18510. * @param serializationObject defines the JSON object
  18511. */
  18512. parse(serializationObject: any): void;
  18513. }
  18514. /**
  18515. * Particle emitter emitting particles from the inside of a cylinder.
  18516. * It emits the particles randomly between two vectors.
  18517. */
  18518. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18519. /**
  18520. * The min limit of the emission direction.
  18521. */
  18522. direction1: Vector3;
  18523. /**
  18524. * The max limit of the emission direction.
  18525. */
  18526. direction2: Vector3;
  18527. /**
  18528. * Creates a new instance CylinderDirectedParticleEmitter
  18529. * @param radius the radius of the emission cylinder (1 by default)
  18530. * @param height the height of the emission cylinder (1 by default)
  18531. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18532. * @param direction1 the min limit of the emission direction (up vector by default)
  18533. * @param direction2 the max limit of the emission direction (up vector by default)
  18534. */
  18535. constructor(radius?: number, height?: number, radiusRange?: number,
  18536. /**
  18537. * The min limit of the emission direction.
  18538. */
  18539. direction1?: Vector3,
  18540. /**
  18541. * The max limit of the emission direction.
  18542. */
  18543. direction2?: Vector3);
  18544. /**
  18545. * Called by the particle System when the direction is computed for the created particle.
  18546. * @param worldMatrix is the world matrix of the particle system
  18547. * @param directionToUpdate is the direction vector to update with the result
  18548. * @param particle is the particle we are computed the direction for
  18549. */
  18550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18551. /**
  18552. * Clones the current emitter and returns a copy of it
  18553. * @returns the new emitter
  18554. */
  18555. clone(): CylinderDirectedParticleEmitter;
  18556. /**
  18557. * Called by the GPUParticleSystem to setup the update shader
  18558. * @param effect defines the update shader
  18559. */
  18560. applyToShader(effect: Effect): void;
  18561. /**
  18562. * Returns a string to use to update the GPU particles update shader
  18563. * @returns a string containng the defines string
  18564. */
  18565. getEffectDefines(): string;
  18566. /**
  18567. * Returns the string "CylinderDirectedParticleEmitter"
  18568. * @returns a string containing the class name
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Serializes the particle system to a JSON object.
  18573. * @returns the JSON object
  18574. */
  18575. serialize(): any;
  18576. /**
  18577. * Parse properties from a JSON object
  18578. * @param serializationObject defines the JSON object
  18579. */
  18580. parse(serializationObject: any): void;
  18581. }
  18582. }
  18583. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18584. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18585. import { Effect } from "babylonjs/Materials/effect";
  18586. import { Particle } from "babylonjs/Particles/particle";
  18587. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18588. /**
  18589. * Particle emitter emitting particles from the inside of a hemisphere.
  18590. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18591. */
  18592. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18593. /**
  18594. * The radius of the emission hemisphere.
  18595. */
  18596. radius: number;
  18597. /**
  18598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18599. */
  18600. radiusRange: number;
  18601. /**
  18602. * How much to randomize the particle direction [0-1].
  18603. */
  18604. directionRandomizer: number;
  18605. /**
  18606. * Creates a new instance HemisphericParticleEmitter
  18607. * @param radius the radius of the emission hemisphere (1 by default)
  18608. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18610. */
  18611. constructor(
  18612. /**
  18613. * The radius of the emission hemisphere.
  18614. */
  18615. radius?: number,
  18616. /**
  18617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18618. */
  18619. radiusRange?: number,
  18620. /**
  18621. * How much to randomize the particle direction [0-1].
  18622. */
  18623. directionRandomizer?: number);
  18624. /**
  18625. * Called by the particle System when the direction is computed for the created particle.
  18626. * @param worldMatrix is the world matrix of the particle system
  18627. * @param directionToUpdate is the direction vector to update with the result
  18628. * @param particle is the particle we are computed the direction for
  18629. */
  18630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18631. /**
  18632. * Called by the particle System when the position is computed for the created particle.
  18633. * @param worldMatrix is the world matrix of the particle system
  18634. * @param positionToUpdate is the position vector to update with the result
  18635. * @param particle is the particle we are computed the position for
  18636. */
  18637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18638. /**
  18639. * Clones the current emitter and returns a copy of it
  18640. * @returns the new emitter
  18641. */
  18642. clone(): HemisphericParticleEmitter;
  18643. /**
  18644. * Called by the GPUParticleSystem to setup the update shader
  18645. * @param effect defines the update shader
  18646. */
  18647. applyToShader(effect: Effect): void;
  18648. /**
  18649. * Returns a string to use to update the GPU particles update shader
  18650. * @returns a string containng the defines string
  18651. */
  18652. getEffectDefines(): string;
  18653. /**
  18654. * Returns the string "HemisphericParticleEmitter"
  18655. * @returns a string containing the class name
  18656. */
  18657. getClassName(): string;
  18658. /**
  18659. * Serializes the particle system to a JSON object.
  18660. * @returns the JSON object
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Parse properties from a JSON object
  18665. * @param serializationObject defines the JSON object
  18666. */
  18667. parse(serializationObject: any): void;
  18668. }
  18669. }
  18670. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18671. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18672. import { Effect } from "babylonjs/Materials/effect";
  18673. import { Particle } from "babylonjs/Particles/particle";
  18674. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18675. /**
  18676. * Particle emitter emitting particles from a point.
  18677. * It emits the particles randomly between 2 given directions.
  18678. */
  18679. export class PointParticleEmitter implements IParticleEmitterType {
  18680. /**
  18681. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18682. */
  18683. direction1: Vector3;
  18684. /**
  18685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18686. */
  18687. direction2: Vector3;
  18688. /**
  18689. * Creates a new instance PointParticleEmitter
  18690. */
  18691. constructor();
  18692. /**
  18693. * Called by the particle System when the direction is computed for the created particle.
  18694. * @param worldMatrix is the world matrix of the particle system
  18695. * @param directionToUpdate is the direction vector to update with the result
  18696. * @param particle is the particle we are computed the direction for
  18697. */
  18698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18699. /**
  18700. * Called by the particle System when the position is computed for the created particle.
  18701. * @param worldMatrix is the world matrix of the particle system
  18702. * @param positionToUpdate is the position vector to update with the result
  18703. * @param particle is the particle we are computed the position for
  18704. */
  18705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18706. /**
  18707. * Clones the current emitter and returns a copy of it
  18708. * @returns the new emitter
  18709. */
  18710. clone(): PointParticleEmitter;
  18711. /**
  18712. * Called by the GPUParticleSystem to setup the update shader
  18713. * @param effect defines the update shader
  18714. */
  18715. applyToShader(effect: Effect): void;
  18716. /**
  18717. * Returns a string to use to update the GPU particles update shader
  18718. * @returns a string containng the defines string
  18719. */
  18720. getEffectDefines(): string;
  18721. /**
  18722. * Returns the string "PointParticleEmitter"
  18723. * @returns a string containing the class name
  18724. */
  18725. getClassName(): string;
  18726. /**
  18727. * Serializes the particle system to a JSON object.
  18728. * @returns the JSON object
  18729. */
  18730. serialize(): any;
  18731. /**
  18732. * Parse properties from a JSON object
  18733. * @param serializationObject defines the JSON object
  18734. */
  18735. parse(serializationObject: any): void;
  18736. }
  18737. }
  18738. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18740. import { Effect } from "babylonjs/Materials/effect";
  18741. import { Particle } from "babylonjs/Particles/particle";
  18742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18743. /**
  18744. * Particle emitter emitting particles from the inside of a sphere.
  18745. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18746. */
  18747. export class SphereParticleEmitter implements IParticleEmitterType {
  18748. /**
  18749. * The radius of the emission sphere.
  18750. */
  18751. radius: number;
  18752. /**
  18753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18754. */
  18755. radiusRange: number;
  18756. /**
  18757. * How much to randomize the particle direction [0-1].
  18758. */
  18759. directionRandomizer: number;
  18760. /**
  18761. * Creates a new instance SphereParticleEmitter
  18762. * @param radius the radius of the emission sphere (1 by default)
  18763. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18764. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18765. */
  18766. constructor(
  18767. /**
  18768. * The radius of the emission sphere.
  18769. */
  18770. radius?: number,
  18771. /**
  18772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18773. */
  18774. radiusRange?: number,
  18775. /**
  18776. * How much to randomize the particle direction [0-1].
  18777. */
  18778. directionRandomizer?: number);
  18779. /**
  18780. * Called by the particle System when the direction is computed for the created particle.
  18781. * @param worldMatrix is the world matrix of the particle system
  18782. * @param directionToUpdate is the direction vector to update with the result
  18783. * @param particle is the particle we are computed the direction for
  18784. */
  18785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18786. /**
  18787. * Called by the particle System when the position is computed for the created particle.
  18788. * @param worldMatrix is the world matrix of the particle system
  18789. * @param positionToUpdate is the position vector to update with the result
  18790. * @param particle is the particle we are computed the position for
  18791. */
  18792. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18793. /**
  18794. * Clones the current emitter and returns a copy of it
  18795. * @returns the new emitter
  18796. */
  18797. clone(): SphereParticleEmitter;
  18798. /**
  18799. * Called by the GPUParticleSystem to setup the update shader
  18800. * @param effect defines the update shader
  18801. */
  18802. applyToShader(effect: Effect): void;
  18803. /**
  18804. * Returns a string to use to update the GPU particles update shader
  18805. * @returns a string containng the defines string
  18806. */
  18807. getEffectDefines(): string;
  18808. /**
  18809. * Returns the string "SphereParticleEmitter"
  18810. * @returns a string containing the class name
  18811. */
  18812. getClassName(): string;
  18813. /**
  18814. * Serializes the particle system to a JSON object.
  18815. * @returns the JSON object
  18816. */
  18817. serialize(): any;
  18818. /**
  18819. * Parse properties from a JSON object
  18820. * @param serializationObject defines the JSON object
  18821. */
  18822. parse(serializationObject: any): void;
  18823. }
  18824. /**
  18825. * Particle emitter emitting particles from the inside of a sphere.
  18826. * It emits the particles randomly between two vectors.
  18827. */
  18828. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18829. /**
  18830. * The min limit of the emission direction.
  18831. */
  18832. direction1: Vector3;
  18833. /**
  18834. * The max limit of the emission direction.
  18835. */
  18836. direction2: Vector3;
  18837. /**
  18838. * Creates a new instance SphereDirectedParticleEmitter
  18839. * @param radius the radius of the emission sphere (1 by default)
  18840. * @param direction1 the min limit of the emission direction (up vector by default)
  18841. * @param direction2 the max limit of the emission direction (up vector by default)
  18842. */
  18843. constructor(radius?: number,
  18844. /**
  18845. * The min limit of the emission direction.
  18846. */
  18847. direction1?: Vector3,
  18848. /**
  18849. * The max limit of the emission direction.
  18850. */
  18851. direction2?: Vector3);
  18852. /**
  18853. * Called by the particle System when the direction is computed for the created particle.
  18854. * @param worldMatrix is the world matrix of the particle system
  18855. * @param directionToUpdate is the direction vector to update with the result
  18856. * @param particle is the particle we are computed the direction for
  18857. */
  18858. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18859. /**
  18860. * Clones the current emitter and returns a copy of it
  18861. * @returns the new emitter
  18862. */
  18863. clone(): SphereDirectedParticleEmitter;
  18864. /**
  18865. * Called by the GPUParticleSystem to setup the update shader
  18866. * @param effect defines the update shader
  18867. */
  18868. applyToShader(effect: Effect): void;
  18869. /**
  18870. * Returns a string to use to update the GPU particles update shader
  18871. * @returns a string containng the defines string
  18872. */
  18873. getEffectDefines(): string;
  18874. /**
  18875. * Returns the string "SphereDirectedParticleEmitter"
  18876. * @returns a string containing the class name
  18877. */
  18878. getClassName(): string;
  18879. /**
  18880. * Serializes the particle system to a JSON object.
  18881. * @returns the JSON object
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Parse properties from a JSON object
  18886. * @param serializationObject defines the JSON object
  18887. */
  18888. parse(serializationObject: any): void;
  18889. }
  18890. }
  18891. declare module "babylonjs/Particles/EmitterTypes/index" {
  18892. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18893. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18894. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18895. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18896. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18897. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18898. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18899. }
  18900. declare module "babylonjs/Particles/IParticleSystem" {
  18901. import { Nullable } from "babylonjs/types";
  18902. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18903. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18906. import { Texture } from "babylonjs/Materials/Textures/texture";
  18907. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18908. import { Scene } from "babylonjs/scene";
  18909. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18910. import { Animation } from "babylonjs/Animations/animation";
  18911. /**
  18912. * Interface representing a particle system in Babylon.js.
  18913. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18914. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18915. */
  18916. export interface IParticleSystem {
  18917. /**
  18918. * List of animations used by the particle system.
  18919. */
  18920. animations: Animation[];
  18921. /**
  18922. * The id of the Particle system.
  18923. */
  18924. id: string;
  18925. /**
  18926. * The name of the Particle system.
  18927. */
  18928. name: string;
  18929. /**
  18930. * The emitter represents the Mesh or position we are attaching the particle system to.
  18931. */
  18932. emitter: Nullable<AbstractMesh | Vector3>;
  18933. /**
  18934. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18935. */
  18936. isBillboardBased: boolean;
  18937. /**
  18938. * The rendering group used by the Particle system to chose when to render.
  18939. */
  18940. renderingGroupId: number;
  18941. /**
  18942. * The layer mask we are rendering the particles through.
  18943. */
  18944. layerMask: number;
  18945. /**
  18946. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18947. */
  18948. updateSpeed: number;
  18949. /**
  18950. * The amount of time the particle system is running (depends of the overall update speed).
  18951. */
  18952. targetStopDuration: number;
  18953. /**
  18954. * The texture used to render each particle. (this can be a spritesheet)
  18955. */
  18956. particleTexture: Nullable<Texture>;
  18957. /**
  18958. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18959. */
  18960. blendMode: number;
  18961. /**
  18962. * Minimum life time of emitting particles.
  18963. */
  18964. minLifeTime: number;
  18965. /**
  18966. * Maximum life time of emitting particles.
  18967. */
  18968. maxLifeTime: number;
  18969. /**
  18970. * Minimum Size of emitting particles.
  18971. */
  18972. minSize: number;
  18973. /**
  18974. * Maximum Size of emitting particles.
  18975. */
  18976. maxSize: number;
  18977. /**
  18978. * Minimum scale of emitting particles on X axis.
  18979. */
  18980. minScaleX: number;
  18981. /**
  18982. * Maximum scale of emitting particles on X axis.
  18983. */
  18984. maxScaleX: number;
  18985. /**
  18986. * Minimum scale of emitting particles on Y axis.
  18987. */
  18988. minScaleY: number;
  18989. /**
  18990. * Maximum scale of emitting particles on Y axis.
  18991. */
  18992. maxScaleY: number;
  18993. /**
  18994. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18995. */
  18996. color1: Color4;
  18997. /**
  18998. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18999. */
  19000. color2: Color4;
  19001. /**
  19002. * Color the particle will have at the end of its lifetime.
  19003. */
  19004. colorDead: Color4;
  19005. /**
  19006. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19007. */
  19008. emitRate: number;
  19009. /**
  19010. * You can use gravity if you want to give an orientation to your particles.
  19011. */
  19012. gravity: Vector3;
  19013. /**
  19014. * Minimum power of emitting particles.
  19015. */
  19016. minEmitPower: number;
  19017. /**
  19018. * Maximum power of emitting particles.
  19019. */
  19020. maxEmitPower: number;
  19021. /**
  19022. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19023. */
  19024. minAngularSpeed: number;
  19025. /**
  19026. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19027. */
  19028. maxAngularSpeed: number;
  19029. /**
  19030. * Gets or sets the minimal initial rotation in radians.
  19031. */
  19032. minInitialRotation: number;
  19033. /**
  19034. * Gets or sets the maximal initial rotation in radians.
  19035. */
  19036. maxInitialRotation: number;
  19037. /**
  19038. * The particle emitter type defines the emitter used by the particle system.
  19039. * It can be for example box, sphere, or cone...
  19040. */
  19041. particleEmitterType: Nullable<IParticleEmitterType>;
  19042. /**
  19043. * Defines the delay in milliseconds before starting the system (0 by default)
  19044. */
  19045. startDelay: number;
  19046. /**
  19047. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  19048. */
  19049. preWarmCycles: number;
  19050. /**
  19051. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19052. */
  19053. preWarmStepOffset: number;
  19054. /**
  19055. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  19056. */
  19057. spriteCellChangeSpeed: number;
  19058. /**
  19059. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19060. */
  19061. startSpriteCellID: number;
  19062. /**
  19063. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19064. */
  19065. endSpriteCellID: number;
  19066. /**
  19067. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19068. */
  19069. spriteCellWidth: number;
  19070. /**
  19071. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19072. */
  19073. spriteCellHeight: number;
  19074. /**
  19075. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19076. */
  19077. spriteRandomStartCell: boolean;
  19078. /**
  19079. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19080. */
  19081. isAnimationSheetEnabled: boolean;
  19082. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19083. translationPivot: Vector2;
  19084. /**
  19085. * Gets or sets a texture used to add random noise to particle positions
  19086. */
  19087. noiseTexture: Nullable<BaseTexture>;
  19088. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19089. noiseStrength: Vector3;
  19090. /**
  19091. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19092. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19093. */
  19094. billboardMode: number;
  19095. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19096. limitVelocityDamping: number;
  19097. /**
  19098. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19099. */
  19100. beginAnimationOnStart: boolean;
  19101. /**
  19102. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19103. */
  19104. beginAnimationFrom: number;
  19105. /**
  19106. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19107. */
  19108. beginAnimationTo: number;
  19109. /**
  19110. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19111. */
  19112. beginAnimationLoop: boolean;
  19113. /**
  19114. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19115. */
  19116. disposeOnStop: boolean;
  19117. /**
  19118. * Gets the maximum number of particles active at the same time.
  19119. * @returns The max number of active particles.
  19120. */
  19121. getCapacity(): number;
  19122. /**
  19123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19124. * @returns True if it has been started, otherwise false.
  19125. */
  19126. isStarted(): boolean;
  19127. /**
  19128. * Animates the particle system for this frame.
  19129. */
  19130. animate(): void;
  19131. /**
  19132. * Renders the particle system in its current state.
  19133. * @returns the current number of particles
  19134. */
  19135. render(): number;
  19136. /**
  19137. * Dispose the particle system and frees its associated resources.
  19138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19139. */
  19140. dispose(disposeTexture?: boolean): void;
  19141. /**
  19142. * Clones the particle system.
  19143. * @param name The name of the cloned object
  19144. * @param newEmitter The new emitter to use
  19145. * @returns the cloned particle system
  19146. */
  19147. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19148. /**
  19149. * Serializes the particle system to a JSON object.
  19150. * @returns the JSON object
  19151. */
  19152. serialize(): any;
  19153. /**
  19154. * Rebuild the particle system
  19155. */
  19156. rebuild(): void;
  19157. /**
  19158. * Starts the particle system and begins to emit
  19159. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19160. */
  19161. start(delay?: number): void;
  19162. /**
  19163. * Stops the particle system.
  19164. */
  19165. stop(): void;
  19166. /**
  19167. * Remove all active particles
  19168. */
  19169. reset(): void;
  19170. /**
  19171. * Is this system ready to be used/rendered
  19172. * @return true if the system is ready
  19173. */
  19174. isReady(): boolean;
  19175. /**
  19176. * Adds a new color gradient
  19177. * @param gradient defines the gradient to use (between 0 and 1)
  19178. * @param color1 defines the color to affect to the specified gradient
  19179. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19180. * @returns the current particle system
  19181. */
  19182. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19183. /**
  19184. * Remove a specific color gradient
  19185. * @param gradient defines the gradient to remove
  19186. * @returns the current particle system
  19187. */
  19188. removeColorGradient(gradient: number): IParticleSystem;
  19189. /**
  19190. * Adds a new size gradient
  19191. * @param gradient defines the gradient to use (between 0 and 1)
  19192. * @param factor defines the size factor to affect to the specified gradient
  19193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19194. * @returns the current particle system
  19195. */
  19196. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19197. /**
  19198. * Remove a specific size gradient
  19199. * @param gradient defines the gradient to remove
  19200. * @returns the current particle system
  19201. */
  19202. removeSizeGradient(gradient: number): IParticleSystem;
  19203. /**
  19204. * Gets the current list of color gradients.
  19205. * You must use addColorGradient and removeColorGradient to udpate this list
  19206. * @returns the list of color gradients
  19207. */
  19208. getColorGradients(): Nullable<Array<ColorGradient>>;
  19209. /**
  19210. * Gets the current list of size gradients.
  19211. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19212. * @returns the list of size gradients
  19213. */
  19214. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19215. /**
  19216. * Gets the current list of angular speed gradients.
  19217. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19218. * @returns the list of angular speed gradients
  19219. */
  19220. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19221. /**
  19222. * Adds a new angular speed gradient
  19223. * @param gradient defines the gradient to use (between 0 and 1)
  19224. * @param factor defines the angular speed to affect to the specified gradient
  19225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19226. * @returns the current particle system
  19227. */
  19228. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19229. /**
  19230. * Remove a specific angular speed gradient
  19231. * @param gradient defines the gradient to remove
  19232. * @returns the current particle system
  19233. */
  19234. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19235. /**
  19236. * Gets the current list of velocity gradients.
  19237. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19238. * @returns the list of velocity gradients
  19239. */
  19240. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19241. /**
  19242. * Adds a new velocity gradient
  19243. * @param gradient defines the gradient to use (between 0 and 1)
  19244. * @param factor defines the velocity to affect to the specified gradient
  19245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19246. * @returns the current particle system
  19247. */
  19248. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19249. /**
  19250. * Remove a specific velocity gradient
  19251. * @param gradient defines the gradient to remove
  19252. * @returns the current particle system
  19253. */
  19254. removeVelocityGradient(gradient: number): IParticleSystem;
  19255. /**
  19256. * Gets the current list of limit velocity gradients.
  19257. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19258. * @returns the list of limit velocity gradients
  19259. */
  19260. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19261. /**
  19262. * Adds a new limit velocity gradient
  19263. * @param gradient defines the gradient to use (between 0 and 1)
  19264. * @param factor defines the limit velocity to affect to the specified gradient
  19265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19266. * @returns the current particle system
  19267. */
  19268. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19269. /**
  19270. * Remove a specific limit velocity gradient
  19271. * @param gradient defines the gradient to remove
  19272. * @returns the current particle system
  19273. */
  19274. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19275. /**
  19276. * Adds a new drag gradient
  19277. * @param gradient defines the gradient to use (between 0 and 1)
  19278. * @param factor defines the drag to affect to the specified gradient
  19279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19280. * @returns the current particle system
  19281. */
  19282. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19283. /**
  19284. * Remove a specific drag gradient
  19285. * @param gradient defines the gradient to remove
  19286. * @returns the current particle system
  19287. */
  19288. removeDragGradient(gradient: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of drag gradients.
  19291. * You must use addDragGradient and removeDragGradient to udpate this list
  19292. * @returns the list of drag gradients
  19293. */
  19294. getDragGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19297. * @param gradient defines the gradient to use (between 0 and 1)
  19298. * @param factor defines the emit rate to affect to the specified gradient
  19299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19300. * @returns the current particle system
  19301. */
  19302. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19303. /**
  19304. * Remove a specific emit rate gradient
  19305. * @param gradient defines the gradient to remove
  19306. * @returns the current particle system
  19307. */
  19308. removeEmitRateGradient(gradient: number): IParticleSystem;
  19309. /**
  19310. * Gets the current list of emit rate gradients.
  19311. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19312. * @returns the list of emit rate gradients
  19313. */
  19314. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19315. /**
  19316. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19317. * @param gradient defines the gradient to use (between 0 and 1)
  19318. * @param factor defines the start size to affect to the specified gradient
  19319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19320. * @returns the current particle system
  19321. */
  19322. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19323. /**
  19324. * Remove a specific start size gradient
  19325. * @param gradient defines the gradient to remove
  19326. * @returns the current particle system
  19327. */
  19328. removeStartSizeGradient(gradient: number): IParticleSystem;
  19329. /**
  19330. * Gets the current list of start size gradients.
  19331. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19332. * @returns the list of start size gradients
  19333. */
  19334. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19335. /**
  19336. * Adds a new life time gradient
  19337. * @param gradient defines the gradient to use (between 0 and 1)
  19338. * @param factor defines the life time factor to affect to the specified gradient
  19339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19340. * @returns the current particle system
  19341. */
  19342. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19343. /**
  19344. * Remove a specific life time gradient
  19345. * @param gradient defines the gradient to remove
  19346. * @returns the current particle system
  19347. */
  19348. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19349. /**
  19350. * Gets the current list of life time gradients.
  19351. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19352. * @returns the list of life time gradients
  19353. */
  19354. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19355. /**
  19356. * Gets the current list of color gradients.
  19357. * You must use addColorGradient and removeColorGradient to udpate this list
  19358. * @returns the list of color gradients
  19359. */
  19360. getColorGradients(): Nullable<Array<ColorGradient>>;
  19361. /**
  19362. * Adds a new ramp gradient used to remap particle colors
  19363. * @param gradient defines the gradient to use (between 0 and 1)
  19364. * @param color defines the color to affect to the specified gradient
  19365. * @returns the current particle system
  19366. */
  19367. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19368. /**
  19369. * Gets the current list of ramp gradients.
  19370. * You must use addRampGradient and removeRampGradient to udpate this list
  19371. * @returns the list of ramp gradients
  19372. */
  19373. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19374. /** Gets or sets a boolean indicating that ramp gradients must be used
  19375. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19376. */
  19377. useRampGradients: boolean;
  19378. /**
  19379. * Adds a new color remap gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param min defines the color remap minimal range
  19382. * @param max defines the color remap maximal range
  19383. * @returns the current particle system
  19384. */
  19385. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19386. /**
  19387. * Gets the current list of color remap gradients.
  19388. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19389. * @returns the list of color remap gradients
  19390. */
  19391. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19392. /**
  19393. * Adds a new alpha remap gradient
  19394. * @param gradient defines the gradient to use (between 0 and 1)
  19395. * @param min defines the alpha remap minimal range
  19396. * @param max defines the alpha remap maximal range
  19397. * @returns the current particle system
  19398. */
  19399. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19400. /**
  19401. * Gets the current list of alpha remap gradients.
  19402. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19403. * @returns the list of alpha remap gradients
  19404. */
  19405. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19406. /**
  19407. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19410. * @returns the emitter
  19411. */
  19412. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19413. /**
  19414. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19415. * @param radius The radius of the hemisphere to emit from
  19416. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19417. * @returns the emitter
  19418. */
  19419. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19420. /**
  19421. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19422. * @param radius The radius of the sphere to emit from
  19423. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19424. * @returns the emitter
  19425. */
  19426. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19427. /**
  19428. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19429. * @param radius The radius of the sphere to emit from
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19432. * @returns the emitter
  19433. */
  19434. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19435. /**
  19436. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19437. * @param radius The radius of the emission cylinder
  19438. * @param height The height of the emission cylinder
  19439. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19440. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19441. * @returns the emitter
  19442. */
  19443. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19444. /**
  19445. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19446. * @param radius The radius of the cylinder to emit from
  19447. * @param height The height of the emission cylinder
  19448. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19449. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19450. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19451. * @returns the emitter
  19452. */
  19453. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19454. /**
  19455. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19456. * @param radius The radius of the cone to emit from
  19457. * @param angle The base angle of the cone
  19458. * @returns the emitter
  19459. */
  19460. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19461. /**
  19462. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19465. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19466. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19467. * @returns the emitter
  19468. */
  19469. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19470. /**
  19471. * Get hosting scene
  19472. * @returns the scene
  19473. */
  19474. getScene(): Scene;
  19475. }
  19476. }
  19477. declare module "babylonjs/Meshes/instancedMesh" {
  19478. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19479. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19480. import { Camera } from "babylonjs/Cameras/camera";
  19481. import { Node } from "babylonjs/node";
  19482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19483. import { Mesh } from "babylonjs/Meshes/mesh";
  19484. import { Material } from "babylonjs/Materials/material";
  19485. import { Skeleton } from "babylonjs/Bones/skeleton";
  19486. import { Light } from "babylonjs/Lights/light";
  19487. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19488. /**
  19489. * Creates an instance based on a source mesh.
  19490. */
  19491. export class InstancedMesh extends AbstractMesh {
  19492. private _sourceMesh;
  19493. private _currentLOD;
  19494. /** @hidden */
  19495. _indexInSourceMeshInstanceArray: number;
  19496. constructor(name: string, source: Mesh);
  19497. /**
  19498. * Returns the string "InstancedMesh".
  19499. */
  19500. getClassName(): string;
  19501. /** Gets the list of lights affecting that mesh */
  19502. readonly lightSources: Light[];
  19503. _resyncLightSources(): void;
  19504. _resyncLighSource(light: Light): void;
  19505. _removeLightSource(light: Light, dispose: boolean): void;
  19506. /**
  19507. * If the source mesh receives shadows
  19508. */
  19509. readonly receiveShadows: boolean;
  19510. /**
  19511. * The material of the source mesh
  19512. */
  19513. readonly material: Nullable<Material>;
  19514. /**
  19515. * Visibility of the source mesh
  19516. */
  19517. readonly visibility: number;
  19518. /**
  19519. * Skeleton of the source mesh
  19520. */
  19521. readonly skeleton: Nullable<Skeleton>;
  19522. /**
  19523. * Rendering ground id of the source mesh
  19524. */
  19525. renderingGroupId: number;
  19526. /**
  19527. * Returns the total number of vertices (integer).
  19528. */
  19529. getTotalVertices(): number;
  19530. /**
  19531. * Returns a positive integer : the total number of indices in this mesh geometry.
  19532. * @returns the numner of indices or zero if the mesh has no geometry.
  19533. */
  19534. getTotalIndices(): number;
  19535. /**
  19536. * The source mesh of the instance
  19537. */
  19538. readonly sourceMesh: Mesh;
  19539. /**
  19540. * Is this node ready to be used/rendered
  19541. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19542. * @return {boolean} is it ready
  19543. */
  19544. isReady(completeCheck?: boolean): boolean;
  19545. /**
  19546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19547. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19548. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19549. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19550. */
  19551. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19552. /**
  19553. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19554. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19555. * The `data` are either a numeric array either a Float32Array.
  19556. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19557. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19558. * Note that a new underlying VertexBuffer object is created each call.
  19559. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19560. *
  19561. * Possible `kind` values :
  19562. * - VertexBuffer.PositionKind
  19563. * - VertexBuffer.UVKind
  19564. * - VertexBuffer.UV2Kind
  19565. * - VertexBuffer.UV3Kind
  19566. * - VertexBuffer.UV4Kind
  19567. * - VertexBuffer.UV5Kind
  19568. * - VertexBuffer.UV6Kind
  19569. * - VertexBuffer.ColorKind
  19570. * - VertexBuffer.MatricesIndicesKind
  19571. * - VertexBuffer.MatricesIndicesExtraKind
  19572. * - VertexBuffer.MatricesWeightsKind
  19573. * - VertexBuffer.MatricesWeightsExtraKind
  19574. *
  19575. * Returns the Mesh.
  19576. */
  19577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19578. /**
  19579. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19580. * If the mesh has no geometry, it is simply returned as it is.
  19581. * The `data` are either a numeric array either a Float32Array.
  19582. * No new underlying VertexBuffer object is created.
  19583. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19584. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19585. *
  19586. * Possible `kind` values :
  19587. * - VertexBuffer.PositionKind
  19588. * - VertexBuffer.UVKind
  19589. * - VertexBuffer.UV2Kind
  19590. * - VertexBuffer.UV3Kind
  19591. * - VertexBuffer.UV4Kind
  19592. * - VertexBuffer.UV5Kind
  19593. * - VertexBuffer.UV6Kind
  19594. * - VertexBuffer.ColorKind
  19595. * - VertexBuffer.MatricesIndicesKind
  19596. * - VertexBuffer.MatricesIndicesExtraKind
  19597. * - VertexBuffer.MatricesWeightsKind
  19598. * - VertexBuffer.MatricesWeightsExtraKind
  19599. *
  19600. * Returns the Mesh.
  19601. */
  19602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19603. /**
  19604. * Sets the mesh indices.
  19605. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19606. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19607. * This method creates a new index buffer each call.
  19608. * Returns the Mesh.
  19609. */
  19610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19611. /**
  19612. * Boolean : True if the mesh owns the requested kind of data.
  19613. */
  19614. isVerticesDataPresent(kind: string): boolean;
  19615. /**
  19616. * Returns an array of indices (IndicesArray).
  19617. */
  19618. getIndices(): Nullable<IndicesArray>;
  19619. readonly _positions: Nullable<Vector3[]>;
  19620. /**
  19621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19622. * This means the mesh underlying bounding box and sphere are recomputed.
  19623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19624. * @returns the current mesh
  19625. */
  19626. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19627. /** @hidden */
  19628. _preActivate(): InstancedMesh;
  19629. /** @hidden */
  19630. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19631. /** @hidden */
  19632. _postActivate(): void;
  19633. getWorldMatrix(): Matrix;
  19634. readonly isAnInstance: boolean;
  19635. /**
  19636. * Returns the current associated LOD AbstractMesh.
  19637. */
  19638. getLOD(camera: Camera): AbstractMesh;
  19639. /** @hidden */
  19640. _syncSubMeshes(): InstancedMesh;
  19641. /** @hidden */
  19642. _generatePointsArray(): boolean;
  19643. /**
  19644. * Creates a new InstancedMesh from the current mesh.
  19645. * - name (string) : the cloned mesh name
  19646. * - newParent (optional Node) : the optional Node to parent the clone to.
  19647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19648. *
  19649. * Returns the clone.
  19650. */
  19651. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19652. /**
  19653. * Disposes the InstancedMesh.
  19654. * Returns nothing.
  19655. */
  19656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19657. }
  19658. module "babylonjs/Meshes/mesh" {
  19659. interface Mesh {
  19660. /**
  19661. * Register a custom buffer that will be instanced
  19662. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19663. * @param kind defines the buffer kind
  19664. * @param stride defines the stride in floats
  19665. */
  19666. registerInstancedBuffer(kind: string, stride: number): void;
  19667. /** @hidden */
  19668. _userInstancedBuffersStorage: {
  19669. data: {
  19670. [key: string]: Float32Array;
  19671. };
  19672. sizes: {
  19673. [key: string]: number;
  19674. };
  19675. vertexBuffers: {
  19676. [key: string]: Nullable<VertexBuffer>;
  19677. };
  19678. strides: {
  19679. [key: string]: number;
  19680. };
  19681. };
  19682. }
  19683. }
  19684. module "babylonjs/Meshes/abstractMesh" {
  19685. interface AbstractMesh {
  19686. /**
  19687. * Object used to store instanced buffers defined by user
  19688. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19689. */
  19690. instancedBuffers: {
  19691. [key: string]: any;
  19692. };
  19693. }
  19694. }
  19695. }
  19696. declare module "babylonjs/Materials/shaderMaterial" {
  19697. import { Scene } from "babylonjs/scene";
  19698. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19700. import { Mesh } from "babylonjs/Meshes/mesh";
  19701. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19703. import { Texture } from "babylonjs/Materials/Textures/texture";
  19704. import { Material } from "babylonjs/Materials/material";
  19705. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19706. /**
  19707. * Defines the options associated with the creation of a shader material.
  19708. */
  19709. export interface IShaderMaterialOptions {
  19710. /**
  19711. * Does the material work in alpha blend mode
  19712. */
  19713. needAlphaBlending: boolean;
  19714. /**
  19715. * Does the material work in alpha test mode
  19716. */
  19717. needAlphaTesting: boolean;
  19718. /**
  19719. * The list of attribute names used in the shader
  19720. */
  19721. attributes: string[];
  19722. /**
  19723. * The list of unifrom names used in the shader
  19724. */
  19725. uniforms: string[];
  19726. /**
  19727. * The list of UBO names used in the shader
  19728. */
  19729. uniformBuffers: string[];
  19730. /**
  19731. * The list of sampler names used in the shader
  19732. */
  19733. samplers: string[];
  19734. /**
  19735. * The list of defines used in the shader
  19736. */
  19737. defines: string[];
  19738. }
  19739. /**
  19740. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19741. *
  19742. * This returned material effects how the mesh will look based on the code in the shaders.
  19743. *
  19744. * @see http://doc.babylonjs.com/how_to/shader_material
  19745. */
  19746. export class ShaderMaterial extends Material {
  19747. private _shaderPath;
  19748. private _options;
  19749. private _textures;
  19750. private _textureArrays;
  19751. private _floats;
  19752. private _ints;
  19753. private _floatsArrays;
  19754. private _colors3;
  19755. private _colors3Arrays;
  19756. private _colors4;
  19757. private _colors4Arrays;
  19758. private _vectors2;
  19759. private _vectors3;
  19760. private _vectors4;
  19761. private _matrices;
  19762. private _matrixArrays;
  19763. private _matrices3x3;
  19764. private _matrices2x2;
  19765. private _vectors2Arrays;
  19766. private _vectors3Arrays;
  19767. private _vectors4Arrays;
  19768. private _cachedWorldViewMatrix;
  19769. private _cachedWorldViewProjectionMatrix;
  19770. private _renderId;
  19771. /**
  19772. * Instantiate a new shader material.
  19773. * 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.
  19774. * This returned material effects how the mesh will look based on the code in the shaders.
  19775. * @see http://doc.babylonjs.com/how_to/shader_material
  19776. * @param name Define the name of the material in the scene
  19777. * @param scene Define the scene the material belongs to
  19778. * @param shaderPath Defines the route to the shader code in one of three ways:
  19779. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19780. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19781. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19782. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19783. * @param options Define the options used to create the shader
  19784. */
  19785. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19786. /**
  19787. * Gets the shader path used to define the shader code
  19788. * It can be modified to trigger a new compilation
  19789. */
  19790. /**
  19791. * Sets the shader path used to define the shader code
  19792. * It can be modified to trigger a new compilation
  19793. */
  19794. shaderPath: any;
  19795. /**
  19796. * Gets the options used to compile the shader.
  19797. * They can be modified to trigger a new compilation
  19798. */
  19799. readonly options: IShaderMaterialOptions;
  19800. /**
  19801. * Gets the current class name of the material e.g. "ShaderMaterial"
  19802. * Mainly use in serialization.
  19803. * @returns the class name
  19804. */
  19805. getClassName(): string;
  19806. /**
  19807. * Specifies if the material will require alpha blending
  19808. * @returns a boolean specifying if alpha blending is needed
  19809. */
  19810. needAlphaBlending(): boolean;
  19811. /**
  19812. * Specifies if this material should be rendered in alpha test mode
  19813. * @returns a boolean specifying if an alpha test is needed.
  19814. */
  19815. needAlphaTesting(): boolean;
  19816. private _checkUniform;
  19817. /**
  19818. * Set a texture in the shader.
  19819. * @param name Define the name of the uniform samplers as defined in the shader
  19820. * @param texture Define the texture to bind to this sampler
  19821. * @return the material itself allowing "fluent" like uniform updates
  19822. */
  19823. setTexture(name: string, texture: Texture): ShaderMaterial;
  19824. /**
  19825. * Set a texture array in the shader.
  19826. * @param name Define the name of the uniform sampler array as defined in the shader
  19827. * @param textures Define the list of textures to bind to this sampler
  19828. * @return the material itself allowing "fluent" like uniform updates
  19829. */
  19830. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19831. /**
  19832. * Set a float in the shader.
  19833. * @param name Define the name of the uniform as defined in the shader
  19834. * @param value Define the value to give to the uniform
  19835. * @return the material itself allowing "fluent" like uniform updates
  19836. */
  19837. setFloat(name: string, value: number): ShaderMaterial;
  19838. /**
  19839. * Set a int in the shader.
  19840. * @param name Define the name of the uniform as defined in the shader
  19841. * @param value Define the value to give to the uniform
  19842. * @return the material itself allowing "fluent" like uniform updates
  19843. */
  19844. setInt(name: string, value: number): ShaderMaterial;
  19845. /**
  19846. * Set an array of floats in the shader.
  19847. * @param name Define the name of the uniform as defined in the shader
  19848. * @param value Define the value to give to the uniform
  19849. * @return the material itself allowing "fluent" like uniform updates
  19850. */
  19851. setFloats(name: string, value: number[]): ShaderMaterial;
  19852. /**
  19853. * Set a vec3 in the shader from a Color3.
  19854. * @param name Define the name of the uniform as defined in the shader
  19855. * @param value Define the value to give to the uniform
  19856. * @return the material itself allowing "fluent" like uniform updates
  19857. */
  19858. setColor3(name: string, value: Color3): ShaderMaterial;
  19859. /**
  19860. * Set a vec3 array in the shader from a Color3 array.
  19861. * @param name Define the name of the uniform as defined in the shader
  19862. * @param value Define the value to give to the uniform
  19863. * @return the material itself allowing "fluent" like uniform updates
  19864. */
  19865. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19866. /**
  19867. * Set a vec4 in the shader from a Color4.
  19868. * @param name Define the name of the uniform as defined in the shader
  19869. * @param value Define the value to give to the uniform
  19870. * @return the material itself allowing "fluent" like uniform updates
  19871. */
  19872. setColor4(name: string, value: Color4): ShaderMaterial;
  19873. /**
  19874. * Set a vec4 array in the shader from a Color4 array.
  19875. * @param name Define the name of the uniform as defined in the shader
  19876. * @param value Define the value to give to the uniform
  19877. * @return the material itself allowing "fluent" like uniform updates
  19878. */
  19879. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19880. /**
  19881. * Set a vec2 in the shader from a Vector2.
  19882. * @param name Define the name of the uniform as defined in the shader
  19883. * @param value Define the value to give to the uniform
  19884. * @return the material itself allowing "fluent" like uniform updates
  19885. */
  19886. setVector2(name: string, value: Vector2): ShaderMaterial;
  19887. /**
  19888. * Set a vec3 in the shader from a Vector3.
  19889. * @param name Define the name of the uniform as defined in the shader
  19890. * @param value Define the value to give to the uniform
  19891. * @return the material itself allowing "fluent" like uniform updates
  19892. */
  19893. setVector3(name: string, value: Vector3): ShaderMaterial;
  19894. /**
  19895. * Set a vec4 in the shader from a Vector4.
  19896. * @param name Define the name of the uniform as defined in the shader
  19897. * @param value Define the value to give to the uniform
  19898. * @return the material itself allowing "fluent" like uniform updates
  19899. */
  19900. setVector4(name: string, value: Vector4): ShaderMaterial;
  19901. /**
  19902. * Set a mat4 in the shader from a Matrix.
  19903. * @param name Define the name of the uniform as defined in the shader
  19904. * @param value Define the value to give to the uniform
  19905. * @return the material itself allowing "fluent" like uniform updates
  19906. */
  19907. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19908. /**
  19909. * Set a float32Array in the shader from a matrix array.
  19910. * @param name Define the name of the uniform as defined in the shader
  19911. * @param value Define the value to give to the uniform
  19912. * @return the material itself allowing "fluent" like uniform updates
  19913. */
  19914. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19915. /**
  19916. * Set a mat3 in the shader from a Float32Array.
  19917. * @param name Define the name of the uniform as defined in the shader
  19918. * @param value Define the value to give to the uniform
  19919. * @return the material itself allowing "fluent" like uniform updates
  19920. */
  19921. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19922. /**
  19923. * Set a mat2 in the shader from a Float32Array.
  19924. * @param name Define the name of the uniform as defined in the shader
  19925. * @param value Define the value to give to the uniform
  19926. * @return the material itself allowing "fluent" like uniform updates
  19927. */
  19928. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19929. /**
  19930. * Set a vec2 array in the shader from a number array.
  19931. * @param name Define the name of the uniform as defined in the shader
  19932. * @param value Define the value to give to the uniform
  19933. * @return the material itself allowing "fluent" like uniform updates
  19934. */
  19935. setArray2(name: string, value: number[]): ShaderMaterial;
  19936. /**
  19937. * Set a vec3 array in the shader from a number array.
  19938. * @param name Define the name of the uniform as defined in the shader
  19939. * @param value Define the value to give to the uniform
  19940. * @return the material itself allowing "fluent" like uniform updates
  19941. */
  19942. setArray3(name: string, value: number[]): ShaderMaterial;
  19943. /**
  19944. * Set a vec4 array in the shader from a number array.
  19945. * @param name Define the name of the uniform as defined in the shader
  19946. * @param value Define the value to give to the uniform
  19947. * @return the material itself allowing "fluent" like uniform updates
  19948. */
  19949. setArray4(name: string, value: number[]): ShaderMaterial;
  19950. private _checkCache;
  19951. /**
  19952. * Specifies that the submesh is ready to be used
  19953. * @param mesh defines the mesh to check
  19954. * @param subMesh defines which submesh to check
  19955. * @param useInstances specifies that instances should be used
  19956. * @returns a boolean indicating that the submesh is ready or not
  19957. */
  19958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19959. /**
  19960. * Checks if the material is ready to render the requested mesh
  19961. * @param mesh Define the mesh to render
  19962. * @param useInstances Define whether or not the material is used with instances
  19963. * @returns true if ready, otherwise false
  19964. */
  19965. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19966. /**
  19967. * Binds the world matrix to the material
  19968. * @param world defines the world transformation matrix
  19969. */
  19970. bindOnlyWorldMatrix(world: Matrix): void;
  19971. /**
  19972. * Binds the material to the mesh
  19973. * @param world defines the world transformation matrix
  19974. * @param mesh defines the mesh to bind the material to
  19975. */
  19976. bind(world: Matrix, mesh?: Mesh): void;
  19977. /**
  19978. * Gets the active textures from the material
  19979. * @returns an array of textures
  19980. */
  19981. getActiveTextures(): BaseTexture[];
  19982. /**
  19983. * Specifies if the material uses a texture
  19984. * @param texture defines the texture to check against the material
  19985. * @returns a boolean specifying if the material uses the texture
  19986. */
  19987. hasTexture(texture: BaseTexture): boolean;
  19988. /**
  19989. * Makes a duplicate of the material, and gives it a new name
  19990. * @param name defines the new name for the duplicated material
  19991. * @returns the cloned material
  19992. */
  19993. clone(name: string): ShaderMaterial;
  19994. /**
  19995. * Disposes the material
  19996. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19997. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19998. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19999. */
  20000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20001. /**
  20002. * Serializes this material in a JSON representation
  20003. * @returns the serialized material object
  20004. */
  20005. serialize(): any;
  20006. /**
  20007. * Creates a shader material from parsed shader material data
  20008. * @param source defines the JSON represnetation of the material
  20009. * @param scene defines the hosting scene
  20010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20011. * @returns a new material
  20012. */
  20013. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20014. }
  20015. }
  20016. declare module "babylonjs/Shaders/color.fragment" {
  20017. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20018. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20019. /** @hidden */
  20020. export var colorPixelShader: {
  20021. name: string;
  20022. shader: string;
  20023. };
  20024. }
  20025. declare module "babylonjs/Shaders/color.vertex" {
  20026. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20027. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20028. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20029. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20030. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20032. /** @hidden */
  20033. export var colorVertexShader: {
  20034. name: string;
  20035. shader: string;
  20036. };
  20037. }
  20038. declare module "babylonjs/Meshes/linesMesh" {
  20039. import { Nullable } from "babylonjs/types";
  20040. import { Scene } from "babylonjs/scene";
  20041. import { Color3 } from "babylonjs/Maths/math.color";
  20042. import { Node } from "babylonjs/node";
  20043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20044. import { Mesh } from "babylonjs/Meshes/mesh";
  20045. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20046. import { Effect } from "babylonjs/Materials/effect";
  20047. import { Material } from "babylonjs/Materials/material";
  20048. import "babylonjs/Shaders/color.fragment";
  20049. import "babylonjs/Shaders/color.vertex";
  20050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20051. /**
  20052. * Line mesh
  20053. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20054. */
  20055. export class LinesMesh extends Mesh {
  20056. /**
  20057. * If vertex color should be applied to the mesh
  20058. */
  20059. readonly useVertexColor?: boolean | undefined;
  20060. /**
  20061. * If vertex alpha should be applied to the mesh
  20062. */
  20063. readonly useVertexAlpha?: boolean | undefined;
  20064. /**
  20065. * Color of the line (Default: White)
  20066. */
  20067. color: Color3;
  20068. /**
  20069. * Alpha of the line (Default: 1)
  20070. */
  20071. alpha: number;
  20072. /**
  20073. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20074. * This margin is expressed in world space coordinates, so its value may vary.
  20075. * Default value is 0.1
  20076. */
  20077. intersectionThreshold: number;
  20078. private _colorShader;
  20079. private color4;
  20080. /**
  20081. * Creates a new LinesMesh
  20082. * @param name defines the name
  20083. * @param scene defines the hosting scene
  20084. * @param parent defines the parent mesh if any
  20085. * @param source defines the optional source LinesMesh used to clone data from
  20086. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20087. * When false, achieved by calling a clone(), also passing False.
  20088. * This will make creation of children, recursive.
  20089. * @param useVertexColor defines if this LinesMesh supports vertex color
  20090. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20091. */
  20092. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20093. /**
  20094. * If vertex color should be applied to the mesh
  20095. */
  20096. useVertexColor?: boolean | undefined,
  20097. /**
  20098. * If vertex alpha should be applied to the mesh
  20099. */
  20100. useVertexAlpha?: boolean | undefined);
  20101. private _addClipPlaneDefine;
  20102. private _removeClipPlaneDefine;
  20103. isReady(): boolean;
  20104. /**
  20105. * Returns the string "LineMesh"
  20106. */
  20107. getClassName(): string;
  20108. /**
  20109. * @hidden
  20110. */
  20111. /**
  20112. * @hidden
  20113. */
  20114. material: Material;
  20115. /**
  20116. * @hidden
  20117. */
  20118. readonly checkCollisions: boolean;
  20119. /** @hidden */
  20120. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20121. /** @hidden */
  20122. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20123. /**
  20124. * Disposes of the line mesh
  20125. * @param doNotRecurse If children should be disposed
  20126. */
  20127. dispose(doNotRecurse?: boolean): void;
  20128. /**
  20129. * Returns a new LineMesh object cloned from the current one.
  20130. */
  20131. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20132. /**
  20133. * Creates a new InstancedLinesMesh object from the mesh model.
  20134. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20135. * @param name defines the name of the new instance
  20136. * @returns a new InstancedLinesMesh
  20137. */
  20138. createInstance(name: string): InstancedLinesMesh;
  20139. }
  20140. /**
  20141. * Creates an instance based on a source LinesMesh
  20142. */
  20143. export class InstancedLinesMesh extends InstancedMesh {
  20144. /**
  20145. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20146. * This margin is expressed in world space coordinates, so its value may vary.
  20147. * Initilized with the intersectionThreshold value of the source LinesMesh
  20148. */
  20149. intersectionThreshold: number;
  20150. constructor(name: string, source: LinesMesh);
  20151. /**
  20152. * Returns the string "InstancedLinesMesh".
  20153. */
  20154. getClassName(): string;
  20155. }
  20156. }
  20157. declare module "babylonjs/Shaders/line.fragment" {
  20158. /** @hidden */
  20159. export var linePixelShader: {
  20160. name: string;
  20161. shader: string;
  20162. };
  20163. }
  20164. declare module "babylonjs/Shaders/line.vertex" {
  20165. /** @hidden */
  20166. export var lineVertexShader: {
  20167. name: string;
  20168. shader: string;
  20169. };
  20170. }
  20171. declare module "babylonjs/Rendering/edgesRenderer" {
  20172. import { Nullable } from "babylonjs/types";
  20173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { Vector3 } from "babylonjs/Maths/math.vector";
  20176. import { IDisposable } from "babylonjs/scene";
  20177. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20178. import "babylonjs/Shaders/line.fragment";
  20179. import "babylonjs/Shaders/line.vertex";
  20180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20181. module "babylonjs/Meshes/abstractMesh" {
  20182. interface AbstractMesh {
  20183. /**
  20184. * Gets the edgesRenderer associated with the mesh
  20185. */
  20186. edgesRenderer: Nullable<EdgesRenderer>;
  20187. }
  20188. }
  20189. module "babylonjs/Meshes/linesMesh" {
  20190. interface LinesMesh {
  20191. /**
  20192. * Enables the edge rendering mode on the mesh.
  20193. * This mode makes the mesh edges visible
  20194. * @param epsilon defines the maximal distance between two angles to detect a face
  20195. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20196. * @returns the currentAbstractMesh
  20197. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20198. */
  20199. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20200. }
  20201. }
  20202. module "babylonjs/Meshes/linesMesh" {
  20203. interface InstancedLinesMesh {
  20204. /**
  20205. * Enables the edge rendering mode on the mesh.
  20206. * This mode makes the mesh edges visible
  20207. * @param epsilon defines the maximal distance between two angles to detect a face
  20208. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20209. * @returns the current InstancedLinesMesh
  20210. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20211. */
  20212. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20213. }
  20214. }
  20215. /**
  20216. * Defines the minimum contract an Edges renderer should follow.
  20217. */
  20218. export interface IEdgesRenderer extends IDisposable {
  20219. /**
  20220. * Gets or sets a boolean indicating if the edgesRenderer is active
  20221. */
  20222. isEnabled: boolean;
  20223. /**
  20224. * Renders the edges of the attached mesh,
  20225. */
  20226. render(): void;
  20227. /**
  20228. * Checks wether or not the edges renderer is ready to render.
  20229. * @return true if ready, otherwise false.
  20230. */
  20231. isReady(): boolean;
  20232. }
  20233. /**
  20234. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20235. */
  20236. export class EdgesRenderer implements IEdgesRenderer {
  20237. /**
  20238. * Define the size of the edges with an orthographic camera
  20239. */
  20240. edgesWidthScalerForOrthographic: number;
  20241. /**
  20242. * Define the size of the edges with a perspective camera
  20243. */
  20244. edgesWidthScalerForPerspective: number;
  20245. protected _source: AbstractMesh;
  20246. protected _linesPositions: number[];
  20247. protected _linesNormals: number[];
  20248. protected _linesIndices: number[];
  20249. protected _epsilon: number;
  20250. protected _indicesCount: number;
  20251. protected _lineShader: ShaderMaterial;
  20252. protected _ib: DataBuffer;
  20253. protected _buffers: {
  20254. [key: string]: Nullable<VertexBuffer>;
  20255. };
  20256. protected _checkVerticesInsteadOfIndices: boolean;
  20257. private _meshRebuildObserver;
  20258. private _meshDisposeObserver;
  20259. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20260. isEnabled: boolean;
  20261. /**
  20262. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20263. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20264. * @param source Mesh used to create edges
  20265. * @param epsilon sum of angles in adjacency to check for edge
  20266. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20267. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20268. */
  20269. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20270. protected _prepareRessources(): void;
  20271. /** @hidden */
  20272. _rebuild(): void;
  20273. /**
  20274. * Releases the required resources for the edges renderer
  20275. */
  20276. dispose(): void;
  20277. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20278. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20279. /**
  20280. * Checks if the pair of p0 and p1 is en edge
  20281. * @param faceIndex
  20282. * @param edge
  20283. * @param faceNormals
  20284. * @param p0
  20285. * @param p1
  20286. * @private
  20287. */
  20288. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20289. /**
  20290. * push line into the position, normal and index buffer
  20291. * @protected
  20292. */
  20293. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20294. /**
  20295. * Generates lines edges from adjacencjes
  20296. * @private
  20297. */
  20298. _generateEdgesLines(): void;
  20299. /**
  20300. * Checks wether or not the edges renderer is ready to render.
  20301. * @return true if ready, otherwise false.
  20302. */
  20303. isReady(): boolean;
  20304. /**
  20305. * Renders the edges of the attached mesh,
  20306. */
  20307. render(): void;
  20308. }
  20309. /**
  20310. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20311. */
  20312. export class LineEdgesRenderer extends EdgesRenderer {
  20313. /**
  20314. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20315. * @param source LineMesh used to generate edges
  20316. * @param epsilon not important (specified angle for edge detection)
  20317. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20318. */
  20319. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20320. /**
  20321. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20322. */
  20323. _generateEdgesLines(): void;
  20324. }
  20325. }
  20326. declare module "babylonjs/Rendering/renderingGroup" {
  20327. import { SmartArray } from "babylonjs/Misc/smartArray";
  20328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20330. import { Nullable } from "babylonjs/types";
  20331. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20332. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20333. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20334. import { Material } from "babylonjs/Materials/material";
  20335. import { Scene } from "babylonjs/scene";
  20336. /**
  20337. * This represents the object necessary to create a rendering group.
  20338. * This is exclusively used and created by the rendering manager.
  20339. * To modify the behavior, you use the available helpers in your scene or meshes.
  20340. * @hidden
  20341. */
  20342. export class RenderingGroup {
  20343. index: number;
  20344. private static _zeroVector;
  20345. private _scene;
  20346. private _opaqueSubMeshes;
  20347. private _transparentSubMeshes;
  20348. private _alphaTestSubMeshes;
  20349. private _depthOnlySubMeshes;
  20350. private _particleSystems;
  20351. private _spriteManagers;
  20352. private _opaqueSortCompareFn;
  20353. private _alphaTestSortCompareFn;
  20354. private _transparentSortCompareFn;
  20355. private _renderOpaque;
  20356. private _renderAlphaTest;
  20357. private _renderTransparent;
  20358. /** @hidden */
  20359. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20360. onBeforeTransparentRendering: () => void;
  20361. /**
  20362. * Set the opaque sort comparison function.
  20363. * If null the sub meshes will be render in the order they were created
  20364. */
  20365. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20366. /**
  20367. * Set the alpha test sort comparison function.
  20368. * If null the sub meshes will be render in the order they were created
  20369. */
  20370. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20371. /**
  20372. * Set the transparent sort comparison function.
  20373. * If null the sub meshes will be render in the order they were created
  20374. */
  20375. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20376. /**
  20377. * Creates a new rendering group.
  20378. * @param index The rendering group index
  20379. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20380. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20381. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20382. */
  20383. 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>);
  20384. /**
  20385. * Render all the sub meshes contained in the group.
  20386. * @param customRenderFunction Used to override the default render behaviour of the group.
  20387. * @returns true if rendered some submeshes.
  20388. */
  20389. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20390. /**
  20391. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20392. * @param subMeshes The submeshes to render
  20393. */
  20394. private renderOpaqueSorted;
  20395. /**
  20396. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20397. * @param subMeshes The submeshes to render
  20398. */
  20399. private renderAlphaTestSorted;
  20400. /**
  20401. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20402. * @param subMeshes The submeshes to render
  20403. */
  20404. private renderTransparentSorted;
  20405. /**
  20406. * Renders the submeshes in a specified order.
  20407. * @param subMeshes The submeshes to sort before render
  20408. * @param sortCompareFn The comparison function use to sort
  20409. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20410. * @param transparent Specifies to activate blending if true
  20411. */
  20412. private static renderSorted;
  20413. /**
  20414. * Renders the submeshes in the order they were dispatched (no sort applied).
  20415. * @param subMeshes The submeshes to render
  20416. */
  20417. private static renderUnsorted;
  20418. /**
  20419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20420. * are rendered back to front if in the same alpha index.
  20421. *
  20422. * @param a The first submesh
  20423. * @param b The second submesh
  20424. * @returns The result of the comparison
  20425. */
  20426. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20427. /**
  20428. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20429. * are rendered back to front.
  20430. *
  20431. * @param a The first submesh
  20432. * @param b The second submesh
  20433. * @returns The result of the comparison
  20434. */
  20435. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20436. /**
  20437. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20438. * are rendered front to back (prevent overdraw).
  20439. *
  20440. * @param a The first submesh
  20441. * @param b The second submesh
  20442. * @returns The result of the comparison
  20443. */
  20444. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20445. /**
  20446. * Resets the different lists of submeshes to prepare a new frame.
  20447. */
  20448. prepare(): void;
  20449. dispose(): void;
  20450. /**
  20451. * Inserts the submesh in its correct queue depending on its material.
  20452. * @param subMesh The submesh to dispatch
  20453. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20454. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20455. */
  20456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20457. dispatchSprites(spriteManager: ISpriteManager): void;
  20458. dispatchParticles(particleSystem: IParticleSystem): void;
  20459. private _renderParticles;
  20460. private _renderSprites;
  20461. }
  20462. }
  20463. declare module "babylonjs/Rendering/renderingManager" {
  20464. import { Nullable } from "babylonjs/types";
  20465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20467. import { SmartArray } from "babylonjs/Misc/smartArray";
  20468. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20469. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20470. import { Material } from "babylonjs/Materials/material";
  20471. import { Scene } from "babylonjs/scene";
  20472. import { Camera } from "babylonjs/Cameras/camera";
  20473. /**
  20474. * Interface describing the different options available in the rendering manager
  20475. * regarding Auto Clear between groups.
  20476. */
  20477. export interface IRenderingManagerAutoClearSetup {
  20478. /**
  20479. * Defines whether or not autoclear is enable.
  20480. */
  20481. autoClear: boolean;
  20482. /**
  20483. * Defines whether or not to autoclear the depth buffer.
  20484. */
  20485. depth: boolean;
  20486. /**
  20487. * Defines whether or not to autoclear the stencil buffer.
  20488. */
  20489. stencil: boolean;
  20490. }
  20491. /**
  20492. * This class is used by the onRenderingGroupObservable
  20493. */
  20494. export class RenderingGroupInfo {
  20495. /**
  20496. * The Scene that being rendered
  20497. */
  20498. scene: Scene;
  20499. /**
  20500. * The camera currently used for the rendering pass
  20501. */
  20502. camera: Nullable<Camera>;
  20503. /**
  20504. * The ID of the renderingGroup being processed
  20505. */
  20506. renderingGroupId: number;
  20507. }
  20508. /**
  20509. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20510. * It is enable to manage the different groups as well as the different necessary sort functions.
  20511. * This should not be used directly aside of the few static configurations
  20512. */
  20513. export class RenderingManager {
  20514. /**
  20515. * The max id used for rendering groups (not included)
  20516. */
  20517. static MAX_RENDERINGGROUPS: number;
  20518. /**
  20519. * The min id used for rendering groups (included)
  20520. */
  20521. static MIN_RENDERINGGROUPS: number;
  20522. /**
  20523. * Used to globally prevent autoclearing scenes.
  20524. */
  20525. static AUTOCLEAR: boolean;
  20526. /**
  20527. * @hidden
  20528. */
  20529. _useSceneAutoClearSetup: boolean;
  20530. private _scene;
  20531. private _renderingGroups;
  20532. private _depthStencilBufferAlreadyCleaned;
  20533. private _autoClearDepthStencil;
  20534. private _customOpaqueSortCompareFn;
  20535. private _customAlphaTestSortCompareFn;
  20536. private _customTransparentSortCompareFn;
  20537. private _renderingGroupInfo;
  20538. /**
  20539. * Instantiates a new rendering group for a particular scene
  20540. * @param scene Defines the scene the groups belongs to
  20541. */
  20542. constructor(scene: Scene);
  20543. private _clearDepthStencilBuffer;
  20544. /**
  20545. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20546. * @hidden
  20547. */
  20548. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20549. /**
  20550. * Resets the different information of the group to prepare a new frame
  20551. * @hidden
  20552. */
  20553. reset(): void;
  20554. /**
  20555. * Dispose and release the group and its associated resources.
  20556. * @hidden
  20557. */
  20558. dispose(): void;
  20559. /**
  20560. * Clear the info related to rendering groups preventing retention points during dispose.
  20561. */
  20562. freeRenderingGroups(): void;
  20563. private _prepareRenderingGroup;
  20564. /**
  20565. * Add a sprite manager to the rendering manager in order to render it this frame.
  20566. * @param spriteManager Define the sprite manager to render
  20567. */
  20568. dispatchSprites(spriteManager: ISpriteManager): void;
  20569. /**
  20570. * Add a particle system to the rendering manager in order to render it this frame.
  20571. * @param particleSystem Define the particle system to render
  20572. */
  20573. dispatchParticles(particleSystem: IParticleSystem): void;
  20574. /**
  20575. * Add a submesh to the manager in order to render it this frame
  20576. * @param subMesh The submesh to dispatch
  20577. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20578. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20579. */
  20580. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20581. /**
  20582. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20583. * This allowed control for front to back rendering or reversly depending of the special needs.
  20584. *
  20585. * @param renderingGroupId The rendering group id corresponding to its index
  20586. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20587. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20588. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20589. */
  20590. 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;
  20591. /**
  20592. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20593. *
  20594. * @param renderingGroupId The rendering group id corresponding to its index
  20595. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20596. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20597. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20598. */
  20599. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20600. /**
  20601. * Gets the current auto clear configuration for one rendering group of the rendering
  20602. * manager.
  20603. * @param index the rendering group index to get the information for
  20604. * @returns The auto clear setup for the requested rendering group
  20605. */
  20606. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20607. }
  20608. }
  20609. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20610. import { Observable } from "babylonjs/Misc/observable";
  20611. import { SmartArray } from "babylonjs/Misc/smartArray";
  20612. import { Nullable } from "babylonjs/types";
  20613. import { Camera } from "babylonjs/Cameras/camera";
  20614. import { Scene } from "babylonjs/scene";
  20615. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20616. import { Color4 } from "babylonjs/Maths/math.color";
  20617. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20621. import { Texture } from "babylonjs/Materials/Textures/texture";
  20622. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20623. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20624. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20625. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20626. import { Engine } from "babylonjs/Engines/engine";
  20627. /**
  20628. * This Helps creating a texture that will be created from a camera in your scene.
  20629. * It is basically a dynamic texture that could be used to create special effects for instance.
  20630. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20631. */
  20632. export class RenderTargetTexture extends Texture {
  20633. isCube: boolean;
  20634. /**
  20635. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20636. */
  20637. static readonly REFRESHRATE_RENDER_ONCE: number;
  20638. /**
  20639. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20640. */
  20641. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20642. /**
  20643. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20644. * the central point of your effect and can save a lot of performances.
  20645. */
  20646. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20647. /**
  20648. * Use this predicate to dynamically define the list of mesh you want to render.
  20649. * If set, the renderList property will be overwritten.
  20650. */
  20651. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20652. private _renderList;
  20653. /**
  20654. * Use this list to define the list of mesh you want to render.
  20655. */
  20656. renderList: Nullable<Array<AbstractMesh>>;
  20657. private _hookArray;
  20658. /**
  20659. * Define if particles should be rendered in your texture.
  20660. */
  20661. renderParticles: boolean;
  20662. /**
  20663. * Define if sprites should be rendered in your texture.
  20664. */
  20665. renderSprites: boolean;
  20666. /**
  20667. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20668. */
  20669. coordinatesMode: number;
  20670. /**
  20671. * Define the camera used to render the texture.
  20672. */
  20673. activeCamera: Nullable<Camera>;
  20674. /**
  20675. * Override the render function of the texture with your own one.
  20676. */
  20677. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20678. /**
  20679. * Define if camera post processes should be use while rendering the texture.
  20680. */
  20681. useCameraPostProcesses: boolean;
  20682. /**
  20683. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20684. */
  20685. ignoreCameraViewport: boolean;
  20686. private _postProcessManager;
  20687. private _postProcesses;
  20688. private _resizeObserver;
  20689. /**
  20690. * An event triggered when the texture is unbind.
  20691. */
  20692. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20693. /**
  20694. * An event triggered when the texture is unbind.
  20695. */
  20696. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20697. private _onAfterUnbindObserver;
  20698. /**
  20699. * Set a after unbind callback in the texture.
  20700. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20701. */
  20702. onAfterUnbind: () => void;
  20703. /**
  20704. * An event triggered before rendering the texture
  20705. */
  20706. onBeforeRenderObservable: Observable<number>;
  20707. private _onBeforeRenderObserver;
  20708. /**
  20709. * Set a before render callback in the texture.
  20710. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20711. */
  20712. onBeforeRender: (faceIndex: number) => void;
  20713. /**
  20714. * An event triggered after rendering the texture
  20715. */
  20716. onAfterRenderObservable: Observable<number>;
  20717. private _onAfterRenderObserver;
  20718. /**
  20719. * Set a after render callback in the texture.
  20720. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20721. */
  20722. onAfterRender: (faceIndex: number) => void;
  20723. /**
  20724. * An event triggered after the texture clear
  20725. */
  20726. onClearObservable: Observable<Engine>;
  20727. private _onClearObserver;
  20728. /**
  20729. * Set a clear callback in the texture.
  20730. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20731. */
  20732. onClear: (Engine: Engine) => void;
  20733. /**
  20734. * An event triggered when the texture is resized.
  20735. */
  20736. onResizeObservable: Observable<RenderTargetTexture>;
  20737. /**
  20738. * Define the clear color of the Render Target if it should be different from the scene.
  20739. */
  20740. clearColor: Color4;
  20741. protected _size: number | {
  20742. width: number;
  20743. height: number;
  20744. };
  20745. protected _initialSizeParameter: number | {
  20746. width: number;
  20747. height: number;
  20748. } | {
  20749. ratio: number;
  20750. };
  20751. protected _sizeRatio: Nullable<number>;
  20752. /** @hidden */
  20753. _generateMipMaps: boolean;
  20754. protected _renderingManager: RenderingManager;
  20755. /** @hidden */
  20756. _waitingRenderList: string[];
  20757. protected _doNotChangeAspectRatio: boolean;
  20758. protected _currentRefreshId: number;
  20759. protected _refreshRate: number;
  20760. protected _textureMatrix: Matrix;
  20761. protected _samples: number;
  20762. protected _renderTargetOptions: RenderTargetCreationOptions;
  20763. /**
  20764. * Gets render target creation options that were used.
  20765. */
  20766. readonly renderTargetOptions: RenderTargetCreationOptions;
  20767. protected _engine: Engine;
  20768. protected _onRatioRescale(): void;
  20769. /**
  20770. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20771. * It must define where the camera used to render the texture is set
  20772. */
  20773. boundingBoxPosition: Vector3;
  20774. private _boundingBoxSize;
  20775. /**
  20776. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20777. * When defined, the cubemap will switch to local mode
  20778. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20779. * @example https://www.babylonjs-playground.com/#RNASML
  20780. */
  20781. boundingBoxSize: Vector3;
  20782. /**
  20783. * In case the RTT has been created with a depth texture, get the associated
  20784. * depth texture.
  20785. * Otherwise, return null.
  20786. */
  20787. depthStencilTexture: Nullable<InternalTexture>;
  20788. /**
  20789. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20790. * or used a shadow, depth texture...
  20791. * @param name The friendly name of the texture
  20792. * @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)
  20793. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20794. * @param generateMipMaps True if mip maps need to be generated after render.
  20795. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20796. * @param type The type of the buffer in the RTT (int, half float, float...)
  20797. * @param isCube True if a cube texture needs to be created
  20798. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20799. * @param generateDepthBuffer True to generate a depth buffer
  20800. * @param generateStencilBuffer True to generate a stencil buffer
  20801. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20802. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20803. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20804. */
  20805. constructor(name: string, size: number | {
  20806. width: number;
  20807. height: number;
  20808. } | {
  20809. ratio: number;
  20810. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20811. /**
  20812. * Creates a depth stencil texture.
  20813. * This is only available in WebGL 2 or with the depth texture extension available.
  20814. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20815. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20816. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20817. */
  20818. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20819. private _processSizeParameter;
  20820. /**
  20821. * Define the number of samples to use in case of MSAA.
  20822. * It defaults to one meaning no MSAA has been enabled.
  20823. */
  20824. samples: number;
  20825. /**
  20826. * Resets the refresh counter of the texture and start bak from scratch.
  20827. * Could be useful to regenerate the texture if it is setup to render only once.
  20828. */
  20829. resetRefreshCounter(): void;
  20830. /**
  20831. * Define the refresh rate of the texture or the rendering frequency.
  20832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20833. */
  20834. refreshRate: number;
  20835. /**
  20836. * Adds a post process to the render target rendering passes.
  20837. * @param postProcess define the post process to add
  20838. */
  20839. addPostProcess(postProcess: PostProcess): void;
  20840. /**
  20841. * Clear all the post processes attached to the render target
  20842. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20843. */
  20844. clearPostProcesses(dispose?: boolean): void;
  20845. /**
  20846. * Remove one of the post process from the list of attached post processes to the texture
  20847. * @param postProcess define the post process to remove from the list
  20848. */
  20849. removePostProcess(postProcess: PostProcess): void;
  20850. /** @hidden */
  20851. _shouldRender(): boolean;
  20852. /**
  20853. * Gets the actual render size of the texture.
  20854. * @returns the width of the render size
  20855. */
  20856. getRenderSize(): number;
  20857. /**
  20858. * Gets the actual render width of the texture.
  20859. * @returns the width of the render size
  20860. */
  20861. getRenderWidth(): number;
  20862. /**
  20863. * Gets the actual render height of the texture.
  20864. * @returns the height of the render size
  20865. */
  20866. getRenderHeight(): number;
  20867. /**
  20868. * Get if the texture can be rescaled or not.
  20869. */
  20870. readonly canRescale: boolean;
  20871. /**
  20872. * Resize the texture using a ratio.
  20873. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20874. */
  20875. scale(ratio: number): void;
  20876. /**
  20877. * Get the texture reflection matrix used to rotate/transform the reflection.
  20878. * @returns the reflection matrix
  20879. */
  20880. getReflectionTextureMatrix(): Matrix;
  20881. /**
  20882. * Resize the texture to a new desired size.
  20883. * Be carrefull as it will recreate all the data in the new texture.
  20884. * @param size Define the new size. It can be:
  20885. * - a number for squared texture,
  20886. * - an object containing { width: number, height: number }
  20887. * - or an object containing a ratio { ratio: number }
  20888. */
  20889. resize(size: number | {
  20890. width: number;
  20891. height: number;
  20892. } | {
  20893. ratio: number;
  20894. }): void;
  20895. /**
  20896. * Renders all the objects from the render list into the texture.
  20897. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20898. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20899. */
  20900. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20901. private _bestReflectionRenderTargetDimension;
  20902. /**
  20903. * @hidden
  20904. * @param faceIndex face index to bind to if this is a cubetexture
  20905. */
  20906. _bindFrameBuffer(faceIndex?: number): void;
  20907. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20908. private renderToTarget;
  20909. /**
  20910. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20911. * This allowed control for front to back rendering or reversly depending of the special needs.
  20912. *
  20913. * @param renderingGroupId The rendering group id corresponding to its index
  20914. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20915. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20916. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20917. */
  20918. 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;
  20919. /**
  20920. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20921. *
  20922. * @param renderingGroupId The rendering group id corresponding to its index
  20923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20924. */
  20925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20926. /**
  20927. * Clones the texture.
  20928. * @returns the cloned texture
  20929. */
  20930. clone(): RenderTargetTexture;
  20931. /**
  20932. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20933. * @returns The JSON representation of the texture
  20934. */
  20935. serialize(): any;
  20936. /**
  20937. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20938. */
  20939. disposeFramebufferObjects(): void;
  20940. /**
  20941. * Dispose the texture and release its associated resources.
  20942. */
  20943. dispose(): void;
  20944. /** @hidden */
  20945. _rebuild(): void;
  20946. /**
  20947. * Clear the info related to rendering groups preventing retention point in material dispose.
  20948. */
  20949. freeRenderingGroups(): void;
  20950. /**
  20951. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20952. * @returns the view count
  20953. */
  20954. getViewCount(): number;
  20955. }
  20956. }
  20957. declare module "babylonjs/Materials/material" {
  20958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20959. import { SmartArray } from "babylonjs/Misc/smartArray";
  20960. import { Observable } from "babylonjs/Misc/observable";
  20961. import { Nullable } from "babylonjs/types";
  20962. import { Scene } from "babylonjs/scene";
  20963. import { Matrix } from "babylonjs/Maths/math.vector";
  20964. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20967. import { Effect } from "babylonjs/Materials/effect";
  20968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20970. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20971. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20972. import { Mesh } from "babylonjs/Meshes/mesh";
  20973. import { Animation } from "babylonjs/Animations/animation";
  20974. /**
  20975. * Options for compiling materials.
  20976. */
  20977. export interface IMaterialCompilationOptions {
  20978. /**
  20979. * Defines whether clip planes are enabled.
  20980. */
  20981. clipPlane: boolean;
  20982. /**
  20983. * Defines whether instances are enabled.
  20984. */
  20985. useInstances: boolean;
  20986. }
  20987. /**
  20988. * Base class for the main features of a material in Babylon.js
  20989. */
  20990. export class Material implements IAnimatable {
  20991. /**
  20992. * Returns the triangle fill mode
  20993. */
  20994. static readonly TriangleFillMode: number;
  20995. /**
  20996. * Returns the wireframe mode
  20997. */
  20998. static readonly WireFrameFillMode: number;
  20999. /**
  21000. * Returns the point fill mode
  21001. */
  21002. static readonly PointFillMode: number;
  21003. /**
  21004. * Returns the point list draw mode
  21005. */
  21006. static readonly PointListDrawMode: number;
  21007. /**
  21008. * Returns the line list draw mode
  21009. */
  21010. static readonly LineListDrawMode: number;
  21011. /**
  21012. * Returns the line loop draw mode
  21013. */
  21014. static readonly LineLoopDrawMode: number;
  21015. /**
  21016. * Returns the line strip draw mode
  21017. */
  21018. static readonly LineStripDrawMode: number;
  21019. /**
  21020. * Returns the triangle strip draw mode
  21021. */
  21022. static readonly TriangleStripDrawMode: number;
  21023. /**
  21024. * Returns the triangle fan draw mode
  21025. */
  21026. static readonly TriangleFanDrawMode: number;
  21027. /**
  21028. * Stores the clock-wise side orientation
  21029. */
  21030. static readonly ClockWiseSideOrientation: number;
  21031. /**
  21032. * Stores the counter clock-wise side orientation
  21033. */
  21034. static readonly CounterClockWiseSideOrientation: number;
  21035. /**
  21036. * The dirty texture flag value
  21037. */
  21038. static readonly TextureDirtyFlag: number;
  21039. /**
  21040. * The dirty light flag value
  21041. */
  21042. static readonly LightDirtyFlag: number;
  21043. /**
  21044. * The dirty fresnel flag value
  21045. */
  21046. static readonly FresnelDirtyFlag: number;
  21047. /**
  21048. * The dirty attribute flag value
  21049. */
  21050. static readonly AttributesDirtyFlag: number;
  21051. /**
  21052. * The dirty misc flag value
  21053. */
  21054. static readonly MiscDirtyFlag: number;
  21055. /**
  21056. * The all dirty flag value
  21057. */
  21058. static readonly AllDirtyFlag: number;
  21059. /**
  21060. * The ID of the material
  21061. */
  21062. id: string;
  21063. /**
  21064. * Gets or sets the unique id of the material
  21065. */
  21066. uniqueId: number;
  21067. /**
  21068. * The name of the material
  21069. */
  21070. name: string;
  21071. /**
  21072. * Gets or sets user defined metadata
  21073. */
  21074. metadata: any;
  21075. /**
  21076. * For internal use only. Please do not use.
  21077. */
  21078. reservedDataStore: any;
  21079. /**
  21080. * Specifies if the ready state should be checked on each call
  21081. */
  21082. checkReadyOnEveryCall: boolean;
  21083. /**
  21084. * Specifies if the ready state should be checked once
  21085. */
  21086. checkReadyOnlyOnce: boolean;
  21087. /**
  21088. * The state of the material
  21089. */
  21090. state: string;
  21091. /**
  21092. * The alpha value of the material
  21093. */
  21094. protected _alpha: number;
  21095. /**
  21096. * List of inspectable custom properties (used by the Inspector)
  21097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21098. */
  21099. inspectableCustomProperties: IInspectable[];
  21100. /**
  21101. * Sets the alpha value of the material
  21102. */
  21103. /**
  21104. * Gets the alpha value of the material
  21105. */
  21106. alpha: number;
  21107. /**
  21108. * Specifies if back face culling is enabled
  21109. */
  21110. protected _backFaceCulling: boolean;
  21111. /**
  21112. * Sets the back-face culling state
  21113. */
  21114. /**
  21115. * Gets the back-face culling state
  21116. */
  21117. backFaceCulling: boolean;
  21118. /**
  21119. * Stores the value for side orientation
  21120. */
  21121. sideOrientation: number;
  21122. /**
  21123. * Callback triggered when the material is compiled
  21124. */
  21125. onCompiled: Nullable<(effect: Effect) => void>;
  21126. /**
  21127. * Callback triggered when an error occurs
  21128. */
  21129. onError: Nullable<(effect: Effect, errors: string) => void>;
  21130. /**
  21131. * Callback triggered to get the render target textures
  21132. */
  21133. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21134. /**
  21135. * Gets a boolean indicating that current material needs to register RTT
  21136. */
  21137. readonly hasRenderTargetTextures: boolean;
  21138. /**
  21139. * Specifies if the material should be serialized
  21140. */
  21141. doNotSerialize: boolean;
  21142. /**
  21143. * @hidden
  21144. */
  21145. _storeEffectOnSubMeshes: boolean;
  21146. /**
  21147. * Stores the animations for the material
  21148. */
  21149. animations: Nullable<Array<Animation>>;
  21150. /**
  21151. * An event triggered when the material is disposed
  21152. */
  21153. onDisposeObservable: Observable<Material>;
  21154. /**
  21155. * An observer which watches for dispose events
  21156. */
  21157. private _onDisposeObserver;
  21158. private _onUnBindObservable;
  21159. /**
  21160. * Called during a dispose event
  21161. */
  21162. onDispose: () => void;
  21163. private _onBindObservable;
  21164. /**
  21165. * An event triggered when the material is bound
  21166. */
  21167. readonly onBindObservable: Observable<AbstractMesh>;
  21168. /**
  21169. * An observer which watches for bind events
  21170. */
  21171. private _onBindObserver;
  21172. /**
  21173. * Called during a bind event
  21174. */
  21175. onBind: (Mesh: AbstractMesh) => void;
  21176. /**
  21177. * An event triggered when the material is unbound
  21178. */
  21179. readonly onUnBindObservable: Observable<Material>;
  21180. /**
  21181. * Stores the value of the alpha mode
  21182. */
  21183. private _alphaMode;
  21184. /**
  21185. * Sets the value of the alpha mode.
  21186. *
  21187. * | Value | Type | Description |
  21188. * | --- | --- | --- |
  21189. * | 0 | ALPHA_DISABLE | |
  21190. * | 1 | ALPHA_ADD | |
  21191. * | 2 | ALPHA_COMBINE | |
  21192. * | 3 | ALPHA_SUBTRACT | |
  21193. * | 4 | ALPHA_MULTIPLY | |
  21194. * | 5 | ALPHA_MAXIMIZED | |
  21195. * | 6 | ALPHA_ONEONE | |
  21196. * | 7 | ALPHA_PREMULTIPLIED | |
  21197. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21198. * | 9 | ALPHA_INTERPOLATE | |
  21199. * | 10 | ALPHA_SCREENMODE | |
  21200. *
  21201. */
  21202. /**
  21203. * Gets the value of the alpha mode
  21204. */
  21205. alphaMode: number;
  21206. /**
  21207. * Stores the state of the need depth pre-pass value
  21208. */
  21209. private _needDepthPrePass;
  21210. /**
  21211. * Sets the need depth pre-pass value
  21212. */
  21213. /**
  21214. * Gets the depth pre-pass value
  21215. */
  21216. needDepthPrePass: boolean;
  21217. /**
  21218. * Specifies if depth writing should be disabled
  21219. */
  21220. disableDepthWrite: boolean;
  21221. /**
  21222. * Specifies if depth writing should be forced
  21223. */
  21224. forceDepthWrite: boolean;
  21225. /**
  21226. * Specifies if there should be a separate pass for culling
  21227. */
  21228. separateCullingPass: boolean;
  21229. /**
  21230. * Stores the state specifing if fog should be enabled
  21231. */
  21232. private _fogEnabled;
  21233. /**
  21234. * Sets the state for enabling fog
  21235. */
  21236. /**
  21237. * Gets the value of the fog enabled state
  21238. */
  21239. fogEnabled: boolean;
  21240. /**
  21241. * Stores the size of points
  21242. */
  21243. pointSize: number;
  21244. /**
  21245. * Stores the z offset value
  21246. */
  21247. zOffset: number;
  21248. /**
  21249. * Gets a value specifying if wireframe mode is enabled
  21250. */
  21251. /**
  21252. * Sets the state of wireframe mode
  21253. */
  21254. wireframe: boolean;
  21255. /**
  21256. * Gets the value specifying if point clouds are enabled
  21257. */
  21258. /**
  21259. * Sets the state of point cloud mode
  21260. */
  21261. pointsCloud: boolean;
  21262. /**
  21263. * Gets the material fill mode
  21264. */
  21265. /**
  21266. * Sets the material fill mode
  21267. */
  21268. fillMode: number;
  21269. /**
  21270. * @hidden
  21271. * Stores the effects for the material
  21272. */
  21273. _effect: Nullable<Effect>;
  21274. /**
  21275. * @hidden
  21276. * Specifies if the material was previously ready
  21277. */
  21278. _wasPreviouslyReady: boolean;
  21279. /**
  21280. * Specifies if uniform buffers should be used
  21281. */
  21282. private _useUBO;
  21283. /**
  21284. * Stores a reference to the scene
  21285. */
  21286. private _scene;
  21287. /**
  21288. * Stores the fill mode state
  21289. */
  21290. private _fillMode;
  21291. /**
  21292. * Specifies if the depth write state should be cached
  21293. */
  21294. private _cachedDepthWriteState;
  21295. /**
  21296. * Stores the uniform buffer
  21297. */
  21298. protected _uniformBuffer: UniformBuffer;
  21299. /** @hidden */
  21300. _indexInSceneMaterialArray: number;
  21301. /** @hidden */
  21302. meshMap: Nullable<{
  21303. [id: string]: AbstractMesh | undefined;
  21304. }>;
  21305. /**
  21306. * Creates a material instance
  21307. * @param name defines the name of the material
  21308. * @param scene defines the scene to reference
  21309. * @param doNotAdd specifies if the material should be added to the scene
  21310. */
  21311. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21312. /**
  21313. * Returns a string representation of the current material
  21314. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21315. * @returns a string with material information
  21316. */
  21317. toString(fullDetails?: boolean): string;
  21318. /**
  21319. * Gets the class name of the material
  21320. * @returns a string with the class name of the material
  21321. */
  21322. getClassName(): string;
  21323. /**
  21324. * Specifies if updates for the material been locked
  21325. */
  21326. readonly isFrozen: boolean;
  21327. /**
  21328. * Locks updates for the material
  21329. */
  21330. freeze(): void;
  21331. /**
  21332. * Unlocks updates for the material
  21333. */
  21334. unfreeze(): void;
  21335. /**
  21336. * Specifies if the material is ready to be used
  21337. * @param mesh defines the mesh to check
  21338. * @param useInstances specifies if instances should be used
  21339. * @returns a boolean indicating if the material is ready to be used
  21340. */
  21341. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21342. /**
  21343. * Specifies that the submesh is ready to be used
  21344. * @param mesh defines the mesh to check
  21345. * @param subMesh defines which submesh to check
  21346. * @param useInstances specifies that instances should be used
  21347. * @returns a boolean indicating that the submesh is ready or not
  21348. */
  21349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21350. /**
  21351. * Returns the material effect
  21352. * @returns the effect associated with the material
  21353. */
  21354. getEffect(): Nullable<Effect>;
  21355. /**
  21356. * Returns the current scene
  21357. * @returns a Scene
  21358. */
  21359. getScene(): Scene;
  21360. /**
  21361. * Specifies if the material will require alpha blending
  21362. * @returns a boolean specifying if alpha blending is needed
  21363. */
  21364. needAlphaBlending(): boolean;
  21365. /**
  21366. * Specifies if the mesh will require alpha blending
  21367. * @param mesh defines the mesh to check
  21368. * @returns a boolean specifying if alpha blending is needed for the mesh
  21369. */
  21370. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21371. /**
  21372. * Specifies if this material should be rendered in alpha test mode
  21373. * @returns a boolean specifying if an alpha test is needed.
  21374. */
  21375. needAlphaTesting(): boolean;
  21376. /**
  21377. * Gets the texture used for the alpha test
  21378. * @returns the texture to use for alpha testing
  21379. */
  21380. getAlphaTestTexture(): Nullable<BaseTexture>;
  21381. /**
  21382. * Marks the material to indicate that it needs to be re-calculated
  21383. */
  21384. markDirty(): void;
  21385. /** @hidden */
  21386. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21387. /**
  21388. * Binds the material to the mesh
  21389. * @param world defines the world transformation matrix
  21390. * @param mesh defines the mesh to bind the material to
  21391. */
  21392. bind(world: Matrix, mesh?: Mesh): void;
  21393. /**
  21394. * Binds the submesh to the material
  21395. * @param world defines the world transformation matrix
  21396. * @param mesh defines the mesh containing the submesh
  21397. * @param subMesh defines the submesh to bind the material to
  21398. */
  21399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21400. /**
  21401. * Binds the world matrix to the material
  21402. * @param world defines the world transformation matrix
  21403. */
  21404. bindOnlyWorldMatrix(world: Matrix): void;
  21405. /**
  21406. * Binds the scene's uniform buffer to the effect.
  21407. * @param effect defines the effect to bind to the scene uniform buffer
  21408. * @param sceneUbo defines the uniform buffer storing scene data
  21409. */
  21410. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21411. /**
  21412. * Binds the view matrix to the effect
  21413. * @param effect defines the effect to bind the view matrix to
  21414. */
  21415. bindView(effect: Effect): void;
  21416. /**
  21417. * Binds the view projection matrix to the effect
  21418. * @param effect defines the effect to bind the view projection matrix to
  21419. */
  21420. bindViewProjection(effect: Effect): void;
  21421. /**
  21422. * Specifies if material alpha testing should be turned on for the mesh
  21423. * @param mesh defines the mesh to check
  21424. */
  21425. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21426. /**
  21427. * Processes to execute after binding the material to a mesh
  21428. * @param mesh defines the rendered mesh
  21429. */
  21430. protected _afterBind(mesh?: Mesh): void;
  21431. /**
  21432. * Unbinds the material from the mesh
  21433. */
  21434. unbind(): void;
  21435. /**
  21436. * Gets the active textures from the material
  21437. * @returns an array of textures
  21438. */
  21439. getActiveTextures(): BaseTexture[];
  21440. /**
  21441. * Specifies if the material uses a texture
  21442. * @param texture defines the texture to check against the material
  21443. * @returns a boolean specifying if the material uses the texture
  21444. */
  21445. hasTexture(texture: BaseTexture): boolean;
  21446. /**
  21447. * Makes a duplicate of the material, and gives it a new name
  21448. * @param name defines the new name for the duplicated material
  21449. * @returns the cloned material
  21450. */
  21451. clone(name: string): Nullable<Material>;
  21452. /**
  21453. * Gets the meshes bound to the material
  21454. * @returns an array of meshes bound to the material
  21455. */
  21456. getBindedMeshes(): AbstractMesh[];
  21457. /**
  21458. * Force shader compilation
  21459. * @param mesh defines the mesh associated with this material
  21460. * @param onCompiled defines a function to execute once the material is compiled
  21461. * @param options defines the options to configure the compilation
  21462. * @param onError defines a function to execute if the material fails compiling
  21463. */
  21464. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21465. /**
  21466. * Force shader compilation
  21467. * @param mesh defines the mesh that will use this material
  21468. * @param options defines additional options for compiling the shaders
  21469. * @returns a promise that resolves when the compilation completes
  21470. */
  21471. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21472. private static readonly _AllDirtyCallBack;
  21473. private static readonly _ImageProcessingDirtyCallBack;
  21474. private static readonly _TextureDirtyCallBack;
  21475. private static readonly _FresnelDirtyCallBack;
  21476. private static readonly _MiscDirtyCallBack;
  21477. private static readonly _LightsDirtyCallBack;
  21478. private static readonly _AttributeDirtyCallBack;
  21479. private static _FresnelAndMiscDirtyCallBack;
  21480. private static _TextureAndMiscDirtyCallBack;
  21481. private static readonly _DirtyCallbackArray;
  21482. private static readonly _RunDirtyCallBacks;
  21483. /**
  21484. * Marks a define in the material to indicate that it needs to be re-computed
  21485. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21486. */
  21487. markAsDirty(flag: number): void;
  21488. /**
  21489. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21490. * @param func defines a function which checks material defines against the submeshes
  21491. */
  21492. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21493. /**
  21494. * Indicates that we need to re-calculated for all submeshes
  21495. */
  21496. protected _markAllSubMeshesAsAllDirty(): void;
  21497. /**
  21498. * Indicates that image processing needs to be re-calculated for all submeshes
  21499. */
  21500. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21501. /**
  21502. * Indicates that textures need to be re-calculated for all submeshes
  21503. */
  21504. protected _markAllSubMeshesAsTexturesDirty(): void;
  21505. /**
  21506. * Indicates that fresnel needs to be re-calculated for all submeshes
  21507. */
  21508. protected _markAllSubMeshesAsFresnelDirty(): void;
  21509. /**
  21510. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21511. */
  21512. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21513. /**
  21514. * Indicates that lights need to be re-calculated for all submeshes
  21515. */
  21516. protected _markAllSubMeshesAsLightsDirty(): void;
  21517. /**
  21518. * Indicates that attributes need to be re-calculated for all submeshes
  21519. */
  21520. protected _markAllSubMeshesAsAttributesDirty(): void;
  21521. /**
  21522. * Indicates that misc needs to be re-calculated for all submeshes
  21523. */
  21524. protected _markAllSubMeshesAsMiscDirty(): void;
  21525. /**
  21526. * Indicates that textures and misc need to be re-calculated for all submeshes
  21527. */
  21528. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21529. /**
  21530. * Disposes the material
  21531. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21532. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21533. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21534. */
  21535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21536. /** @hidden */
  21537. private releaseVertexArrayObject;
  21538. /**
  21539. * Serializes this material
  21540. * @returns the serialized material object
  21541. */
  21542. serialize(): any;
  21543. /**
  21544. * Creates a material from parsed material data
  21545. * @param parsedMaterial defines parsed material data
  21546. * @param scene defines the hosting scene
  21547. * @param rootUrl defines the root URL to use to load textures
  21548. * @returns a new material
  21549. */
  21550. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21551. }
  21552. }
  21553. declare module "babylonjs/Materials/multiMaterial" {
  21554. import { Nullable } from "babylonjs/types";
  21555. import { Scene } from "babylonjs/scene";
  21556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21557. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21559. import { Material } from "babylonjs/Materials/material";
  21560. /**
  21561. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21562. * separate meshes. This can be use to improve performances.
  21563. * @see http://doc.babylonjs.com/how_to/multi_materials
  21564. */
  21565. export class MultiMaterial extends Material {
  21566. private _subMaterials;
  21567. /**
  21568. * Gets or Sets the list of Materials used within the multi material.
  21569. * They need to be ordered according to the submeshes order in the associated mesh
  21570. */
  21571. subMaterials: Nullable<Material>[];
  21572. /**
  21573. * Function used to align with Node.getChildren()
  21574. * @returns the list of Materials used within the multi material
  21575. */
  21576. getChildren(): Nullable<Material>[];
  21577. /**
  21578. * Instantiates a new Multi Material
  21579. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21580. * separate meshes. This can be use to improve performances.
  21581. * @see http://doc.babylonjs.com/how_to/multi_materials
  21582. * @param name Define the name in the scene
  21583. * @param scene Define the scene the material belongs to
  21584. */
  21585. constructor(name: string, scene: Scene);
  21586. private _hookArray;
  21587. /**
  21588. * Get one of the submaterial by its index in the submaterials array
  21589. * @param index The index to look the sub material at
  21590. * @returns The Material if the index has been defined
  21591. */
  21592. getSubMaterial(index: number): Nullable<Material>;
  21593. /**
  21594. * Get the list of active textures for the whole sub materials list.
  21595. * @returns All the textures that will be used during the rendering
  21596. */
  21597. getActiveTextures(): BaseTexture[];
  21598. /**
  21599. * Gets the current class name of the material e.g. "MultiMaterial"
  21600. * Mainly use in serialization.
  21601. * @returns the class name
  21602. */
  21603. getClassName(): string;
  21604. /**
  21605. * Checks if the material is ready to render the requested sub mesh
  21606. * @param mesh Define the mesh the submesh belongs to
  21607. * @param subMesh Define the sub mesh to look readyness for
  21608. * @param useInstances Define whether or not the material is used with instances
  21609. * @returns true if ready, otherwise false
  21610. */
  21611. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21612. /**
  21613. * Clones the current material and its related sub materials
  21614. * @param name Define the name of the newly cloned material
  21615. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21616. * @returns the cloned material
  21617. */
  21618. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21619. /**
  21620. * Serializes the materials into a JSON representation.
  21621. * @returns the JSON representation
  21622. */
  21623. serialize(): any;
  21624. /**
  21625. * Dispose the material and release its associated resources
  21626. * @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)
  21627. * @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)
  21628. * @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)
  21629. */
  21630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21631. /**
  21632. * Creates a MultiMaterial from parsed MultiMaterial data.
  21633. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21634. * @param scene defines the hosting scene
  21635. * @returns a new MultiMaterial
  21636. */
  21637. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21638. }
  21639. }
  21640. declare module "babylonjs/Meshes/subMesh" {
  21641. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21642. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21643. import { Engine } from "babylonjs/Engines/engine";
  21644. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21645. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21646. import { Effect } from "babylonjs/Materials/effect";
  21647. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21648. import { Plane } from "babylonjs/Maths/math.plane";
  21649. import { Collider } from "babylonjs/Collisions/collider";
  21650. import { Material } from "babylonjs/Materials/material";
  21651. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21653. import { Mesh } from "babylonjs/Meshes/mesh";
  21654. import { Ray } from "babylonjs/Culling/ray";
  21655. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21656. /**
  21657. * Base class for submeshes
  21658. */
  21659. export class BaseSubMesh {
  21660. /** @hidden */
  21661. _materialDefines: Nullable<MaterialDefines>;
  21662. /** @hidden */
  21663. _materialEffect: Nullable<Effect>;
  21664. /**
  21665. * Gets associated effect
  21666. */
  21667. readonly effect: Nullable<Effect>;
  21668. /**
  21669. * Sets associated effect (effect used to render this submesh)
  21670. * @param effect defines the effect to associate with
  21671. * @param defines defines the set of defines used to compile this effect
  21672. */
  21673. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21674. }
  21675. /**
  21676. * Defines a subdivision inside a mesh
  21677. */
  21678. export class SubMesh extends BaseSubMesh implements ICullable {
  21679. /** the material index to use */
  21680. materialIndex: number;
  21681. /** vertex index start */
  21682. verticesStart: number;
  21683. /** vertices count */
  21684. verticesCount: number;
  21685. /** index start */
  21686. indexStart: number;
  21687. /** indices count */
  21688. indexCount: number;
  21689. /** @hidden */
  21690. _linesIndexCount: number;
  21691. private _mesh;
  21692. private _renderingMesh;
  21693. private _boundingInfo;
  21694. private _linesIndexBuffer;
  21695. /** @hidden */
  21696. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21697. /** @hidden */
  21698. _trianglePlanes: Plane[];
  21699. /** @hidden */
  21700. _lastColliderTransformMatrix: Nullable<Matrix>;
  21701. /** @hidden */
  21702. _renderId: number;
  21703. /** @hidden */
  21704. _alphaIndex: number;
  21705. /** @hidden */
  21706. _distanceToCamera: number;
  21707. /** @hidden */
  21708. _id: number;
  21709. private _currentMaterial;
  21710. /**
  21711. * Add a new submesh to a mesh
  21712. * @param materialIndex defines the material index to use
  21713. * @param verticesStart defines vertex index start
  21714. * @param verticesCount defines vertices count
  21715. * @param indexStart defines index start
  21716. * @param indexCount defines indices count
  21717. * @param mesh defines the parent mesh
  21718. * @param renderingMesh defines an optional rendering mesh
  21719. * @param createBoundingBox defines if bounding box should be created for this submesh
  21720. * @returns the new submesh
  21721. */
  21722. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21723. /**
  21724. * Creates a new submesh
  21725. * @param materialIndex defines the material index to use
  21726. * @param verticesStart defines vertex index start
  21727. * @param verticesCount defines vertices count
  21728. * @param indexStart defines index start
  21729. * @param indexCount defines indices count
  21730. * @param mesh defines the parent mesh
  21731. * @param renderingMesh defines an optional rendering mesh
  21732. * @param createBoundingBox defines if bounding box should be created for this submesh
  21733. */
  21734. constructor(
  21735. /** the material index to use */
  21736. materialIndex: number,
  21737. /** vertex index start */
  21738. verticesStart: number,
  21739. /** vertices count */
  21740. verticesCount: number,
  21741. /** index start */
  21742. indexStart: number,
  21743. /** indices count */
  21744. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21745. /**
  21746. * Returns true if this submesh covers the entire parent mesh
  21747. * @ignorenaming
  21748. */
  21749. readonly IsGlobal: boolean;
  21750. /**
  21751. * Returns the submesh BoudingInfo object
  21752. * @returns current bounding info (or mesh's one if the submesh is global)
  21753. */
  21754. getBoundingInfo(): BoundingInfo;
  21755. /**
  21756. * Sets the submesh BoundingInfo
  21757. * @param boundingInfo defines the new bounding info to use
  21758. * @returns the SubMesh
  21759. */
  21760. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21761. /**
  21762. * Returns the mesh of the current submesh
  21763. * @return the parent mesh
  21764. */
  21765. getMesh(): AbstractMesh;
  21766. /**
  21767. * Returns the rendering mesh of the submesh
  21768. * @returns the rendering mesh (could be different from parent mesh)
  21769. */
  21770. getRenderingMesh(): Mesh;
  21771. /**
  21772. * Returns the submesh material
  21773. * @returns null or the current material
  21774. */
  21775. getMaterial(): Nullable<Material>;
  21776. /**
  21777. * Sets a new updated BoundingInfo object to the submesh
  21778. * @param data defines an optional position array to use to determine the bounding info
  21779. * @returns the SubMesh
  21780. */
  21781. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21782. /** @hidden */
  21783. _checkCollision(collider: Collider): boolean;
  21784. /**
  21785. * Updates the submesh BoundingInfo
  21786. * @param world defines the world matrix to use to update the bounding info
  21787. * @returns the submesh
  21788. */
  21789. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21790. /**
  21791. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21792. * @param frustumPlanes defines the frustum planes
  21793. * @returns true if the submesh is intersecting with the frustum
  21794. */
  21795. isInFrustum(frustumPlanes: Plane[]): boolean;
  21796. /**
  21797. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21798. * @param frustumPlanes defines the frustum planes
  21799. * @returns true if the submesh is inside the frustum
  21800. */
  21801. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21802. /**
  21803. * Renders the submesh
  21804. * @param enableAlphaMode defines if alpha needs to be used
  21805. * @returns the submesh
  21806. */
  21807. render(enableAlphaMode: boolean): SubMesh;
  21808. /**
  21809. * @hidden
  21810. */
  21811. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21812. /**
  21813. * Checks if the submesh intersects with a ray
  21814. * @param ray defines the ray to test
  21815. * @returns true is the passed ray intersects the submesh bounding box
  21816. */
  21817. canIntersects(ray: Ray): boolean;
  21818. /**
  21819. * Intersects current submesh with a ray
  21820. * @param ray defines the ray to test
  21821. * @param positions defines mesh's positions array
  21822. * @param indices defines mesh's indices array
  21823. * @param fastCheck defines if only bounding info should be used
  21824. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21825. * @returns intersection info or null if no intersection
  21826. */
  21827. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21828. /** @hidden */
  21829. private _intersectLines;
  21830. /** @hidden */
  21831. private _intersectUnIndexedLines;
  21832. /** @hidden */
  21833. private _intersectTriangles;
  21834. /** @hidden */
  21835. private _intersectUnIndexedTriangles;
  21836. /** @hidden */
  21837. _rebuild(): void;
  21838. /**
  21839. * Creates a new submesh from the passed mesh
  21840. * @param newMesh defines the new hosting mesh
  21841. * @param newRenderingMesh defines an optional rendering mesh
  21842. * @returns the new submesh
  21843. */
  21844. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21845. /**
  21846. * Release associated resources
  21847. */
  21848. dispose(): void;
  21849. /**
  21850. * Gets the class name
  21851. * @returns the string "SubMesh".
  21852. */
  21853. getClassName(): string;
  21854. /**
  21855. * Creates a new submesh from indices data
  21856. * @param materialIndex the index of the main mesh material
  21857. * @param startIndex the index where to start the copy in the mesh indices array
  21858. * @param indexCount the number of indices to copy then from the startIndex
  21859. * @param mesh the main mesh to create the submesh from
  21860. * @param renderingMesh the optional rendering mesh
  21861. * @returns a new submesh
  21862. */
  21863. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21864. }
  21865. }
  21866. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21867. /**
  21868. * Class used to represent data loading progression
  21869. */
  21870. export class SceneLoaderFlags {
  21871. private static _ForceFullSceneLoadingForIncremental;
  21872. private static _ShowLoadingScreen;
  21873. private static _CleanBoneMatrixWeights;
  21874. private static _loggingLevel;
  21875. /**
  21876. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21877. */
  21878. static ForceFullSceneLoadingForIncremental: boolean;
  21879. /**
  21880. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21881. */
  21882. static ShowLoadingScreen: boolean;
  21883. /**
  21884. * Defines the current logging level (while loading the scene)
  21885. * @ignorenaming
  21886. */
  21887. static loggingLevel: number;
  21888. /**
  21889. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21890. */
  21891. static CleanBoneMatrixWeights: boolean;
  21892. }
  21893. }
  21894. declare module "babylonjs/Meshes/geometry" {
  21895. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21896. import { Scene } from "babylonjs/scene";
  21897. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21898. import { Engine } from "babylonjs/Engines/engine";
  21899. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21901. import { Effect } from "babylonjs/Materials/effect";
  21902. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21903. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21904. import { Mesh } from "babylonjs/Meshes/mesh";
  21905. /**
  21906. * Class used to store geometry data (vertex buffers + index buffer)
  21907. */
  21908. export class Geometry implements IGetSetVerticesData {
  21909. /**
  21910. * Gets or sets the ID of the geometry
  21911. */
  21912. id: string;
  21913. /**
  21914. * Gets or sets the unique ID of the geometry
  21915. */
  21916. uniqueId: number;
  21917. /**
  21918. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21919. */
  21920. delayLoadState: number;
  21921. /**
  21922. * Gets the file containing the data to load when running in delay load state
  21923. */
  21924. delayLoadingFile: Nullable<string>;
  21925. /**
  21926. * Callback called when the geometry is updated
  21927. */
  21928. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21929. private _scene;
  21930. private _engine;
  21931. private _meshes;
  21932. private _totalVertices;
  21933. /** @hidden */
  21934. _indices: IndicesArray;
  21935. /** @hidden */
  21936. _vertexBuffers: {
  21937. [key: string]: VertexBuffer;
  21938. };
  21939. private _isDisposed;
  21940. private _extend;
  21941. private _boundingBias;
  21942. /** @hidden */
  21943. _delayInfo: Array<string>;
  21944. private _indexBuffer;
  21945. private _indexBufferIsUpdatable;
  21946. /** @hidden */
  21947. _boundingInfo: Nullable<BoundingInfo>;
  21948. /** @hidden */
  21949. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21950. /** @hidden */
  21951. _softwareSkinningFrameId: number;
  21952. private _vertexArrayObjects;
  21953. private _updatable;
  21954. /** @hidden */
  21955. _positions: Nullable<Vector3[]>;
  21956. /**
  21957. * 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
  21958. */
  21959. /**
  21960. * 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
  21961. */
  21962. boundingBias: Vector2;
  21963. /**
  21964. * Static function used to attach a new empty geometry to a mesh
  21965. * @param mesh defines the mesh to attach the geometry to
  21966. * @returns the new Geometry
  21967. */
  21968. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21969. /**
  21970. * Creates a new geometry
  21971. * @param id defines the unique ID
  21972. * @param scene defines the hosting scene
  21973. * @param vertexData defines the VertexData used to get geometry data
  21974. * @param updatable defines if geometry must be updatable (false by default)
  21975. * @param mesh defines the mesh that will be associated with the geometry
  21976. */
  21977. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21978. /**
  21979. * Gets the current extend of the geometry
  21980. */
  21981. readonly extend: {
  21982. minimum: Vector3;
  21983. maximum: Vector3;
  21984. };
  21985. /**
  21986. * Gets the hosting scene
  21987. * @returns the hosting Scene
  21988. */
  21989. getScene(): Scene;
  21990. /**
  21991. * Gets the hosting engine
  21992. * @returns the hosting Engine
  21993. */
  21994. getEngine(): Engine;
  21995. /**
  21996. * Defines if the geometry is ready to use
  21997. * @returns true if the geometry is ready to be used
  21998. */
  21999. isReady(): boolean;
  22000. /**
  22001. * Gets a value indicating that the geometry should not be serialized
  22002. */
  22003. readonly doNotSerialize: boolean;
  22004. /** @hidden */
  22005. _rebuild(): void;
  22006. /**
  22007. * Affects all geometry data in one call
  22008. * @param vertexData defines the geometry data
  22009. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22010. */
  22011. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22012. /**
  22013. * Set specific vertex data
  22014. * @param kind defines the data kind (Position, normal, etc...)
  22015. * @param data defines the vertex data to use
  22016. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22017. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22018. */
  22019. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22020. /**
  22021. * Removes a specific vertex data
  22022. * @param kind defines the data kind (Position, normal, etc...)
  22023. */
  22024. removeVerticesData(kind: string): void;
  22025. /**
  22026. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22027. * @param buffer defines the vertex buffer to use
  22028. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22029. */
  22030. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22031. /**
  22032. * Update a specific vertex buffer
  22033. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22034. * It will do nothing if the buffer is not updatable
  22035. * @param kind defines the data kind (Position, normal, etc...)
  22036. * @param data defines the data to use
  22037. * @param offset defines the offset in the target buffer where to store the data
  22038. * @param useBytes set to true if the offset is in bytes
  22039. */
  22040. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22041. /**
  22042. * Update a specific vertex buffer
  22043. * This function will create a new buffer if the current one is not updatable
  22044. * @param kind defines the data kind (Position, normal, etc...)
  22045. * @param data defines the data to use
  22046. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22047. */
  22048. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22049. private _updateBoundingInfo;
  22050. /** @hidden */
  22051. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22052. /**
  22053. * Gets total number of vertices
  22054. * @returns the total number of vertices
  22055. */
  22056. getTotalVertices(): number;
  22057. /**
  22058. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22059. * @param kind defines the data kind (Position, normal, etc...)
  22060. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22061. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22062. * @returns a float array containing vertex data
  22063. */
  22064. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22065. /**
  22066. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22067. * @param kind defines the data kind (Position, normal, etc...)
  22068. * @returns true if the vertex buffer with the specified kind is updatable
  22069. */
  22070. isVertexBufferUpdatable(kind: string): boolean;
  22071. /**
  22072. * Gets a specific vertex buffer
  22073. * @param kind defines the data kind (Position, normal, etc...)
  22074. * @returns a VertexBuffer
  22075. */
  22076. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22077. /**
  22078. * Returns all vertex buffers
  22079. * @return an object holding all vertex buffers indexed by kind
  22080. */
  22081. getVertexBuffers(): Nullable<{
  22082. [key: string]: VertexBuffer;
  22083. }>;
  22084. /**
  22085. * Gets a boolean indicating if specific vertex buffer is present
  22086. * @param kind defines the data kind (Position, normal, etc...)
  22087. * @returns true if data is present
  22088. */
  22089. isVerticesDataPresent(kind: string): boolean;
  22090. /**
  22091. * Gets a list of all attached data kinds (Position, normal, etc...)
  22092. * @returns a list of string containing all kinds
  22093. */
  22094. getVerticesDataKinds(): string[];
  22095. /**
  22096. * Update index buffer
  22097. * @param indices defines the indices to store in the index buffer
  22098. * @param offset defines the offset in the target buffer where to store the data
  22099. * @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)
  22100. */
  22101. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22102. /**
  22103. * Creates a new index buffer
  22104. * @param indices defines the indices to store in the index buffer
  22105. * @param totalVertices defines the total number of vertices (could be null)
  22106. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22107. */
  22108. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22109. /**
  22110. * Return the total number of indices
  22111. * @returns the total number of indices
  22112. */
  22113. getTotalIndices(): number;
  22114. /**
  22115. * Gets the index buffer array
  22116. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22117. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22118. * @returns the index buffer array
  22119. */
  22120. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22121. /**
  22122. * Gets the index buffer
  22123. * @return the index buffer
  22124. */
  22125. getIndexBuffer(): Nullable<DataBuffer>;
  22126. /** @hidden */
  22127. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22128. /**
  22129. * Release the associated resources for a specific mesh
  22130. * @param mesh defines the source mesh
  22131. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22132. */
  22133. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22134. /**
  22135. * Apply current geometry to a given mesh
  22136. * @param mesh defines the mesh to apply geometry to
  22137. */
  22138. applyToMesh(mesh: Mesh): void;
  22139. private _updateExtend;
  22140. private _applyToMesh;
  22141. private notifyUpdate;
  22142. /**
  22143. * Load the geometry if it was flagged as delay loaded
  22144. * @param scene defines the hosting scene
  22145. * @param onLoaded defines a callback called when the geometry is loaded
  22146. */
  22147. load(scene: Scene, onLoaded?: () => void): void;
  22148. private _queueLoad;
  22149. /**
  22150. * Invert the geometry to move from a right handed system to a left handed one.
  22151. */
  22152. toLeftHanded(): void;
  22153. /** @hidden */
  22154. _resetPointsArrayCache(): void;
  22155. /** @hidden */
  22156. _generatePointsArray(): boolean;
  22157. /**
  22158. * Gets a value indicating if the geometry is disposed
  22159. * @returns true if the geometry was disposed
  22160. */
  22161. isDisposed(): boolean;
  22162. private _disposeVertexArrayObjects;
  22163. /**
  22164. * Free all associated resources
  22165. */
  22166. dispose(): void;
  22167. /**
  22168. * Clone the current geometry into a new geometry
  22169. * @param id defines the unique ID of the new geometry
  22170. * @returns a new geometry object
  22171. */
  22172. copy(id: string): Geometry;
  22173. /**
  22174. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22175. * @return a JSON representation of the current geometry data (without the vertices data)
  22176. */
  22177. serialize(): any;
  22178. private toNumberArray;
  22179. /**
  22180. * Serialize all vertices data into a JSON oject
  22181. * @returns a JSON representation of the current geometry data
  22182. */
  22183. serializeVerticeData(): any;
  22184. /**
  22185. * Extracts a clone of a mesh geometry
  22186. * @param mesh defines the source mesh
  22187. * @param id defines the unique ID of the new geometry object
  22188. * @returns the new geometry object
  22189. */
  22190. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22191. /**
  22192. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22193. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22194. * Be aware Math.random() could cause collisions, but:
  22195. * "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"
  22196. * @returns a string containing a new GUID
  22197. */
  22198. static RandomId(): string;
  22199. /** @hidden */
  22200. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22201. private static _CleanMatricesWeights;
  22202. /**
  22203. * Create a new geometry from persisted data (Using .babylon file format)
  22204. * @param parsedVertexData defines the persisted data
  22205. * @param scene defines the hosting scene
  22206. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22207. * @returns the new geometry object
  22208. */
  22209. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22210. }
  22211. }
  22212. declare module "babylonjs/Meshes/mesh.vertexData" {
  22213. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22214. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22215. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22216. import { Geometry } from "babylonjs/Meshes/geometry";
  22217. import { Mesh } from "babylonjs/Meshes/mesh";
  22218. /**
  22219. * Define an interface for all classes that will get and set the data on vertices
  22220. */
  22221. export interface IGetSetVerticesData {
  22222. /**
  22223. * Gets a boolean indicating if specific vertex data is present
  22224. * @param kind defines the vertex data kind to use
  22225. * @returns true is data kind is present
  22226. */
  22227. isVerticesDataPresent(kind: string): boolean;
  22228. /**
  22229. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22230. * @param kind defines the data kind (Position, normal, etc...)
  22231. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22232. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22233. * @returns a float array containing vertex data
  22234. */
  22235. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22236. /**
  22237. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22238. * @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.
  22239. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22240. * @returns the indices array or an empty array if the mesh has no geometry
  22241. */
  22242. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22243. /**
  22244. * Set specific vertex data
  22245. * @param kind defines the data kind (Position, normal, etc...)
  22246. * @param data defines the vertex data to use
  22247. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22248. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22249. */
  22250. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22251. /**
  22252. * Update a specific associated vertex buffer
  22253. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22254. * - VertexBuffer.PositionKind
  22255. * - VertexBuffer.UVKind
  22256. * - VertexBuffer.UV2Kind
  22257. * - VertexBuffer.UV3Kind
  22258. * - VertexBuffer.UV4Kind
  22259. * - VertexBuffer.UV5Kind
  22260. * - VertexBuffer.UV6Kind
  22261. * - VertexBuffer.ColorKind
  22262. * - VertexBuffer.MatricesIndicesKind
  22263. * - VertexBuffer.MatricesIndicesExtraKind
  22264. * - VertexBuffer.MatricesWeightsKind
  22265. * - VertexBuffer.MatricesWeightsExtraKind
  22266. * @param data defines the data source
  22267. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22268. * @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)
  22269. */
  22270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22271. /**
  22272. * Creates a new index buffer
  22273. * @param indices defines the indices to store in the index buffer
  22274. * @param totalVertices defines the total number of vertices (could be null)
  22275. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22276. */
  22277. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22278. }
  22279. /**
  22280. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22281. */
  22282. export class VertexData {
  22283. /**
  22284. * Mesh side orientation : usually the external or front surface
  22285. */
  22286. static readonly FRONTSIDE: number;
  22287. /**
  22288. * Mesh side orientation : usually the internal or back surface
  22289. */
  22290. static readonly BACKSIDE: number;
  22291. /**
  22292. * Mesh side orientation : both internal and external or front and back surfaces
  22293. */
  22294. static readonly DOUBLESIDE: number;
  22295. /**
  22296. * Mesh side orientation : by default, `FRONTSIDE`
  22297. */
  22298. static readonly DEFAULTSIDE: number;
  22299. /**
  22300. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22301. */
  22302. positions: Nullable<FloatArray>;
  22303. /**
  22304. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22305. */
  22306. normals: Nullable<FloatArray>;
  22307. /**
  22308. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22309. */
  22310. tangents: Nullable<FloatArray>;
  22311. /**
  22312. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22313. */
  22314. uvs: Nullable<FloatArray>;
  22315. /**
  22316. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22317. */
  22318. uvs2: Nullable<FloatArray>;
  22319. /**
  22320. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22321. */
  22322. uvs3: Nullable<FloatArray>;
  22323. /**
  22324. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22325. */
  22326. uvs4: Nullable<FloatArray>;
  22327. /**
  22328. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22329. */
  22330. uvs5: Nullable<FloatArray>;
  22331. /**
  22332. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22333. */
  22334. uvs6: Nullable<FloatArray>;
  22335. /**
  22336. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22337. */
  22338. colors: Nullable<FloatArray>;
  22339. /**
  22340. * 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).
  22341. */
  22342. matricesIndices: Nullable<FloatArray>;
  22343. /**
  22344. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22345. */
  22346. matricesWeights: Nullable<FloatArray>;
  22347. /**
  22348. * An array extending the number of possible indices
  22349. */
  22350. matricesIndicesExtra: Nullable<FloatArray>;
  22351. /**
  22352. * An array extending the number of possible weights when the number of indices is extended
  22353. */
  22354. matricesWeightsExtra: Nullable<FloatArray>;
  22355. /**
  22356. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22357. */
  22358. indices: Nullable<IndicesArray>;
  22359. /**
  22360. * Uses the passed data array to set the set the values for the specified kind of data
  22361. * @param data a linear array of floating numbers
  22362. * @param kind the type of data that is being set, eg positions, colors etc
  22363. */
  22364. set(data: FloatArray, kind: string): void;
  22365. /**
  22366. * Associates the vertexData to the passed Mesh.
  22367. * Sets it as updatable or not (default `false`)
  22368. * @param mesh the mesh the vertexData is applied to
  22369. * @param updatable when used and having the value true allows new data to update the vertexData
  22370. * @returns the VertexData
  22371. */
  22372. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22373. /**
  22374. * Associates the vertexData to the passed Geometry.
  22375. * Sets it as updatable or not (default `false`)
  22376. * @param geometry the geometry the vertexData is applied to
  22377. * @param updatable when used and having the value true allows new data to update the vertexData
  22378. * @returns VertexData
  22379. */
  22380. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22381. /**
  22382. * Updates the associated mesh
  22383. * @param mesh the mesh to be updated
  22384. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22385. * @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
  22386. * @returns VertexData
  22387. */
  22388. updateMesh(mesh: Mesh): VertexData;
  22389. /**
  22390. * Updates the associated geometry
  22391. * @param geometry the geometry to be updated
  22392. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22393. * @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
  22394. * @returns VertexData.
  22395. */
  22396. updateGeometry(geometry: Geometry): VertexData;
  22397. private _applyTo;
  22398. private _update;
  22399. /**
  22400. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22401. * @param matrix the transforming matrix
  22402. * @returns the VertexData
  22403. */
  22404. transform(matrix: Matrix): VertexData;
  22405. /**
  22406. * Merges the passed VertexData into the current one
  22407. * @param other the VertexData to be merged into the current one
  22408. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22409. * @returns the modified VertexData
  22410. */
  22411. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22412. private _mergeElement;
  22413. private _validate;
  22414. /**
  22415. * Serializes the VertexData
  22416. * @returns a serialized object
  22417. */
  22418. serialize(): any;
  22419. /**
  22420. * Extracts the vertexData from a mesh
  22421. * @param mesh the mesh from which to extract the VertexData
  22422. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22423. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22424. * @returns the object VertexData associated to the passed mesh
  22425. */
  22426. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22427. /**
  22428. * Extracts the vertexData from the geometry
  22429. * @param geometry the geometry from which to extract the VertexData
  22430. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22431. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22432. * @returns the object VertexData associated to the passed mesh
  22433. */
  22434. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22435. private static _ExtractFrom;
  22436. /**
  22437. * Creates the VertexData for a Ribbon
  22438. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22439. * * pathArray array of paths, each of which an array of successive Vector3
  22440. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22441. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22442. * * 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
  22443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22444. * * 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)
  22445. * * 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)
  22446. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22447. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22448. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22449. * @returns the VertexData of the ribbon
  22450. */
  22451. static CreateRibbon(options: {
  22452. pathArray: Vector3[][];
  22453. closeArray?: boolean;
  22454. closePath?: boolean;
  22455. offset?: number;
  22456. sideOrientation?: number;
  22457. frontUVs?: Vector4;
  22458. backUVs?: Vector4;
  22459. invertUV?: boolean;
  22460. uvs?: Vector2[];
  22461. colors?: Color4[];
  22462. }): VertexData;
  22463. /**
  22464. * Creates the VertexData for a box
  22465. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22466. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22467. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22468. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22469. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22470. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22471. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22473. * * 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)
  22474. * * 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)
  22475. * @returns the VertexData of the box
  22476. */
  22477. static CreateBox(options: {
  22478. size?: number;
  22479. width?: number;
  22480. height?: number;
  22481. depth?: number;
  22482. faceUV?: Vector4[];
  22483. faceColors?: Color4[];
  22484. sideOrientation?: number;
  22485. frontUVs?: Vector4;
  22486. backUVs?: Vector4;
  22487. }): VertexData;
  22488. /**
  22489. * Creates the VertexData for a tiled box
  22490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22491. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22492. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22493. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22495. * @returns the VertexData of the box
  22496. */
  22497. static CreateTiledBox(options: {
  22498. pattern?: number;
  22499. width?: number;
  22500. height?: number;
  22501. depth?: number;
  22502. tileSize?: number;
  22503. tileWidth?: number;
  22504. tileHeight?: number;
  22505. alignHorizontal?: number;
  22506. alignVertical?: number;
  22507. faceUV?: Vector4[];
  22508. faceColors?: Color4[];
  22509. sideOrientation?: number;
  22510. }): VertexData;
  22511. /**
  22512. * Creates the VertexData for a tiled plane
  22513. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22514. * * pattern a limited pattern arrangement depending on the number
  22515. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22516. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22517. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22519. * * 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)
  22520. * * 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)
  22521. * @returns the VertexData of the tiled plane
  22522. */
  22523. static CreateTiledPlane(options: {
  22524. pattern?: number;
  22525. tileSize?: number;
  22526. tileWidth?: number;
  22527. tileHeight?: number;
  22528. size?: number;
  22529. width?: number;
  22530. height?: number;
  22531. alignHorizontal?: number;
  22532. alignVertical?: number;
  22533. sideOrientation?: number;
  22534. frontUVs?: Vector4;
  22535. backUVs?: Vector4;
  22536. }): VertexData;
  22537. /**
  22538. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22540. * * segments sets the number of horizontal strips optional, default 32
  22541. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22542. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22543. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22544. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22545. * * 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
  22546. * * 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
  22547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22548. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22549. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22550. * @returns the VertexData of the ellipsoid
  22551. */
  22552. static CreateSphere(options: {
  22553. segments?: number;
  22554. diameter?: number;
  22555. diameterX?: number;
  22556. diameterY?: number;
  22557. diameterZ?: number;
  22558. arc?: number;
  22559. slice?: number;
  22560. sideOrientation?: number;
  22561. frontUVs?: Vector4;
  22562. backUVs?: Vector4;
  22563. }): VertexData;
  22564. /**
  22565. * Creates the VertexData for a cylinder, cone or prism
  22566. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22567. * * height sets the height (y direction) of the cylinder, optional, default 2
  22568. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22569. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22570. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22571. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22572. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22573. * * 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
  22574. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22575. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22576. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22577. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22580. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22581. * @returns the VertexData of the cylinder, cone or prism
  22582. */
  22583. static CreateCylinder(options: {
  22584. height?: number;
  22585. diameterTop?: number;
  22586. diameterBottom?: number;
  22587. diameter?: number;
  22588. tessellation?: number;
  22589. subdivisions?: number;
  22590. arc?: number;
  22591. faceColors?: Color4[];
  22592. faceUV?: Vector4[];
  22593. hasRings?: boolean;
  22594. enclose?: boolean;
  22595. sideOrientation?: number;
  22596. frontUVs?: Vector4;
  22597. backUVs?: Vector4;
  22598. }): VertexData;
  22599. /**
  22600. * Creates the VertexData for a torus
  22601. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22602. * * diameter the diameter of the torus, optional default 1
  22603. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22604. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * @returns the VertexData of the torus
  22609. */
  22610. static CreateTorus(options: {
  22611. diameter?: number;
  22612. thickness?: number;
  22613. tessellation?: number;
  22614. sideOrientation?: number;
  22615. frontUVs?: Vector4;
  22616. backUVs?: Vector4;
  22617. }): VertexData;
  22618. /**
  22619. * Creates the VertexData of the LineSystem
  22620. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22621. * - lines an array of lines, each line being an array of successive Vector3
  22622. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22623. * @returns the VertexData of the LineSystem
  22624. */
  22625. static CreateLineSystem(options: {
  22626. lines: Vector3[][];
  22627. colors?: Nullable<Color4[][]>;
  22628. }): VertexData;
  22629. /**
  22630. * Create the VertexData for a DashedLines
  22631. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22632. * - points an array successive Vector3
  22633. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22634. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22635. * - dashNb the intended total number of dashes, optional, default 200
  22636. * @returns the VertexData for the DashedLines
  22637. */
  22638. static CreateDashedLines(options: {
  22639. points: Vector3[];
  22640. dashSize?: number;
  22641. gapSize?: number;
  22642. dashNb?: number;
  22643. }): VertexData;
  22644. /**
  22645. * Creates the VertexData for a Ground
  22646. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22647. * - width the width (x direction) of the ground, optional, default 1
  22648. * - height the height (z direction) of the ground, optional, default 1
  22649. * - subdivisions the number of subdivisions per side, optional, default 1
  22650. * @returns the VertexData of the Ground
  22651. */
  22652. static CreateGround(options: {
  22653. width?: number;
  22654. height?: number;
  22655. subdivisions?: number;
  22656. subdivisionsX?: number;
  22657. subdivisionsY?: number;
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22661. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22662. * * xmin the ground minimum X coordinate, optional, default -1
  22663. * * zmin the ground minimum Z coordinate, optional, default -1
  22664. * * xmax the ground maximum X coordinate, optional, default 1
  22665. * * zmax the ground maximum Z coordinate, optional, default 1
  22666. * * 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}
  22667. * * 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}
  22668. * @returns the VertexData of the TiledGround
  22669. */
  22670. static CreateTiledGround(options: {
  22671. xmin: number;
  22672. zmin: number;
  22673. xmax: number;
  22674. zmax: number;
  22675. subdivisions?: {
  22676. w: number;
  22677. h: number;
  22678. };
  22679. precision?: {
  22680. w: number;
  22681. h: number;
  22682. };
  22683. }): VertexData;
  22684. /**
  22685. * Creates the VertexData of the Ground designed from a heightmap
  22686. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22687. * * width the width (x direction) of the ground
  22688. * * height the height (z direction) of the ground
  22689. * * subdivisions the number of subdivisions per side
  22690. * * minHeight the minimum altitude on the ground, optional, default 0
  22691. * * maxHeight the maximum altitude on the ground, optional default 1
  22692. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22693. * * buffer the array holding the image color data
  22694. * * bufferWidth the width of image
  22695. * * bufferHeight the height of image
  22696. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22697. * @returns the VertexData of the Ground designed from a heightmap
  22698. */
  22699. static CreateGroundFromHeightMap(options: {
  22700. width: number;
  22701. height: number;
  22702. subdivisions: number;
  22703. minHeight: number;
  22704. maxHeight: number;
  22705. colorFilter: Color3;
  22706. buffer: Uint8Array;
  22707. bufferWidth: number;
  22708. bufferHeight: number;
  22709. alphaFilter: number;
  22710. }): VertexData;
  22711. /**
  22712. * Creates the VertexData for a Plane
  22713. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22714. * * size sets the width and height of the plane to the value of size, optional default 1
  22715. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22716. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22718. * * 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)
  22719. * * 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)
  22720. * @returns the VertexData of the box
  22721. */
  22722. static CreatePlane(options: {
  22723. size?: number;
  22724. width?: number;
  22725. height?: number;
  22726. sideOrientation?: number;
  22727. frontUVs?: Vector4;
  22728. backUVs?: Vector4;
  22729. }): VertexData;
  22730. /**
  22731. * Creates the VertexData of the Disc or regular Polygon
  22732. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22733. * * radius the radius of the disc, optional default 0.5
  22734. * * tessellation the number of polygon sides, optional, default 64
  22735. * * 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
  22736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22737. * * 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)
  22738. * * 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)
  22739. * @returns the VertexData of the box
  22740. */
  22741. static CreateDisc(options: {
  22742. radius?: number;
  22743. tessellation?: number;
  22744. arc?: number;
  22745. sideOrientation?: number;
  22746. frontUVs?: Vector4;
  22747. backUVs?: Vector4;
  22748. }): VertexData;
  22749. /**
  22750. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22751. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22752. * @param polygon a mesh built from polygonTriangulation.build()
  22753. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22754. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22755. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22756. * @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)
  22757. * @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)
  22758. * @returns the VertexData of the Polygon
  22759. */
  22760. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22761. /**
  22762. * Creates the VertexData of the IcoSphere
  22763. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22764. * * radius the radius of the IcoSphere, optional default 1
  22765. * * radiusX allows stretching in the x direction, optional, default radius
  22766. * * radiusY allows stretching in the y direction, optional, default radius
  22767. * * radiusZ allows stretching in the z direction, optional, default radius
  22768. * * flat when true creates a flat shaded mesh, optional, default true
  22769. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22771. * * 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)
  22772. * * 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)
  22773. * @returns the VertexData of the IcoSphere
  22774. */
  22775. static CreateIcoSphere(options: {
  22776. radius?: number;
  22777. radiusX?: number;
  22778. radiusY?: number;
  22779. radiusZ?: number;
  22780. flat?: boolean;
  22781. subdivisions?: number;
  22782. sideOrientation?: number;
  22783. frontUVs?: Vector4;
  22784. backUVs?: Vector4;
  22785. }): VertexData;
  22786. /**
  22787. * Creates the VertexData for a Polyhedron
  22788. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22789. * * type provided types are:
  22790. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22791. * * 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)
  22792. * * size the size of the IcoSphere, optional default 1
  22793. * * sizeX allows stretching in the x direction, optional, default size
  22794. * * sizeY allows stretching in the y direction, optional, default size
  22795. * * sizeZ allows stretching in the z direction, optional, default size
  22796. * * 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
  22797. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22798. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22799. * * flat when true creates a flat shaded mesh, optional, default true
  22800. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22802. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22803. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22804. * @returns the VertexData of the Polyhedron
  22805. */
  22806. static CreatePolyhedron(options: {
  22807. type?: number;
  22808. size?: number;
  22809. sizeX?: number;
  22810. sizeY?: number;
  22811. sizeZ?: number;
  22812. custom?: any;
  22813. faceUV?: Vector4[];
  22814. faceColors?: Color4[];
  22815. flat?: boolean;
  22816. sideOrientation?: number;
  22817. frontUVs?: Vector4;
  22818. backUVs?: Vector4;
  22819. }): VertexData;
  22820. /**
  22821. * Creates the VertexData for a TorusKnot
  22822. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22823. * * radius the radius of the torus knot, optional, default 2
  22824. * * tube the thickness of the tube, optional, default 0.5
  22825. * * radialSegments the number of sides on each tube segments, optional, default 32
  22826. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22827. * * p the number of windings around the z axis, optional, default 2
  22828. * * q the number of windings around the x axis, optional, default 3
  22829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22830. * * 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)
  22831. * * 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)
  22832. * @returns the VertexData of the Torus Knot
  22833. */
  22834. static CreateTorusKnot(options: {
  22835. radius?: number;
  22836. tube?: number;
  22837. radialSegments?: number;
  22838. tubularSegments?: number;
  22839. p?: number;
  22840. q?: number;
  22841. sideOrientation?: number;
  22842. frontUVs?: Vector4;
  22843. backUVs?: Vector4;
  22844. }): VertexData;
  22845. /**
  22846. * Compute normals for given positions and indices
  22847. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22848. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22849. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22850. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22851. * * facetNormals : optional array of facet normals (vector3)
  22852. * * facetPositions : optional array of facet positions (vector3)
  22853. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22854. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22855. * * bInfo : optional bounding info, required for facetPartitioning computation
  22856. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22857. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22858. * * useRightHandedSystem: optional boolean to for right handed system computation
  22859. * * depthSort : optional boolean to enable the facet depth sort computation
  22860. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22861. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22862. */
  22863. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22864. facetNormals?: any;
  22865. facetPositions?: any;
  22866. facetPartitioning?: any;
  22867. ratio?: number;
  22868. bInfo?: any;
  22869. bbSize?: Vector3;
  22870. subDiv?: any;
  22871. useRightHandedSystem?: boolean;
  22872. depthSort?: boolean;
  22873. distanceTo?: Vector3;
  22874. depthSortedFacets?: any;
  22875. }): void;
  22876. /** @hidden */
  22877. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22878. /**
  22879. * Applies VertexData created from the imported parameters to the geometry
  22880. * @param parsedVertexData the parsed data from an imported file
  22881. * @param geometry the geometry to apply the VertexData to
  22882. */
  22883. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22884. }
  22885. }
  22886. declare module "babylonjs/Morph/morphTarget" {
  22887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22888. import { Observable } from "babylonjs/Misc/observable";
  22889. import { Nullable, FloatArray } from "babylonjs/types";
  22890. import { Scene } from "babylonjs/scene";
  22891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22892. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22893. /**
  22894. * Defines a target to use with MorphTargetManager
  22895. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22896. */
  22897. export class MorphTarget implements IAnimatable {
  22898. /** defines the name of the target */
  22899. name: string;
  22900. /**
  22901. * Gets or sets the list of animations
  22902. */
  22903. animations: import("babylonjs/Animations/animation").Animation[];
  22904. private _scene;
  22905. private _positions;
  22906. private _normals;
  22907. private _tangents;
  22908. private _uvs;
  22909. private _influence;
  22910. private _uniqueId;
  22911. /**
  22912. * Observable raised when the influence changes
  22913. */
  22914. onInfluenceChanged: Observable<boolean>;
  22915. /** @hidden */
  22916. _onDataLayoutChanged: Observable<void>;
  22917. /**
  22918. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22919. */
  22920. influence: number;
  22921. /**
  22922. * Gets or sets the id of the morph Target
  22923. */
  22924. id: string;
  22925. private _animationPropertiesOverride;
  22926. /**
  22927. * Gets or sets the animation properties override
  22928. */
  22929. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22930. /**
  22931. * Creates a new MorphTarget
  22932. * @param name defines the name of the target
  22933. * @param influence defines the influence to use
  22934. * @param scene defines the scene the morphtarget belongs to
  22935. */
  22936. constructor(
  22937. /** defines the name of the target */
  22938. name: string, influence?: number, scene?: Nullable<Scene>);
  22939. /**
  22940. * Gets the unique ID of this manager
  22941. */
  22942. readonly uniqueId: number;
  22943. /**
  22944. * Gets a boolean defining if the target contains position data
  22945. */
  22946. readonly hasPositions: boolean;
  22947. /**
  22948. * Gets a boolean defining if the target contains normal data
  22949. */
  22950. readonly hasNormals: boolean;
  22951. /**
  22952. * Gets a boolean defining if the target contains tangent data
  22953. */
  22954. readonly hasTangents: boolean;
  22955. /**
  22956. * Gets a boolean defining if the target contains texture coordinates data
  22957. */
  22958. readonly hasUVs: boolean;
  22959. /**
  22960. * Affects position data to this target
  22961. * @param data defines the position data to use
  22962. */
  22963. setPositions(data: Nullable<FloatArray>): void;
  22964. /**
  22965. * Gets the position data stored in this target
  22966. * @returns a FloatArray containing the position data (or null if not present)
  22967. */
  22968. getPositions(): Nullable<FloatArray>;
  22969. /**
  22970. * Affects normal data to this target
  22971. * @param data defines the normal data to use
  22972. */
  22973. setNormals(data: Nullable<FloatArray>): void;
  22974. /**
  22975. * Gets the normal data stored in this target
  22976. * @returns a FloatArray containing the normal data (or null if not present)
  22977. */
  22978. getNormals(): Nullable<FloatArray>;
  22979. /**
  22980. * Affects tangent data to this target
  22981. * @param data defines the tangent data to use
  22982. */
  22983. setTangents(data: Nullable<FloatArray>): void;
  22984. /**
  22985. * Gets the tangent data stored in this target
  22986. * @returns a FloatArray containing the tangent data (or null if not present)
  22987. */
  22988. getTangents(): Nullable<FloatArray>;
  22989. /**
  22990. * Affects texture coordinates data to this target
  22991. * @param data defines the texture coordinates data to use
  22992. */
  22993. setUVs(data: Nullable<FloatArray>): void;
  22994. /**
  22995. * Gets the texture coordinates data stored in this target
  22996. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22997. */
  22998. getUVs(): Nullable<FloatArray>;
  22999. /**
  23000. * Clone the current target
  23001. * @returns a new MorphTarget
  23002. */
  23003. clone(): MorphTarget;
  23004. /**
  23005. * Serializes the current target into a Serialization object
  23006. * @returns the serialized object
  23007. */
  23008. serialize(): any;
  23009. /**
  23010. * Returns the string "MorphTarget"
  23011. * @returns "MorphTarget"
  23012. */
  23013. getClassName(): string;
  23014. /**
  23015. * Creates a new target from serialized data
  23016. * @param serializationObject defines the serialized data to use
  23017. * @returns a new MorphTarget
  23018. */
  23019. static Parse(serializationObject: any): MorphTarget;
  23020. /**
  23021. * Creates a MorphTarget from mesh data
  23022. * @param mesh defines the source mesh
  23023. * @param name defines the name to use for the new target
  23024. * @param influence defines the influence to attach to the target
  23025. * @returns a new MorphTarget
  23026. */
  23027. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23028. }
  23029. }
  23030. declare module "babylonjs/Morph/morphTargetManager" {
  23031. import { Nullable } from "babylonjs/types";
  23032. import { Scene } from "babylonjs/scene";
  23033. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23034. /**
  23035. * This class is used to deform meshes using morphing between different targets
  23036. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23037. */
  23038. export class MorphTargetManager {
  23039. private _targets;
  23040. private _targetInfluenceChangedObservers;
  23041. private _targetDataLayoutChangedObservers;
  23042. private _activeTargets;
  23043. private _scene;
  23044. private _influences;
  23045. private _supportsNormals;
  23046. private _supportsTangents;
  23047. private _supportsUVs;
  23048. private _vertexCount;
  23049. private _uniqueId;
  23050. private _tempInfluences;
  23051. /**
  23052. * Gets or sets a boolean indicating if normals must be morphed
  23053. */
  23054. enableNormalMorphing: boolean;
  23055. /**
  23056. * Gets or sets a boolean indicating if tangents must be morphed
  23057. */
  23058. enableTangentMorphing: boolean;
  23059. /**
  23060. * Gets or sets a boolean indicating if UV must be morphed
  23061. */
  23062. enableUVMorphing: boolean;
  23063. /**
  23064. * Creates a new MorphTargetManager
  23065. * @param scene defines the current scene
  23066. */
  23067. constructor(scene?: Nullable<Scene>);
  23068. /**
  23069. * Gets the unique ID of this manager
  23070. */
  23071. readonly uniqueId: number;
  23072. /**
  23073. * Gets the number of vertices handled by this manager
  23074. */
  23075. readonly vertexCount: number;
  23076. /**
  23077. * Gets a boolean indicating if this manager supports morphing of normals
  23078. */
  23079. readonly supportsNormals: boolean;
  23080. /**
  23081. * Gets a boolean indicating if this manager supports morphing of tangents
  23082. */
  23083. readonly supportsTangents: boolean;
  23084. /**
  23085. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23086. */
  23087. readonly supportsUVs: boolean;
  23088. /**
  23089. * Gets the number of targets stored in this manager
  23090. */
  23091. readonly numTargets: number;
  23092. /**
  23093. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23094. */
  23095. readonly numInfluencers: number;
  23096. /**
  23097. * Gets the list of influences (one per target)
  23098. */
  23099. readonly influences: Float32Array;
  23100. /**
  23101. * Gets the active target at specified index. An active target is a target with an influence > 0
  23102. * @param index defines the index to check
  23103. * @returns the requested target
  23104. */
  23105. getActiveTarget(index: number): MorphTarget;
  23106. /**
  23107. * Gets the target at specified index
  23108. * @param index defines the index to check
  23109. * @returns the requested target
  23110. */
  23111. getTarget(index: number): MorphTarget;
  23112. /**
  23113. * Add a new target to this manager
  23114. * @param target defines the target to add
  23115. */
  23116. addTarget(target: MorphTarget): void;
  23117. /**
  23118. * Removes a target from the manager
  23119. * @param target defines the target to remove
  23120. */
  23121. removeTarget(target: MorphTarget): void;
  23122. /**
  23123. * Clone the current manager
  23124. * @returns a new MorphTargetManager
  23125. */
  23126. clone(): MorphTargetManager;
  23127. /**
  23128. * Serializes the current manager into a Serialization object
  23129. * @returns the serialized object
  23130. */
  23131. serialize(): any;
  23132. private _syncActiveTargets;
  23133. /**
  23134. * Syncrhonize the targets with all the meshes using this morph target manager
  23135. */
  23136. synchronize(): void;
  23137. /**
  23138. * Creates a new MorphTargetManager from serialized data
  23139. * @param serializationObject defines the serialized data
  23140. * @param scene defines the hosting scene
  23141. * @returns the new MorphTargetManager
  23142. */
  23143. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23144. }
  23145. }
  23146. declare module "babylonjs/Meshes/meshLODLevel" {
  23147. import { Mesh } from "babylonjs/Meshes/mesh";
  23148. import { Nullable } from "babylonjs/types";
  23149. /**
  23150. * Class used to represent a specific level of detail of a mesh
  23151. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23152. */
  23153. export class MeshLODLevel {
  23154. /** Defines the distance where this level should start being displayed */
  23155. distance: number;
  23156. /** Defines the mesh to use to render this level */
  23157. mesh: Nullable<Mesh>;
  23158. /**
  23159. * Creates a new LOD level
  23160. * @param distance defines the distance where this level should star being displayed
  23161. * @param mesh defines the mesh to use to render this level
  23162. */
  23163. constructor(
  23164. /** Defines the distance where this level should start being displayed */
  23165. distance: number,
  23166. /** Defines the mesh to use to render this level */
  23167. mesh: Nullable<Mesh>);
  23168. }
  23169. }
  23170. declare module "babylonjs/Meshes/groundMesh" {
  23171. import { Scene } from "babylonjs/scene";
  23172. import { Vector3 } from "babylonjs/Maths/math.vector";
  23173. import { Mesh } from "babylonjs/Meshes/mesh";
  23174. /**
  23175. * Mesh representing the gorund
  23176. */
  23177. export class GroundMesh extends Mesh {
  23178. /** If octree should be generated */
  23179. generateOctree: boolean;
  23180. private _heightQuads;
  23181. /** @hidden */
  23182. _subdivisionsX: number;
  23183. /** @hidden */
  23184. _subdivisionsY: number;
  23185. /** @hidden */
  23186. _width: number;
  23187. /** @hidden */
  23188. _height: number;
  23189. /** @hidden */
  23190. _minX: number;
  23191. /** @hidden */
  23192. _maxX: number;
  23193. /** @hidden */
  23194. _minZ: number;
  23195. /** @hidden */
  23196. _maxZ: number;
  23197. constructor(name: string, scene: Scene);
  23198. /**
  23199. * "GroundMesh"
  23200. * @returns "GroundMesh"
  23201. */
  23202. getClassName(): string;
  23203. /**
  23204. * The minimum of x and y subdivisions
  23205. */
  23206. readonly subdivisions: number;
  23207. /**
  23208. * X subdivisions
  23209. */
  23210. readonly subdivisionsX: number;
  23211. /**
  23212. * Y subdivisions
  23213. */
  23214. readonly subdivisionsY: number;
  23215. /**
  23216. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23217. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23218. * @param chunksCount the number of subdivisions for x and y
  23219. * @param octreeBlocksSize (Default: 32)
  23220. */
  23221. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23222. /**
  23223. * Returns a height (y) value in the Worl system :
  23224. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23225. * @param x x coordinate
  23226. * @param z z coordinate
  23227. * @returns the ground y position if (x, z) are outside the ground surface.
  23228. */
  23229. getHeightAtCoordinates(x: number, z: number): number;
  23230. /**
  23231. * Returns a normalized vector (Vector3) orthogonal to the ground
  23232. * at the ground coordinates (x, z) expressed in the World system.
  23233. * @param x x coordinate
  23234. * @param z z coordinate
  23235. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23236. */
  23237. getNormalAtCoordinates(x: number, z: number): Vector3;
  23238. /**
  23239. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23240. * at the ground coordinates (x, z) expressed in the World system.
  23241. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23242. * @param x x coordinate
  23243. * @param z z coordinate
  23244. * @param ref vector to store the result
  23245. * @returns the GroundMesh.
  23246. */
  23247. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23248. /**
  23249. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23250. * if the ground has been updated.
  23251. * This can be used in the render loop.
  23252. * @returns the GroundMesh.
  23253. */
  23254. updateCoordinateHeights(): GroundMesh;
  23255. private _getFacetAt;
  23256. private _initHeightQuads;
  23257. private _computeHeightQuads;
  23258. /**
  23259. * Serializes this ground mesh
  23260. * @param serializationObject object to write serialization to
  23261. */
  23262. serialize(serializationObject: any): void;
  23263. /**
  23264. * Parses a serialized ground mesh
  23265. * @param parsedMesh the serialized mesh
  23266. * @param scene the scene to create the ground mesh in
  23267. * @returns the created ground mesh
  23268. */
  23269. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23270. }
  23271. }
  23272. declare module "babylonjs/Physics/physicsJoint" {
  23273. import { Vector3 } from "babylonjs/Maths/math.vector";
  23274. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23275. /**
  23276. * Interface for Physics-Joint data
  23277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23278. */
  23279. export interface PhysicsJointData {
  23280. /**
  23281. * The main pivot of the joint
  23282. */
  23283. mainPivot?: Vector3;
  23284. /**
  23285. * The connected pivot of the joint
  23286. */
  23287. connectedPivot?: Vector3;
  23288. /**
  23289. * The main axis of the joint
  23290. */
  23291. mainAxis?: Vector3;
  23292. /**
  23293. * The connected axis of the joint
  23294. */
  23295. connectedAxis?: Vector3;
  23296. /**
  23297. * The collision of the joint
  23298. */
  23299. collision?: boolean;
  23300. /**
  23301. * Native Oimo/Cannon/Energy data
  23302. */
  23303. nativeParams?: any;
  23304. }
  23305. /**
  23306. * This is a holder class for the physics joint created by the physics plugin
  23307. * It holds a set of functions to control the underlying joint
  23308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23309. */
  23310. export class PhysicsJoint {
  23311. /**
  23312. * The type of the physics joint
  23313. */
  23314. type: number;
  23315. /**
  23316. * The data for the physics joint
  23317. */
  23318. jointData: PhysicsJointData;
  23319. private _physicsJoint;
  23320. protected _physicsPlugin: IPhysicsEnginePlugin;
  23321. /**
  23322. * Initializes the physics joint
  23323. * @param type The type of the physics joint
  23324. * @param jointData The data for the physics joint
  23325. */
  23326. constructor(
  23327. /**
  23328. * The type of the physics joint
  23329. */
  23330. type: number,
  23331. /**
  23332. * The data for the physics joint
  23333. */
  23334. jointData: PhysicsJointData);
  23335. /**
  23336. * Gets the physics joint
  23337. */
  23338. /**
  23339. * Sets the physics joint
  23340. */
  23341. physicsJoint: any;
  23342. /**
  23343. * Sets the physics plugin
  23344. */
  23345. physicsPlugin: IPhysicsEnginePlugin;
  23346. /**
  23347. * Execute a function that is physics-plugin specific.
  23348. * @param {Function} func the function that will be executed.
  23349. * It accepts two parameters: the physics world and the physics joint
  23350. */
  23351. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23352. /**
  23353. * Distance-Joint type
  23354. */
  23355. static DistanceJoint: number;
  23356. /**
  23357. * Hinge-Joint type
  23358. */
  23359. static HingeJoint: number;
  23360. /**
  23361. * Ball-and-Socket joint type
  23362. */
  23363. static BallAndSocketJoint: number;
  23364. /**
  23365. * Wheel-Joint type
  23366. */
  23367. static WheelJoint: number;
  23368. /**
  23369. * Slider-Joint type
  23370. */
  23371. static SliderJoint: number;
  23372. /**
  23373. * Prismatic-Joint type
  23374. */
  23375. static PrismaticJoint: number;
  23376. /**
  23377. * Universal-Joint type
  23378. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23379. */
  23380. static UniversalJoint: number;
  23381. /**
  23382. * Hinge-Joint 2 type
  23383. */
  23384. static Hinge2Joint: number;
  23385. /**
  23386. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23387. */
  23388. static PointToPointJoint: number;
  23389. /**
  23390. * Spring-Joint type
  23391. */
  23392. static SpringJoint: number;
  23393. /**
  23394. * Lock-Joint type
  23395. */
  23396. static LockJoint: number;
  23397. }
  23398. /**
  23399. * A class representing a physics distance joint
  23400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23401. */
  23402. export class DistanceJoint extends PhysicsJoint {
  23403. /**
  23404. *
  23405. * @param jointData The data for the Distance-Joint
  23406. */
  23407. constructor(jointData: DistanceJointData);
  23408. /**
  23409. * Update the predefined distance.
  23410. * @param maxDistance The maximum preferred distance
  23411. * @param minDistance The minimum preferred distance
  23412. */
  23413. updateDistance(maxDistance: number, minDistance?: number): void;
  23414. }
  23415. /**
  23416. * Represents a Motor-Enabled Joint
  23417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23418. */
  23419. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23420. /**
  23421. * Initializes the Motor-Enabled Joint
  23422. * @param type The type of the joint
  23423. * @param jointData The physica joint data for the joint
  23424. */
  23425. constructor(type: number, jointData: PhysicsJointData);
  23426. /**
  23427. * Set the motor values.
  23428. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23429. * @param force the force to apply
  23430. * @param maxForce max force for this motor.
  23431. */
  23432. setMotor(force?: number, maxForce?: number): void;
  23433. /**
  23434. * Set the motor's limits.
  23435. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23436. * @param upperLimit The upper limit of the motor
  23437. * @param lowerLimit The lower limit of the motor
  23438. */
  23439. setLimit(upperLimit: number, lowerLimit?: number): void;
  23440. }
  23441. /**
  23442. * This class represents a single physics Hinge-Joint
  23443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23444. */
  23445. export class HingeJoint extends MotorEnabledJoint {
  23446. /**
  23447. * Initializes the Hinge-Joint
  23448. * @param jointData The joint data for the Hinge-Joint
  23449. */
  23450. constructor(jointData: PhysicsJointData);
  23451. /**
  23452. * Set the motor values.
  23453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23454. * @param {number} force the force to apply
  23455. * @param {number} maxForce max force for this motor.
  23456. */
  23457. setMotor(force?: number, maxForce?: number): void;
  23458. /**
  23459. * Set the motor's limits.
  23460. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23461. * @param upperLimit The upper limit of the motor
  23462. * @param lowerLimit The lower limit of the motor
  23463. */
  23464. setLimit(upperLimit: number, lowerLimit?: number): void;
  23465. }
  23466. /**
  23467. * This class represents a dual hinge physics joint (same as wheel joint)
  23468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23469. */
  23470. export class Hinge2Joint extends MotorEnabledJoint {
  23471. /**
  23472. * Initializes the Hinge2-Joint
  23473. * @param jointData The joint data for the Hinge2-Joint
  23474. */
  23475. constructor(jointData: PhysicsJointData);
  23476. /**
  23477. * Set the motor values.
  23478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23479. * @param {number} targetSpeed the speed the motor is to reach
  23480. * @param {number} maxForce max force for this motor.
  23481. * @param {motorIndex} the motor's index, 0 or 1.
  23482. */
  23483. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23484. /**
  23485. * Set the motor limits.
  23486. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23487. * @param {number} upperLimit the upper limit
  23488. * @param {number} lowerLimit lower limit
  23489. * @param {motorIndex} the motor's index, 0 or 1.
  23490. */
  23491. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23492. }
  23493. /**
  23494. * Interface for a motor enabled joint
  23495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23496. */
  23497. export interface IMotorEnabledJoint {
  23498. /**
  23499. * Physics joint
  23500. */
  23501. physicsJoint: any;
  23502. /**
  23503. * Sets the motor of the motor-enabled joint
  23504. * @param force The force of the motor
  23505. * @param maxForce The maximum force of the motor
  23506. * @param motorIndex The index of the motor
  23507. */
  23508. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23509. /**
  23510. * Sets the limit of the motor
  23511. * @param upperLimit The upper limit of the motor
  23512. * @param lowerLimit The lower limit of the motor
  23513. * @param motorIndex The index of the motor
  23514. */
  23515. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23516. }
  23517. /**
  23518. * Joint data for a Distance-Joint
  23519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23520. */
  23521. export interface DistanceJointData extends PhysicsJointData {
  23522. /**
  23523. * Max distance the 2 joint objects can be apart
  23524. */
  23525. maxDistance: number;
  23526. }
  23527. /**
  23528. * Joint data from a spring joint
  23529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23530. */
  23531. export interface SpringJointData extends PhysicsJointData {
  23532. /**
  23533. * Length of the spring
  23534. */
  23535. length: number;
  23536. /**
  23537. * Stiffness of the spring
  23538. */
  23539. stiffness: number;
  23540. /**
  23541. * Damping of the spring
  23542. */
  23543. damping: number;
  23544. /** this callback will be called when applying the force to the impostors. */
  23545. forceApplicationCallback: () => void;
  23546. }
  23547. }
  23548. declare module "babylonjs/Physics/physicsRaycastResult" {
  23549. import { Vector3 } from "babylonjs/Maths/math.vector";
  23550. /**
  23551. * Holds the data for the raycast result
  23552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23553. */
  23554. export class PhysicsRaycastResult {
  23555. private _hasHit;
  23556. private _hitDistance;
  23557. private _hitNormalWorld;
  23558. private _hitPointWorld;
  23559. private _rayFromWorld;
  23560. private _rayToWorld;
  23561. /**
  23562. * Gets if there was a hit
  23563. */
  23564. readonly hasHit: boolean;
  23565. /**
  23566. * Gets the distance from the hit
  23567. */
  23568. readonly hitDistance: number;
  23569. /**
  23570. * Gets the hit normal/direction in the world
  23571. */
  23572. readonly hitNormalWorld: Vector3;
  23573. /**
  23574. * Gets the hit point in the world
  23575. */
  23576. readonly hitPointWorld: Vector3;
  23577. /**
  23578. * Gets the ray "start point" of the ray in the world
  23579. */
  23580. readonly rayFromWorld: Vector3;
  23581. /**
  23582. * Gets the ray "end point" of the ray in the world
  23583. */
  23584. readonly rayToWorld: Vector3;
  23585. /**
  23586. * Sets the hit data (normal & point in world space)
  23587. * @param hitNormalWorld defines the normal in world space
  23588. * @param hitPointWorld defines the point in world space
  23589. */
  23590. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23591. /**
  23592. * Sets the distance from the start point to the hit point
  23593. * @param distance
  23594. */
  23595. setHitDistance(distance: number): void;
  23596. /**
  23597. * Calculates the distance manually
  23598. */
  23599. calculateHitDistance(): void;
  23600. /**
  23601. * Resets all the values to default
  23602. * @param from The from point on world space
  23603. * @param to The to point on world space
  23604. */
  23605. reset(from?: Vector3, to?: Vector3): void;
  23606. }
  23607. /**
  23608. * Interface for the size containing width and height
  23609. */
  23610. interface IXYZ {
  23611. /**
  23612. * X
  23613. */
  23614. x: number;
  23615. /**
  23616. * Y
  23617. */
  23618. y: number;
  23619. /**
  23620. * Z
  23621. */
  23622. z: number;
  23623. }
  23624. }
  23625. declare module "babylonjs/Physics/IPhysicsEngine" {
  23626. import { Nullable } from "babylonjs/types";
  23627. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23629. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23630. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23631. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23632. /**
  23633. * Interface used to describe a physics joint
  23634. */
  23635. export interface PhysicsImpostorJoint {
  23636. /** Defines the main impostor to which the joint is linked */
  23637. mainImpostor: PhysicsImpostor;
  23638. /** Defines the impostor that is connected to the main impostor using this joint */
  23639. connectedImpostor: PhysicsImpostor;
  23640. /** Defines the joint itself */
  23641. joint: PhysicsJoint;
  23642. }
  23643. /** @hidden */
  23644. export interface IPhysicsEnginePlugin {
  23645. world: any;
  23646. name: string;
  23647. setGravity(gravity: Vector3): void;
  23648. setTimeStep(timeStep: number): void;
  23649. getTimeStep(): number;
  23650. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23651. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23652. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23653. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23654. removePhysicsBody(impostor: PhysicsImpostor): void;
  23655. generateJoint(joint: PhysicsImpostorJoint): void;
  23656. removeJoint(joint: PhysicsImpostorJoint): void;
  23657. isSupported(): boolean;
  23658. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23659. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23660. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23661. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23662. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23663. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23664. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23665. getBodyMass(impostor: PhysicsImpostor): number;
  23666. getBodyFriction(impostor: PhysicsImpostor): number;
  23667. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23668. getBodyRestitution(impostor: PhysicsImpostor): number;
  23669. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23670. getBodyPressure?(impostor: PhysicsImpostor): number;
  23671. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23672. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23673. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23674. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23675. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23676. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23677. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23678. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23679. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23680. sleepBody(impostor: PhysicsImpostor): void;
  23681. wakeUpBody(impostor: PhysicsImpostor): void;
  23682. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23683. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23684. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23685. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23686. getRadius(impostor: PhysicsImpostor): number;
  23687. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23688. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23689. dispose(): void;
  23690. }
  23691. /**
  23692. * Interface used to define a physics engine
  23693. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23694. */
  23695. export interface IPhysicsEngine {
  23696. /**
  23697. * Gets the gravity vector used by the simulation
  23698. */
  23699. gravity: Vector3;
  23700. /**
  23701. * Sets the gravity vector used by the simulation
  23702. * @param gravity defines the gravity vector to use
  23703. */
  23704. setGravity(gravity: Vector3): void;
  23705. /**
  23706. * Set the time step of the physics engine.
  23707. * Default is 1/60.
  23708. * To slow it down, enter 1/600 for example.
  23709. * To speed it up, 1/30
  23710. * @param newTimeStep the new timestep to apply to this world.
  23711. */
  23712. setTimeStep(newTimeStep: number): void;
  23713. /**
  23714. * Get the time step of the physics engine.
  23715. * @returns the current time step
  23716. */
  23717. getTimeStep(): number;
  23718. /**
  23719. * Release all resources
  23720. */
  23721. dispose(): void;
  23722. /**
  23723. * Gets the name of the current physics plugin
  23724. * @returns the name of the plugin
  23725. */
  23726. getPhysicsPluginName(): string;
  23727. /**
  23728. * Adding a new impostor for the impostor tracking.
  23729. * This will be done by the impostor itself.
  23730. * @param impostor the impostor to add
  23731. */
  23732. addImpostor(impostor: PhysicsImpostor): void;
  23733. /**
  23734. * Remove an impostor from the engine.
  23735. * This impostor and its mesh will not longer be updated by the physics engine.
  23736. * @param impostor the impostor to remove
  23737. */
  23738. removeImpostor(impostor: PhysicsImpostor): void;
  23739. /**
  23740. * Add a joint to the physics engine
  23741. * @param mainImpostor defines the main impostor to which the joint is added.
  23742. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23743. * @param joint defines the joint that will connect both impostors.
  23744. */
  23745. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23746. /**
  23747. * Removes a joint from the simulation
  23748. * @param mainImpostor defines the impostor used with the joint
  23749. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23750. * @param joint defines the joint to remove
  23751. */
  23752. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23753. /**
  23754. * Gets the current plugin used to run the simulation
  23755. * @returns current plugin
  23756. */
  23757. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23758. /**
  23759. * Gets the list of physic impostors
  23760. * @returns an array of PhysicsImpostor
  23761. */
  23762. getImpostors(): Array<PhysicsImpostor>;
  23763. /**
  23764. * Gets the impostor for a physics enabled object
  23765. * @param object defines the object impersonated by the impostor
  23766. * @returns the PhysicsImpostor or null if not found
  23767. */
  23768. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23769. /**
  23770. * Gets the impostor for a physics body object
  23771. * @param body defines physics body used by the impostor
  23772. * @returns the PhysicsImpostor or null if not found
  23773. */
  23774. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23775. /**
  23776. * Does a raycast in the physics world
  23777. * @param from when should the ray start?
  23778. * @param to when should the ray end?
  23779. * @returns PhysicsRaycastResult
  23780. */
  23781. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23782. /**
  23783. * Called by the scene. No need to call it.
  23784. * @param delta defines the timespam between frames
  23785. */
  23786. _step(delta: number): void;
  23787. }
  23788. }
  23789. declare module "babylonjs/Physics/physicsImpostor" {
  23790. import { Nullable, IndicesArray } from "babylonjs/types";
  23791. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23792. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23794. import { Scene } from "babylonjs/scene";
  23795. import { Bone } from "babylonjs/Bones/bone";
  23796. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23797. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23798. import { Space } from "babylonjs/Maths/math.axis";
  23799. /**
  23800. * The interface for the physics imposter parameters
  23801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23802. */
  23803. export interface PhysicsImpostorParameters {
  23804. /**
  23805. * The mass of the physics imposter
  23806. */
  23807. mass: number;
  23808. /**
  23809. * The friction of the physics imposter
  23810. */
  23811. friction?: number;
  23812. /**
  23813. * The coefficient of restitution of the physics imposter
  23814. */
  23815. restitution?: number;
  23816. /**
  23817. * The native options of the physics imposter
  23818. */
  23819. nativeOptions?: any;
  23820. /**
  23821. * Specifies if the parent should be ignored
  23822. */
  23823. ignoreParent?: boolean;
  23824. /**
  23825. * Specifies if bi-directional transformations should be disabled
  23826. */
  23827. disableBidirectionalTransformation?: boolean;
  23828. /**
  23829. * The pressure inside the physics imposter, soft object only
  23830. */
  23831. pressure?: number;
  23832. /**
  23833. * The stiffness the physics imposter, soft object only
  23834. */
  23835. stiffness?: number;
  23836. /**
  23837. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23838. */
  23839. velocityIterations?: number;
  23840. /**
  23841. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23842. */
  23843. positionIterations?: number;
  23844. /**
  23845. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23846. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23847. * Add to fix multiple points
  23848. */
  23849. fixedPoints?: number;
  23850. /**
  23851. * The collision margin around a soft object
  23852. */
  23853. margin?: number;
  23854. /**
  23855. * The collision margin around a soft object
  23856. */
  23857. damping?: number;
  23858. /**
  23859. * The path for a rope based on an extrusion
  23860. */
  23861. path?: any;
  23862. /**
  23863. * The shape of an extrusion used for a rope based on an extrusion
  23864. */
  23865. shape?: any;
  23866. }
  23867. /**
  23868. * Interface for a physics-enabled object
  23869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23870. */
  23871. export interface IPhysicsEnabledObject {
  23872. /**
  23873. * The position of the physics-enabled object
  23874. */
  23875. position: Vector3;
  23876. /**
  23877. * The rotation of the physics-enabled object
  23878. */
  23879. rotationQuaternion: Nullable<Quaternion>;
  23880. /**
  23881. * The scale of the physics-enabled object
  23882. */
  23883. scaling: Vector3;
  23884. /**
  23885. * The rotation of the physics-enabled object
  23886. */
  23887. rotation?: Vector3;
  23888. /**
  23889. * The parent of the physics-enabled object
  23890. */
  23891. parent?: any;
  23892. /**
  23893. * The bounding info of the physics-enabled object
  23894. * @returns The bounding info of the physics-enabled object
  23895. */
  23896. getBoundingInfo(): BoundingInfo;
  23897. /**
  23898. * Computes the world matrix
  23899. * @param force Specifies if the world matrix should be computed by force
  23900. * @returns A world matrix
  23901. */
  23902. computeWorldMatrix(force: boolean): Matrix;
  23903. /**
  23904. * Gets the world matrix
  23905. * @returns A world matrix
  23906. */
  23907. getWorldMatrix?(): Matrix;
  23908. /**
  23909. * Gets the child meshes
  23910. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23911. * @returns An array of abstract meshes
  23912. */
  23913. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23914. /**
  23915. * Gets the vertex data
  23916. * @param kind The type of vertex data
  23917. * @returns A nullable array of numbers, or a float32 array
  23918. */
  23919. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23920. /**
  23921. * Gets the indices from the mesh
  23922. * @returns A nullable array of index arrays
  23923. */
  23924. getIndices?(): Nullable<IndicesArray>;
  23925. /**
  23926. * Gets the scene from the mesh
  23927. * @returns the indices array or null
  23928. */
  23929. getScene?(): Scene;
  23930. /**
  23931. * Gets the absolute position from the mesh
  23932. * @returns the absolute position
  23933. */
  23934. getAbsolutePosition(): Vector3;
  23935. /**
  23936. * Gets the absolute pivot point from the mesh
  23937. * @returns the absolute pivot point
  23938. */
  23939. getAbsolutePivotPoint(): Vector3;
  23940. /**
  23941. * Rotates the mesh
  23942. * @param axis The axis of rotation
  23943. * @param amount The amount of rotation
  23944. * @param space The space of the rotation
  23945. * @returns The rotation transform node
  23946. */
  23947. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23948. /**
  23949. * Translates the mesh
  23950. * @param axis The axis of translation
  23951. * @param distance The distance of translation
  23952. * @param space The space of the translation
  23953. * @returns The transform node
  23954. */
  23955. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23956. /**
  23957. * Sets the absolute position of the mesh
  23958. * @param absolutePosition The absolute position of the mesh
  23959. * @returns The transform node
  23960. */
  23961. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23962. /**
  23963. * Gets the class name of the mesh
  23964. * @returns The class name
  23965. */
  23966. getClassName(): string;
  23967. }
  23968. /**
  23969. * Represents a physics imposter
  23970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23971. */
  23972. export class PhysicsImpostor {
  23973. /**
  23974. * The physics-enabled object used as the physics imposter
  23975. */
  23976. object: IPhysicsEnabledObject;
  23977. /**
  23978. * The type of the physics imposter
  23979. */
  23980. type: number;
  23981. private _options;
  23982. private _scene?;
  23983. /**
  23984. * The default object size of the imposter
  23985. */
  23986. static DEFAULT_OBJECT_SIZE: Vector3;
  23987. /**
  23988. * The identity quaternion of the imposter
  23989. */
  23990. static IDENTITY_QUATERNION: Quaternion;
  23991. /** @hidden */
  23992. _pluginData: any;
  23993. private _physicsEngine;
  23994. private _physicsBody;
  23995. private _bodyUpdateRequired;
  23996. private _onBeforePhysicsStepCallbacks;
  23997. private _onAfterPhysicsStepCallbacks;
  23998. /** @hidden */
  23999. _onPhysicsCollideCallbacks: Array<{
  24000. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24001. otherImpostors: Array<PhysicsImpostor>;
  24002. }>;
  24003. private _deltaPosition;
  24004. private _deltaRotation;
  24005. private _deltaRotationConjugated;
  24006. /** @hidden */
  24007. _isFromLine: boolean;
  24008. private _parent;
  24009. private _isDisposed;
  24010. private static _tmpVecs;
  24011. private static _tmpQuat;
  24012. /**
  24013. * Specifies if the physics imposter is disposed
  24014. */
  24015. readonly isDisposed: boolean;
  24016. /**
  24017. * Gets the mass of the physics imposter
  24018. */
  24019. mass: number;
  24020. /**
  24021. * Gets the coefficient of friction
  24022. */
  24023. /**
  24024. * Sets the coefficient of friction
  24025. */
  24026. friction: number;
  24027. /**
  24028. * Gets the coefficient of restitution
  24029. */
  24030. /**
  24031. * Sets the coefficient of restitution
  24032. */
  24033. restitution: number;
  24034. /**
  24035. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24036. */
  24037. /**
  24038. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24039. */
  24040. pressure: number;
  24041. /**
  24042. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24043. */
  24044. /**
  24045. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24046. */
  24047. stiffness: number;
  24048. /**
  24049. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24050. */
  24051. /**
  24052. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24053. */
  24054. velocityIterations: number;
  24055. /**
  24056. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24057. */
  24058. /**
  24059. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24060. */
  24061. positionIterations: number;
  24062. /**
  24063. * The unique id of the physics imposter
  24064. * set by the physics engine when adding this impostor to the array
  24065. */
  24066. uniqueId: number;
  24067. /**
  24068. * @hidden
  24069. */
  24070. soft: boolean;
  24071. /**
  24072. * @hidden
  24073. */
  24074. segments: number;
  24075. private _joints;
  24076. /**
  24077. * Initializes the physics imposter
  24078. * @param object The physics-enabled object used as the physics imposter
  24079. * @param type The type of the physics imposter
  24080. * @param _options The options for the physics imposter
  24081. * @param _scene The Babylon scene
  24082. */
  24083. constructor(
  24084. /**
  24085. * The physics-enabled object used as the physics imposter
  24086. */
  24087. object: IPhysicsEnabledObject,
  24088. /**
  24089. * The type of the physics imposter
  24090. */
  24091. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24092. /**
  24093. * This function will completly initialize this impostor.
  24094. * It will create a new body - but only if this mesh has no parent.
  24095. * If it has, this impostor will not be used other than to define the impostor
  24096. * of the child mesh.
  24097. * @hidden
  24098. */
  24099. _init(): void;
  24100. private _getPhysicsParent;
  24101. /**
  24102. * Should a new body be generated.
  24103. * @returns boolean specifying if body initialization is required
  24104. */
  24105. isBodyInitRequired(): boolean;
  24106. /**
  24107. * Sets the updated scaling
  24108. * @param updated Specifies if the scaling is updated
  24109. */
  24110. setScalingUpdated(): void;
  24111. /**
  24112. * Force a regeneration of this or the parent's impostor's body.
  24113. * Use under cautious - This will remove all joints already implemented.
  24114. */
  24115. forceUpdate(): void;
  24116. /**
  24117. * Gets the body that holds this impostor. Either its own, or its parent.
  24118. */
  24119. /**
  24120. * Set the physics body. Used mainly by the physics engine/plugin
  24121. */
  24122. physicsBody: any;
  24123. /**
  24124. * Get the parent of the physics imposter
  24125. * @returns Physics imposter or null
  24126. */
  24127. /**
  24128. * Sets the parent of the physics imposter
  24129. */
  24130. parent: Nullable<PhysicsImpostor>;
  24131. /**
  24132. * Resets the update flags
  24133. */
  24134. resetUpdateFlags(): void;
  24135. /**
  24136. * Gets the object extend size
  24137. * @returns the object extend size
  24138. */
  24139. getObjectExtendSize(): Vector3;
  24140. /**
  24141. * Gets the object center
  24142. * @returns The object center
  24143. */
  24144. getObjectCenter(): Vector3;
  24145. /**
  24146. * Get a specific parametes from the options parameter
  24147. * @param paramName The object parameter name
  24148. * @returns The object parameter
  24149. */
  24150. getParam(paramName: string): any;
  24151. /**
  24152. * Sets a specific parameter in the options given to the physics plugin
  24153. * @param paramName The parameter name
  24154. * @param value The value of the parameter
  24155. */
  24156. setParam(paramName: string, value: number): void;
  24157. /**
  24158. * Specifically change the body's mass option. Won't recreate the physics body object
  24159. * @param mass The mass of the physics imposter
  24160. */
  24161. setMass(mass: number): void;
  24162. /**
  24163. * Gets the linear velocity
  24164. * @returns linear velocity or null
  24165. */
  24166. getLinearVelocity(): Nullable<Vector3>;
  24167. /**
  24168. * Sets the linear velocity
  24169. * @param velocity linear velocity or null
  24170. */
  24171. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24172. /**
  24173. * Gets the angular velocity
  24174. * @returns angular velocity or null
  24175. */
  24176. getAngularVelocity(): Nullable<Vector3>;
  24177. /**
  24178. * Sets the angular velocity
  24179. * @param velocity The velocity or null
  24180. */
  24181. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24182. /**
  24183. * Execute a function with the physics plugin native code
  24184. * Provide a function the will have two variables - the world object and the physics body object
  24185. * @param func The function to execute with the physics plugin native code
  24186. */
  24187. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24188. /**
  24189. * Register a function that will be executed before the physics world is stepping forward
  24190. * @param func The function to execute before the physics world is stepped forward
  24191. */
  24192. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24193. /**
  24194. * Unregister a function that will be executed before the physics world is stepping forward
  24195. * @param func The function to execute before the physics world is stepped forward
  24196. */
  24197. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24198. /**
  24199. * Register a function that will be executed after the physics step
  24200. * @param func The function to execute after physics step
  24201. */
  24202. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24203. /**
  24204. * Unregisters a function that will be executed after the physics step
  24205. * @param func The function to execute after physics step
  24206. */
  24207. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24208. /**
  24209. * register a function that will be executed when this impostor collides against a different body
  24210. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24211. * @param func Callback that is executed on collision
  24212. */
  24213. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24214. /**
  24215. * Unregisters the physics imposter on contact
  24216. * @param collideAgainst The physics object to collide against
  24217. * @param func Callback to execute on collision
  24218. */
  24219. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24220. private _tmpQuat;
  24221. private _tmpQuat2;
  24222. /**
  24223. * Get the parent rotation
  24224. * @returns The parent rotation
  24225. */
  24226. getParentsRotation(): Quaternion;
  24227. /**
  24228. * this function is executed by the physics engine.
  24229. */
  24230. beforeStep: () => void;
  24231. /**
  24232. * this function is executed by the physics engine
  24233. */
  24234. afterStep: () => void;
  24235. /**
  24236. * Legacy collision detection event support
  24237. */
  24238. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24239. /**
  24240. * event and body object due to cannon's event-based architecture.
  24241. */
  24242. onCollide: (e: {
  24243. body: any;
  24244. }) => void;
  24245. /**
  24246. * Apply a force
  24247. * @param force The force to apply
  24248. * @param contactPoint The contact point for the force
  24249. * @returns The physics imposter
  24250. */
  24251. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24252. /**
  24253. * Apply an impulse
  24254. * @param force The impulse force
  24255. * @param contactPoint The contact point for the impulse force
  24256. * @returns The physics imposter
  24257. */
  24258. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24259. /**
  24260. * A help function to create a joint
  24261. * @param otherImpostor A physics imposter used to create a joint
  24262. * @param jointType The type of joint
  24263. * @param jointData The data for the joint
  24264. * @returns The physics imposter
  24265. */
  24266. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24267. /**
  24268. * Add a joint to this impostor with a different impostor
  24269. * @param otherImpostor A physics imposter used to add a joint
  24270. * @param joint The joint to add
  24271. * @returns The physics imposter
  24272. */
  24273. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24274. /**
  24275. * Add an anchor to a cloth impostor
  24276. * @param otherImpostor rigid impostor to anchor to
  24277. * @param width ratio across width from 0 to 1
  24278. * @param height ratio up height from 0 to 1
  24279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24280. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24281. * @returns impostor the soft imposter
  24282. */
  24283. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24284. /**
  24285. * Add a hook to a rope impostor
  24286. * @param otherImpostor rigid impostor to anchor to
  24287. * @param length ratio across rope from 0 to 1
  24288. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24290. * @returns impostor the rope imposter
  24291. */
  24292. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24293. /**
  24294. * Will keep this body still, in a sleep mode.
  24295. * @returns the physics imposter
  24296. */
  24297. sleep(): PhysicsImpostor;
  24298. /**
  24299. * Wake the body up.
  24300. * @returns The physics imposter
  24301. */
  24302. wakeUp(): PhysicsImpostor;
  24303. /**
  24304. * Clones the physics imposter
  24305. * @param newObject The physics imposter clones to this physics-enabled object
  24306. * @returns A nullable physics imposter
  24307. */
  24308. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24309. /**
  24310. * Disposes the physics imposter
  24311. */
  24312. dispose(): void;
  24313. /**
  24314. * Sets the delta position
  24315. * @param position The delta position amount
  24316. */
  24317. setDeltaPosition(position: Vector3): void;
  24318. /**
  24319. * Sets the delta rotation
  24320. * @param rotation The delta rotation amount
  24321. */
  24322. setDeltaRotation(rotation: Quaternion): void;
  24323. /**
  24324. * Gets the box size of the physics imposter and stores the result in the input parameter
  24325. * @param result Stores the box size
  24326. * @returns The physics imposter
  24327. */
  24328. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24329. /**
  24330. * Gets the radius of the physics imposter
  24331. * @returns Radius of the physics imposter
  24332. */
  24333. getRadius(): number;
  24334. /**
  24335. * Sync a bone with this impostor
  24336. * @param bone The bone to sync to the impostor.
  24337. * @param boneMesh The mesh that the bone is influencing.
  24338. * @param jointPivot The pivot of the joint / bone in local space.
  24339. * @param distToJoint Optional distance from the impostor to the joint.
  24340. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24341. */
  24342. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24343. /**
  24344. * Sync impostor to a bone
  24345. * @param bone The bone that the impostor will be synced to.
  24346. * @param boneMesh The mesh that the bone is influencing.
  24347. * @param jointPivot The pivot of the joint / bone in local space.
  24348. * @param distToJoint Optional distance from the impostor to the joint.
  24349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24350. * @param boneAxis Optional vector3 axis the bone is aligned with
  24351. */
  24352. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24353. /**
  24354. * No-Imposter type
  24355. */
  24356. static NoImpostor: number;
  24357. /**
  24358. * Sphere-Imposter type
  24359. */
  24360. static SphereImpostor: number;
  24361. /**
  24362. * Box-Imposter type
  24363. */
  24364. static BoxImpostor: number;
  24365. /**
  24366. * Plane-Imposter type
  24367. */
  24368. static PlaneImpostor: number;
  24369. /**
  24370. * Mesh-imposter type
  24371. */
  24372. static MeshImpostor: number;
  24373. /**
  24374. * Capsule-Impostor type (Ammo.js plugin only)
  24375. */
  24376. static CapsuleImpostor: number;
  24377. /**
  24378. * Cylinder-Imposter type
  24379. */
  24380. static CylinderImpostor: number;
  24381. /**
  24382. * Particle-Imposter type
  24383. */
  24384. static ParticleImpostor: number;
  24385. /**
  24386. * Heightmap-Imposter type
  24387. */
  24388. static HeightmapImpostor: number;
  24389. /**
  24390. * ConvexHull-Impostor type (Ammo.js plugin only)
  24391. */
  24392. static ConvexHullImpostor: number;
  24393. /**
  24394. * Rope-Imposter type
  24395. */
  24396. static RopeImpostor: number;
  24397. /**
  24398. * Cloth-Imposter type
  24399. */
  24400. static ClothImpostor: number;
  24401. /**
  24402. * Softbody-Imposter type
  24403. */
  24404. static SoftbodyImpostor: number;
  24405. }
  24406. }
  24407. declare module "babylonjs/Meshes/mesh" {
  24408. import { Observable } from "babylonjs/Misc/observable";
  24409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24410. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24411. import { Camera } from "babylonjs/Cameras/camera";
  24412. import { Scene } from "babylonjs/scene";
  24413. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24414. import { Color4 } from "babylonjs/Maths/math.color";
  24415. import { Engine } from "babylonjs/Engines/engine";
  24416. import { Node } from "babylonjs/node";
  24417. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24418. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24419. import { Buffer } from "babylonjs/Meshes/buffer";
  24420. import { Geometry } from "babylonjs/Meshes/geometry";
  24421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24422. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24423. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24424. import { Effect } from "babylonjs/Materials/effect";
  24425. import { Material } from "babylonjs/Materials/material";
  24426. import { Skeleton } from "babylonjs/Bones/skeleton";
  24427. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24428. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24429. import { Path3D } from "babylonjs/Maths/math.path";
  24430. import { Plane } from "babylonjs/Maths/math.plane";
  24431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24432. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24433. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24434. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24435. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24436. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24437. /**
  24438. * @hidden
  24439. **/
  24440. export class _CreationDataStorage {
  24441. closePath?: boolean;
  24442. closeArray?: boolean;
  24443. idx: number[];
  24444. dashSize: number;
  24445. gapSize: number;
  24446. path3D: Path3D;
  24447. pathArray: Vector3[][];
  24448. arc: number;
  24449. radius: number;
  24450. cap: number;
  24451. tessellation: number;
  24452. }
  24453. /**
  24454. * @hidden
  24455. **/
  24456. class _InstanceDataStorage {
  24457. visibleInstances: any;
  24458. batchCache: _InstancesBatch;
  24459. instancesBufferSize: number;
  24460. instancesBuffer: Nullable<Buffer>;
  24461. instancesData: Float32Array;
  24462. overridenInstanceCount: number;
  24463. isFrozen: boolean;
  24464. previousBatch: Nullable<_InstancesBatch>;
  24465. hardwareInstancedRendering: boolean;
  24466. sideOrientation: number;
  24467. manualUpdate: boolean;
  24468. }
  24469. /**
  24470. * @hidden
  24471. **/
  24472. export class _InstancesBatch {
  24473. mustReturn: boolean;
  24474. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24475. renderSelf: boolean[];
  24476. hardwareInstancedRendering: boolean[];
  24477. }
  24478. /**
  24479. * Class used to represent renderable models
  24480. */
  24481. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24482. /**
  24483. * Mesh side orientation : usually the external or front surface
  24484. */
  24485. static readonly FRONTSIDE: number;
  24486. /**
  24487. * Mesh side orientation : usually the internal or back surface
  24488. */
  24489. static readonly BACKSIDE: number;
  24490. /**
  24491. * Mesh side orientation : both internal and external or front and back surfaces
  24492. */
  24493. static readonly DOUBLESIDE: number;
  24494. /**
  24495. * Mesh side orientation : by default, `FRONTSIDE`
  24496. */
  24497. static readonly DEFAULTSIDE: number;
  24498. /**
  24499. * Mesh cap setting : no cap
  24500. */
  24501. static readonly NO_CAP: number;
  24502. /**
  24503. * Mesh cap setting : one cap at the beginning of the mesh
  24504. */
  24505. static readonly CAP_START: number;
  24506. /**
  24507. * Mesh cap setting : one cap at the end of the mesh
  24508. */
  24509. static readonly CAP_END: number;
  24510. /**
  24511. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24512. */
  24513. static readonly CAP_ALL: number;
  24514. /**
  24515. * Mesh pattern setting : no flip or rotate
  24516. */
  24517. static readonly NO_FLIP: number;
  24518. /**
  24519. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24520. */
  24521. static readonly FLIP_TILE: number;
  24522. /**
  24523. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24524. */
  24525. static readonly ROTATE_TILE: number;
  24526. /**
  24527. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24528. */
  24529. static readonly FLIP_ROW: number;
  24530. /**
  24531. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24532. */
  24533. static readonly ROTATE_ROW: number;
  24534. /**
  24535. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24536. */
  24537. static readonly FLIP_N_ROTATE_TILE: number;
  24538. /**
  24539. * Mesh pattern setting : rotate pattern and rotate
  24540. */
  24541. static readonly FLIP_N_ROTATE_ROW: number;
  24542. /**
  24543. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24544. */
  24545. static readonly CENTER: number;
  24546. /**
  24547. * Mesh tile positioning : part tiles on left
  24548. */
  24549. static readonly LEFT: number;
  24550. /**
  24551. * Mesh tile positioning : part tiles on right
  24552. */
  24553. static readonly RIGHT: number;
  24554. /**
  24555. * Mesh tile positioning : part tiles on top
  24556. */
  24557. static readonly TOP: number;
  24558. /**
  24559. * Mesh tile positioning : part tiles on bottom
  24560. */
  24561. static readonly BOTTOM: number;
  24562. /**
  24563. * Gets the default side orientation.
  24564. * @param orientation the orientation to value to attempt to get
  24565. * @returns the default orientation
  24566. * @hidden
  24567. */
  24568. static _GetDefaultSideOrientation(orientation?: number): number;
  24569. private _internalMeshDataInfo;
  24570. /**
  24571. * An event triggered before rendering the mesh
  24572. */
  24573. readonly onBeforeRenderObservable: Observable<Mesh>;
  24574. /**
  24575. * An event triggered before binding the mesh
  24576. */
  24577. readonly onBeforeBindObservable: Observable<Mesh>;
  24578. /**
  24579. * An event triggered after rendering the mesh
  24580. */
  24581. readonly onAfterRenderObservable: Observable<Mesh>;
  24582. /**
  24583. * An event triggered before drawing the mesh
  24584. */
  24585. readonly onBeforeDrawObservable: Observable<Mesh>;
  24586. private _onBeforeDrawObserver;
  24587. /**
  24588. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24589. */
  24590. onBeforeDraw: () => void;
  24591. readonly hasInstances: boolean;
  24592. /**
  24593. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24594. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24595. */
  24596. delayLoadState: number;
  24597. /**
  24598. * Gets the list of instances created from this mesh
  24599. * it is not supposed to be modified manually.
  24600. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24601. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24602. */
  24603. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24604. /**
  24605. * Gets the file containing delay loading data for this mesh
  24606. */
  24607. delayLoadingFile: string;
  24608. /** @hidden */
  24609. _binaryInfo: any;
  24610. /**
  24611. * User defined function used to change how LOD level selection is done
  24612. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24613. */
  24614. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24615. /**
  24616. * Gets or sets the morph target manager
  24617. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24618. */
  24619. morphTargetManager: Nullable<MorphTargetManager>;
  24620. /** @hidden */
  24621. _creationDataStorage: Nullable<_CreationDataStorage>;
  24622. /** @hidden */
  24623. _geometry: Nullable<Geometry>;
  24624. /** @hidden */
  24625. _delayInfo: Array<string>;
  24626. /** @hidden */
  24627. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24628. /** @hidden */
  24629. _instanceDataStorage: _InstanceDataStorage;
  24630. private _effectiveMaterial;
  24631. /** @hidden */
  24632. _shouldGenerateFlatShading: boolean;
  24633. /** @hidden */
  24634. _originalBuilderSideOrientation: number;
  24635. /**
  24636. * Use this property to change the original side orientation defined at construction time
  24637. */
  24638. overrideMaterialSideOrientation: Nullable<number>;
  24639. /**
  24640. * Gets the source mesh (the one used to clone this one from)
  24641. */
  24642. readonly source: Nullable<Mesh>;
  24643. /**
  24644. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24645. */
  24646. isUnIndexed: boolean;
  24647. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24648. readonly worldMatrixInstancedBuffer: Float32Array;
  24649. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24650. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24651. /**
  24652. * @constructor
  24653. * @param name The value used by scene.getMeshByName() to do a lookup.
  24654. * @param scene The scene to add this mesh to.
  24655. * @param parent The parent of this mesh, if it has one
  24656. * @param source An optional Mesh from which geometry is shared, cloned.
  24657. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24658. * When false, achieved by calling a clone(), also passing False.
  24659. * This will make creation of children, recursive.
  24660. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24661. */
  24662. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24663. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24664. doNotInstantiate: boolean;
  24665. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24666. /**
  24667. * Gets the class name
  24668. * @returns the string "Mesh".
  24669. */
  24670. getClassName(): string;
  24671. /** @hidden */
  24672. readonly _isMesh: boolean;
  24673. /**
  24674. * Returns a description of this mesh
  24675. * @param fullDetails define if full details about this mesh must be used
  24676. * @returns a descriptive string representing this mesh
  24677. */
  24678. toString(fullDetails?: boolean): string;
  24679. /** @hidden */
  24680. _unBindEffect(): void;
  24681. /**
  24682. * Gets a boolean indicating if this mesh has LOD
  24683. */
  24684. readonly hasLODLevels: boolean;
  24685. /**
  24686. * Gets the list of MeshLODLevel associated with the current mesh
  24687. * @returns an array of MeshLODLevel
  24688. */
  24689. getLODLevels(): MeshLODLevel[];
  24690. private _sortLODLevels;
  24691. /**
  24692. * Add a mesh as LOD level triggered at the given distance.
  24693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24694. * @param distance The distance from the center of the object to show this level
  24695. * @param mesh The mesh to be added as LOD level (can be null)
  24696. * @return This mesh (for chaining)
  24697. */
  24698. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24699. /**
  24700. * Returns the LOD level mesh at the passed distance or null if not found.
  24701. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24702. * @param distance The distance from the center of the object to show this level
  24703. * @returns a Mesh or `null`
  24704. */
  24705. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24706. /**
  24707. * Remove a mesh from the LOD array
  24708. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24709. * @param mesh defines the mesh to be removed
  24710. * @return This mesh (for chaining)
  24711. */
  24712. removeLODLevel(mesh: Mesh): Mesh;
  24713. /**
  24714. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24716. * @param camera defines the camera to use to compute distance
  24717. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24718. * @return This mesh (for chaining)
  24719. */
  24720. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24721. /**
  24722. * Gets the mesh internal Geometry object
  24723. */
  24724. readonly geometry: Nullable<Geometry>;
  24725. /**
  24726. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24727. * @returns the total number of vertices
  24728. */
  24729. getTotalVertices(): number;
  24730. /**
  24731. * Returns the content of an associated vertex buffer
  24732. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24733. * - VertexBuffer.PositionKind
  24734. * - VertexBuffer.UVKind
  24735. * - VertexBuffer.UV2Kind
  24736. * - VertexBuffer.UV3Kind
  24737. * - VertexBuffer.UV4Kind
  24738. * - VertexBuffer.UV5Kind
  24739. * - VertexBuffer.UV6Kind
  24740. * - VertexBuffer.ColorKind
  24741. * - VertexBuffer.MatricesIndicesKind
  24742. * - VertexBuffer.MatricesIndicesExtraKind
  24743. * - VertexBuffer.MatricesWeightsKind
  24744. * - VertexBuffer.MatricesWeightsExtraKind
  24745. * @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
  24746. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24747. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24748. */
  24749. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24750. /**
  24751. * Returns the mesh VertexBuffer object from the requested `kind`
  24752. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24753. * - VertexBuffer.PositionKind
  24754. * - VertexBuffer.NormalKind
  24755. * - VertexBuffer.UVKind
  24756. * - VertexBuffer.UV2Kind
  24757. * - VertexBuffer.UV3Kind
  24758. * - VertexBuffer.UV4Kind
  24759. * - VertexBuffer.UV5Kind
  24760. * - VertexBuffer.UV6Kind
  24761. * - VertexBuffer.ColorKind
  24762. * - VertexBuffer.MatricesIndicesKind
  24763. * - VertexBuffer.MatricesIndicesExtraKind
  24764. * - VertexBuffer.MatricesWeightsKind
  24765. * - VertexBuffer.MatricesWeightsExtraKind
  24766. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24767. */
  24768. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24769. /**
  24770. * Tests if a specific vertex buffer is associated with this mesh
  24771. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24772. * - VertexBuffer.PositionKind
  24773. * - VertexBuffer.NormalKind
  24774. * - VertexBuffer.UVKind
  24775. * - VertexBuffer.UV2Kind
  24776. * - VertexBuffer.UV3Kind
  24777. * - VertexBuffer.UV4Kind
  24778. * - VertexBuffer.UV5Kind
  24779. * - VertexBuffer.UV6Kind
  24780. * - VertexBuffer.ColorKind
  24781. * - VertexBuffer.MatricesIndicesKind
  24782. * - VertexBuffer.MatricesIndicesExtraKind
  24783. * - VertexBuffer.MatricesWeightsKind
  24784. * - VertexBuffer.MatricesWeightsExtraKind
  24785. * @returns a boolean
  24786. */
  24787. isVerticesDataPresent(kind: string): boolean;
  24788. /**
  24789. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24790. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24791. * - VertexBuffer.PositionKind
  24792. * - VertexBuffer.UVKind
  24793. * - VertexBuffer.UV2Kind
  24794. * - VertexBuffer.UV3Kind
  24795. * - VertexBuffer.UV4Kind
  24796. * - VertexBuffer.UV5Kind
  24797. * - VertexBuffer.UV6Kind
  24798. * - VertexBuffer.ColorKind
  24799. * - VertexBuffer.MatricesIndicesKind
  24800. * - VertexBuffer.MatricesIndicesExtraKind
  24801. * - VertexBuffer.MatricesWeightsKind
  24802. * - VertexBuffer.MatricesWeightsExtraKind
  24803. * @returns a boolean
  24804. */
  24805. isVertexBufferUpdatable(kind: string): boolean;
  24806. /**
  24807. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24808. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24809. * - VertexBuffer.PositionKind
  24810. * - VertexBuffer.NormalKind
  24811. * - VertexBuffer.UVKind
  24812. * - VertexBuffer.UV2Kind
  24813. * - VertexBuffer.UV3Kind
  24814. * - VertexBuffer.UV4Kind
  24815. * - VertexBuffer.UV5Kind
  24816. * - VertexBuffer.UV6Kind
  24817. * - VertexBuffer.ColorKind
  24818. * - VertexBuffer.MatricesIndicesKind
  24819. * - VertexBuffer.MatricesIndicesExtraKind
  24820. * - VertexBuffer.MatricesWeightsKind
  24821. * - VertexBuffer.MatricesWeightsExtraKind
  24822. * @returns an array of strings
  24823. */
  24824. getVerticesDataKinds(): string[];
  24825. /**
  24826. * Returns a positive integer : the total number of indices in this mesh geometry.
  24827. * @returns the numner of indices or zero if the mesh has no geometry.
  24828. */
  24829. getTotalIndices(): number;
  24830. /**
  24831. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24832. * @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.
  24833. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24834. * @returns the indices array or an empty array if the mesh has no geometry
  24835. */
  24836. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24837. readonly isBlocked: boolean;
  24838. /**
  24839. * Determine if the current mesh is ready to be rendered
  24840. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24841. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24842. * @returns true if all associated assets are ready (material, textures, shaders)
  24843. */
  24844. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24845. /**
  24846. * 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.
  24847. */
  24848. readonly areNormalsFrozen: boolean;
  24849. /**
  24850. * 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.
  24851. * @returns the current mesh
  24852. */
  24853. freezeNormals(): Mesh;
  24854. /**
  24855. * 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
  24856. * @returns the current mesh
  24857. */
  24858. unfreezeNormals(): Mesh;
  24859. /**
  24860. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24861. */
  24862. overridenInstanceCount: number;
  24863. /** @hidden */
  24864. _preActivate(): Mesh;
  24865. /** @hidden */
  24866. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24867. /** @hidden */
  24868. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24869. /**
  24870. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24871. * This means the mesh underlying bounding box and sphere are recomputed.
  24872. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24873. * @returns the current mesh
  24874. */
  24875. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24876. /** @hidden */
  24877. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24878. /**
  24879. * This function will subdivide the mesh into multiple submeshes
  24880. * @param count defines the expected number of submeshes
  24881. */
  24882. subdivide(count: number): void;
  24883. /**
  24884. * Copy a FloatArray into a specific associated vertex buffer
  24885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24886. * - VertexBuffer.PositionKind
  24887. * - VertexBuffer.UVKind
  24888. * - VertexBuffer.UV2Kind
  24889. * - VertexBuffer.UV3Kind
  24890. * - VertexBuffer.UV4Kind
  24891. * - VertexBuffer.UV5Kind
  24892. * - VertexBuffer.UV6Kind
  24893. * - VertexBuffer.ColorKind
  24894. * - VertexBuffer.MatricesIndicesKind
  24895. * - VertexBuffer.MatricesIndicesExtraKind
  24896. * - VertexBuffer.MatricesWeightsKind
  24897. * - VertexBuffer.MatricesWeightsExtraKind
  24898. * @param data defines the data source
  24899. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24900. * @param stride defines the data stride size (can be null)
  24901. * @returns the current mesh
  24902. */
  24903. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24904. /**
  24905. * Delete a vertex buffer associated with this mesh
  24906. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24907. * - VertexBuffer.PositionKind
  24908. * - VertexBuffer.UVKind
  24909. * - VertexBuffer.UV2Kind
  24910. * - VertexBuffer.UV3Kind
  24911. * - VertexBuffer.UV4Kind
  24912. * - VertexBuffer.UV5Kind
  24913. * - VertexBuffer.UV6Kind
  24914. * - VertexBuffer.ColorKind
  24915. * - VertexBuffer.MatricesIndicesKind
  24916. * - VertexBuffer.MatricesIndicesExtraKind
  24917. * - VertexBuffer.MatricesWeightsKind
  24918. * - VertexBuffer.MatricesWeightsExtraKind
  24919. */
  24920. removeVerticesData(kind: string): void;
  24921. /**
  24922. * Flags an associated vertex buffer as updatable
  24923. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24924. * - VertexBuffer.PositionKind
  24925. * - VertexBuffer.UVKind
  24926. * - VertexBuffer.UV2Kind
  24927. * - VertexBuffer.UV3Kind
  24928. * - VertexBuffer.UV4Kind
  24929. * - VertexBuffer.UV5Kind
  24930. * - VertexBuffer.UV6Kind
  24931. * - VertexBuffer.ColorKind
  24932. * - VertexBuffer.MatricesIndicesKind
  24933. * - VertexBuffer.MatricesIndicesExtraKind
  24934. * - VertexBuffer.MatricesWeightsKind
  24935. * - VertexBuffer.MatricesWeightsExtraKind
  24936. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24937. */
  24938. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24939. /**
  24940. * Sets the mesh global Vertex Buffer
  24941. * @param buffer defines the buffer to use
  24942. * @returns the current mesh
  24943. */
  24944. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24945. /**
  24946. * Update a specific associated vertex buffer
  24947. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24948. * - VertexBuffer.PositionKind
  24949. * - VertexBuffer.UVKind
  24950. * - VertexBuffer.UV2Kind
  24951. * - VertexBuffer.UV3Kind
  24952. * - VertexBuffer.UV4Kind
  24953. * - VertexBuffer.UV5Kind
  24954. * - VertexBuffer.UV6Kind
  24955. * - VertexBuffer.ColorKind
  24956. * - VertexBuffer.MatricesIndicesKind
  24957. * - VertexBuffer.MatricesIndicesExtraKind
  24958. * - VertexBuffer.MatricesWeightsKind
  24959. * - VertexBuffer.MatricesWeightsExtraKind
  24960. * @param data defines the data source
  24961. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24962. * @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)
  24963. * @returns the current mesh
  24964. */
  24965. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24966. /**
  24967. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24968. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24969. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24970. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24971. * @returns the current mesh
  24972. */
  24973. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24974. /**
  24975. * Creates a un-shared specific occurence of the geometry for the mesh.
  24976. * @returns the current mesh
  24977. */
  24978. makeGeometryUnique(): Mesh;
  24979. /**
  24980. * Set the index buffer of this mesh
  24981. * @param indices defines the source data
  24982. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24983. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24984. * @returns the current mesh
  24985. */
  24986. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24987. /**
  24988. * Update the current index buffer
  24989. * @param indices defines the source data
  24990. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24991. * @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)
  24992. * @returns the current mesh
  24993. */
  24994. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24995. /**
  24996. * Invert the geometry to move from a right handed system to a left handed one.
  24997. * @returns the current mesh
  24998. */
  24999. toLeftHanded(): Mesh;
  25000. /** @hidden */
  25001. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25002. /** @hidden */
  25003. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25004. /**
  25005. * Registers for this mesh a javascript function called just before the rendering process
  25006. * @param func defines the function to call before rendering this mesh
  25007. * @returns the current mesh
  25008. */
  25009. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25010. /**
  25011. * Disposes a previously registered javascript function called before the rendering
  25012. * @param func defines the function to remove
  25013. * @returns the current mesh
  25014. */
  25015. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25016. /**
  25017. * Registers for this mesh a javascript function called just after the rendering is complete
  25018. * @param func defines the function to call after rendering this mesh
  25019. * @returns the current mesh
  25020. */
  25021. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25022. /**
  25023. * Disposes a previously registered javascript function called after the rendering.
  25024. * @param func defines the function to remove
  25025. * @returns the current mesh
  25026. */
  25027. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25028. /** @hidden */
  25029. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  25030. /** @hidden */
  25031. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25032. /** @hidden */
  25033. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25034. /** @hidden */
  25035. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25036. /** @hidden */
  25037. _rebuild(): void;
  25038. /** @hidden */
  25039. _freeze(): void;
  25040. /** @hidden */
  25041. _unFreeze(): void;
  25042. /**
  25043. * 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
  25044. * @param subMesh defines the subMesh to render
  25045. * @param enableAlphaMode defines if alpha mode can be changed
  25046. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25047. * @returns the current mesh
  25048. */
  25049. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25050. private _onBeforeDraw;
  25051. /**
  25052. * Renormalize the mesh and patch it up if there are no weights
  25053. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25054. * However in the case of zero weights then we set just a single influence to 1.
  25055. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25056. */
  25057. cleanMatrixWeights(): void;
  25058. private normalizeSkinFourWeights;
  25059. private normalizeSkinWeightsAndExtra;
  25060. /**
  25061. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25062. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25063. * the user know there was an issue with importing the mesh
  25064. * @returns a validation object with skinned, valid and report string
  25065. */
  25066. validateSkinning(): {
  25067. skinned: boolean;
  25068. valid: boolean;
  25069. report: string;
  25070. };
  25071. /** @hidden */
  25072. _checkDelayState(): Mesh;
  25073. private _queueLoad;
  25074. /**
  25075. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25076. * A mesh is in the frustum if its bounding box intersects the frustum
  25077. * @param frustumPlanes defines the frustum to test
  25078. * @returns true if the mesh is in the frustum planes
  25079. */
  25080. isInFrustum(frustumPlanes: Plane[]): boolean;
  25081. /**
  25082. * Sets the mesh material by the material or multiMaterial `id` property
  25083. * @param id is a string identifying the material or the multiMaterial
  25084. * @returns the current mesh
  25085. */
  25086. setMaterialByID(id: string): Mesh;
  25087. /**
  25088. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25089. * @returns an array of IAnimatable
  25090. */
  25091. getAnimatables(): IAnimatable[];
  25092. /**
  25093. * Modifies the mesh geometry according to the passed transformation matrix.
  25094. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25095. * The mesh normals are modified using the same transformation.
  25096. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25097. * @param transform defines the transform matrix to use
  25098. * @see http://doc.babylonjs.com/resources/baking_transformations
  25099. * @returns the current mesh
  25100. */
  25101. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25102. /**
  25103. * Modifies the mesh geometry according to its own current World Matrix.
  25104. * The mesh World Matrix is then reset.
  25105. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25106. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25107. * @see http://doc.babylonjs.com/resources/baking_transformations
  25108. * @returns the current mesh
  25109. */
  25110. bakeCurrentTransformIntoVertices(): Mesh;
  25111. /** @hidden */
  25112. readonly _positions: Nullable<Vector3[]>;
  25113. /** @hidden */
  25114. _resetPointsArrayCache(): Mesh;
  25115. /** @hidden */
  25116. _generatePointsArray(): boolean;
  25117. /**
  25118. * Returns a new Mesh object generated from the current mesh properties.
  25119. * This method must not get confused with createInstance()
  25120. * @param name is a string, the name given to the new mesh
  25121. * @param newParent can be any Node object (default `null`)
  25122. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25123. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25124. * @returns a new mesh
  25125. */
  25126. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25127. /**
  25128. * Releases resources associated with this mesh.
  25129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25131. */
  25132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25133. /** @hidden */
  25134. _disposeInstanceSpecificData(): void;
  25135. /**
  25136. * Modifies the mesh geometry according to a displacement map.
  25137. * 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.
  25138. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25139. * @param url is a string, the URL from the image file is to be downloaded.
  25140. * @param minHeight is the lower limit of the displacement.
  25141. * @param maxHeight is the upper limit of the displacement.
  25142. * @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.
  25143. * @param uvOffset is an optional vector2 used to offset UV.
  25144. * @param uvScale is an optional vector2 used to scale UV.
  25145. * @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.
  25146. * @returns the Mesh.
  25147. */
  25148. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25149. /**
  25150. * Modifies the mesh geometry according to a displacementMap buffer.
  25151. * 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.
  25152. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25153. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25154. * @param heightMapWidth is the width of the buffer image.
  25155. * @param heightMapHeight is the height of the buffer image.
  25156. * @param minHeight is the lower limit of the displacement.
  25157. * @param maxHeight is the upper limit of the displacement.
  25158. * @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.
  25159. * @param uvOffset is an optional vector2 used to offset UV.
  25160. * @param uvScale is an optional vector2 used to scale UV.
  25161. * @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.
  25162. * @returns the Mesh.
  25163. */
  25164. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25165. /**
  25166. * Modify the mesh to get a flat shading rendering.
  25167. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25168. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25169. * @returns current mesh
  25170. */
  25171. convertToFlatShadedMesh(): Mesh;
  25172. /**
  25173. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25174. * In other words, more vertices, no more indices and a single bigger VBO.
  25175. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25176. * @returns current mesh
  25177. */
  25178. convertToUnIndexedMesh(): Mesh;
  25179. /**
  25180. * Inverses facet orientations.
  25181. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25182. * @param flipNormals will also inverts the normals
  25183. * @returns current mesh
  25184. */
  25185. flipFaces(flipNormals?: boolean): Mesh;
  25186. /**
  25187. * Increase the number of facets and hence vertices in a mesh
  25188. * Vertex normals are interpolated from existing vertex normals
  25189. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25190. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25191. */
  25192. increaseVertices(numberPerEdge: number): void;
  25193. /**
  25194. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25195. * This will undo any application of covertToFlatShadedMesh
  25196. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25197. */
  25198. forceSharedVertices(): void;
  25199. /** @hidden */
  25200. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25201. /** @hidden */
  25202. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25203. /**
  25204. * Creates a new InstancedMesh object from the mesh model.
  25205. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25206. * @param name defines the name of the new instance
  25207. * @returns a new InstancedMesh
  25208. */
  25209. createInstance(name: string): InstancedMesh;
  25210. /**
  25211. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25212. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25213. * @returns the current mesh
  25214. */
  25215. synchronizeInstances(): Mesh;
  25216. /**
  25217. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25218. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25219. * This should be used together with the simplification to avoid disappearing triangles.
  25220. * @param successCallback an optional success callback to be called after the optimization finished.
  25221. * @returns the current mesh
  25222. */
  25223. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25224. /**
  25225. * Serialize current mesh
  25226. * @param serializationObject defines the object which will receive the serialization data
  25227. */
  25228. serialize(serializationObject: any): void;
  25229. /** @hidden */
  25230. _syncGeometryWithMorphTargetManager(): void;
  25231. /** @hidden */
  25232. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25233. /**
  25234. * Returns a new Mesh object parsed from the source provided.
  25235. * @param parsedMesh is the source
  25236. * @param scene defines the hosting scene
  25237. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25238. * @returns a new Mesh
  25239. */
  25240. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25241. /**
  25242. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25243. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25244. * @param name defines the name of the mesh to create
  25245. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25246. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25247. * @param closePath creates a seam between the first and the last points of each path of the path array
  25248. * @param offset is taken in account only if the `pathArray` is containing a single path
  25249. * @param scene defines the hosting scene
  25250. * @param updatable defines if the mesh must be flagged as updatable
  25251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25252. * @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)
  25253. * @returns a new Mesh
  25254. */
  25255. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25256. /**
  25257. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25258. * @param name defines the name of the mesh to create
  25259. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25260. * @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
  25261. * @param scene defines the hosting scene
  25262. * @param updatable defines if the mesh must be flagged as updatable
  25263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25264. * @returns a new Mesh
  25265. */
  25266. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25267. /**
  25268. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25269. * @param name defines the name of the mesh to create
  25270. * @param size sets the size (float) of each box side (default 1)
  25271. * @param scene defines the hosting scene
  25272. * @param updatable defines if the mesh must be flagged as updatable
  25273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25274. * @returns a new Mesh
  25275. */
  25276. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25277. /**
  25278. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25279. * @param name defines the name of the mesh to create
  25280. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25281. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25282. * @param scene defines the hosting scene
  25283. * @param updatable defines if the mesh must be flagged as updatable
  25284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25285. * @returns a new Mesh
  25286. */
  25287. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25288. /**
  25289. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25290. * @param name defines the name of the mesh to create
  25291. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25292. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25293. * @param scene defines the hosting scene
  25294. * @returns a new Mesh
  25295. */
  25296. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25297. /**
  25298. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25299. * @param name defines the name of the mesh to create
  25300. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25301. * @param diameterTop set the top cap diameter (floats, default 1)
  25302. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25303. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25304. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25305. * @param scene defines the hosting scene
  25306. * @param updatable defines if the mesh must be flagged as updatable
  25307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25308. * @returns a new Mesh
  25309. */
  25310. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25311. /**
  25312. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25313. * @param name defines the name of the mesh to create
  25314. * @param diameter sets the diameter size (float) of the torus (default 1)
  25315. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25316. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25317. * @param scene defines the hosting scene
  25318. * @param updatable defines if the mesh must be flagged as updatable
  25319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25320. * @returns a new Mesh
  25321. */
  25322. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25323. /**
  25324. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25325. * @param name defines the name of the mesh to create
  25326. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25327. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25328. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25329. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25330. * @param p the number of windings on X axis (positive integers, default 2)
  25331. * @param q the number of windings on Y axis (positive integers, default 3)
  25332. * @param scene defines the hosting scene
  25333. * @param updatable defines if the mesh must be flagged as updatable
  25334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25335. * @returns a new Mesh
  25336. */
  25337. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25338. /**
  25339. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25340. * @param name defines the name of the mesh to create
  25341. * @param points is an array successive Vector3
  25342. * @param scene defines the hosting scene
  25343. * @param updatable defines if the mesh must be flagged as updatable
  25344. * @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).
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25348. /**
  25349. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25350. * @param name defines the name of the mesh to create
  25351. * @param points is an array successive Vector3
  25352. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25353. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25354. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25355. * @param scene defines the hosting scene
  25356. * @param updatable defines if the mesh must be flagged as updatable
  25357. * @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)
  25358. * @returns a new Mesh
  25359. */
  25360. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25361. /**
  25362. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25363. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25364. * 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.
  25365. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25366. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25367. * Remember you can only change the shape positions, not their number when updating a polygon.
  25368. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25369. * @param name defines the name of the mesh to create
  25370. * @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
  25371. * @param scene defines the hosting scene
  25372. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25373. * @param updatable defines if the mesh must be flagged as updatable
  25374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25375. * @param earcutInjection can be used to inject your own earcut reference
  25376. * @returns a new Mesh
  25377. */
  25378. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25379. /**
  25380. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25382. * @param name defines the name of the mesh to create
  25383. * @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
  25384. * @param depth defines the height of extrusion
  25385. * @param scene defines the hosting scene
  25386. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25387. * @param updatable defines if the mesh must be flagged as updatable
  25388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25389. * @param earcutInjection can be used to inject your own earcut reference
  25390. * @returns a new Mesh
  25391. */
  25392. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25393. /**
  25394. * Creates an extruded shape mesh.
  25395. * 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
  25396. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25398. * @param name defines the name of the mesh to create
  25399. * @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
  25400. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25401. * @param scale is the value to scale the shape
  25402. * @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
  25403. * @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
  25404. * @param scene defines the hosting scene
  25405. * @param updatable defines if the mesh must be flagged as updatable
  25406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25407. * @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)
  25408. * @returns a new Mesh
  25409. */
  25410. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25411. /**
  25412. * Creates an custom extruded shape mesh.
  25413. * The custom extrusion is a parametric shape.
  25414. * It has no predefined shape. Its final shape will depend on the input parameters.
  25415. * Please consider using the same method from the MeshBuilder class instead
  25416. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25417. * @param name defines the name of the mesh to create
  25418. * @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
  25419. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25420. * @param scaleFunction is a custom Javascript function called on each path point
  25421. * @param rotationFunction is a custom Javascript function called on each path point
  25422. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25423. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25424. * @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
  25425. * @param scene defines the hosting scene
  25426. * @param updatable defines if the mesh must be flagged as updatable
  25427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25428. * @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)
  25429. * @returns a new Mesh
  25430. */
  25431. 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;
  25432. /**
  25433. * Creates lathe mesh.
  25434. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25435. * Please consider using the same method from the MeshBuilder class instead
  25436. * @param name defines the name of the mesh to create
  25437. * @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
  25438. * @param radius is the radius value of the lathe
  25439. * @param tessellation is the side number of the lathe.
  25440. * @param scene defines the hosting scene
  25441. * @param updatable defines if the mesh must be flagged as updatable
  25442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25443. * @returns a new Mesh
  25444. */
  25445. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25446. /**
  25447. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25448. * @param name defines the name of the mesh to create
  25449. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25450. * @param scene defines the hosting scene
  25451. * @param updatable defines if the mesh must be flagged as updatable
  25452. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25453. * @returns a new Mesh
  25454. */
  25455. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25456. /**
  25457. * Creates a ground mesh.
  25458. * Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param width set the width of the ground
  25461. * @param height set the height of the ground
  25462. * @param subdivisions sets the number of subdivisions per side
  25463. * @param scene defines the hosting scene
  25464. * @param updatable defines if the mesh must be flagged as updatable
  25465. * @returns a new Mesh
  25466. */
  25467. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25468. /**
  25469. * Creates a tiled ground mesh.
  25470. * Please consider using the same method from the MeshBuilder class instead
  25471. * @param name defines the name of the mesh to create
  25472. * @param xmin set the ground minimum X coordinate
  25473. * @param zmin set the ground minimum Y coordinate
  25474. * @param xmax set the ground maximum X coordinate
  25475. * @param zmax set the ground maximum Z coordinate
  25476. * @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
  25477. * @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
  25478. * @param scene defines the hosting scene
  25479. * @param updatable defines if the mesh must be flagged as updatable
  25480. * @returns a new Mesh
  25481. */
  25482. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25483. w: number;
  25484. h: number;
  25485. }, precision: {
  25486. w: number;
  25487. h: number;
  25488. }, scene: Scene, updatable?: boolean): Mesh;
  25489. /**
  25490. * Creates a ground mesh from a height map.
  25491. * Please consider using the same method from the MeshBuilder class instead
  25492. * @see http://doc.babylonjs.com/babylon101/height_map
  25493. * @param name defines the name of the mesh to create
  25494. * @param url sets the URL of the height map image resource
  25495. * @param width set the ground width size
  25496. * @param height set the ground height size
  25497. * @param subdivisions sets the number of subdivision per side
  25498. * @param minHeight is the minimum altitude on the ground
  25499. * @param maxHeight is the maximum altitude on the ground
  25500. * @param scene defines the hosting scene
  25501. * @param updatable defines if the mesh must be flagged as updatable
  25502. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25503. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25504. * @returns a new Mesh
  25505. */
  25506. 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;
  25507. /**
  25508. * Creates a tube mesh.
  25509. * The tube is a parametric shape.
  25510. * It has no predefined shape. Its final shape will depend on the input parameters.
  25511. * Please consider using the same method from the MeshBuilder class instead
  25512. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25513. * @param name defines the name of the mesh to create
  25514. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25515. * @param radius sets the tube radius size
  25516. * @param tessellation is the number of sides on the tubular surface
  25517. * @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
  25518. * @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
  25519. * @param scene defines the hosting scene
  25520. * @param updatable defines if the mesh must be flagged as updatable
  25521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25522. * @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)
  25523. * @returns a new Mesh
  25524. */
  25525. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25526. (i: number, distance: number): number;
  25527. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25528. /**
  25529. * Creates a polyhedron mesh.
  25530. * Please consider using the same method from the MeshBuilder class instead.
  25531. * * 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
  25532. * * The parameter `size` (positive float, default 1) sets the polygon size
  25533. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25534. * * 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`
  25535. * * 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
  25536. * * 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)`)
  25537. * * 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
  25538. * * 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
  25539. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25540. * * If you create a double-sided mesh, you can choose what parts of 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
  25541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25542. * @param name defines the name of the mesh to create
  25543. * @param options defines the options used to create the mesh
  25544. * @param scene defines the hosting scene
  25545. * @returns a new Mesh
  25546. */
  25547. static CreatePolyhedron(name: string, options: {
  25548. type?: number;
  25549. size?: number;
  25550. sizeX?: number;
  25551. sizeY?: number;
  25552. sizeZ?: number;
  25553. custom?: any;
  25554. faceUV?: Vector4[];
  25555. faceColors?: Color4[];
  25556. updatable?: boolean;
  25557. sideOrientation?: number;
  25558. }, scene: Scene): Mesh;
  25559. /**
  25560. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25561. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25562. * * 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`)
  25563. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25564. * * 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
  25565. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25566. * * If you create a double-sided mesh, you can choose what parts of 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
  25567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25568. * @param name defines the name of the mesh
  25569. * @param options defines the options used to create the mesh
  25570. * @param scene defines the hosting scene
  25571. * @returns a new Mesh
  25572. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25573. */
  25574. static CreateIcoSphere(name: string, options: {
  25575. radius?: number;
  25576. flat?: boolean;
  25577. subdivisions?: number;
  25578. sideOrientation?: number;
  25579. updatable?: boolean;
  25580. }, scene: Scene): Mesh;
  25581. /**
  25582. * Creates a decal mesh.
  25583. * Please consider using the same method from the MeshBuilder class instead.
  25584. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25585. * @param name defines the name of the mesh
  25586. * @param sourceMesh defines the mesh receiving the decal
  25587. * @param position sets the position of the decal in world coordinates
  25588. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25589. * @param size sets the decal scaling
  25590. * @param angle sets the angle to rotate the decal
  25591. * @returns a new Mesh
  25592. */
  25593. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25594. /**
  25595. * Prepare internal position array for software CPU skinning
  25596. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25597. */
  25598. setPositionsForCPUSkinning(): Float32Array;
  25599. /**
  25600. * Prepare internal normal array for software CPU skinning
  25601. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25602. */
  25603. setNormalsForCPUSkinning(): Float32Array;
  25604. /**
  25605. * Updates the vertex buffer by applying transformation from the bones
  25606. * @param skeleton defines the skeleton to apply to current mesh
  25607. * @returns the current mesh
  25608. */
  25609. applySkeleton(skeleton: Skeleton): Mesh;
  25610. /**
  25611. * 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
  25612. * @param meshes defines the list of meshes to scan
  25613. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25614. */
  25615. static MinMax(meshes: AbstractMesh[]): {
  25616. min: Vector3;
  25617. max: Vector3;
  25618. };
  25619. /**
  25620. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25621. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25622. * @returns a vector3
  25623. */
  25624. static Center(meshesOrMinMaxVector: {
  25625. min: Vector3;
  25626. max: Vector3;
  25627. } | AbstractMesh[]): Vector3;
  25628. /**
  25629. * Merge the array of meshes into a single mesh for performance reasons.
  25630. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25631. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25632. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25633. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25634. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25635. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25636. * @returns a new mesh
  25637. */
  25638. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25639. /** @hidden */
  25640. addInstance(instance: InstancedMesh): void;
  25641. /** @hidden */
  25642. removeInstance(instance: InstancedMesh): void;
  25643. }
  25644. }
  25645. declare module "babylonjs/Cameras/camera" {
  25646. import { SmartArray } from "babylonjs/Misc/smartArray";
  25647. import { Observable } from "babylonjs/Misc/observable";
  25648. import { Nullable } from "babylonjs/types";
  25649. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25650. import { Scene } from "babylonjs/scene";
  25651. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25652. import { Node } from "babylonjs/node";
  25653. import { Mesh } from "babylonjs/Meshes/mesh";
  25654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25655. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25656. import { Viewport } from "babylonjs/Maths/math.viewport";
  25657. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25659. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25660. import { Ray } from "babylonjs/Culling/ray";
  25661. /**
  25662. * This is the base class of all the camera used in the application.
  25663. * @see http://doc.babylonjs.com/features/cameras
  25664. */
  25665. export class Camera extends Node {
  25666. /** @hidden */
  25667. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25668. /**
  25669. * This is the default projection mode used by the cameras.
  25670. * It helps recreating a feeling of perspective and better appreciate depth.
  25671. * This is the best way to simulate real life cameras.
  25672. */
  25673. static readonly PERSPECTIVE_CAMERA: number;
  25674. /**
  25675. * This helps creating camera with an orthographic mode.
  25676. * 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.
  25677. */
  25678. static readonly ORTHOGRAPHIC_CAMERA: number;
  25679. /**
  25680. * This is the default FOV mode for perspective cameras.
  25681. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25682. */
  25683. static readonly FOVMODE_VERTICAL_FIXED: number;
  25684. /**
  25685. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25686. */
  25687. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25688. /**
  25689. * This specifies ther is no need for a camera rig.
  25690. * Basically only one eye is rendered corresponding to the camera.
  25691. */
  25692. static readonly RIG_MODE_NONE: number;
  25693. /**
  25694. * Simulates a camera Rig with one blue eye and one red eye.
  25695. * This can be use with 3d blue and red glasses.
  25696. */
  25697. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25698. /**
  25699. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25700. */
  25701. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25702. /**
  25703. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25704. */
  25705. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25706. /**
  25707. * Defines that both eyes of the camera will be rendered over under each other.
  25708. */
  25709. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25710. /**
  25711. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25712. */
  25713. static readonly RIG_MODE_VR: number;
  25714. /**
  25715. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25716. */
  25717. static readonly RIG_MODE_WEBVR: number;
  25718. /**
  25719. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25720. */
  25721. static readonly RIG_MODE_CUSTOM: number;
  25722. /**
  25723. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25724. */
  25725. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25726. /**
  25727. * Define the input manager associated with the camera.
  25728. */
  25729. inputs: CameraInputsManager<Camera>;
  25730. /** @hidden */
  25731. _position: Vector3;
  25732. /**
  25733. * Define the current local position of the camera in the scene
  25734. */
  25735. position: Vector3;
  25736. /**
  25737. * The vector the camera should consider as up.
  25738. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25739. */
  25740. upVector: Vector3;
  25741. /**
  25742. * Define the current limit on the left side for an orthographic camera
  25743. * In scene unit
  25744. */
  25745. orthoLeft: Nullable<number>;
  25746. /**
  25747. * Define the current limit on the right side for an orthographic camera
  25748. * In scene unit
  25749. */
  25750. orthoRight: Nullable<number>;
  25751. /**
  25752. * Define the current limit on the bottom side for an orthographic camera
  25753. * In scene unit
  25754. */
  25755. orthoBottom: Nullable<number>;
  25756. /**
  25757. * Define the current limit on the top side for an orthographic camera
  25758. * In scene unit
  25759. */
  25760. orthoTop: Nullable<number>;
  25761. /**
  25762. * Field Of View is set in Radians. (default is 0.8)
  25763. */
  25764. fov: number;
  25765. /**
  25766. * Define the minimum distance the camera can see from.
  25767. * This is important to note that the depth buffer are not infinite and the closer it starts
  25768. * the more your scene might encounter depth fighting issue.
  25769. */
  25770. minZ: number;
  25771. /**
  25772. * Define the maximum distance the camera can see to.
  25773. * This is important to note that the depth buffer are not infinite and the further it end
  25774. * the more your scene might encounter depth fighting issue.
  25775. */
  25776. maxZ: number;
  25777. /**
  25778. * Define the default inertia of the camera.
  25779. * This helps giving a smooth feeling to the camera movement.
  25780. */
  25781. inertia: number;
  25782. /**
  25783. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25784. */
  25785. mode: number;
  25786. /**
  25787. * Define wether the camera is intermediate.
  25788. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25789. */
  25790. isIntermediate: boolean;
  25791. /**
  25792. * Define the viewport of the camera.
  25793. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25794. */
  25795. viewport: Viewport;
  25796. /**
  25797. * Restricts the camera to viewing objects with the same layerMask.
  25798. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25799. */
  25800. layerMask: number;
  25801. /**
  25802. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25803. */
  25804. fovMode: number;
  25805. /**
  25806. * Rig mode of the camera.
  25807. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25808. * This is normally controlled byt the camera themselves as internal use.
  25809. */
  25810. cameraRigMode: number;
  25811. /**
  25812. * Defines the distance between both "eyes" in case of a RIG
  25813. */
  25814. interaxialDistance: number;
  25815. /**
  25816. * Defines if stereoscopic rendering is done side by side or over under.
  25817. */
  25818. isStereoscopicSideBySide: boolean;
  25819. /**
  25820. * 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
  25821. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25822. * else in the scene. (Eg. security camera)
  25823. *
  25824. * 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)
  25825. */
  25826. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25827. /**
  25828. * When set, the camera will render to this render target instead of the default canvas
  25829. *
  25830. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25831. */
  25832. outputRenderTarget: Nullable<RenderTargetTexture>;
  25833. /**
  25834. * Observable triggered when the camera view matrix has changed.
  25835. */
  25836. onViewMatrixChangedObservable: Observable<Camera>;
  25837. /**
  25838. * Observable triggered when the camera Projection matrix has changed.
  25839. */
  25840. onProjectionMatrixChangedObservable: Observable<Camera>;
  25841. /**
  25842. * Observable triggered when the inputs have been processed.
  25843. */
  25844. onAfterCheckInputsObservable: Observable<Camera>;
  25845. /**
  25846. * Observable triggered when reset has been called and applied to the camera.
  25847. */
  25848. onRestoreStateObservable: Observable<Camera>;
  25849. /** @hidden */
  25850. _cameraRigParams: any;
  25851. /** @hidden */
  25852. _rigCameras: Camera[];
  25853. /** @hidden */
  25854. _rigPostProcess: Nullable<PostProcess>;
  25855. protected _webvrViewMatrix: Matrix;
  25856. /** @hidden */
  25857. _skipRendering: boolean;
  25858. /** @hidden */
  25859. _projectionMatrix: Matrix;
  25860. /** @hidden */
  25861. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25862. /** @hidden */
  25863. _activeMeshes: SmartArray<AbstractMesh>;
  25864. protected _globalPosition: Vector3;
  25865. /** @hidden */
  25866. _computedViewMatrix: Matrix;
  25867. private _doNotComputeProjectionMatrix;
  25868. private _transformMatrix;
  25869. private _frustumPlanes;
  25870. private _refreshFrustumPlanes;
  25871. private _storedFov;
  25872. private _stateStored;
  25873. /**
  25874. * Instantiates a new camera object.
  25875. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25876. * @see http://doc.babylonjs.com/features/cameras
  25877. * @param name Defines the name of the camera in the scene
  25878. * @param position Defines the position of the camera
  25879. * @param scene Defines the scene the camera belongs too
  25880. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25881. */
  25882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25883. /**
  25884. * Store current camera state (fov, position, etc..)
  25885. * @returns the camera
  25886. */
  25887. storeState(): Camera;
  25888. /**
  25889. * Restores the camera state values if it has been stored. You must call storeState() first
  25890. */
  25891. protected _restoreStateValues(): boolean;
  25892. /**
  25893. * Restored camera state. You must call storeState() first.
  25894. * @returns true if restored and false otherwise
  25895. */
  25896. restoreState(): boolean;
  25897. /**
  25898. * Gets the class name of the camera.
  25899. * @returns the class name
  25900. */
  25901. getClassName(): string;
  25902. /** @hidden */
  25903. readonly _isCamera: boolean;
  25904. /**
  25905. * Gets a string representation of the camera useful for debug purpose.
  25906. * @param fullDetails Defines that a more verboe level of logging is required
  25907. * @returns the string representation
  25908. */
  25909. toString(fullDetails?: boolean): string;
  25910. /**
  25911. * Gets the current world space position of the camera.
  25912. */
  25913. readonly globalPosition: Vector3;
  25914. /**
  25915. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25916. * @returns the active meshe list
  25917. */
  25918. getActiveMeshes(): SmartArray<AbstractMesh>;
  25919. /**
  25920. * Check wether a mesh is part of the current active mesh list of the camera
  25921. * @param mesh Defines the mesh to check
  25922. * @returns true if active, false otherwise
  25923. */
  25924. isActiveMesh(mesh: Mesh): boolean;
  25925. /**
  25926. * Is this camera ready to be used/rendered
  25927. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25928. * @return true if the camera is ready
  25929. */
  25930. isReady(completeCheck?: boolean): boolean;
  25931. /** @hidden */
  25932. _initCache(): void;
  25933. /** @hidden */
  25934. _updateCache(ignoreParentClass?: boolean): void;
  25935. /** @hidden */
  25936. _isSynchronized(): boolean;
  25937. /** @hidden */
  25938. _isSynchronizedViewMatrix(): boolean;
  25939. /** @hidden */
  25940. _isSynchronizedProjectionMatrix(): boolean;
  25941. /**
  25942. * Attach the input controls to a specific dom element to get the input from.
  25943. * @param element Defines the element the controls should be listened from
  25944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25945. */
  25946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25947. /**
  25948. * Detach the current controls from the specified dom element.
  25949. * @param element Defines the element to stop listening the inputs from
  25950. */
  25951. detachControl(element: HTMLElement): void;
  25952. /**
  25953. * Update the camera state according to the different inputs gathered during the frame.
  25954. */
  25955. update(): void;
  25956. /** @hidden */
  25957. _checkInputs(): void;
  25958. /** @hidden */
  25959. readonly rigCameras: Camera[];
  25960. /**
  25961. * Gets the post process used by the rig cameras
  25962. */
  25963. readonly rigPostProcess: Nullable<PostProcess>;
  25964. /**
  25965. * Internal, gets the first post proces.
  25966. * @returns the first post process to be run on this camera.
  25967. */
  25968. _getFirstPostProcess(): Nullable<PostProcess>;
  25969. private _cascadePostProcessesToRigCams;
  25970. /**
  25971. * Attach a post process to the camera.
  25972. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25973. * @param postProcess The post process to attach to the camera
  25974. * @param insertAt The position of the post process in case several of them are in use in the scene
  25975. * @returns the position the post process has been inserted at
  25976. */
  25977. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25978. /**
  25979. * Detach a post process to the camera.
  25980. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25981. * @param postProcess The post process to detach from the camera
  25982. */
  25983. detachPostProcess(postProcess: PostProcess): void;
  25984. /**
  25985. * Gets the current world matrix of the camera
  25986. */
  25987. getWorldMatrix(): Matrix;
  25988. /** @hidden */
  25989. _getViewMatrix(): Matrix;
  25990. /**
  25991. * Gets the current view matrix of the camera.
  25992. * @param force forces the camera to recompute the matrix without looking at the cached state
  25993. * @returns the view matrix
  25994. */
  25995. getViewMatrix(force?: boolean): Matrix;
  25996. /**
  25997. * Freeze the projection matrix.
  25998. * It will prevent the cache check of the camera projection compute and can speed up perf
  25999. * if no parameter of the camera are meant to change
  26000. * @param projection Defines manually a projection if necessary
  26001. */
  26002. freezeProjectionMatrix(projection?: Matrix): void;
  26003. /**
  26004. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26005. */
  26006. unfreezeProjectionMatrix(): void;
  26007. /**
  26008. * Gets the current projection matrix of the camera.
  26009. * @param force forces the camera to recompute the matrix without looking at the cached state
  26010. * @returns the projection matrix
  26011. */
  26012. getProjectionMatrix(force?: boolean): Matrix;
  26013. /**
  26014. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26015. * @returns a Matrix
  26016. */
  26017. getTransformationMatrix(): Matrix;
  26018. private _updateFrustumPlanes;
  26019. /**
  26020. * Checks if a cullable object (mesh...) is in the camera frustum
  26021. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26022. * @param target The object to check
  26023. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26024. * @returns true if the object is in frustum otherwise false
  26025. */
  26026. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26027. /**
  26028. * Checks if a cullable object (mesh...) is in the camera frustum
  26029. * Unlike isInFrustum this cheks the full bounding box
  26030. * @param target The object to check
  26031. * @returns true if the object is in frustum otherwise false
  26032. */
  26033. isCompletelyInFrustum(target: ICullable): boolean;
  26034. /**
  26035. * Gets a ray in the forward direction from the camera.
  26036. * @param length Defines the length of the ray to create
  26037. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26038. * @param origin Defines the start point of the ray which defaults to the camera position
  26039. * @returns the forward ray
  26040. */
  26041. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26042. /**
  26043. * Releases resources associated with this node.
  26044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26046. */
  26047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26048. /** @hidden */
  26049. _isLeftCamera: boolean;
  26050. /**
  26051. * Gets the left camera of a rig setup in case of Rigged Camera
  26052. */
  26053. readonly isLeftCamera: boolean;
  26054. /** @hidden */
  26055. _isRightCamera: boolean;
  26056. /**
  26057. * Gets the right camera of a rig setup in case of Rigged Camera
  26058. */
  26059. readonly isRightCamera: boolean;
  26060. /**
  26061. * Gets the left camera of a rig setup in case of Rigged Camera
  26062. */
  26063. readonly leftCamera: Nullable<FreeCamera>;
  26064. /**
  26065. * Gets the right camera of a rig setup in case of Rigged Camera
  26066. */
  26067. readonly rightCamera: Nullable<FreeCamera>;
  26068. /**
  26069. * Gets the left camera target of a rig setup in case of Rigged Camera
  26070. * @returns the target position
  26071. */
  26072. getLeftTarget(): Nullable<Vector3>;
  26073. /**
  26074. * Gets the right camera target of a rig setup in case of Rigged Camera
  26075. * @returns the target position
  26076. */
  26077. getRightTarget(): Nullable<Vector3>;
  26078. /**
  26079. * @hidden
  26080. */
  26081. setCameraRigMode(mode: number, rigParams: any): void;
  26082. /** @hidden */
  26083. static _setStereoscopicRigMode(camera: Camera): void;
  26084. /** @hidden */
  26085. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26086. /** @hidden */
  26087. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26088. /** @hidden */
  26089. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26090. /** @hidden */
  26091. _getVRProjectionMatrix(): Matrix;
  26092. protected _updateCameraRotationMatrix(): void;
  26093. protected _updateWebVRCameraRotationMatrix(): void;
  26094. /**
  26095. * This function MUST be overwritten by the different WebVR cameras available.
  26096. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26097. * @hidden
  26098. */
  26099. _getWebVRProjectionMatrix(): Matrix;
  26100. /**
  26101. * This function MUST be overwritten by the different WebVR cameras available.
  26102. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26103. * @hidden
  26104. */
  26105. _getWebVRViewMatrix(): Matrix;
  26106. /** @hidden */
  26107. setCameraRigParameter(name: string, value: any): void;
  26108. /**
  26109. * needs to be overridden by children so sub has required properties to be copied
  26110. * @hidden
  26111. */
  26112. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26113. /**
  26114. * May need to be overridden by children
  26115. * @hidden
  26116. */
  26117. _updateRigCameras(): void;
  26118. /** @hidden */
  26119. _setupInputs(): void;
  26120. /**
  26121. * Serialiaze the camera setup to a json represention
  26122. * @returns the JSON representation
  26123. */
  26124. serialize(): any;
  26125. /**
  26126. * Clones the current camera.
  26127. * @param name The cloned camera name
  26128. * @returns the cloned camera
  26129. */
  26130. clone(name: string): Camera;
  26131. /**
  26132. * Gets the direction of the camera relative to a given local axis.
  26133. * @param localAxis Defines the reference axis to provide a relative direction.
  26134. * @return the direction
  26135. */
  26136. getDirection(localAxis: Vector3): Vector3;
  26137. /**
  26138. * Returns the current camera absolute rotation
  26139. */
  26140. readonly absoluteRotation: Quaternion;
  26141. /**
  26142. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26143. * @param localAxis Defines the reference axis to provide a relative direction.
  26144. * @param result Defines the vector to store the result in
  26145. */
  26146. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26147. /**
  26148. * Gets a camera constructor for a given camera type
  26149. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26150. * @param name The name of the camera the result will be able to instantiate
  26151. * @param scene The scene the result will construct the camera in
  26152. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26153. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26154. * @returns a factory method to construc the camera
  26155. */
  26156. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26157. /**
  26158. * Compute the world matrix of the camera.
  26159. * @returns the camera world matrix
  26160. */
  26161. computeWorldMatrix(): Matrix;
  26162. /**
  26163. * Parse a JSON and creates the camera from the parsed information
  26164. * @param parsedCamera The JSON to parse
  26165. * @param scene The scene to instantiate the camera in
  26166. * @returns the newly constructed camera
  26167. */
  26168. static Parse(parsedCamera: any, scene: Scene): Camera;
  26169. }
  26170. }
  26171. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26172. import { Nullable } from "babylonjs/types";
  26173. import { Scene } from "babylonjs/scene";
  26174. import { Vector4 } from "babylonjs/Maths/math.vector";
  26175. import { Mesh } from "babylonjs/Meshes/mesh";
  26176. /**
  26177. * Class containing static functions to help procedurally build meshes
  26178. */
  26179. export class DiscBuilder {
  26180. /**
  26181. * Creates a plane polygonal mesh. By default, this is a disc
  26182. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26183. * * 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
  26184. * * 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
  26185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26188. * @param name defines the name of the mesh
  26189. * @param options defines the options used to create the mesh
  26190. * @param scene defines the hosting scene
  26191. * @returns the plane polygonal mesh
  26192. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26193. */
  26194. static CreateDisc(name: string, options: {
  26195. radius?: number;
  26196. tessellation?: number;
  26197. arc?: number;
  26198. updatable?: boolean;
  26199. sideOrientation?: number;
  26200. frontUVs?: Vector4;
  26201. backUVs?: Vector4;
  26202. }, scene?: Nullable<Scene>): Mesh;
  26203. }
  26204. }
  26205. declare module "babylonjs/Particles/solidParticleSystem" {
  26206. import { Nullable } from "babylonjs/types";
  26207. import { Vector3 } from "babylonjs/Maths/math.vector";
  26208. import { Mesh } from "babylonjs/Meshes/mesh";
  26209. import { Scene, IDisposable } from "babylonjs/scene";
  26210. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26211. /**
  26212. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26213. *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.
  26214. * The SPS is also a particle system. It provides some methods to manage the particles.
  26215. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26216. *
  26217. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26218. */
  26219. export class SolidParticleSystem implements IDisposable {
  26220. /**
  26221. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26222. * Example : var p = SPS.particles[i];
  26223. */
  26224. particles: SolidParticle[];
  26225. /**
  26226. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26227. */
  26228. nbParticles: number;
  26229. /**
  26230. * If the particles must ever face the camera (default false). Useful for planar particles.
  26231. */
  26232. billboard: boolean;
  26233. /**
  26234. * Recompute normals when adding a shape
  26235. */
  26236. recomputeNormals: boolean;
  26237. /**
  26238. * This a counter ofr your own usage. It's not set by any SPS functions.
  26239. */
  26240. counter: number;
  26241. /**
  26242. * The SPS name. This name is also given to the underlying mesh.
  26243. */
  26244. name: string;
  26245. /**
  26246. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26247. */
  26248. mesh: Mesh;
  26249. /**
  26250. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26251. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26252. */
  26253. vars: any;
  26254. /**
  26255. * This array is populated when the SPS is set as 'pickable'.
  26256. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26257. * Each element of this array is an object `{idx: int, faceId: int}`.
  26258. * `idx` is the picked particle index in the `SPS.particles` array
  26259. * `faceId` is the picked face index counted within this particle.
  26260. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26261. */
  26262. pickedParticles: {
  26263. idx: number;
  26264. faceId: number;
  26265. }[];
  26266. /**
  26267. * This array is populated when `enableDepthSort` is set to true.
  26268. * Each element of this array is an instance of the class DepthSortedParticle.
  26269. */
  26270. depthSortedParticles: DepthSortedParticle[];
  26271. /**
  26272. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26273. * @hidden
  26274. */
  26275. _bSphereOnly: boolean;
  26276. /**
  26277. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26278. * @hidden
  26279. */
  26280. _bSphereRadiusFactor: number;
  26281. private _scene;
  26282. private _positions;
  26283. private _indices;
  26284. private _normals;
  26285. private _colors;
  26286. private _uvs;
  26287. private _indices32;
  26288. private _positions32;
  26289. private _normals32;
  26290. private _fixedNormal32;
  26291. private _colors32;
  26292. private _uvs32;
  26293. private _index;
  26294. private _updatable;
  26295. private _pickable;
  26296. private _isVisibilityBoxLocked;
  26297. private _alwaysVisible;
  26298. private _depthSort;
  26299. private _expandable;
  26300. private _shapeCounter;
  26301. private _copy;
  26302. private _color;
  26303. private _computeParticleColor;
  26304. private _computeParticleTexture;
  26305. private _computeParticleRotation;
  26306. private _computeParticleVertex;
  26307. private _computeBoundingBox;
  26308. private _depthSortParticles;
  26309. private _camera;
  26310. private _mustUnrotateFixedNormals;
  26311. private _particlesIntersect;
  26312. private _needs32Bits;
  26313. private _isNotBuilt;
  26314. private _lastParticleId;
  26315. private _idxOfId;
  26316. /**
  26317. * Creates a SPS (Solid Particle System) object.
  26318. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26319. * @param scene (Scene) is the scene in which the SPS is added.
  26320. * @param options defines the options of the sps e.g.
  26321. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26322. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26323. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26324. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26325. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26326. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26327. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26328. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26329. */
  26330. constructor(name: string, scene: Scene, options?: {
  26331. updatable?: boolean;
  26332. isPickable?: boolean;
  26333. enableDepthSort?: boolean;
  26334. particleIntersection?: boolean;
  26335. boundingSphereOnly?: boolean;
  26336. bSphereRadiusFactor?: number;
  26337. expandable?: boolean;
  26338. });
  26339. /**
  26340. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26341. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26342. * @returns the created mesh
  26343. */
  26344. buildMesh(): Mesh;
  26345. /**
  26346. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26347. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26348. * Thus the particles generated from `digest()` have their property `position` set yet.
  26349. * @param mesh ( Mesh ) is the mesh to be digested
  26350. * @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
  26351. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26352. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26354. * @returns the current SPS
  26355. */
  26356. digest(mesh: Mesh, options?: {
  26357. facetNb?: number;
  26358. number?: number;
  26359. delta?: number;
  26360. storage?: [];
  26361. }): SolidParticleSystem;
  26362. /**
  26363. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26364. * @hidden
  26365. */
  26366. private _unrotateFixedNormals;
  26367. /**
  26368. * Resets the temporary working copy particle
  26369. * @hidden
  26370. */
  26371. private _resetCopy;
  26372. /**
  26373. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26374. * @param p the current index in the positions array to be updated
  26375. * @param shape a Vector3 array, the shape geometry
  26376. * @param positions the positions array to be updated
  26377. * @param meshInd the shape indices array
  26378. * @param indices the indices array to be updated
  26379. * @param meshUV the shape uv array
  26380. * @param uvs the uv array to be updated
  26381. * @param meshCol the shape color array
  26382. * @param colors the color array to be updated
  26383. * @param meshNor the shape normals array
  26384. * @param normals the normals array to be updated
  26385. * @param idx the particle index
  26386. * @param idxInShape the particle index in its shape
  26387. * @param options the addShape() method passed options
  26388. * @hidden
  26389. */
  26390. private _meshBuilder;
  26391. /**
  26392. * Returns a shape Vector3 array from positions float array
  26393. * @param positions float array
  26394. * @returns a vector3 array
  26395. * @hidden
  26396. */
  26397. private _posToShape;
  26398. /**
  26399. * Returns a shapeUV array from a float uvs (array deep copy)
  26400. * @param uvs as a float array
  26401. * @returns a shapeUV array
  26402. * @hidden
  26403. */
  26404. private _uvsToShapeUV;
  26405. /**
  26406. * Adds a new particle object in the particles array
  26407. * @param idx particle index in particles array
  26408. * @param id particle id
  26409. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26410. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26411. * @param model particle ModelShape object
  26412. * @param shapeId model shape identifier
  26413. * @param idxInShape index of the particle in the current model
  26414. * @param bInfo model bounding info object
  26415. * @param storage target storage array, if any
  26416. * @hidden
  26417. */
  26418. private _addParticle;
  26419. /**
  26420. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26421. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26422. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26423. * @param nb (positive integer) the number of particles to be created from this model
  26424. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26425. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26426. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26427. * @returns the number of shapes in the system
  26428. */
  26429. addShape(mesh: Mesh, nb: number, options?: {
  26430. positionFunction?: any;
  26431. vertexFunction?: any;
  26432. storage?: [];
  26433. }): number;
  26434. /**
  26435. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26436. * @hidden
  26437. */
  26438. private _rebuildParticle;
  26439. /**
  26440. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26441. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26442. * @returns the SPS.
  26443. */
  26444. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26445. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26446. * Returns an array with the removed particles.
  26447. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26448. * The SPS can't be empty so at least one particle needs to remain in place.
  26449. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26450. * @param start index of the first particle to remove
  26451. * @param end index of the last particle to remove (included)
  26452. * @returns an array populated with the removed particles
  26453. */
  26454. removeParticles(start: number, end: number): SolidParticle[];
  26455. /**
  26456. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26457. * @param solidParticleArray an array populated with Solid Particles objects
  26458. * @returns the SPS
  26459. */
  26460. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26461. /**
  26462. * Creates a new particle and modifies the SPS mesh geometry :
  26463. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26464. * - calls _addParticle() to populate the particle array
  26465. * factorized code from addShape() and insertParticlesFromArray()
  26466. * @param idx particle index in the particles array
  26467. * @param i particle index in its shape
  26468. * @param modelShape particle ModelShape object
  26469. * @param shape shape vertex array
  26470. * @param meshInd shape indices array
  26471. * @param meshUV shape uv array
  26472. * @param meshCol shape color array
  26473. * @param meshNor shape normals array
  26474. * @param bbInfo shape bounding info
  26475. * @param storage target particle storage
  26476. * @options addShape() passed options
  26477. * @hidden
  26478. */
  26479. private _insertNewParticle;
  26480. /**
  26481. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26482. * This method calls `updateParticle()` for each particle of the SPS.
  26483. * For an animated SPS, it is usually called within the render loop.
  26484. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26485. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26486. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26487. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26488. * @returns the SPS.
  26489. */
  26490. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26491. /**
  26492. * Disposes the SPS.
  26493. */
  26494. dispose(): void;
  26495. /**
  26496. * Returns a SolidParticle object from its identifier : particle.id
  26497. * @param id (integer) the particle Id
  26498. * @returns the searched particle or null if not found in the SPS.
  26499. */
  26500. getParticleById(id: number): Nullable<SolidParticle>;
  26501. /**
  26502. * Returns a new array populated with the particles having the passed shapeId.
  26503. * @param shapeId (integer) the shape identifier
  26504. * @returns a new solid particle array
  26505. */
  26506. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26507. /**
  26508. * Populates the passed array "ref" with the particles having the passed shapeId.
  26509. * @param shapeId the shape identifier
  26510. * @returns the SPS
  26511. * @param ref
  26512. */
  26513. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26514. /**
  26515. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26516. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26517. * @returns the SPS.
  26518. */
  26519. refreshVisibleSize(): SolidParticleSystem;
  26520. /**
  26521. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26522. * @param size the size (float) of the visibility box
  26523. * note : this doesn't lock the SPS mesh bounding box.
  26524. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26525. */
  26526. setVisibilityBox(size: number): void;
  26527. /**
  26528. * Gets whether the SPS as always visible or not
  26529. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26530. */
  26531. /**
  26532. * Sets the SPS as always visible or not
  26533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26534. */
  26535. isAlwaysVisible: boolean;
  26536. /**
  26537. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26538. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26539. */
  26540. /**
  26541. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26543. */
  26544. isVisibilityBoxLocked: boolean;
  26545. /**
  26546. * Tells to `setParticles()` to compute the particle rotations or not.
  26547. * Default value : true. The SPS is faster when it's set to false.
  26548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26549. */
  26550. /**
  26551. * Gets if `setParticles()` computes the particle rotations or not.
  26552. * Default value : true. The SPS is faster when it's set to false.
  26553. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26554. */
  26555. computeParticleRotation: boolean;
  26556. /**
  26557. * Tells to `setParticles()` to compute the particle colors or not.
  26558. * Default value : true. The SPS is faster when it's set to false.
  26559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26560. */
  26561. /**
  26562. * Gets if `setParticles()` computes the particle colors or not.
  26563. * Default value : true. The SPS is faster when it's set to false.
  26564. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26565. */
  26566. computeParticleColor: boolean;
  26567. /**
  26568. * Gets if `setParticles()` computes the particle textures or not.
  26569. * Default value : true. The SPS is faster when it's set to false.
  26570. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26571. */
  26572. computeParticleTexture: boolean;
  26573. /**
  26574. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26575. * Default value : false. The SPS is faster when it's set to false.
  26576. * Note : the particle custom vertex positions aren't stored values.
  26577. */
  26578. /**
  26579. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26580. * Default value : false. The SPS is faster when it's set to false.
  26581. * Note : the particle custom vertex positions aren't stored values.
  26582. */
  26583. computeParticleVertex: boolean;
  26584. /**
  26585. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26586. */
  26587. /**
  26588. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26589. */
  26590. computeBoundingBox: boolean;
  26591. /**
  26592. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26593. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26594. * Default : `true`
  26595. */
  26596. /**
  26597. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26598. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26599. * Default : `true`
  26600. */
  26601. depthSortParticles: boolean;
  26602. /**
  26603. * Gets if the SPS is created as expandable at construction time.
  26604. * Default : `false`
  26605. */
  26606. readonly expandable: boolean;
  26607. /**
  26608. * This function does nothing. It may be overwritten to set all the particle first values.
  26609. * The SPS doesn't call this function, you may have to call it by your own.
  26610. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26611. */
  26612. initParticles(): void;
  26613. /**
  26614. * This function does nothing. It may be overwritten to recycle a particle.
  26615. * The SPS doesn't call this function, you may have to call it by your own.
  26616. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26617. * @param particle The particle to recycle
  26618. * @returns the recycled particle
  26619. */
  26620. recycleParticle(particle: SolidParticle): SolidParticle;
  26621. /**
  26622. * Updates a particle : this function should be overwritten by the user.
  26623. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26624. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26625. * @example : just set a particle position or velocity and recycle conditions
  26626. * @param particle The particle to update
  26627. * @returns the updated particle
  26628. */
  26629. updateParticle(particle: SolidParticle): SolidParticle;
  26630. /**
  26631. * Updates a vertex of a particle : it can be overwritten by the user.
  26632. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26633. * @param particle the current particle
  26634. * @param vertex the current index of the current particle
  26635. * @param pt the index of the current vertex in the particle shape
  26636. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26637. * @example : just set a vertex particle position
  26638. * @returns the updated vertex
  26639. */
  26640. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26641. /**
  26642. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26643. * This does nothing and may be overwritten by the user.
  26644. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26645. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26646. * @param update the boolean update value actually passed to setParticles()
  26647. */
  26648. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26649. /**
  26650. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26651. * This will be passed three parameters.
  26652. * This does nothing and may be overwritten by the user.
  26653. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26654. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26655. * @param update the boolean update value actually passed to setParticles()
  26656. */
  26657. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26658. }
  26659. }
  26660. declare module "babylonjs/Particles/solidParticle" {
  26661. import { Nullable } from "babylonjs/types";
  26662. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26663. import { Color4 } from "babylonjs/Maths/math.color";
  26664. import { Mesh } from "babylonjs/Meshes/mesh";
  26665. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26666. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26667. import { Plane } from "babylonjs/Maths/math.plane";
  26668. /**
  26669. * Represents one particle of a solid particle system.
  26670. */
  26671. export class SolidParticle {
  26672. /**
  26673. * particle global index
  26674. */
  26675. idx: number;
  26676. /**
  26677. * particle identifier
  26678. */
  26679. id: number;
  26680. /**
  26681. * The color of the particle
  26682. */
  26683. color: Nullable<Color4>;
  26684. /**
  26685. * The world space position of the particle.
  26686. */
  26687. position: Vector3;
  26688. /**
  26689. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26690. */
  26691. rotation: Vector3;
  26692. /**
  26693. * The world space rotation quaternion of the particle.
  26694. */
  26695. rotationQuaternion: Nullable<Quaternion>;
  26696. /**
  26697. * The scaling of the particle.
  26698. */
  26699. scaling: Vector3;
  26700. /**
  26701. * The uvs of the particle.
  26702. */
  26703. uvs: Vector4;
  26704. /**
  26705. * The current speed of the particle.
  26706. */
  26707. velocity: Vector3;
  26708. /**
  26709. * The pivot point in the particle local space.
  26710. */
  26711. pivot: Vector3;
  26712. /**
  26713. * Must the particle be translated from its pivot point in its local space ?
  26714. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26715. * Default : false
  26716. */
  26717. translateFromPivot: boolean;
  26718. /**
  26719. * Is the particle active or not ?
  26720. */
  26721. alive: boolean;
  26722. /**
  26723. * Is the particle visible or not ?
  26724. */
  26725. isVisible: boolean;
  26726. /**
  26727. * Index of this particle in the global "positions" array (Internal use)
  26728. * @hidden
  26729. */
  26730. _pos: number;
  26731. /**
  26732. * @hidden Index of this particle in the global "indices" array (Internal use)
  26733. */
  26734. _ind: number;
  26735. /**
  26736. * @hidden ModelShape of this particle (Internal use)
  26737. */
  26738. _model: ModelShape;
  26739. /**
  26740. * ModelShape id of this particle
  26741. */
  26742. shapeId: number;
  26743. /**
  26744. * Index of the particle in its shape id
  26745. */
  26746. idxInShape: number;
  26747. /**
  26748. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26749. */
  26750. _modelBoundingInfo: BoundingInfo;
  26751. /**
  26752. * @hidden Particle BoundingInfo object (Internal use)
  26753. */
  26754. _boundingInfo: BoundingInfo;
  26755. /**
  26756. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26757. */
  26758. _sps: SolidParticleSystem;
  26759. /**
  26760. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26761. */
  26762. _stillInvisible: boolean;
  26763. /**
  26764. * @hidden Last computed particle rotation matrix
  26765. */
  26766. _rotationMatrix: number[];
  26767. /**
  26768. * Parent particle Id, if any.
  26769. * Default null.
  26770. */
  26771. parentId: Nullable<number>;
  26772. /**
  26773. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26774. * The possible values are :
  26775. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26776. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26777. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26778. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26779. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26780. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26781. * */
  26782. cullingStrategy: number;
  26783. /**
  26784. * @hidden Internal global position in the SPS.
  26785. */
  26786. _globalPosition: Vector3;
  26787. /**
  26788. * Creates a Solid Particle object.
  26789. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26790. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26791. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26792. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26793. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26794. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26795. * @param shapeId (integer) is the model shape identifier in the SPS.
  26796. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26797. * @param sps defines the sps it is associated to
  26798. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26799. */
  26800. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26801. /**
  26802. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26803. * @param target the particle target
  26804. * @returns the current particle
  26805. */
  26806. copyToRef(target: SolidParticle): SolidParticle;
  26807. /**
  26808. * Legacy support, changed scale to scaling
  26809. */
  26810. /**
  26811. * Legacy support, changed scale to scaling
  26812. */
  26813. scale: Vector3;
  26814. /**
  26815. * Legacy support, changed quaternion to rotationQuaternion
  26816. */
  26817. /**
  26818. * Legacy support, changed quaternion to rotationQuaternion
  26819. */
  26820. quaternion: Nullable<Quaternion>;
  26821. /**
  26822. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26823. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26824. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26825. * @returns true if it intersects
  26826. */
  26827. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26828. /**
  26829. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26830. * A particle is in the frustum if its bounding box intersects the frustum
  26831. * @param frustumPlanes defines the frustum to test
  26832. * @returns true if the particle is in the frustum planes
  26833. */
  26834. isInFrustum(frustumPlanes: Plane[]): boolean;
  26835. /**
  26836. * get the rotation matrix of the particle
  26837. * @hidden
  26838. */
  26839. getRotationMatrix(m: Matrix): void;
  26840. }
  26841. /**
  26842. * Represents the shape of the model used by one particle of a solid particle system.
  26843. * SPS internal tool, don't use it manually.
  26844. */
  26845. export class ModelShape {
  26846. /**
  26847. * The shape id
  26848. * @hidden
  26849. */
  26850. shapeID: number;
  26851. /**
  26852. * flat array of model positions (internal use)
  26853. * @hidden
  26854. */
  26855. _shape: Vector3[];
  26856. /**
  26857. * flat array of model UVs (internal use)
  26858. * @hidden
  26859. */
  26860. _shapeUV: number[];
  26861. /**
  26862. * color array of the model
  26863. * @hidden
  26864. */
  26865. _shapeColors: number[];
  26866. /**
  26867. * indices array of the model
  26868. * @hidden
  26869. */
  26870. _indices: number[];
  26871. /**
  26872. * normals array of the model
  26873. * @hidden
  26874. */
  26875. _normals: number[];
  26876. /**
  26877. * length of the shape in the model indices array (internal use)
  26878. * @hidden
  26879. */
  26880. _indicesLength: number;
  26881. /**
  26882. * Custom position function (internal use)
  26883. * @hidden
  26884. */
  26885. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26886. /**
  26887. * Custom vertex function (internal use)
  26888. * @hidden
  26889. */
  26890. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26891. /**
  26892. * 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.
  26893. * SPS internal tool, don't use it manually.
  26894. * @hidden
  26895. */
  26896. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26897. }
  26898. /**
  26899. * Represents a Depth Sorted Particle in the solid particle system.
  26900. */
  26901. export class DepthSortedParticle {
  26902. /**
  26903. * Index of the particle in the "indices" array
  26904. */
  26905. ind: number;
  26906. /**
  26907. * Length of the particle shape in the "indices" array
  26908. */
  26909. indicesLength: number;
  26910. /**
  26911. * Squared distance from the particle to the camera
  26912. */
  26913. sqDistance: number;
  26914. }
  26915. }
  26916. declare module "babylonjs/Collisions/meshCollisionData" {
  26917. import { Collider } from "babylonjs/Collisions/collider";
  26918. import { Vector3 } from "babylonjs/Maths/math.vector";
  26919. import { Nullable } from "babylonjs/types";
  26920. import { Observer } from "babylonjs/Misc/observable";
  26921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26922. /**
  26923. * @hidden
  26924. */
  26925. export class _MeshCollisionData {
  26926. _checkCollisions: boolean;
  26927. _collisionMask: number;
  26928. _collisionGroup: number;
  26929. _collider: Nullable<Collider>;
  26930. _oldPositionForCollisions: Vector3;
  26931. _diffPositionForCollisions: Vector3;
  26932. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26933. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26934. }
  26935. }
  26936. declare module "babylonjs/Meshes/abstractMesh" {
  26937. import { Observable } from "babylonjs/Misc/observable";
  26938. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26939. import { Camera } from "babylonjs/Cameras/camera";
  26940. import { Scene, IDisposable } from "babylonjs/scene";
  26941. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26942. import { Node } from "babylonjs/node";
  26943. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26946. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26947. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26948. import { Material } from "babylonjs/Materials/material";
  26949. import { Light } from "babylonjs/Lights/light";
  26950. import { Skeleton } from "babylonjs/Bones/skeleton";
  26951. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26952. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26953. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26954. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26955. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26956. import { Plane } from "babylonjs/Maths/math.plane";
  26957. import { Ray } from "babylonjs/Culling/ray";
  26958. import { Collider } from "babylonjs/Collisions/collider";
  26959. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26960. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26961. /** @hidden */
  26962. class _FacetDataStorage {
  26963. facetPositions: Vector3[];
  26964. facetNormals: Vector3[];
  26965. facetPartitioning: number[][];
  26966. facetNb: number;
  26967. partitioningSubdivisions: number;
  26968. partitioningBBoxRatio: number;
  26969. facetDataEnabled: boolean;
  26970. facetParameters: any;
  26971. bbSize: Vector3;
  26972. subDiv: {
  26973. max: number;
  26974. X: number;
  26975. Y: number;
  26976. Z: number;
  26977. };
  26978. facetDepthSort: boolean;
  26979. facetDepthSortEnabled: boolean;
  26980. depthSortedIndices: IndicesArray;
  26981. depthSortedFacets: {
  26982. ind: number;
  26983. sqDistance: number;
  26984. }[];
  26985. facetDepthSortFunction: (f1: {
  26986. ind: number;
  26987. sqDistance: number;
  26988. }, f2: {
  26989. ind: number;
  26990. sqDistance: number;
  26991. }) => number;
  26992. facetDepthSortFrom: Vector3;
  26993. facetDepthSortOrigin: Vector3;
  26994. invertedMatrix: Matrix;
  26995. }
  26996. /**
  26997. * @hidden
  26998. **/
  26999. class _InternalAbstractMeshDataInfo {
  27000. _hasVertexAlpha: boolean;
  27001. _useVertexColors: boolean;
  27002. _numBoneInfluencers: number;
  27003. _applyFog: boolean;
  27004. _receiveShadows: boolean;
  27005. _facetData: _FacetDataStorage;
  27006. _visibility: number;
  27007. _skeleton: Nullable<Skeleton>;
  27008. _layerMask: number;
  27009. _computeBonesUsingShaders: boolean;
  27010. _isActive: boolean;
  27011. _onlyForInstances: boolean;
  27012. _isActiveIntermediate: boolean;
  27013. _onlyForInstancesIntermediate: boolean;
  27014. _actAsRegularMesh: boolean;
  27015. }
  27016. /**
  27017. * Class used to store all common mesh properties
  27018. */
  27019. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27020. /** No occlusion */
  27021. static OCCLUSION_TYPE_NONE: number;
  27022. /** Occlusion set to optimisitic */
  27023. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27024. /** Occlusion set to strict */
  27025. static OCCLUSION_TYPE_STRICT: number;
  27026. /** Use an accurante occlusion algorithm */
  27027. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27028. /** Use a conservative occlusion algorithm */
  27029. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27030. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27031. * Test order :
  27032. * Is the bounding sphere outside the frustum ?
  27033. * If not, are the bounding box vertices outside the frustum ?
  27034. * It not, then the cullable object is in the frustum.
  27035. */
  27036. static readonly CULLINGSTRATEGY_STANDARD: number;
  27037. /** Culling strategy : Bounding Sphere Only.
  27038. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27039. * It's also less accurate than the standard because some not visible objects can still be selected.
  27040. * Test : is the bounding sphere outside the frustum ?
  27041. * If not, then the cullable object is in the frustum.
  27042. */
  27043. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27044. /** Culling strategy : Optimistic Inclusion.
  27045. * This in an inclusion test first, then the standard exclusion test.
  27046. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27047. * 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.
  27048. * Anyway, it's as accurate as the standard strategy.
  27049. * Test :
  27050. * Is the cullable object bounding sphere center in the frustum ?
  27051. * If not, apply the default culling strategy.
  27052. */
  27053. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27054. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27055. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27056. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27057. * 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.
  27058. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27059. * Test :
  27060. * Is the cullable object bounding sphere center in the frustum ?
  27061. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27062. */
  27063. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27064. /**
  27065. * No billboard
  27066. */
  27067. static readonly BILLBOARDMODE_NONE: number;
  27068. /** Billboard on X axis */
  27069. static readonly BILLBOARDMODE_X: number;
  27070. /** Billboard on Y axis */
  27071. static readonly BILLBOARDMODE_Y: number;
  27072. /** Billboard on Z axis */
  27073. static readonly BILLBOARDMODE_Z: number;
  27074. /** Billboard on all axes */
  27075. static readonly BILLBOARDMODE_ALL: number;
  27076. /** Billboard on using position instead of orientation */
  27077. static readonly BILLBOARDMODE_USE_POSITION: number;
  27078. /** @hidden */
  27079. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27080. /**
  27081. * The culling strategy to use to check whether the mesh must be rendered or not.
  27082. * This value can be changed at any time and will be used on the next render mesh selection.
  27083. * The possible values are :
  27084. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27085. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27088. * Please read each static variable documentation to get details about the culling process.
  27089. * */
  27090. cullingStrategy: number;
  27091. /**
  27092. * Gets the number of facets in the mesh
  27093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27094. */
  27095. readonly facetNb: number;
  27096. /**
  27097. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27099. */
  27100. partitioningSubdivisions: number;
  27101. /**
  27102. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27103. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27105. */
  27106. partitioningBBoxRatio: number;
  27107. /**
  27108. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27109. * Works only for updatable meshes.
  27110. * Doesn't work with multi-materials
  27111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27112. */
  27113. mustDepthSortFacets: boolean;
  27114. /**
  27115. * The location (Vector3) where the facet depth sort must be computed from.
  27116. * By default, the active camera position.
  27117. * Used only when facet depth sort is enabled
  27118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27119. */
  27120. facetDepthSortFrom: Vector3;
  27121. /**
  27122. * gets a boolean indicating if facetData is enabled
  27123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27124. */
  27125. readonly isFacetDataEnabled: boolean;
  27126. /** @hidden */
  27127. _updateNonUniformScalingState(value: boolean): boolean;
  27128. /**
  27129. * An event triggered when this mesh collides with another one
  27130. */
  27131. onCollideObservable: Observable<AbstractMesh>;
  27132. /** Set a function to call when this mesh collides with another one */
  27133. onCollide: () => void;
  27134. /**
  27135. * An event triggered when the collision's position changes
  27136. */
  27137. onCollisionPositionChangeObservable: Observable<Vector3>;
  27138. /** Set a function to call when the collision's position changes */
  27139. onCollisionPositionChange: () => void;
  27140. /**
  27141. * An event triggered when material is changed
  27142. */
  27143. onMaterialChangedObservable: Observable<AbstractMesh>;
  27144. /**
  27145. * Gets or sets the orientation for POV movement & rotation
  27146. */
  27147. definedFacingForward: boolean;
  27148. /** @hidden */
  27149. _occlusionQuery: Nullable<WebGLQuery>;
  27150. /** @hidden */
  27151. _renderingGroup: Nullable<RenderingGroup>;
  27152. /**
  27153. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27154. */
  27155. /**
  27156. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27157. */
  27158. visibility: number;
  27159. /** Gets or sets the alpha index used to sort transparent meshes
  27160. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27161. */
  27162. alphaIndex: number;
  27163. /**
  27164. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27165. */
  27166. isVisible: boolean;
  27167. /**
  27168. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27169. */
  27170. isPickable: boolean;
  27171. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27172. showSubMeshesBoundingBox: boolean;
  27173. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27175. */
  27176. isBlocker: boolean;
  27177. /**
  27178. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27179. */
  27180. enablePointerMoveEvents: boolean;
  27181. /**
  27182. * Specifies the rendering group id for this mesh (0 by default)
  27183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27184. */
  27185. renderingGroupId: number;
  27186. private _material;
  27187. /** Gets or sets current material */
  27188. material: Nullable<Material>;
  27189. /**
  27190. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27191. * @see http://doc.babylonjs.com/babylon101/shadows
  27192. */
  27193. receiveShadows: boolean;
  27194. /** Defines color to use when rendering outline */
  27195. outlineColor: Color3;
  27196. /** Define width to use when rendering outline */
  27197. outlineWidth: number;
  27198. /** Defines color to use when rendering overlay */
  27199. overlayColor: Color3;
  27200. /** Defines alpha to use when rendering overlay */
  27201. overlayAlpha: number;
  27202. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27203. hasVertexAlpha: boolean;
  27204. /** 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) */
  27205. useVertexColors: boolean;
  27206. /**
  27207. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27208. */
  27209. computeBonesUsingShaders: boolean;
  27210. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27211. numBoneInfluencers: number;
  27212. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27213. applyFog: boolean;
  27214. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27215. useOctreeForRenderingSelection: boolean;
  27216. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27217. useOctreeForPicking: boolean;
  27218. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27219. useOctreeForCollisions: boolean;
  27220. /**
  27221. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27222. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27223. */
  27224. layerMask: number;
  27225. /**
  27226. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27227. */
  27228. alwaysSelectAsActiveMesh: boolean;
  27229. /**
  27230. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27231. */
  27232. doNotSyncBoundingInfo: boolean;
  27233. /**
  27234. * Gets or sets the current action manager
  27235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27236. */
  27237. actionManager: Nullable<AbstractActionManager>;
  27238. private _meshCollisionData;
  27239. /**
  27240. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27241. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27242. */
  27243. ellipsoid: Vector3;
  27244. /**
  27245. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27247. */
  27248. ellipsoidOffset: Vector3;
  27249. /**
  27250. * Gets or sets a collision mask used to mask collisions (default is -1).
  27251. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27252. */
  27253. collisionMask: number;
  27254. /**
  27255. * Gets or sets the current collision group mask (-1 by default).
  27256. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27257. */
  27258. collisionGroup: number;
  27259. /**
  27260. * Defines edge width used when edgesRenderer is enabled
  27261. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27262. */
  27263. edgesWidth: number;
  27264. /**
  27265. * Defines edge color used when edgesRenderer is enabled
  27266. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27267. */
  27268. edgesColor: Color4;
  27269. /** @hidden */
  27270. _edgesRenderer: Nullable<IEdgesRenderer>;
  27271. /** @hidden */
  27272. _masterMesh: Nullable<AbstractMesh>;
  27273. /** @hidden */
  27274. _boundingInfo: Nullable<BoundingInfo>;
  27275. /** @hidden */
  27276. _renderId: number;
  27277. /**
  27278. * Gets or sets the list of subMeshes
  27279. * @see http://doc.babylonjs.com/how_to/multi_materials
  27280. */
  27281. subMeshes: SubMesh[];
  27282. /** @hidden */
  27283. _intersectionsInProgress: AbstractMesh[];
  27284. /** @hidden */
  27285. _unIndexed: boolean;
  27286. /** @hidden */
  27287. _lightSources: Light[];
  27288. /** Gets the list of lights affecting that mesh */
  27289. readonly lightSources: Light[];
  27290. /** @hidden */
  27291. readonly _positions: Nullable<Vector3[]>;
  27292. /** @hidden */
  27293. _waitingData: {
  27294. lods: Nullable<any>;
  27295. actions: Nullable<any>;
  27296. freezeWorldMatrix: Nullable<boolean>;
  27297. };
  27298. /** @hidden */
  27299. _bonesTransformMatrices: Nullable<Float32Array>;
  27300. /** @hidden */
  27301. _transformMatrixTexture: Nullable<RawTexture>;
  27302. /**
  27303. * Gets or sets a skeleton to apply skining transformations
  27304. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27305. */
  27306. skeleton: Nullable<Skeleton>;
  27307. /**
  27308. * An event triggered when the mesh is rebuilt.
  27309. */
  27310. onRebuildObservable: Observable<AbstractMesh>;
  27311. /**
  27312. * Creates a new AbstractMesh
  27313. * @param name defines the name of the mesh
  27314. * @param scene defines the hosting scene
  27315. */
  27316. constructor(name: string, scene?: Nullable<Scene>);
  27317. /**
  27318. * Returns the string "AbstractMesh"
  27319. * @returns "AbstractMesh"
  27320. */
  27321. getClassName(): string;
  27322. /**
  27323. * Gets a string representation of the current mesh
  27324. * @param fullDetails defines a boolean indicating if full details must be included
  27325. * @returns a string representation of the current mesh
  27326. */
  27327. toString(fullDetails?: boolean): string;
  27328. /**
  27329. * @hidden
  27330. */
  27331. protected _getEffectiveParent(): Nullable<Node>;
  27332. /** @hidden */
  27333. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27334. /** @hidden */
  27335. _rebuild(): void;
  27336. /** @hidden */
  27337. _resyncLightSources(): void;
  27338. /** @hidden */
  27339. _resyncLighSource(light: Light): void;
  27340. /** @hidden */
  27341. _unBindEffect(): void;
  27342. /** @hidden */
  27343. _removeLightSource(light: Light, dispose: boolean): void;
  27344. private _markSubMeshesAsDirty;
  27345. /** @hidden */
  27346. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27347. /** @hidden */
  27348. _markSubMeshesAsAttributesDirty(): void;
  27349. /** @hidden */
  27350. _markSubMeshesAsMiscDirty(): void;
  27351. /**
  27352. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27353. */
  27354. scaling: Vector3;
  27355. /**
  27356. * Returns true if the mesh is blocked. Implemented by child classes
  27357. */
  27358. readonly isBlocked: boolean;
  27359. /**
  27360. * Returns the mesh itself by default. Implemented by child classes
  27361. * @param camera defines the camera to use to pick the right LOD level
  27362. * @returns the currentAbstractMesh
  27363. */
  27364. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27365. /**
  27366. * Returns 0 by default. Implemented by child classes
  27367. * @returns an integer
  27368. */
  27369. getTotalVertices(): number;
  27370. /**
  27371. * Returns a positive integer : the total number of indices in this mesh geometry.
  27372. * @returns the numner of indices or zero if the mesh has no geometry.
  27373. */
  27374. getTotalIndices(): number;
  27375. /**
  27376. * Returns null by default. Implemented by child classes
  27377. * @returns null
  27378. */
  27379. getIndices(): Nullable<IndicesArray>;
  27380. /**
  27381. * Returns the array of the requested vertex data kind. Implemented by child classes
  27382. * @param kind defines the vertex data kind to use
  27383. * @returns null
  27384. */
  27385. getVerticesData(kind: string): Nullable<FloatArray>;
  27386. /**
  27387. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27388. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27389. * Note that a new underlying VertexBuffer object is created each call.
  27390. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27391. * @param kind defines vertex data kind:
  27392. * * VertexBuffer.PositionKind
  27393. * * VertexBuffer.UVKind
  27394. * * VertexBuffer.UV2Kind
  27395. * * VertexBuffer.UV3Kind
  27396. * * VertexBuffer.UV4Kind
  27397. * * VertexBuffer.UV5Kind
  27398. * * VertexBuffer.UV6Kind
  27399. * * VertexBuffer.ColorKind
  27400. * * VertexBuffer.MatricesIndicesKind
  27401. * * VertexBuffer.MatricesIndicesExtraKind
  27402. * * VertexBuffer.MatricesWeightsKind
  27403. * * VertexBuffer.MatricesWeightsExtraKind
  27404. * @param data defines the data source
  27405. * @param updatable defines if the data must be flagged as updatable (or static)
  27406. * @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
  27407. * @returns the current mesh
  27408. */
  27409. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27410. /**
  27411. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27412. * If the mesh has no geometry, it is simply returned as it is.
  27413. * @param kind defines vertex data kind:
  27414. * * VertexBuffer.PositionKind
  27415. * * VertexBuffer.UVKind
  27416. * * VertexBuffer.UV2Kind
  27417. * * VertexBuffer.UV3Kind
  27418. * * VertexBuffer.UV4Kind
  27419. * * VertexBuffer.UV5Kind
  27420. * * VertexBuffer.UV6Kind
  27421. * * VertexBuffer.ColorKind
  27422. * * VertexBuffer.MatricesIndicesKind
  27423. * * VertexBuffer.MatricesIndicesExtraKind
  27424. * * VertexBuffer.MatricesWeightsKind
  27425. * * VertexBuffer.MatricesWeightsExtraKind
  27426. * @param data defines the data source
  27427. * @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
  27428. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27429. * @returns the current mesh
  27430. */
  27431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27432. /**
  27433. * Sets the mesh indices,
  27434. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27435. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27436. * @param totalVertices Defines the total number of vertices
  27437. * @returns the current mesh
  27438. */
  27439. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27440. /**
  27441. * Gets a boolean indicating if specific vertex data is present
  27442. * @param kind defines the vertex data kind to use
  27443. * @returns true is data kind is present
  27444. */
  27445. isVerticesDataPresent(kind: string): boolean;
  27446. /**
  27447. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27448. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27449. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27450. * @returns a BoundingInfo
  27451. */
  27452. getBoundingInfo(): BoundingInfo;
  27453. /**
  27454. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27455. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27456. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27457. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27458. * @returns the current mesh
  27459. */
  27460. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27461. /**
  27462. * Overwrite the current bounding info
  27463. * @param boundingInfo defines the new bounding info
  27464. * @returns the current mesh
  27465. */
  27466. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27467. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27468. readonly useBones: boolean;
  27469. /** @hidden */
  27470. _preActivate(): void;
  27471. /** @hidden */
  27472. _preActivateForIntermediateRendering(renderId: number): void;
  27473. /** @hidden */
  27474. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27475. /** @hidden */
  27476. _postActivate(): void;
  27477. /** @hidden */
  27478. _freeze(): void;
  27479. /** @hidden */
  27480. _unFreeze(): void;
  27481. /**
  27482. * Gets the current world matrix
  27483. * @returns a Matrix
  27484. */
  27485. getWorldMatrix(): Matrix;
  27486. /** @hidden */
  27487. _getWorldMatrixDeterminant(): number;
  27488. /**
  27489. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27490. */
  27491. readonly isAnInstance: boolean;
  27492. /**
  27493. * Gets a boolean indicating if this mesh has instances
  27494. */
  27495. readonly hasInstances: boolean;
  27496. /**
  27497. * Perform relative position change from the point of view of behind the front of the mesh.
  27498. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27499. * Supports definition of mesh facing forward or backward
  27500. * @param amountRight defines the distance on the right axis
  27501. * @param amountUp defines the distance on the up axis
  27502. * @param amountForward defines the distance on the forward axis
  27503. * @returns the current mesh
  27504. */
  27505. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27506. /**
  27507. * Calculate relative position change from the point of view of behind the front of the mesh.
  27508. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27509. * Supports definition of mesh facing forward or backward
  27510. * @param amountRight defines the distance on the right axis
  27511. * @param amountUp defines the distance on the up axis
  27512. * @param amountForward defines the distance on the forward axis
  27513. * @returns the new displacement vector
  27514. */
  27515. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27516. /**
  27517. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27518. * Supports definition of mesh facing forward or backward
  27519. * @param flipBack defines the flip
  27520. * @param twirlClockwise defines the twirl
  27521. * @param tiltRight defines the tilt
  27522. * @returns the current mesh
  27523. */
  27524. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27525. /**
  27526. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27527. * Supports definition of mesh facing forward or backward.
  27528. * @param flipBack defines the flip
  27529. * @param twirlClockwise defines the twirl
  27530. * @param tiltRight defines the tilt
  27531. * @returns the new rotation vector
  27532. */
  27533. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27534. /**
  27535. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27536. * This means the mesh underlying bounding box and sphere are recomputed.
  27537. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27538. * @returns the current mesh
  27539. */
  27540. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27541. /** @hidden */
  27542. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27543. /** @hidden */
  27544. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27545. /** @hidden */
  27546. _updateBoundingInfo(): AbstractMesh;
  27547. /** @hidden */
  27548. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27549. /** @hidden */
  27550. protected _afterComputeWorldMatrix(): void;
  27551. /** @hidden */
  27552. readonly _effectiveMesh: AbstractMesh;
  27553. /**
  27554. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27555. * A mesh is in the frustum if its bounding box intersects the frustum
  27556. * @param frustumPlanes defines the frustum to test
  27557. * @returns true if the mesh is in the frustum planes
  27558. */
  27559. isInFrustum(frustumPlanes: Plane[]): boolean;
  27560. /**
  27561. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27562. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27563. * @param frustumPlanes defines the frustum to test
  27564. * @returns true if the mesh is completely in the frustum planes
  27565. */
  27566. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27567. /**
  27568. * True if the mesh intersects another mesh or a SolidParticle object
  27569. * @param mesh defines a target mesh or SolidParticle to test
  27570. * @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)
  27571. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27572. * @returns true if there is an intersection
  27573. */
  27574. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27575. /**
  27576. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27577. * @param point defines the point to test
  27578. * @returns true if there is an intersection
  27579. */
  27580. intersectsPoint(point: Vector3): boolean;
  27581. /**
  27582. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27583. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27584. */
  27585. checkCollisions: boolean;
  27586. /**
  27587. * Gets Collider object used to compute collisions (not physics)
  27588. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27589. */
  27590. readonly collider: Nullable<Collider>;
  27591. /**
  27592. * Move the mesh using collision engine
  27593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27594. * @param displacement defines the requested displacement vector
  27595. * @returns the current mesh
  27596. */
  27597. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27598. private _onCollisionPositionChange;
  27599. /** @hidden */
  27600. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27601. /** @hidden */
  27602. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27603. /** @hidden */
  27604. _checkCollision(collider: Collider): AbstractMesh;
  27605. /** @hidden */
  27606. _generatePointsArray(): boolean;
  27607. /**
  27608. * Checks if the passed Ray intersects with the mesh
  27609. * @param ray defines the ray to use
  27610. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27611. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27612. * @returns the picking info
  27613. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27614. */
  27615. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27616. /**
  27617. * Clones the current mesh
  27618. * @param name defines the mesh name
  27619. * @param newParent defines the new mesh parent
  27620. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27621. * @returns the new mesh
  27622. */
  27623. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27624. /**
  27625. * Disposes all the submeshes of the current meshnp
  27626. * @returns the current mesh
  27627. */
  27628. releaseSubMeshes(): AbstractMesh;
  27629. /**
  27630. * Releases resources associated with this abstract mesh.
  27631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27633. */
  27634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27635. /**
  27636. * Adds the passed mesh as a child to the current mesh
  27637. * @param mesh defines the child mesh
  27638. * @returns the current mesh
  27639. */
  27640. addChild(mesh: AbstractMesh): AbstractMesh;
  27641. /**
  27642. * Removes the passed mesh from the current mesh children list
  27643. * @param mesh defines the child mesh
  27644. * @returns the current mesh
  27645. */
  27646. removeChild(mesh: AbstractMesh): AbstractMesh;
  27647. /** @hidden */
  27648. private _initFacetData;
  27649. /**
  27650. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27651. * This method can be called within the render loop.
  27652. * 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
  27653. * @returns the current mesh
  27654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27655. */
  27656. updateFacetData(): AbstractMesh;
  27657. /**
  27658. * Returns the facetLocalNormals array.
  27659. * The normals are expressed in the mesh local spac
  27660. * @returns an array of Vector3
  27661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27662. */
  27663. getFacetLocalNormals(): Vector3[];
  27664. /**
  27665. * Returns the facetLocalPositions array.
  27666. * The facet positions are expressed in the mesh local space
  27667. * @returns an array of Vector3
  27668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27669. */
  27670. getFacetLocalPositions(): Vector3[];
  27671. /**
  27672. * Returns the facetLocalPartioning array
  27673. * @returns an array of array of numbers
  27674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27675. */
  27676. getFacetLocalPartitioning(): number[][];
  27677. /**
  27678. * Returns the i-th facet position in the world system.
  27679. * This method allocates a new Vector3 per call
  27680. * @param i defines the facet index
  27681. * @returns a new Vector3
  27682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27683. */
  27684. getFacetPosition(i: number): Vector3;
  27685. /**
  27686. * Sets the reference Vector3 with the i-th facet position in the world system
  27687. * @param i defines the facet index
  27688. * @param ref defines the target vector
  27689. * @returns the current mesh
  27690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27691. */
  27692. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27693. /**
  27694. * Returns the i-th facet normal in the world system.
  27695. * This method allocates a new Vector3 per call
  27696. * @param i defines the facet index
  27697. * @returns a new Vector3
  27698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27699. */
  27700. getFacetNormal(i: number): Vector3;
  27701. /**
  27702. * Sets the reference Vector3 with the i-th facet normal in the world system
  27703. * @param i defines the facet index
  27704. * @param ref defines the target vector
  27705. * @returns the current mesh
  27706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27707. */
  27708. getFacetNormalToRef(i: number, ref: Vector3): this;
  27709. /**
  27710. * 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)
  27711. * @param x defines x coordinate
  27712. * @param y defines y coordinate
  27713. * @param z defines z coordinate
  27714. * @returns the array of facet indexes
  27715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27716. */
  27717. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27718. /**
  27719. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27720. * @param projected sets as the (x,y,z) world projection on the facet
  27721. * @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
  27722. * @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
  27723. * @param x defines x coordinate
  27724. * @param y defines y coordinate
  27725. * @param z defines z coordinate
  27726. * @returns the face index if found (or null instead)
  27727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27728. */
  27729. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27730. /**
  27731. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27732. * @param projected sets as the (x,y,z) local projection on the facet
  27733. * @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
  27734. * @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
  27735. * @param x defines x coordinate
  27736. * @param y defines y coordinate
  27737. * @param z defines z coordinate
  27738. * @returns the face index if found (or null instead)
  27739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27740. */
  27741. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27742. /**
  27743. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27744. * @returns the parameters
  27745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27746. */
  27747. getFacetDataParameters(): any;
  27748. /**
  27749. * Disables the feature FacetData and frees the related memory
  27750. * @returns the current mesh
  27751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27752. */
  27753. disableFacetData(): AbstractMesh;
  27754. /**
  27755. * Updates the AbstractMesh indices array
  27756. * @param indices defines the data source
  27757. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27758. * @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)
  27759. * @returns the current mesh
  27760. */
  27761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27762. /**
  27763. * Creates new normals data for the mesh
  27764. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27765. * @returns the current mesh
  27766. */
  27767. createNormals(updatable: boolean): AbstractMesh;
  27768. /**
  27769. * Align the mesh with a normal
  27770. * @param normal defines the normal to use
  27771. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27772. * @returns the current mesh
  27773. */
  27774. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27775. /** @hidden */
  27776. _checkOcclusionQuery(): boolean;
  27777. /**
  27778. * Disables the mesh edge rendering mode
  27779. * @returns the currentAbstractMesh
  27780. */
  27781. disableEdgesRendering(): AbstractMesh;
  27782. /**
  27783. * Enables the edge rendering mode on the mesh.
  27784. * This mode makes the mesh edges visible
  27785. * @param epsilon defines the maximal distance between two angles to detect a face
  27786. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27787. * @returns the currentAbstractMesh
  27788. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27789. */
  27790. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27791. }
  27792. }
  27793. declare module "babylonjs/Actions/actionEvent" {
  27794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27795. import { Nullable } from "babylonjs/types";
  27796. import { Sprite } from "babylonjs/Sprites/sprite";
  27797. import { Scene } from "babylonjs/scene";
  27798. import { Vector2 } from "babylonjs/Maths/math.vector";
  27799. /**
  27800. * Interface used to define ActionEvent
  27801. */
  27802. export interface IActionEvent {
  27803. /** The mesh or sprite that triggered the action */
  27804. source: any;
  27805. /** The X mouse cursor position at the time of the event */
  27806. pointerX: number;
  27807. /** The Y mouse cursor position at the time of the event */
  27808. pointerY: number;
  27809. /** The mesh that is currently pointed at (can be null) */
  27810. meshUnderPointer: Nullable<AbstractMesh>;
  27811. /** the original (browser) event that triggered the ActionEvent */
  27812. sourceEvent?: any;
  27813. /** additional data for the event */
  27814. additionalData?: any;
  27815. }
  27816. /**
  27817. * ActionEvent is the event being sent when an action is triggered.
  27818. */
  27819. export class ActionEvent implements IActionEvent {
  27820. /** The mesh or sprite that triggered the action */
  27821. source: any;
  27822. /** The X mouse cursor position at the time of the event */
  27823. pointerX: number;
  27824. /** The Y mouse cursor position at the time of the event */
  27825. pointerY: number;
  27826. /** The mesh that is currently pointed at (can be null) */
  27827. meshUnderPointer: Nullable<AbstractMesh>;
  27828. /** the original (browser) event that triggered the ActionEvent */
  27829. sourceEvent?: any;
  27830. /** additional data for the event */
  27831. additionalData?: any;
  27832. /**
  27833. * Creates a new ActionEvent
  27834. * @param source The mesh or sprite that triggered the action
  27835. * @param pointerX The X mouse cursor position at the time of the event
  27836. * @param pointerY The Y mouse cursor position at the time of the event
  27837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27839. * @param additionalData additional data for the event
  27840. */
  27841. constructor(
  27842. /** The mesh or sprite that triggered the action */
  27843. source: any,
  27844. /** The X mouse cursor position at the time of the event */
  27845. pointerX: number,
  27846. /** The Y mouse cursor position at the time of the event */
  27847. pointerY: number,
  27848. /** The mesh that is currently pointed at (can be null) */
  27849. meshUnderPointer: Nullable<AbstractMesh>,
  27850. /** the original (browser) event that triggered the ActionEvent */
  27851. sourceEvent?: any,
  27852. /** additional data for the event */
  27853. additionalData?: any);
  27854. /**
  27855. * Helper function to auto-create an ActionEvent from a source mesh.
  27856. * @param source The source mesh that triggered the event
  27857. * @param evt The original (browser) event
  27858. * @param additionalData additional data for the event
  27859. * @returns the new ActionEvent
  27860. */
  27861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27862. /**
  27863. * Helper function to auto-create an ActionEvent from a source sprite
  27864. * @param source The source sprite that triggered the event
  27865. * @param scene Scene associated with the sprite
  27866. * @param evt The original (browser) event
  27867. * @param additionalData additional data for the event
  27868. * @returns the new ActionEvent
  27869. */
  27870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27871. /**
  27872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27873. * @param scene the scene where the event occurred
  27874. * @param evt The original (browser) event
  27875. * @returns the new ActionEvent
  27876. */
  27877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27878. /**
  27879. * Helper function to auto-create an ActionEvent from a primitive
  27880. * @param prim defines the target primitive
  27881. * @param pointerPos defines the pointer position
  27882. * @param evt The original (browser) event
  27883. * @param additionalData additional data for the event
  27884. * @returns the new ActionEvent
  27885. */
  27886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27887. }
  27888. }
  27889. declare module "babylonjs/Actions/abstractActionManager" {
  27890. import { IDisposable } from "babylonjs/scene";
  27891. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27892. import { IAction } from "babylonjs/Actions/action";
  27893. import { Nullable } from "babylonjs/types";
  27894. /**
  27895. * Abstract class used to decouple action Manager from scene and meshes.
  27896. * Do not instantiate.
  27897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27898. */
  27899. export abstract class AbstractActionManager implements IDisposable {
  27900. /** Gets the list of active triggers */
  27901. static Triggers: {
  27902. [key: string]: number;
  27903. };
  27904. /** Gets the cursor to use when hovering items */
  27905. hoverCursor: string;
  27906. /** Gets the list of actions */
  27907. actions: IAction[];
  27908. /**
  27909. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27910. */
  27911. isRecursive: boolean;
  27912. /**
  27913. * Releases all associated resources
  27914. */
  27915. abstract dispose(): void;
  27916. /**
  27917. * Does this action manager has pointer triggers
  27918. */
  27919. abstract readonly hasPointerTriggers: boolean;
  27920. /**
  27921. * Does this action manager has pick triggers
  27922. */
  27923. abstract readonly hasPickTriggers: boolean;
  27924. /**
  27925. * Process a specific trigger
  27926. * @param trigger defines the trigger to process
  27927. * @param evt defines the event details to be processed
  27928. */
  27929. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27930. /**
  27931. * Does this action manager handles actions of any of the given triggers
  27932. * @param triggers defines the triggers to be tested
  27933. * @return a boolean indicating whether one (or more) of the triggers is handled
  27934. */
  27935. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27936. /**
  27937. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27938. * speed.
  27939. * @param triggerA defines the trigger to be tested
  27940. * @param triggerB defines the trigger to be tested
  27941. * @return a boolean indicating whether one (or more) of the triggers is handled
  27942. */
  27943. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27944. /**
  27945. * Does this action manager handles actions of a given trigger
  27946. * @param trigger defines the trigger to be tested
  27947. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27948. * @return whether the trigger is handled
  27949. */
  27950. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27951. /**
  27952. * Serialize this manager to a JSON object
  27953. * @param name defines the property name to store this manager
  27954. * @returns a JSON representation of this manager
  27955. */
  27956. abstract serialize(name: string): any;
  27957. /**
  27958. * Registers an action to this action manager
  27959. * @param action defines the action to be registered
  27960. * @return the action amended (prepared) after registration
  27961. */
  27962. abstract registerAction(action: IAction): Nullable<IAction>;
  27963. /**
  27964. * Unregisters an action to this action manager
  27965. * @param action defines the action to be unregistered
  27966. * @return a boolean indicating whether the action has been unregistered
  27967. */
  27968. abstract unregisterAction(action: IAction): Boolean;
  27969. /**
  27970. * Does exist one action manager with at least one trigger
  27971. **/
  27972. static readonly HasTriggers: boolean;
  27973. /**
  27974. * Does exist one action manager with at least one pick trigger
  27975. **/
  27976. static readonly HasPickTriggers: boolean;
  27977. /**
  27978. * Does exist one action manager that handles actions of a given trigger
  27979. * @param trigger defines the trigger to be tested
  27980. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27981. **/
  27982. static HasSpecificTrigger(trigger: number): boolean;
  27983. }
  27984. }
  27985. declare module "babylonjs/node" {
  27986. import { Scene } from "babylonjs/scene";
  27987. import { Nullable } from "babylonjs/types";
  27988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27989. import { Engine } from "babylonjs/Engines/engine";
  27990. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27991. import { Observable } from "babylonjs/Misc/observable";
  27992. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27993. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27994. import { Animatable } from "babylonjs/Animations/animatable";
  27995. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27996. import { Animation } from "babylonjs/Animations/animation";
  27997. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27999. /**
  28000. * Defines how a node can be built from a string name.
  28001. */
  28002. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28003. /**
  28004. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28005. */
  28006. export class Node implements IBehaviorAware<Node> {
  28007. /** @hidden */
  28008. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28009. private static _NodeConstructors;
  28010. /**
  28011. * Add a new node constructor
  28012. * @param type defines the type name of the node to construct
  28013. * @param constructorFunc defines the constructor function
  28014. */
  28015. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28016. /**
  28017. * Returns a node constructor based on type name
  28018. * @param type defines the type name
  28019. * @param name defines the new node name
  28020. * @param scene defines the hosting scene
  28021. * @param options defines optional options to transmit to constructors
  28022. * @returns the new constructor or null
  28023. */
  28024. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28025. /**
  28026. * Gets or sets the name of the node
  28027. */
  28028. name: string;
  28029. /**
  28030. * Gets or sets the id of the node
  28031. */
  28032. id: string;
  28033. /**
  28034. * Gets or sets the unique id of the node
  28035. */
  28036. uniqueId: number;
  28037. /**
  28038. * Gets or sets a string used to store user defined state for the node
  28039. */
  28040. state: string;
  28041. /**
  28042. * Gets or sets an object used to store user defined information for the node
  28043. */
  28044. metadata: any;
  28045. /**
  28046. * For internal use only. Please do not use.
  28047. */
  28048. reservedDataStore: any;
  28049. /**
  28050. * List of inspectable custom properties (used by the Inspector)
  28051. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28052. */
  28053. inspectableCustomProperties: IInspectable[];
  28054. private _doNotSerialize;
  28055. /**
  28056. * Gets or sets a boolean used to define if the node must be serialized
  28057. */
  28058. doNotSerialize: boolean;
  28059. /** @hidden */
  28060. _isDisposed: boolean;
  28061. /**
  28062. * Gets a list of Animations associated with the node
  28063. */
  28064. animations: import("babylonjs/Animations/animation").Animation[];
  28065. protected _ranges: {
  28066. [name: string]: Nullable<AnimationRange>;
  28067. };
  28068. /**
  28069. * Callback raised when the node is ready to be used
  28070. */
  28071. onReady: Nullable<(node: Node) => void>;
  28072. private _isEnabled;
  28073. private _isParentEnabled;
  28074. private _isReady;
  28075. /** @hidden */
  28076. _currentRenderId: number;
  28077. private _parentUpdateId;
  28078. /** @hidden */
  28079. _childUpdateId: number;
  28080. /** @hidden */
  28081. _waitingParentId: Nullable<string>;
  28082. /** @hidden */
  28083. _scene: Scene;
  28084. /** @hidden */
  28085. _cache: any;
  28086. private _parentNode;
  28087. private _children;
  28088. /** @hidden */
  28089. _worldMatrix: Matrix;
  28090. /** @hidden */
  28091. _worldMatrixDeterminant: number;
  28092. /** @hidden */
  28093. _worldMatrixDeterminantIsDirty: boolean;
  28094. /** @hidden */
  28095. private _sceneRootNodesIndex;
  28096. /**
  28097. * Gets a boolean indicating if the node has been disposed
  28098. * @returns true if the node was disposed
  28099. */
  28100. isDisposed(): boolean;
  28101. /**
  28102. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28103. * @see https://doc.babylonjs.com/how_to/parenting
  28104. */
  28105. parent: Nullable<Node>;
  28106. /** @hidden */
  28107. _addToSceneRootNodes(): void;
  28108. /** @hidden */
  28109. _removeFromSceneRootNodes(): void;
  28110. private _animationPropertiesOverride;
  28111. /**
  28112. * Gets or sets the animation properties override
  28113. */
  28114. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28115. /**
  28116. * Gets a string idenfifying the name of the class
  28117. * @returns "Node" string
  28118. */
  28119. getClassName(): string;
  28120. /** @hidden */
  28121. readonly _isNode: boolean;
  28122. /**
  28123. * An event triggered when the mesh is disposed
  28124. */
  28125. onDisposeObservable: Observable<Node>;
  28126. private _onDisposeObserver;
  28127. /**
  28128. * Sets a callback that will be raised when the node will be disposed
  28129. */
  28130. onDispose: () => void;
  28131. /**
  28132. * Creates a new Node
  28133. * @param name the name and id to be given to this node
  28134. * @param scene the scene this node will be added to
  28135. */
  28136. constructor(name: string, scene?: Nullable<Scene>);
  28137. /**
  28138. * Gets the scene of the node
  28139. * @returns a scene
  28140. */
  28141. getScene(): Scene;
  28142. /**
  28143. * Gets the engine of the node
  28144. * @returns a Engine
  28145. */
  28146. getEngine(): Engine;
  28147. private _behaviors;
  28148. /**
  28149. * Attach a behavior to the node
  28150. * @see http://doc.babylonjs.com/features/behaviour
  28151. * @param behavior defines the behavior to attach
  28152. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28153. * @returns the current Node
  28154. */
  28155. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28156. /**
  28157. * Remove an attached behavior
  28158. * @see http://doc.babylonjs.com/features/behaviour
  28159. * @param behavior defines the behavior to attach
  28160. * @returns the current Node
  28161. */
  28162. removeBehavior(behavior: Behavior<Node>): Node;
  28163. /**
  28164. * Gets the list of attached behaviors
  28165. * @see http://doc.babylonjs.com/features/behaviour
  28166. */
  28167. readonly behaviors: Behavior<Node>[];
  28168. /**
  28169. * Gets an attached behavior by name
  28170. * @param name defines the name of the behavior to look for
  28171. * @see http://doc.babylonjs.com/features/behaviour
  28172. * @returns null if behavior was not found else the requested behavior
  28173. */
  28174. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28175. /**
  28176. * Returns the latest update of the World matrix
  28177. * @returns a Matrix
  28178. */
  28179. getWorldMatrix(): Matrix;
  28180. /** @hidden */
  28181. _getWorldMatrixDeterminant(): number;
  28182. /**
  28183. * Returns directly the latest state of the mesh World matrix.
  28184. * A Matrix is returned.
  28185. */
  28186. readonly worldMatrixFromCache: Matrix;
  28187. /** @hidden */
  28188. _initCache(): void;
  28189. /** @hidden */
  28190. updateCache(force?: boolean): void;
  28191. /** @hidden */
  28192. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28193. /** @hidden */
  28194. _updateCache(ignoreParentClass?: boolean): void;
  28195. /** @hidden */
  28196. _isSynchronized(): boolean;
  28197. /** @hidden */
  28198. _markSyncedWithParent(): void;
  28199. /** @hidden */
  28200. isSynchronizedWithParent(): boolean;
  28201. /** @hidden */
  28202. isSynchronized(): boolean;
  28203. /**
  28204. * Is this node ready to be used/rendered
  28205. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28206. * @return true if the node is ready
  28207. */
  28208. isReady(completeCheck?: boolean): boolean;
  28209. /**
  28210. * Is this node enabled?
  28211. * 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
  28212. * @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
  28213. * @return whether this node (and its parent) is enabled
  28214. */
  28215. isEnabled(checkAncestors?: boolean): boolean;
  28216. /** @hidden */
  28217. protected _syncParentEnabledState(): void;
  28218. /**
  28219. * Set the enabled state of this node
  28220. * @param value defines the new enabled state
  28221. */
  28222. setEnabled(value: boolean): void;
  28223. /**
  28224. * Is this node a descendant of the given node?
  28225. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28226. * @param ancestor defines the parent node to inspect
  28227. * @returns a boolean indicating if this node is a descendant of the given node
  28228. */
  28229. isDescendantOf(ancestor: Node): boolean;
  28230. /** @hidden */
  28231. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28232. /**
  28233. * Will return all nodes that have this node as ascendant
  28234. * @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
  28235. * @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
  28236. * @return all children nodes of all types
  28237. */
  28238. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28239. /**
  28240. * Get all child-meshes of this node
  28241. * @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)
  28242. * @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
  28243. * @returns an array of AbstractMesh
  28244. */
  28245. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28246. /**
  28247. * Get all direct children of this node
  28248. * @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
  28249. * @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)
  28250. * @returns an array of Node
  28251. */
  28252. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28253. /** @hidden */
  28254. _setReady(state: boolean): void;
  28255. /**
  28256. * Get an animation by name
  28257. * @param name defines the name of the animation to look for
  28258. * @returns null if not found else the requested animation
  28259. */
  28260. getAnimationByName(name: string): Nullable<Animation>;
  28261. /**
  28262. * Creates an animation range for this node
  28263. * @param name defines the name of the range
  28264. * @param from defines the starting key
  28265. * @param to defines the end key
  28266. */
  28267. createAnimationRange(name: string, from: number, to: number): void;
  28268. /**
  28269. * Delete a specific animation range
  28270. * @param name defines the name of the range to delete
  28271. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28272. */
  28273. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28274. /**
  28275. * Get an animation range by name
  28276. * @param name defines the name of the animation range to look for
  28277. * @returns null if not found else the requested animation range
  28278. */
  28279. getAnimationRange(name: string): Nullable<AnimationRange>;
  28280. /**
  28281. * Gets the list of all animation ranges defined on this node
  28282. * @returns an array
  28283. */
  28284. getAnimationRanges(): Nullable<AnimationRange>[];
  28285. /**
  28286. * Will start the animation sequence
  28287. * @param name defines the range frames for animation sequence
  28288. * @param loop defines if the animation should loop (false by default)
  28289. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28290. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28291. * @returns the object created for this animation. If range does not exist, it will return null
  28292. */
  28293. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28294. /**
  28295. * Serialize animation ranges into a JSON compatible object
  28296. * @returns serialization object
  28297. */
  28298. serializeAnimationRanges(): any;
  28299. /**
  28300. * Computes the world matrix of the node
  28301. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28302. * @returns the world matrix
  28303. */
  28304. computeWorldMatrix(force?: boolean): Matrix;
  28305. /**
  28306. * Releases resources associated with this node.
  28307. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28308. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28309. */
  28310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28311. /**
  28312. * Parse animation range data from a serialization object and store them into a given node
  28313. * @param node defines where to store the animation ranges
  28314. * @param parsedNode defines the serialization object to read data from
  28315. * @param scene defines the hosting scene
  28316. */
  28317. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28318. /**
  28319. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28320. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28321. * @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
  28322. * @returns the new bounding vectors
  28323. */
  28324. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28325. min: Vector3;
  28326. max: Vector3;
  28327. };
  28328. }
  28329. }
  28330. declare module "babylonjs/Animations/animation" {
  28331. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28332. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28333. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28334. import { Nullable } from "babylonjs/types";
  28335. import { Scene } from "babylonjs/scene";
  28336. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28337. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28338. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28339. import { Node } from "babylonjs/node";
  28340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28341. import { Size } from "babylonjs/Maths/math.size";
  28342. import { Animatable } from "babylonjs/Animations/animatable";
  28343. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28344. /**
  28345. * @hidden
  28346. */
  28347. export class _IAnimationState {
  28348. key: number;
  28349. repeatCount: number;
  28350. workValue?: any;
  28351. loopMode?: number;
  28352. offsetValue?: any;
  28353. highLimitValue?: any;
  28354. }
  28355. /**
  28356. * Class used to store any kind of animation
  28357. */
  28358. export class Animation {
  28359. /**Name of the animation */
  28360. name: string;
  28361. /**Property to animate */
  28362. targetProperty: string;
  28363. /**The frames per second of the animation */
  28364. framePerSecond: number;
  28365. /**The data type of the animation */
  28366. dataType: number;
  28367. /**The loop mode of the animation */
  28368. loopMode?: number | undefined;
  28369. /**Specifies if blending should be enabled */
  28370. enableBlending?: boolean | undefined;
  28371. /**
  28372. * Use matrix interpolation instead of using direct key value when animating matrices
  28373. */
  28374. static AllowMatricesInterpolation: boolean;
  28375. /**
  28376. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28377. */
  28378. static AllowMatrixDecomposeForInterpolation: boolean;
  28379. /**
  28380. * Stores the key frames of the animation
  28381. */
  28382. private _keys;
  28383. /**
  28384. * Stores the easing function of the animation
  28385. */
  28386. private _easingFunction;
  28387. /**
  28388. * @hidden Internal use only
  28389. */
  28390. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28391. /**
  28392. * The set of event that will be linked to this animation
  28393. */
  28394. private _events;
  28395. /**
  28396. * Stores an array of target property paths
  28397. */
  28398. targetPropertyPath: string[];
  28399. /**
  28400. * Stores the blending speed of the animation
  28401. */
  28402. blendingSpeed: number;
  28403. /**
  28404. * Stores the animation ranges for the animation
  28405. */
  28406. private _ranges;
  28407. /**
  28408. * @hidden Internal use
  28409. */
  28410. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28411. /**
  28412. * Sets up an animation
  28413. * @param property The property to animate
  28414. * @param animationType The animation type to apply
  28415. * @param framePerSecond The frames per second of the animation
  28416. * @param easingFunction The easing function used in the animation
  28417. * @returns The created animation
  28418. */
  28419. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28420. /**
  28421. * Create and start an animation on a node
  28422. * @param name defines the name of the global animation that will be run on all nodes
  28423. * @param node defines the root node where the animation will take place
  28424. * @param targetProperty defines property to animate
  28425. * @param framePerSecond defines the number of frame per second yo use
  28426. * @param totalFrame defines the number of frames in total
  28427. * @param from defines the initial value
  28428. * @param to defines the final value
  28429. * @param loopMode defines which loop mode you want to use (off by default)
  28430. * @param easingFunction defines the easing function to use (linear by default)
  28431. * @param onAnimationEnd defines the callback to call when animation end
  28432. * @returns the animatable created for this animation
  28433. */
  28434. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28435. /**
  28436. * Create and start an animation on a node and its descendants
  28437. * @param name defines the name of the global animation that will be run on all nodes
  28438. * @param node defines the root node where the animation will take place
  28439. * @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
  28440. * @param targetProperty defines property to animate
  28441. * @param framePerSecond defines the number of frame per second to use
  28442. * @param totalFrame defines the number of frames in total
  28443. * @param from defines the initial value
  28444. * @param to defines the final value
  28445. * @param loopMode defines which loop mode you want to use (off by default)
  28446. * @param easingFunction defines the easing function to use (linear by default)
  28447. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28448. * @returns the list of animatables created for all nodes
  28449. * @example https://www.babylonjs-playground.com/#MH0VLI
  28450. */
  28451. 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[]>;
  28452. /**
  28453. * Creates a new animation, merges it with the existing animations and starts it
  28454. * @param name Name of the animation
  28455. * @param node Node which contains the scene that begins the animations
  28456. * @param targetProperty Specifies which property to animate
  28457. * @param framePerSecond The frames per second of the animation
  28458. * @param totalFrame The total number of frames
  28459. * @param from The frame at the beginning of the animation
  28460. * @param to The frame at the end of the animation
  28461. * @param loopMode Specifies the loop mode of the animation
  28462. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28463. * @param onAnimationEnd Callback to run once the animation is complete
  28464. * @returns Nullable animation
  28465. */
  28466. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28467. /**
  28468. * Transition property of an host to the target Value
  28469. * @param property The property to transition
  28470. * @param targetValue The target Value of the property
  28471. * @param host The object where the property to animate belongs
  28472. * @param scene Scene used to run the animation
  28473. * @param frameRate Framerate (in frame/s) to use
  28474. * @param transition The transition type we want to use
  28475. * @param duration The duration of the animation, in milliseconds
  28476. * @param onAnimationEnd Callback trigger at the end of the animation
  28477. * @returns Nullable animation
  28478. */
  28479. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28480. /**
  28481. * Return the array of runtime animations currently using this animation
  28482. */
  28483. readonly runtimeAnimations: RuntimeAnimation[];
  28484. /**
  28485. * Specifies if any of the runtime animations are currently running
  28486. */
  28487. readonly hasRunningRuntimeAnimations: boolean;
  28488. /**
  28489. * Initializes the animation
  28490. * @param name Name of the animation
  28491. * @param targetProperty Property to animate
  28492. * @param framePerSecond The frames per second of the animation
  28493. * @param dataType The data type of the animation
  28494. * @param loopMode The loop mode of the animation
  28495. * @param enableBlending Specifies if blending should be enabled
  28496. */
  28497. constructor(
  28498. /**Name of the animation */
  28499. name: string,
  28500. /**Property to animate */
  28501. targetProperty: string,
  28502. /**The frames per second of the animation */
  28503. framePerSecond: number,
  28504. /**The data type of the animation */
  28505. dataType: number,
  28506. /**The loop mode of the animation */
  28507. loopMode?: number | undefined,
  28508. /**Specifies if blending should be enabled */
  28509. enableBlending?: boolean | undefined);
  28510. /**
  28511. * Converts the animation to a string
  28512. * @param fullDetails support for multiple levels of logging within scene loading
  28513. * @returns String form of the animation
  28514. */
  28515. toString(fullDetails?: boolean): string;
  28516. /**
  28517. * Add an event to this animation
  28518. * @param event Event to add
  28519. */
  28520. addEvent(event: AnimationEvent): void;
  28521. /**
  28522. * Remove all events found at the given frame
  28523. * @param frame The frame to remove events from
  28524. */
  28525. removeEvents(frame: number): void;
  28526. /**
  28527. * Retrieves all the events from the animation
  28528. * @returns Events from the animation
  28529. */
  28530. getEvents(): AnimationEvent[];
  28531. /**
  28532. * Creates an animation range
  28533. * @param name Name of the animation range
  28534. * @param from Starting frame of the animation range
  28535. * @param to Ending frame of the animation
  28536. */
  28537. createRange(name: string, from: number, to: number): void;
  28538. /**
  28539. * Deletes an animation range by name
  28540. * @param name Name of the animation range to delete
  28541. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28542. */
  28543. deleteRange(name: string, deleteFrames?: boolean): void;
  28544. /**
  28545. * Gets the animation range by name, or null if not defined
  28546. * @param name Name of the animation range
  28547. * @returns Nullable animation range
  28548. */
  28549. getRange(name: string): Nullable<AnimationRange>;
  28550. /**
  28551. * Gets the key frames from the animation
  28552. * @returns The key frames of the animation
  28553. */
  28554. getKeys(): Array<IAnimationKey>;
  28555. /**
  28556. * Gets the highest frame rate of the animation
  28557. * @returns Highest frame rate of the animation
  28558. */
  28559. getHighestFrame(): number;
  28560. /**
  28561. * Gets the easing function of the animation
  28562. * @returns Easing function of the animation
  28563. */
  28564. getEasingFunction(): IEasingFunction;
  28565. /**
  28566. * Sets the easing function of the animation
  28567. * @param easingFunction A custom mathematical formula for animation
  28568. */
  28569. setEasingFunction(easingFunction: EasingFunction): void;
  28570. /**
  28571. * Interpolates a scalar linearly
  28572. * @param startValue Start value of the animation curve
  28573. * @param endValue End value of the animation curve
  28574. * @param gradient Scalar amount to interpolate
  28575. * @returns Interpolated scalar value
  28576. */
  28577. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28578. /**
  28579. * Interpolates a scalar cubically
  28580. * @param startValue Start value of the animation curve
  28581. * @param outTangent End tangent of the animation
  28582. * @param endValue End value of the animation curve
  28583. * @param inTangent Start tangent of the animation curve
  28584. * @param gradient Scalar amount to interpolate
  28585. * @returns Interpolated scalar value
  28586. */
  28587. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28588. /**
  28589. * Interpolates a quaternion using a spherical linear interpolation
  28590. * @param startValue Start value of the animation curve
  28591. * @param endValue End value of the animation curve
  28592. * @param gradient Scalar amount to interpolate
  28593. * @returns Interpolated quaternion value
  28594. */
  28595. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28596. /**
  28597. * Interpolates a quaternion cubically
  28598. * @param startValue Start value of the animation curve
  28599. * @param outTangent End tangent of the animation curve
  28600. * @param endValue End value of the animation curve
  28601. * @param inTangent Start tangent of the animation curve
  28602. * @param gradient Scalar amount to interpolate
  28603. * @returns Interpolated quaternion value
  28604. */
  28605. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28606. /**
  28607. * Interpolates a Vector3 linearl
  28608. * @param startValue Start value of the animation curve
  28609. * @param endValue End value of the animation curve
  28610. * @param gradient Scalar amount to interpolate
  28611. * @returns Interpolated scalar value
  28612. */
  28613. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28614. /**
  28615. * Interpolates a Vector3 cubically
  28616. * @param startValue Start value of the animation curve
  28617. * @param outTangent End tangent of the animation
  28618. * @param endValue End value of the animation curve
  28619. * @param inTangent Start tangent of the animation curve
  28620. * @param gradient Scalar amount to interpolate
  28621. * @returns InterpolatedVector3 value
  28622. */
  28623. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28624. /**
  28625. * Interpolates a Vector2 linearly
  28626. * @param startValue Start value of the animation curve
  28627. * @param endValue End value of the animation curve
  28628. * @param gradient Scalar amount to interpolate
  28629. * @returns Interpolated Vector2 value
  28630. */
  28631. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28632. /**
  28633. * Interpolates a Vector2 cubically
  28634. * @param startValue Start value of the animation curve
  28635. * @param outTangent End tangent of the animation
  28636. * @param endValue End value of the animation curve
  28637. * @param inTangent Start tangent of the animation curve
  28638. * @param gradient Scalar amount to interpolate
  28639. * @returns Interpolated Vector2 value
  28640. */
  28641. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28642. /**
  28643. * Interpolates a size linearly
  28644. * @param startValue Start value of the animation curve
  28645. * @param endValue End value of the animation curve
  28646. * @param gradient Scalar amount to interpolate
  28647. * @returns Interpolated Size value
  28648. */
  28649. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28650. /**
  28651. * Interpolates a Color3 linearly
  28652. * @param startValue Start value of the animation curve
  28653. * @param endValue End value of the animation curve
  28654. * @param gradient Scalar amount to interpolate
  28655. * @returns Interpolated Color3 value
  28656. */
  28657. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28658. /**
  28659. * Interpolates a Color4 linearly
  28660. * @param startValue Start value of the animation curve
  28661. * @param endValue End value of the animation curve
  28662. * @param gradient Scalar amount to interpolate
  28663. * @returns Interpolated Color3 value
  28664. */
  28665. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28666. /**
  28667. * @hidden Internal use only
  28668. */
  28669. _getKeyValue(value: any): any;
  28670. /**
  28671. * @hidden Internal use only
  28672. */
  28673. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28674. /**
  28675. * Defines the function to use to interpolate matrices
  28676. * @param startValue defines the start matrix
  28677. * @param endValue defines the end matrix
  28678. * @param gradient defines the gradient between both matrices
  28679. * @param result defines an optional target matrix where to store the interpolation
  28680. * @returns the interpolated matrix
  28681. */
  28682. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28683. /**
  28684. * Makes a copy of the animation
  28685. * @returns Cloned animation
  28686. */
  28687. clone(): Animation;
  28688. /**
  28689. * Sets the key frames of the animation
  28690. * @param values The animation key frames to set
  28691. */
  28692. setKeys(values: Array<IAnimationKey>): void;
  28693. /**
  28694. * Serializes the animation to an object
  28695. * @returns Serialized object
  28696. */
  28697. serialize(): any;
  28698. /**
  28699. * Float animation type
  28700. */
  28701. static readonly ANIMATIONTYPE_FLOAT: number;
  28702. /**
  28703. * Vector3 animation type
  28704. */
  28705. static readonly ANIMATIONTYPE_VECTOR3: number;
  28706. /**
  28707. * Quaternion animation type
  28708. */
  28709. static readonly ANIMATIONTYPE_QUATERNION: number;
  28710. /**
  28711. * Matrix animation type
  28712. */
  28713. static readonly ANIMATIONTYPE_MATRIX: number;
  28714. /**
  28715. * Color3 animation type
  28716. */
  28717. static readonly ANIMATIONTYPE_COLOR3: number;
  28718. /**
  28719. * Color3 animation type
  28720. */
  28721. static readonly ANIMATIONTYPE_COLOR4: number;
  28722. /**
  28723. * Vector2 animation type
  28724. */
  28725. static readonly ANIMATIONTYPE_VECTOR2: number;
  28726. /**
  28727. * Size animation type
  28728. */
  28729. static readonly ANIMATIONTYPE_SIZE: number;
  28730. /**
  28731. * Relative Loop Mode
  28732. */
  28733. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28734. /**
  28735. * Cycle Loop Mode
  28736. */
  28737. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28738. /**
  28739. * Constant Loop Mode
  28740. */
  28741. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28742. /** @hidden */
  28743. static _UniversalLerp(left: any, right: any, amount: number): any;
  28744. /**
  28745. * Parses an animation object and creates an animation
  28746. * @param parsedAnimation Parsed animation object
  28747. * @returns Animation object
  28748. */
  28749. static Parse(parsedAnimation: any): Animation;
  28750. /**
  28751. * Appends the serialized animations from the source animations
  28752. * @param source Source containing the animations
  28753. * @param destination Target to store the animations
  28754. */
  28755. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28756. }
  28757. }
  28758. declare module "babylonjs/Animations/animatable.interface" {
  28759. import { Nullable } from "babylonjs/types";
  28760. import { Animation } from "babylonjs/Animations/animation";
  28761. /**
  28762. * Interface containing an array of animations
  28763. */
  28764. export interface IAnimatable {
  28765. /**
  28766. * Array of animations
  28767. */
  28768. animations: Nullable<Array<Animation>>;
  28769. }
  28770. }
  28771. declare module "babylonjs/Materials/fresnelParameters" {
  28772. import { Color3 } from "babylonjs/Maths/math.color";
  28773. /**
  28774. * This represents all the required information to add a fresnel effect on a material:
  28775. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28776. */
  28777. export class FresnelParameters {
  28778. private _isEnabled;
  28779. /**
  28780. * Define if the fresnel effect is enable or not.
  28781. */
  28782. isEnabled: boolean;
  28783. /**
  28784. * Define the color used on edges (grazing angle)
  28785. */
  28786. leftColor: Color3;
  28787. /**
  28788. * Define the color used on center
  28789. */
  28790. rightColor: Color3;
  28791. /**
  28792. * Define bias applied to computed fresnel term
  28793. */
  28794. bias: number;
  28795. /**
  28796. * Defined the power exponent applied to fresnel term
  28797. */
  28798. power: number;
  28799. /**
  28800. * Clones the current fresnel and its valuues
  28801. * @returns a clone fresnel configuration
  28802. */
  28803. clone(): FresnelParameters;
  28804. /**
  28805. * Serializes the current fresnel parameters to a JSON representation.
  28806. * @return the JSON serialization
  28807. */
  28808. serialize(): any;
  28809. /**
  28810. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28811. * @param parsedFresnelParameters Define the JSON representation
  28812. * @returns the parsed parameters
  28813. */
  28814. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28815. }
  28816. }
  28817. declare module "babylonjs/Misc/decorators" {
  28818. import { Nullable } from "babylonjs/types";
  28819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28820. import { Scene } from "babylonjs/scene";
  28821. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28822. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28823. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28824. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28825. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28826. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28827. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28828. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28829. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28830. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28831. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28832. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28833. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28834. /**
  28835. * Decorator used to define property that can be serialized as reference to a camera
  28836. * @param sourceName defines the name of the property to decorate
  28837. */
  28838. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28839. /**
  28840. * Class used to help serialization objects
  28841. */
  28842. export class SerializationHelper {
  28843. /** @hidden */
  28844. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28845. /** @hidden */
  28846. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28847. /** @hidden */
  28848. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28849. /** @hidden */
  28850. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28851. /**
  28852. * Appends the serialized animations from the source animations
  28853. * @param source Source containing the animations
  28854. * @param destination Target to store the animations
  28855. */
  28856. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28857. /**
  28858. * Static function used to serialized a specific entity
  28859. * @param entity defines the entity to serialize
  28860. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28861. * @returns a JSON compatible object representing the serialization of the entity
  28862. */
  28863. static Serialize<T>(entity: T, serializationObject?: any): any;
  28864. /**
  28865. * Creates a new entity from a serialization data object
  28866. * @param creationFunction defines a function used to instanciated the new entity
  28867. * @param source defines the source serialization data
  28868. * @param scene defines the hosting scene
  28869. * @param rootUrl defines the root url for resources
  28870. * @returns a new entity
  28871. */
  28872. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28873. /**
  28874. * Clones an object
  28875. * @param creationFunction defines the function used to instanciate the new object
  28876. * @param source defines the source object
  28877. * @returns the cloned object
  28878. */
  28879. static Clone<T>(creationFunction: () => T, source: T): T;
  28880. /**
  28881. * Instanciates a new object based on a source one (some data will be shared between both object)
  28882. * @param creationFunction defines the function used to instanciate the new object
  28883. * @param source defines the source object
  28884. * @returns the new object
  28885. */
  28886. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28887. }
  28888. }
  28889. declare module "babylonjs/Misc/guid" {
  28890. /**
  28891. * Class used to manipulate GUIDs
  28892. */
  28893. export class GUID {
  28894. /**
  28895. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28896. * Be aware Math.random() could cause collisions, but:
  28897. * "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"
  28898. * @returns a pseudo random id
  28899. */
  28900. static RandomId(): string;
  28901. }
  28902. }
  28903. declare module "babylonjs/Materials/Textures/baseTexture" {
  28904. import { Observable } from "babylonjs/Misc/observable";
  28905. import { Nullable } from "babylonjs/types";
  28906. import { Scene } from "babylonjs/scene";
  28907. import { Matrix } from "babylonjs/Maths/math.vector";
  28908. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28909. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28910. import { ISize } from "babylonjs/Maths/math.size";
  28911. /**
  28912. * Base class of all the textures in babylon.
  28913. * It groups all the common properties the materials, post process, lights... might need
  28914. * in order to make a correct use of the texture.
  28915. */
  28916. export class BaseTexture implements IAnimatable {
  28917. /**
  28918. * Default anisotropic filtering level for the application.
  28919. * It is set to 4 as a good tradeoff between perf and quality.
  28920. */
  28921. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28922. /**
  28923. * Gets or sets the unique id of the texture
  28924. */
  28925. uniqueId: number;
  28926. /**
  28927. * Define the name of the texture.
  28928. */
  28929. name: string;
  28930. /**
  28931. * Gets or sets an object used to store user defined information.
  28932. */
  28933. metadata: any;
  28934. /**
  28935. * For internal use only. Please do not use.
  28936. */
  28937. reservedDataStore: any;
  28938. private _hasAlpha;
  28939. /**
  28940. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28941. */
  28942. hasAlpha: boolean;
  28943. /**
  28944. * Defines if the alpha value should be determined via the rgb values.
  28945. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28946. */
  28947. getAlphaFromRGB: boolean;
  28948. /**
  28949. * Intensity or strength of the texture.
  28950. * It is commonly used by materials to fine tune the intensity of the texture
  28951. */
  28952. level: number;
  28953. /**
  28954. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28955. * This is part of the texture as textures usually maps to one uv set.
  28956. */
  28957. coordinatesIndex: number;
  28958. private _coordinatesMode;
  28959. /**
  28960. * How a texture is mapped.
  28961. *
  28962. * | Value | Type | Description |
  28963. * | ----- | ----------------------------------- | ----------- |
  28964. * | 0 | EXPLICIT_MODE | |
  28965. * | 1 | SPHERICAL_MODE | |
  28966. * | 2 | PLANAR_MODE | |
  28967. * | 3 | CUBIC_MODE | |
  28968. * | 4 | PROJECTION_MODE | |
  28969. * | 5 | SKYBOX_MODE | |
  28970. * | 6 | INVCUBIC_MODE | |
  28971. * | 7 | EQUIRECTANGULAR_MODE | |
  28972. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28973. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28974. */
  28975. coordinatesMode: number;
  28976. /**
  28977. * | Value | Type | Description |
  28978. * | ----- | ------------------ | ----------- |
  28979. * | 0 | CLAMP_ADDRESSMODE | |
  28980. * | 1 | WRAP_ADDRESSMODE | |
  28981. * | 2 | MIRROR_ADDRESSMODE | |
  28982. */
  28983. wrapU: number;
  28984. /**
  28985. * | Value | Type | Description |
  28986. * | ----- | ------------------ | ----------- |
  28987. * | 0 | CLAMP_ADDRESSMODE | |
  28988. * | 1 | WRAP_ADDRESSMODE | |
  28989. * | 2 | MIRROR_ADDRESSMODE | |
  28990. */
  28991. wrapV: number;
  28992. /**
  28993. * | Value | Type | Description |
  28994. * | ----- | ------------------ | ----------- |
  28995. * | 0 | CLAMP_ADDRESSMODE | |
  28996. * | 1 | WRAP_ADDRESSMODE | |
  28997. * | 2 | MIRROR_ADDRESSMODE | |
  28998. */
  28999. wrapR: number;
  29000. /**
  29001. * With compliant hardware and browser (supporting anisotropic filtering)
  29002. * this defines the level of anisotropic filtering in the texture.
  29003. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29004. */
  29005. anisotropicFilteringLevel: number;
  29006. /**
  29007. * Define if the texture is a cube texture or if false a 2d texture.
  29008. */
  29009. isCube: boolean;
  29010. /**
  29011. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29012. */
  29013. is3D: boolean;
  29014. /**
  29015. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29016. */
  29017. is2DArray: boolean;
  29018. /**
  29019. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29020. * HDR texture are usually stored in linear space.
  29021. * This only impacts the PBR and Background materials
  29022. */
  29023. gammaSpace: boolean;
  29024. /**
  29025. * Gets or sets whether or not the texture contains RGBD data.
  29026. */
  29027. isRGBD: boolean;
  29028. /**
  29029. * Is Z inverted in the texture (useful in a cube texture).
  29030. */
  29031. invertZ: boolean;
  29032. /**
  29033. * Are mip maps generated for this texture or not.
  29034. */
  29035. readonly noMipmap: boolean;
  29036. /**
  29037. * @hidden
  29038. */
  29039. lodLevelInAlpha: boolean;
  29040. /**
  29041. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29042. */
  29043. lodGenerationOffset: number;
  29044. /**
  29045. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29046. */
  29047. lodGenerationScale: number;
  29048. /**
  29049. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29050. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29051. * average roughness values.
  29052. */
  29053. linearSpecularLOD: boolean;
  29054. /**
  29055. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29056. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29057. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29058. */
  29059. irradianceTexture: Nullable<BaseTexture>;
  29060. /**
  29061. * Define if the texture is a render target.
  29062. */
  29063. isRenderTarget: boolean;
  29064. /**
  29065. * Define the unique id of the texture in the scene.
  29066. */
  29067. readonly uid: string;
  29068. /**
  29069. * Return a string representation of the texture.
  29070. * @returns the texture as a string
  29071. */
  29072. toString(): string;
  29073. /**
  29074. * Get the class name of the texture.
  29075. * @returns "BaseTexture"
  29076. */
  29077. getClassName(): string;
  29078. /**
  29079. * Define the list of animation attached to the texture.
  29080. */
  29081. animations: import("babylonjs/Animations/animation").Animation[];
  29082. /**
  29083. * An event triggered when the texture is disposed.
  29084. */
  29085. onDisposeObservable: Observable<BaseTexture>;
  29086. private _onDisposeObserver;
  29087. /**
  29088. * Callback triggered when the texture has been disposed.
  29089. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29090. */
  29091. onDispose: () => void;
  29092. /**
  29093. * Define the current state of the loading sequence when in delayed load mode.
  29094. */
  29095. delayLoadState: number;
  29096. private _scene;
  29097. /** @hidden */
  29098. _texture: Nullable<InternalTexture>;
  29099. private _uid;
  29100. /**
  29101. * Define if the texture is preventinga material to render or not.
  29102. * If not and the texture is not ready, the engine will use a default black texture instead.
  29103. */
  29104. readonly isBlocking: boolean;
  29105. /**
  29106. * Instantiates a new BaseTexture.
  29107. * Base class of all the textures in babylon.
  29108. * It groups all the common properties the materials, post process, lights... might need
  29109. * in order to make a correct use of the texture.
  29110. * @param scene Define the scene the texture blongs to
  29111. */
  29112. constructor(scene: Nullable<Scene>);
  29113. /**
  29114. * Get the scene the texture belongs to.
  29115. * @returns the scene or null if undefined
  29116. */
  29117. getScene(): Nullable<Scene>;
  29118. /**
  29119. * Get the texture transform matrix used to offset tile the texture for istance.
  29120. * @returns the transformation matrix
  29121. */
  29122. getTextureMatrix(): Matrix;
  29123. /**
  29124. * Get the texture reflection matrix used to rotate/transform the reflection.
  29125. * @returns the reflection matrix
  29126. */
  29127. getReflectionTextureMatrix(): Matrix;
  29128. /**
  29129. * Get the underlying lower level texture from Babylon.
  29130. * @returns the insternal texture
  29131. */
  29132. getInternalTexture(): Nullable<InternalTexture>;
  29133. /**
  29134. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29135. * @returns true if ready or not blocking
  29136. */
  29137. isReadyOrNotBlocking(): boolean;
  29138. /**
  29139. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29140. * @returns true if fully ready
  29141. */
  29142. isReady(): boolean;
  29143. private _cachedSize;
  29144. /**
  29145. * Get the size of the texture.
  29146. * @returns the texture size.
  29147. */
  29148. getSize(): ISize;
  29149. /**
  29150. * Get the base size of the texture.
  29151. * It can be different from the size if the texture has been resized for POT for instance
  29152. * @returns the base size
  29153. */
  29154. getBaseSize(): ISize;
  29155. /**
  29156. * Update the sampling mode of the texture.
  29157. * Default is Trilinear mode.
  29158. *
  29159. * | Value | Type | Description |
  29160. * | ----- | ------------------ | ----------- |
  29161. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29162. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29163. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29164. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29165. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29166. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29167. * | 7 | NEAREST_LINEAR | |
  29168. * | 8 | NEAREST_NEAREST | |
  29169. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29170. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29171. * | 11 | LINEAR_LINEAR | |
  29172. * | 12 | LINEAR_NEAREST | |
  29173. *
  29174. * > _mag_: magnification filter (close to the viewer)
  29175. * > _min_: minification filter (far from the viewer)
  29176. * > _mip_: filter used between mip map levels
  29177. *@param samplingMode Define the new sampling mode of the texture
  29178. */
  29179. updateSamplingMode(samplingMode: number): void;
  29180. /**
  29181. * Scales the texture if is `canRescale()`
  29182. * @param ratio the resize factor we want to use to rescale
  29183. */
  29184. scale(ratio: number): void;
  29185. /**
  29186. * Get if the texture can rescale.
  29187. */
  29188. readonly canRescale: boolean;
  29189. /** @hidden */
  29190. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29191. /** @hidden */
  29192. _rebuild(): void;
  29193. /**
  29194. * Triggers the load sequence in delayed load mode.
  29195. */
  29196. delayLoad(): void;
  29197. /**
  29198. * Clones the texture.
  29199. * @returns the cloned texture
  29200. */
  29201. clone(): Nullable<BaseTexture>;
  29202. /**
  29203. * Get the texture underlying type (INT, FLOAT...)
  29204. */
  29205. readonly textureType: number;
  29206. /**
  29207. * Get the texture underlying format (RGB, RGBA...)
  29208. */
  29209. readonly textureFormat: number;
  29210. /**
  29211. * Indicates that textures need to be re-calculated for all materials
  29212. */
  29213. protected _markAllSubMeshesAsTexturesDirty(): void;
  29214. /**
  29215. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29216. * This will returns an RGBA array buffer containing either in values (0-255) or
  29217. * float values (0-1) depending of the underlying buffer type.
  29218. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29219. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29220. * @param buffer defines a user defined buffer to fill with data (can be null)
  29221. * @returns The Array buffer containing the pixels data.
  29222. */
  29223. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29224. /**
  29225. * Release and destroy the underlying lower level texture aka internalTexture.
  29226. */
  29227. releaseInternalTexture(): void;
  29228. /** @hidden */
  29229. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29230. /** @hidden */
  29231. readonly _lodTextureMid: Nullable<BaseTexture>;
  29232. /** @hidden */
  29233. readonly _lodTextureLow: Nullable<BaseTexture>;
  29234. /**
  29235. * Dispose the texture and release its associated resources.
  29236. */
  29237. dispose(): void;
  29238. /**
  29239. * Serialize the texture into a JSON representation that can be parsed later on.
  29240. * @returns the JSON representation of the texture
  29241. */
  29242. serialize(): any;
  29243. /**
  29244. * Helper function to be called back once a list of texture contains only ready textures.
  29245. * @param textures Define the list of textures to wait for
  29246. * @param callback Define the callback triggered once the entire list will be ready
  29247. */
  29248. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29249. }
  29250. }
  29251. declare module "babylonjs/Materials/effect" {
  29252. import { Observable } from "babylonjs/Misc/observable";
  29253. import { Nullable } from "babylonjs/types";
  29254. import { IDisposable } from "babylonjs/scene";
  29255. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29256. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29257. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29258. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29259. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29260. import { Engine } from "babylonjs/Engines/engine";
  29261. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29265. /**
  29266. * Options to be used when creating an effect.
  29267. */
  29268. export interface IEffectCreationOptions {
  29269. /**
  29270. * Atrributes that will be used in the shader.
  29271. */
  29272. attributes: string[];
  29273. /**
  29274. * Uniform varible names that will be set in the shader.
  29275. */
  29276. uniformsNames: string[];
  29277. /**
  29278. * Uniform buffer varible names that will be set in the shader.
  29279. */
  29280. uniformBuffersNames: string[];
  29281. /**
  29282. * Sampler texture variable names that will be set in the shader.
  29283. */
  29284. samplers: string[];
  29285. /**
  29286. * Define statements that will be set in the shader.
  29287. */
  29288. defines: any;
  29289. /**
  29290. * Possible fallbacks for this effect to improve performance when needed.
  29291. */
  29292. fallbacks: Nullable<IEffectFallbacks>;
  29293. /**
  29294. * Callback that will be called when the shader is compiled.
  29295. */
  29296. onCompiled: Nullable<(effect: Effect) => void>;
  29297. /**
  29298. * Callback that will be called if an error occurs during shader compilation.
  29299. */
  29300. onError: Nullable<(effect: Effect, errors: string) => void>;
  29301. /**
  29302. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29303. */
  29304. indexParameters?: any;
  29305. /**
  29306. * Max number of lights that can be used in the shader.
  29307. */
  29308. maxSimultaneousLights?: number;
  29309. /**
  29310. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29311. */
  29312. transformFeedbackVaryings?: Nullable<string[]>;
  29313. }
  29314. /**
  29315. * Effect containing vertex and fragment shader that can be executed on an object.
  29316. */
  29317. export class Effect implements IDisposable {
  29318. /**
  29319. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29320. */
  29321. static ShadersRepository: string;
  29322. /**
  29323. * Name of the effect.
  29324. */
  29325. name: any;
  29326. /**
  29327. * String container all the define statements that should be set on the shader.
  29328. */
  29329. defines: string;
  29330. /**
  29331. * Callback that will be called when the shader is compiled.
  29332. */
  29333. onCompiled: Nullable<(effect: Effect) => void>;
  29334. /**
  29335. * Callback that will be called if an error occurs during shader compilation.
  29336. */
  29337. onError: Nullable<(effect: Effect, errors: string) => void>;
  29338. /**
  29339. * Callback that will be called when effect is bound.
  29340. */
  29341. onBind: Nullable<(effect: Effect) => void>;
  29342. /**
  29343. * Unique ID of the effect.
  29344. */
  29345. uniqueId: number;
  29346. /**
  29347. * Observable that will be called when the shader is compiled.
  29348. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29349. */
  29350. onCompileObservable: Observable<Effect>;
  29351. /**
  29352. * Observable that will be called if an error occurs during shader compilation.
  29353. */
  29354. onErrorObservable: Observable<Effect>;
  29355. /** @hidden */
  29356. _onBindObservable: Nullable<Observable<Effect>>;
  29357. /**
  29358. * Observable that will be called when effect is bound.
  29359. */
  29360. readonly onBindObservable: Observable<Effect>;
  29361. /** @hidden */
  29362. _bonesComputationForcedToCPU: boolean;
  29363. private static _uniqueIdSeed;
  29364. private _engine;
  29365. private _uniformBuffersNames;
  29366. private _uniformsNames;
  29367. private _samplerList;
  29368. private _samplers;
  29369. private _isReady;
  29370. private _compilationError;
  29371. private _allFallbacksProcessed;
  29372. private _attributesNames;
  29373. private _attributes;
  29374. private _uniforms;
  29375. /**
  29376. * Key for the effect.
  29377. * @hidden
  29378. */
  29379. _key: string;
  29380. private _indexParameters;
  29381. private _fallbacks;
  29382. private _vertexSourceCode;
  29383. private _fragmentSourceCode;
  29384. private _vertexSourceCodeOverride;
  29385. private _fragmentSourceCodeOverride;
  29386. private _transformFeedbackVaryings;
  29387. /**
  29388. * Compiled shader to webGL program.
  29389. * @hidden
  29390. */
  29391. _pipelineContext: Nullable<IPipelineContext>;
  29392. private _valueCache;
  29393. private static _baseCache;
  29394. /**
  29395. * Instantiates an effect.
  29396. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29397. * @param baseName Name of the effect.
  29398. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29399. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29400. * @param samplers List of sampler variables that will be passed to the shader.
  29401. * @param engine Engine to be used to render the effect
  29402. * @param defines Define statements to be added to the shader.
  29403. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29404. * @param onCompiled Callback that will be called when the shader is compiled.
  29405. * @param onError Callback that will be called if an error occurs during shader compilation.
  29406. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29407. */
  29408. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29409. private _useFinalCode;
  29410. /**
  29411. * Unique key for this effect
  29412. */
  29413. readonly key: string;
  29414. /**
  29415. * If the effect has been compiled and prepared.
  29416. * @returns if the effect is compiled and prepared.
  29417. */
  29418. isReady(): boolean;
  29419. private _isReadyInternal;
  29420. /**
  29421. * The engine the effect was initialized with.
  29422. * @returns the engine.
  29423. */
  29424. getEngine(): Engine;
  29425. /**
  29426. * The pipeline context for this effect
  29427. * @returns the associated pipeline context
  29428. */
  29429. getPipelineContext(): Nullable<IPipelineContext>;
  29430. /**
  29431. * The set of names of attribute variables for the shader.
  29432. * @returns An array of attribute names.
  29433. */
  29434. getAttributesNames(): string[];
  29435. /**
  29436. * Returns the attribute at the given index.
  29437. * @param index The index of the attribute.
  29438. * @returns The location of the attribute.
  29439. */
  29440. getAttributeLocation(index: number): number;
  29441. /**
  29442. * Returns the attribute based on the name of the variable.
  29443. * @param name of the attribute to look up.
  29444. * @returns the attribute location.
  29445. */
  29446. getAttributeLocationByName(name: string): number;
  29447. /**
  29448. * The number of attributes.
  29449. * @returns the numnber of attributes.
  29450. */
  29451. getAttributesCount(): number;
  29452. /**
  29453. * Gets the index of a uniform variable.
  29454. * @param uniformName of the uniform to look up.
  29455. * @returns the index.
  29456. */
  29457. getUniformIndex(uniformName: string): number;
  29458. /**
  29459. * Returns the attribute based on the name of the variable.
  29460. * @param uniformName of the uniform to look up.
  29461. * @returns the location of the uniform.
  29462. */
  29463. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29464. /**
  29465. * Returns an array of sampler variable names
  29466. * @returns The array of sampler variable neames.
  29467. */
  29468. getSamplers(): string[];
  29469. /**
  29470. * The error from the last compilation.
  29471. * @returns the error string.
  29472. */
  29473. getCompilationError(): string;
  29474. /**
  29475. * Gets a boolean indicating that all fallbacks were used during compilation
  29476. * @returns true if all fallbacks were used
  29477. */
  29478. allFallbacksProcessed(): boolean;
  29479. /**
  29480. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29481. * @param func The callback to be used.
  29482. */
  29483. executeWhenCompiled(func: (effect: Effect) => void): void;
  29484. private _checkIsReady;
  29485. private _loadShader;
  29486. /**
  29487. * Recompiles the webGL program
  29488. * @param vertexSourceCode The source code for the vertex shader.
  29489. * @param fragmentSourceCode The source code for the fragment shader.
  29490. * @param onCompiled Callback called when completed.
  29491. * @param onError Callback called on error.
  29492. * @hidden
  29493. */
  29494. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29495. /**
  29496. * Prepares the effect
  29497. * @hidden
  29498. */
  29499. _prepareEffect(): void;
  29500. private _processCompilationErrors;
  29501. /**
  29502. * Checks if the effect is supported. (Must be called after compilation)
  29503. */
  29504. readonly isSupported: boolean;
  29505. /**
  29506. * Binds a texture to the engine to be used as output of the shader.
  29507. * @param channel Name of the output variable.
  29508. * @param texture Texture to bind.
  29509. * @hidden
  29510. */
  29511. _bindTexture(channel: string, texture: InternalTexture): void;
  29512. /**
  29513. * Sets a texture on the engine to be used in the shader.
  29514. * @param channel Name of the sampler variable.
  29515. * @param texture Texture to set.
  29516. */
  29517. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29518. /**
  29519. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29520. * @param channel Name of the sampler variable.
  29521. * @param texture Texture to set.
  29522. */
  29523. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29524. /**
  29525. * Sets an array of textures on the engine to be used in the shader.
  29526. * @param channel Name of the variable.
  29527. * @param textures Textures to set.
  29528. */
  29529. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29530. /**
  29531. * 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)
  29532. * @param channel Name of the sampler variable.
  29533. * @param postProcess Post process to get the input texture from.
  29534. */
  29535. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29536. /**
  29537. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29538. * 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)
  29539. * @param channel Name of the sampler variable.
  29540. * @param postProcess Post process to get the output texture from.
  29541. */
  29542. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29543. /** @hidden */
  29544. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29545. /** @hidden */
  29546. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29547. /** @hidden */
  29548. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29549. /** @hidden */
  29550. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29551. /**
  29552. * Binds a buffer to a uniform.
  29553. * @param buffer Buffer to bind.
  29554. * @param name Name of the uniform variable to bind to.
  29555. */
  29556. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29557. /**
  29558. * Binds block to a uniform.
  29559. * @param blockName Name of the block to bind.
  29560. * @param index Index to bind.
  29561. */
  29562. bindUniformBlock(blockName: string, index: number): void;
  29563. /**
  29564. * Sets an interger value on a uniform variable.
  29565. * @param uniformName Name of the variable.
  29566. * @param value Value to be set.
  29567. * @returns this effect.
  29568. */
  29569. setInt(uniformName: string, value: number): Effect;
  29570. /**
  29571. * Sets an int array on a uniform variable.
  29572. * @param uniformName Name of the variable.
  29573. * @param array array to be set.
  29574. * @returns this effect.
  29575. */
  29576. setIntArray(uniformName: string, array: Int32Array): Effect;
  29577. /**
  29578. * 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)
  29579. * @param uniformName Name of the variable.
  29580. * @param array array to be set.
  29581. * @returns this effect.
  29582. */
  29583. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29584. /**
  29585. * 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)
  29586. * @param uniformName Name of the variable.
  29587. * @param array array to be set.
  29588. * @returns this effect.
  29589. */
  29590. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29591. /**
  29592. * 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)
  29593. * @param uniformName Name of the variable.
  29594. * @param array array to be set.
  29595. * @returns this effect.
  29596. */
  29597. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29598. /**
  29599. * Sets an float array on a uniform variable.
  29600. * @param uniformName Name of the variable.
  29601. * @param array array to be set.
  29602. * @returns this effect.
  29603. */
  29604. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29605. /**
  29606. * 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)
  29607. * @param uniformName Name of the variable.
  29608. * @param array array to be set.
  29609. * @returns this effect.
  29610. */
  29611. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29612. /**
  29613. * 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)
  29614. * @param uniformName Name of the variable.
  29615. * @param array array to be set.
  29616. * @returns this effect.
  29617. */
  29618. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29619. /**
  29620. * 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)
  29621. * @param uniformName Name of the variable.
  29622. * @param array array to be set.
  29623. * @returns this effect.
  29624. */
  29625. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29626. /**
  29627. * Sets an array on a uniform variable.
  29628. * @param uniformName Name of the variable.
  29629. * @param array array to be set.
  29630. * @returns this effect.
  29631. */
  29632. setArray(uniformName: string, array: number[]): Effect;
  29633. /**
  29634. * 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)
  29635. * @param uniformName Name of the variable.
  29636. * @param array array to be set.
  29637. * @returns this effect.
  29638. */
  29639. setArray2(uniformName: string, array: number[]): Effect;
  29640. /**
  29641. * 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)
  29642. * @param uniformName Name of the variable.
  29643. * @param array array to be set.
  29644. * @returns this effect.
  29645. */
  29646. setArray3(uniformName: string, array: number[]): Effect;
  29647. /**
  29648. * 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)
  29649. * @param uniformName Name of the variable.
  29650. * @param array array to be set.
  29651. * @returns this effect.
  29652. */
  29653. setArray4(uniformName: string, array: number[]): Effect;
  29654. /**
  29655. * Sets matrices on a uniform variable.
  29656. * @param uniformName Name of the variable.
  29657. * @param matrices matrices to be set.
  29658. * @returns this effect.
  29659. */
  29660. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29661. /**
  29662. * Sets matrix on a uniform variable.
  29663. * @param uniformName Name of the variable.
  29664. * @param matrix matrix to be set.
  29665. * @returns this effect.
  29666. */
  29667. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29668. /**
  29669. * 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)
  29670. * @param uniformName Name of the variable.
  29671. * @param matrix matrix to be set.
  29672. * @returns this effect.
  29673. */
  29674. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29675. /**
  29676. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29677. * @param uniformName Name of the variable.
  29678. * @param matrix matrix to be set.
  29679. * @returns this effect.
  29680. */
  29681. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29682. /**
  29683. * Sets a float on a uniform variable.
  29684. * @param uniformName Name of the variable.
  29685. * @param value value to be set.
  29686. * @returns this effect.
  29687. */
  29688. setFloat(uniformName: string, value: number): Effect;
  29689. /**
  29690. * Sets a boolean on a uniform variable.
  29691. * @param uniformName Name of the variable.
  29692. * @param bool value to be set.
  29693. * @returns this effect.
  29694. */
  29695. setBool(uniformName: string, bool: boolean): Effect;
  29696. /**
  29697. * Sets a Vector2 on a uniform variable.
  29698. * @param uniformName Name of the variable.
  29699. * @param vector2 vector2 to be set.
  29700. * @returns this effect.
  29701. */
  29702. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29703. /**
  29704. * Sets a float2 on a uniform variable.
  29705. * @param uniformName Name of the variable.
  29706. * @param x First float in float2.
  29707. * @param y Second float in float2.
  29708. * @returns this effect.
  29709. */
  29710. setFloat2(uniformName: string, x: number, y: number): Effect;
  29711. /**
  29712. * Sets a Vector3 on a uniform variable.
  29713. * @param uniformName Name of the variable.
  29714. * @param vector3 Value to be set.
  29715. * @returns this effect.
  29716. */
  29717. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29718. /**
  29719. * Sets a float3 on a uniform variable.
  29720. * @param uniformName Name of the variable.
  29721. * @param x First float in float3.
  29722. * @param y Second float in float3.
  29723. * @param z Third float in float3.
  29724. * @returns this effect.
  29725. */
  29726. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29727. /**
  29728. * Sets a Vector4 on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param vector4 Value to be set.
  29731. * @returns this effect.
  29732. */
  29733. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29734. /**
  29735. * Sets a float4 on a uniform variable.
  29736. * @param uniformName Name of the variable.
  29737. * @param x First float in float4.
  29738. * @param y Second float in float4.
  29739. * @param z Third float in float4.
  29740. * @param w Fourth float in float4.
  29741. * @returns this effect.
  29742. */
  29743. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29744. /**
  29745. * Sets a Color3 on a uniform variable.
  29746. * @param uniformName Name of the variable.
  29747. * @param color3 Value to be set.
  29748. * @returns this effect.
  29749. */
  29750. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29751. /**
  29752. * Sets a Color4 on a uniform variable.
  29753. * @param uniformName Name of the variable.
  29754. * @param color3 Value to be set.
  29755. * @param alpha Alpha value to be set.
  29756. * @returns this effect.
  29757. */
  29758. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29759. /**
  29760. * Sets a Color4 on a uniform variable
  29761. * @param uniformName defines the name of the variable
  29762. * @param color4 defines the value to be set
  29763. * @returns this effect.
  29764. */
  29765. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29766. /** Release all associated resources */
  29767. dispose(): void;
  29768. /**
  29769. * This function will add a new shader to the shader store
  29770. * @param name the name of the shader
  29771. * @param pixelShader optional pixel shader content
  29772. * @param vertexShader optional vertex shader content
  29773. */
  29774. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29775. /**
  29776. * Store of each shader (The can be looked up using effect.key)
  29777. */
  29778. static ShadersStore: {
  29779. [key: string]: string;
  29780. };
  29781. /**
  29782. * Store of each included file for a shader (The can be looked up using effect.key)
  29783. */
  29784. static IncludesShadersStore: {
  29785. [key: string]: string;
  29786. };
  29787. /**
  29788. * Resets the cache of effects.
  29789. */
  29790. static ResetCache(): void;
  29791. }
  29792. }
  29793. declare module "babylonjs/Engines/engineCapabilities" {
  29794. /**
  29795. * Interface used to describe the capabilities of the engine relatively to the current browser
  29796. */
  29797. export interface EngineCapabilities {
  29798. /** Maximum textures units per fragment shader */
  29799. maxTexturesImageUnits: number;
  29800. /** Maximum texture units per vertex shader */
  29801. maxVertexTextureImageUnits: number;
  29802. /** Maximum textures units in the entire pipeline */
  29803. maxCombinedTexturesImageUnits: number;
  29804. /** Maximum texture size */
  29805. maxTextureSize: number;
  29806. /** Maximum cube texture size */
  29807. maxCubemapTextureSize: number;
  29808. /** Maximum render texture size */
  29809. maxRenderTextureSize: number;
  29810. /** Maximum number of vertex attributes */
  29811. maxVertexAttribs: number;
  29812. /** Maximum number of varyings */
  29813. maxVaryingVectors: number;
  29814. /** Maximum number of uniforms per vertex shader */
  29815. maxVertexUniformVectors: number;
  29816. /** Maximum number of uniforms per fragment shader */
  29817. maxFragmentUniformVectors: number;
  29818. /** Defines if standard derivates (dx/dy) are supported */
  29819. standardDerivatives: boolean;
  29820. /** Defines if s3tc texture compression is supported */
  29821. s3tc?: WEBGL_compressed_texture_s3tc;
  29822. /** Defines if pvrtc texture compression is supported */
  29823. pvrtc: any;
  29824. /** Defines if etc1 texture compression is supported */
  29825. etc1: any;
  29826. /** Defines if etc2 texture compression is supported */
  29827. etc2: any;
  29828. /** Defines if astc texture compression is supported */
  29829. astc: any;
  29830. /** Defines if float textures are supported */
  29831. textureFloat: boolean;
  29832. /** Defines if vertex array objects are supported */
  29833. vertexArrayObject: boolean;
  29834. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29835. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29836. /** Gets the maximum level of anisotropy supported */
  29837. maxAnisotropy: number;
  29838. /** Defines if instancing is supported */
  29839. instancedArrays: boolean;
  29840. /** Defines if 32 bits indices are supported */
  29841. uintIndices: boolean;
  29842. /** Defines if high precision shaders are supported */
  29843. highPrecisionShaderSupported: boolean;
  29844. /** Defines if depth reading in the fragment shader is supported */
  29845. fragmentDepthSupported: boolean;
  29846. /** Defines if float texture linear filtering is supported*/
  29847. textureFloatLinearFiltering: boolean;
  29848. /** Defines if rendering to float textures is supported */
  29849. textureFloatRender: boolean;
  29850. /** Defines if half float textures are supported*/
  29851. textureHalfFloat: boolean;
  29852. /** Defines if half float texture linear filtering is supported*/
  29853. textureHalfFloatLinearFiltering: boolean;
  29854. /** Defines if rendering to half float textures is supported */
  29855. textureHalfFloatRender: boolean;
  29856. /** Defines if textureLOD shader command is supported */
  29857. textureLOD: boolean;
  29858. /** Defines if draw buffers extension is supported */
  29859. drawBuffersExtension: boolean;
  29860. /** Defines if depth textures are supported */
  29861. depthTextureExtension: boolean;
  29862. /** Defines if float color buffer are supported */
  29863. colorBufferFloat: boolean;
  29864. /** Gets disjoint timer query extension (null if not supported) */
  29865. timerQuery?: EXT_disjoint_timer_query;
  29866. /** Defines if timestamp can be used with timer query */
  29867. canUseTimestampForTimerQuery: boolean;
  29868. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29869. multiview?: any;
  29870. /** Function used to let the system compiles shaders in background */
  29871. parallelShaderCompile?: {
  29872. COMPLETION_STATUS_KHR: number;
  29873. };
  29874. /** Max number of texture samples for MSAA */
  29875. maxMSAASamples: number;
  29876. /** Defines if the blend min max extension is supported */
  29877. blendMinMax: boolean;
  29878. }
  29879. }
  29880. declare module "babylonjs/States/depthCullingState" {
  29881. import { Nullable } from "babylonjs/types";
  29882. /**
  29883. * @hidden
  29884. **/
  29885. export class DepthCullingState {
  29886. private _isDepthTestDirty;
  29887. private _isDepthMaskDirty;
  29888. private _isDepthFuncDirty;
  29889. private _isCullFaceDirty;
  29890. private _isCullDirty;
  29891. private _isZOffsetDirty;
  29892. private _isFrontFaceDirty;
  29893. private _depthTest;
  29894. private _depthMask;
  29895. private _depthFunc;
  29896. private _cull;
  29897. private _cullFace;
  29898. private _zOffset;
  29899. private _frontFace;
  29900. /**
  29901. * Initializes the state.
  29902. */
  29903. constructor();
  29904. readonly isDirty: boolean;
  29905. zOffset: number;
  29906. cullFace: Nullable<number>;
  29907. cull: Nullable<boolean>;
  29908. depthFunc: Nullable<number>;
  29909. depthMask: boolean;
  29910. depthTest: boolean;
  29911. frontFace: Nullable<number>;
  29912. reset(): void;
  29913. apply(gl: WebGLRenderingContext): void;
  29914. }
  29915. }
  29916. declare module "babylonjs/States/stencilState" {
  29917. /**
  29918. * @hidden
  29919. **/
  29920. export class StencilState {
  29921. /** 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 */
  29922. static readonly ALWAYS: number;
  29923. /** Passed to stencilOperation to specify that stencil value must be kept */
  29924. static readonly KEEP: number;
  29925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29926. static readonly REPLACE: number;
  29927. private _isStencilTestDirty;
  29928. private _isStencilMaskDirty;
  29929. private _isStencilFuncDirty;
  29930. private _isStencilOpDirty;
  29931. private _stencilTest;
  29932. private _stencilMask;
  29933. private _stencilFunc;
  29934. private _stencilFuncRef;
  29935. private _stencilFuncMask;
  29936. private _stencilOpStencilFail;
  29937. private _stencilOpDepthFail;
  29938. private _stencilOpStencilDepthPass;
  29939. readonly isDirty: boolean;
  29940. stencilFunc: number;
  29941. stencilFuncRef: number;
  29942. stencilFuncMask: number;
  29943. stencilOpStencilFail: number;
  29944. stencilOpDepthFail: number;
  29945. stencilOpStencilDepthPass: number;
  29946. stencilMask: number;
  29947. stencilTest: boolean;
  29948. constructor();
  29949. reset(): void;
  29950. apply(gl: WebGLRenderingContext): void;
  29951. }
  29952. }
  29953. declare module "babylonjs/States/alphaCullingState" {
  29954. /**
  29955. * @hidden
  29956. **/
  29957. export class AlphaState {
  29958. private _isAlphaBlendDirty;
  29959. private _isBlendFunctionParametersDirty;
  29960. private _isBlendEquationParametersDirty;
  29961. private _isBlendConstantsDirty;
  29962. private _alphaBlend;
  29963. private _blendFunctionParameters;
  29964. private _blendEquationParameters;
  29965. private _blendConstants;
  29966. /**
  29967. * Initializes the state.
  29968. */
  29969. constructor();
  29970. readonly isDirty: boolean;
  29971. alphaBlend: boolean;
  29972. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29973. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29974. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29975. reset(): void;
  29976. apply(gl: WebGLRenderingContext): void;
  29977. }
  29978. }
  29979. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29980. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29981. /** @hidden */
  29982. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29983. attributeProcessor(attribute: string): string;
  29984. varyingProcessor(varying: string, isFragment: boolean): string;
  29985. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29986. }
  29987. }
  29988. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29989. /**
  29990. * Interface for attribute information associated with buffer instanciation
  29991. */
  29992. export interface InstancingAttributeInfo {
  29993. /**
  29994. * Index/offset of the attribute in the vertex shader
  29995. */
  29996. index: number;
  29997. /**
  29998. * size of the attribute, 1, 2, 3 or 4
  29999. */
  30000. attributeSize: number;
  30001. /**
  30002. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30003. * default is FLOAT
  30004. */
  30005. attributeType: number;
  30006. /**
  30007. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30008. */
  30009. normalized: boolean;
  30010. /**
  30011. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30012. */
  30013. offset: number;
  30014. /**
  30015. * Name of the GLSL attribute, for debugging purpose only
  30016. */
  30017. attributeName: string;
  30018. }
  30019. }
  30020. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30022. import { Nullable } from "babylonjs/types";
  30023. module "babylonjs/Engines/thinEngine" {
  30024. interface ThinEngine {
  30025. /**
  30026. * Update a video texture
  30027. * @param texture defines the texture to update
  30028. * @param video defines the video element to use
  30029. * @param invertY defines if data must be stored with Y axis inverted
  30030. */
  30031. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30032. }
  30033. }
  30034. }
  30035. declare module "babylonjs/Materials/Textures/videoTexture" {
  30036. import { Observable } from "babylonjs/Misc/observable";
  30037. import { Nullable } from "babylonjs/types";
  30038. import { Scene } from "babylonjs/scene";
  30039. import { Texture } from "babylonjs/Materials/Textures/texture";
  30040. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30041. /**
  30042. * Settings for finer control over video usage
  30043. */
  30044. export interface VideoTextureSettings {
  30045. /**
  30046. * Applies `autoplay` to video, if specified
  30047. */
  30048. autoPlay?: boolean;
  30049. /**
  30050. * Applies `loop` to video, if specified
  30051. */
  30052. loop?: boolean;
  30053. /**
  30054. * Automatically updates internal texture from video at every frame in the render loop
  30055. */
  30056. autoUpdateTexture: boolean;
  30057. /**
  30058. * Image src displayed during the video loading or until the user interacts with the video.
  30059. */
  30060. poster?: string;
  30061. }
  30062. /**
  30063. * If you want to display a video in your scene, this is the special texture for that.
  30064. * This special texture works similar to other textures, with the exception of a few parameters.
  30065. * @see https://doc.babylonjs.com/how_to/video_texture
  30066. */
  30067. export class VideoTexture extends Texture {
  30068. /**
  30069. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30070. */
  30071. readonly autoUpdateTexture: boolean;
  30072. /**
  30073. * The video instance used by the texture internally
  30074. */
  30075. readonly video: HTMLVideoElement;
  30076. private _onUserActionRequestedObservable;
  30077. /**
  30078. * Event triggerd when a dom action is required by the user to play the video.
  30079. * This happens due to recent changes in browser policies preventing video to auto start.
  30080. */
  30081. readonly onUserActionRequestedObservable: Observable<Texture>;
  30082. private _generateMipMaps;
  30083. private _engine;
  30084. private _stillImageCaptured;
  30085. private _displayingPosterTexture;
  30086. private _settings;
  30087. private _createInternalTextureOnEvent;
  30088. private _frameId;
  30089. /**
  30090. * Creates a video texture.
  30091. * If you want to display a video in your scene, this is the special texture for that.
  30092. * This special texture works similar to other textures, with the exception of a few parameters.
  30093. * @see https://doc.babylonjs.com/how_to/video_texture
  30094. * @param name optional name, will detect from video source, if not defined
  30095. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30096. * @param scene is obviously the current scene.
  30097. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30098. * @param invertY is false by default but can be used to invert video on Y axis
  30099. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30100. * @param settings allows finer control over video usage
  30101. */
  30102. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30103. private _getName;
  30104. private _getVideo;
  30105. private _createInternalTexture;
  30106. private reset;
  30107. /**
  30108. * @hidden Internal method to initiate `update`.
  30109. */
  30110. _rebuild(): void;
  30111. /**
  30112. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30113. */
  30114. update(): void;
  30115. /**
  30116. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30117. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30118. */
  30119. updateTexture(isVisible: boolean): void;
  30120. protected _updateInternalTexture: () => void;
  30121. /**
  30122. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30123. * @param url New url.
  30124. */
  30125. updateURL(url: string): void;
  30126. /**
  30127. * Dispose the texture and release its associated resources.
  30128. */
  30129. dispose(): void;
  30130. /**
  30131. * Creates a video texture straight from a stream.
  30132. * @param scene Define the scene the texture should be created in
  30133. * @param stream Define the stream the texture should be created from
  30134. * @returns The created video texture as a promise
  30135. */
  30136. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30137. /**
  30138. * Creates a video texture straight from your WebCam video feed.
  30139. * @param scene Define the scene the texture should be created in
  30140. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30141. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30142. * @returns The created video texture as a promise
  30143. */
  30144. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30145. minWidth: number;
  30146. maxWidth: number;
  30147. minHeight: number;
  30148. maxHeight: number;
  30149. deviceId: string;
  30150. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30151. /**
  30152. * Creates a video texture straight from your WebCam video feed.
  30153. * @param scene Define the scene the texture should be created in
  30154. * @param onReady Define a callback to triggered once the texture will be ready
  30155. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30156. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30157. */
  30158. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30159. minWidth: number;
  30160. maxWidth: number;
  30161. minHeight: number;
  30162. maxHeight: number;
  30163. deviceId: string;
  30164. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30165. }
  30166. }
  30167. declare module "babylonjs/Engines/thinEngine" {
  30168. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30169. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30170. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30171. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30172. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30173. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30174. import { Observable } from "babylonjs/Misc/observable";
  30175. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30176. import { StencilState } from "babylonjs/States/stencilState";
  30177. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30178. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30179. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30181. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30182. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30183. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30184. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30185. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30187. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30188. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30189. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30190. /**
  30191. * Defines the interface used by objects working like Scene
  30192. * @hidden
  30193. */
  30194. interface ISceneLike {
  30195. _addPendingData(data: any): void;
  30196. _removePendingData(data: any): void;
  30197. offlineProvider: IOfflineProvider;
  30198. }
  30199. /** Interface defining initialization parameters for Engine class */
  30200. export interface EngineOptions extends WebGLContextAttributes {
  30201. /**
  30202. * Defines if the engine should no exceed a specified device ratio
  30203. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30204. */
  30205. limitDeviceRatio?: number;
  30206. /**
  30207. * Defines if webvr should be enabled automatically
  30208. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30209. */
  30210. autoEnableWebVR?: boolean;
  30211. /**
  30212. * Defines if webgl2 should be turned off even if supported
  30213. * @see http://doc.babylonjs.com/features/webgl2
  30214. */
  30215. disableWebGL2Support?: boolean;
  30216. /**
  30217. * Defines if webaudio should be initialized as well
  30218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30219. */
  30220. audioEngine?: boolean;
  30221. /**
  30222. * Defines if animations should run using a deterministic lock step
  30223. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30224. */
  30225. deterministicLockstep?: boolean;
  30226. /** Defines the maximum steps to use with deterministic lock step mode */
  30227. lockstepMaxSteps?: number;
  30228. /**
  30229. * Defines that engine should ignore context lost events
  30230. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30231. */
  30232. doNotHandleContextLost?: boolean;
  30233. /**
  30234. * Defines that engine should ignore modifying touch action attribute and style
  30235. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30236. */
  30237. doNotHandleTouchAction?: boolean;
  30238. /**
  30239. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30240. */
  30241. useHighPrecisionFloats?: boolean;
  30242. }
  30243. /**
  30244. * The base engine class (root of all engines)
  30245. */
  30246. export class ThinEngine {
  30247. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30248. static ExceptionList: ({
  30249. key: string;
  30250. capture: string;
  30251. captureConstraint: number;
  30252. targets: string[];
  30253. } | {
  30254. key: string;
  30255. capture: null;
  30256. captureConstraint: null;
  30257. targets: string[];
  30258. })[];
  30259. /** @hidden */
  30260. static _TextureLoaders: IInternalTextureLoader[];
  30261. /**
  30262. * Returns the current npm package of the sdk
  30263. */
  30264. static readonly NpmPackage: string;
  30265. /**
  30266. * Returns the current version of the framework
  30267. */
  30268. static readonly Version: string;
  30269. /**
  30270. * Returns a string describing the current engine
  30271. */
  30272. readonly description: string;
  30273. /**
  30274. * Gets or sets the epsilon value used by collision engine
  30275. */
  30276. static CollisionsEpsilon: number;
  30277. /**
  30278. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30279. */
  30280. static ShadersRepository: string;
  30281. /** @hidden */
  30282. _shaderProcessor: IShaderProcessor;
  30283. /**
  30284. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30285. */
  30286. forcePOTTextures: boolean;
  30287. /**
  30288. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30289. */
  30290. isFullscreen: boolean;
  30291. /**
  30292. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30293. */
  30294. cullBackFaces: boolean;
  30295. /**
  30296. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30297. */
  30298. renderEvenInBackground: boolean;
  30299. /**
  30300. * Gets or sets a boolean indicating that cache can be kept between frames
  30301. */
  30302. preventCacheWipeBetweenFrames: boolean;
  30303. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30304. validateShaderPrograms: boolean;
  30305. /**
  30306. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30307. */
  30308. disableUniformBuffers: boolean;
  30309. /** @hidden */
  30310. _uniformBuffers: UniformBuffer[];
  30311. /**
  30312. * Gets a boolean indicating that the engine supports uniform buffers
  30313. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30314. */
  30315. readonly supportsUniformBuffers: boolean;
  30316. /** @hidden */
  30317. _gl: WebGLRenderingContext;
  30318. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30319. protected _windowIsBackground: boolean;
  30320. protected _webGLVersion: number;
  30321. protected _creationOptions: EngineOptions;
  30322. protected _highPrecisionShadersAllowed: boolean;
  30323. /** @hidden */
  30324. readonly _shouldUseHighPrecisionShader: boolean;
  30325. /**
  30326. * Gets a boolean indicating that only power of 2 textures are supported
  30327. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30328. */
  30329. readonly needPOTTextures: boolean;
  30330. /** @hidden */
  30331. _badOS: boolean;
  30332. /** @hidden */
  30333. _badDesktopOS: boolean;
  30334. private _hardwareScalingLevel;
  30335. /** @hidden */
  30336. _caps: EngineCapabilities;
  30337. private _isStencilEnable;
  30338. protected _colorWrite: boolean;
  30339. private _glVersion;
  30340. private _glRenderer;
  30341. private _glVendor;
  30342. /** @hidden */
  30343. _videoTextureSupported: boolean;
  30344. protected _renderingQueueLaunched: boolean;
  30345. protected _activeRenderLoops: (() => void)[];
  30346. /**
  30347. * Observable signaled when a context lost event is raised
  30348. */
  30349. onContextLostObservable: Observable<ThinEngine>;
  30350. /**
  30351. * Observable signaled when a context restored event is raised
  30352. */
  30353. onContextRestoredObservable: Observable<ThinEngine>;
  30354. private _onContextLost;
  30355. private _onContextRestored;
  30356. protected _contextWasLost: boolean;
  30357. /** @hidden */
  30358. _doNotHandleContextLost: boolean;
  30359. /**
  30360. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30362. */
  30363. doNotHandleContextLost: boolean;
  30364. /**
  30365. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30366. */
  30367. disableVertexArrayObjects: boolean;
  30368. /** @hidden */
  30369. protected _depthCullingState: DepthCullingState;
  30370. /** @hidden */
  30371. protected _stencilState: StencilState;
  30372. /** @hidden */
  30373. protected _alphaState: AlphaState;
  30374. /** @hidden */
  30375. _internalTexturesCache: InternalTexture[];
  30376. /** @hidden */
  30377. protected _activeChannel: number;
  30378. private _currentTextureChannel;
  30379. /** @hidden */
  30380. protected _boundTexturesCache: {
  30381. [key: string]: Nullable<InternalTexture>;
  30382. };
  30383. /** @hidden */
  30384. protected _currentEffect: Nullable<Effect>;
  30385. /** @hidden */
  30386. protected _currentProgram: Nullable<WebGLProgram>;
  30387. private _compiledEffects;
  30388. private _vertexAttribArraysEnabled;
  30389. /** @hidden */
  30390. protected _cachedViewport: Nullable<IViewportLike>;
  30391. private _cachedVertexArrayObject;
  30392. /** @hidden */
  30393. protected _cachedVertexBuffers: any;
  30394. /** @hidden */
  30395. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30396. /** @hidden */
  30397. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30398. /** @hidden */
  30399. _currentRenderTarget: Nullable<InternalTexture>;
  30400. private _uintIndicesCurrentlySet;
  30401. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30402. /** @hidden */
  30403. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30404. private _currentBufferPointers;
  30405. private _currentInstanceLocations;
  30406. private _currentInstanceBuffers;
  30407. private _textureUnits;
  30408. /** @hidden */
  30409. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30410. /** @hidden */
  30411. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30412. /** @hidden */
  30413. _boundRenderFunction: any;
  30414. private _vaoRecordInProgress;
  30415. private _mustWipeVertexAttributes;
  30416. private _emptyTexture;
  30417. private _emptyCubeTexture;
  30418. private _emptyTexture3D;
  30419. private _emptyTexture2DArray;
  30420. /** @hidden */
  30421. _frameHandler: number;
  30422. private _nextFreeTextureSlots;
  30423. private _maxSimultaneousTextures;
  30424. private _activeRequests;
  30425. protected _texturesSupported: string[];
  30426. /** @hidden */
  30427. _textureFormatInUse: Nullable<string>;
  30428. protected readonly _supportsHardwareTextureRescaling: boolean;
  30429. /**
  30430. * Gets the list of texture formats supported
  30431. */
  30432. readonly texturesSupported: Array<string>;
  30433. /**
  30434. * Gets the list of texture formats in use
  30435. */
  30436. readonly textureFormatInUse: Nullable<string>;
  30437. /**
  30438. * Gets the current viewport
  30439. */
  30440. readonly currentViewport: Nullable<IViewportLike>;
  30441. /**
  30442. * Gets the default empty texture
  30443. */
  30444. readonly emptyTexture: InternalTexture;
  30445. /**
  30446. * Gets the default empty 3D texture
  30447. */
  30448. readonly emptyTexture3D: InternalTexture;
  30449. /**
  30450. * Gets the default empty 2D array texture
  30451. */
  30452. readonly emptyTexture2DArray: InternalTexture;
  30453. /**
  30454. * Gets the default empty cube texture
  30455. */
  30456. readonly emptyCubeTexture: InternalTexture;
  30457. /**
  30458. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30459. */
  30460. readonly premultipliedAlpha: boolean;
  30461. /**
  30462. * Observable event triggered before each texture is initialized
  30463. */
  30464. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30465. /**
  30466. * Creates a new engine
  30467. * @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
  30468. * @param antialias defines enable antialiasing (default: false)
  30469. * @param options defines further options to be sent to the getContext() function
  30470. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30471. */
  30472. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30473. private _rebuildInternalTextures;
  30474. private _rebuildEffects;
  30475. /**
  30476. * Gets a boolean indicating if all created effects are ready
  30477. * @returns true if all effects are ready
  30478. */
  30479. areAllEffectsReady(): boolean;
  30480. protected _rebuildBuffers(): void;
  30481. private _initGLContext;
  30482. /**
  30483. * Gets version of the current webGL context
  30484. */
  30485. readonly webGLVersion: number;
  30486. /**
  30487. * Gets a string idenfifying the name of the class
  30488. * @returns "Engine" string
  30489. */
  30490. getClassName(): string;
  30491. /**
  30492. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30493. */
  30494. readonly isStencilEnable: boolean;
  30495. /** @hidden */
  30496. _prepareWorkingCanvas(): void;
  30497. /**
  30498. * Reset the texture cache to empty state
  30499. */
  30500. resetTextureCache(): void;
  30501. /**
  30502. * Gets an object containing information about the current webGL context
  30503. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30504. */
  30505. getGlInfo(): {
  30506. vendor: string;
  30507. renderer: string;
  30508. version: string;
  30509. };
  30510. /**
  30511. * Defines the hardware scaling level.
  30512. * By default the hardware scaling level is computed from the window device ratio.
  30513. * 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.
  30514. * @param level defines the level to use
  30515. */
  30516. setHardwareScalingLevel(level: number): void;
  30517. /**
  30518. * Gets the current hardware scaling level.
  30519. * By default the hardware scaling level is computed from the window device ratio.
  30520. * 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.
  30521. * @returns a number indicating the current hardware scaling level
  30522. */
  30523. getHardwareScalingLevel(): number;
  30524. /**
  30525. * Gets the list of loaded textures
  30526. * @returns an array containing all loaded textures
  30527. */
  30528. getLoadedTexturesCache(): InternalTexture[];
  30529. /**
  30530. * Gets the object containing all engine capabilities
  30531. * @returns the EngineCapabilities object
  30532. */
  30533. getCaps(): EngineCapabilities;
  30534. /**
  30535. * stop executing a render loop function and remove it from the execution array
  30536. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30537. */
  30538. stopRenderLoop(renderFunction?: () => void): void;
  30539. /** @hidden */
  30540. _renderLoop(): void;
  30541. /**
  30542. * Gets the HTML canvas attached with the current webGL context
  30543. * @returns a HTML canvas
  30544. */
  30545. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30546. /**
  30547. * Gets host window
  30548. * @returns the host window object
  30549. */
  30550. getHostWindow(): Nullable<Window>;
  30551. /**
  30552. * Gets the current render width
  30553. * @param useScreen defines if screen size must be used (or the current render target if any)
  30554. * @returns a number defining the current render width
  30555. */
  30556. getRenderWidth(useScreen?: boolean): number;
  30557. /**
  30558. * Gets the current render height
  30559. * @param useScreen defines if screen size must be used (or the current render target if any)
  30560. * @returns a number defining the current render height
  30561. */
  30562. getRenderHeight(useScreen?: boolean): number;
  30563. /**
  30564. * Can be used to override the current requestAnimationFrame requester.
  30565. * @hidden
  30566. */
  30567. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30568. /**
  30569. * Register and execute a render loop. The engine can have more than one render function
  30570. * @param renderFunction defines the function to continuously execute
  30571. */
  30572. runRenderLoop(renderFunction: () => void): void;
  30573. /**
  30574. * Clear the current render buffer or the current render target (if any is set up)
  30575. * @param color defines the color to use
  30576. * @param backBuffer defines if the back buffer must be cleared
  30577. * @param depth defines if the depth buffer must be cleared
  30578. * @param stencil defines if the stencil buffer must be cleared
  30579. */
  30580. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30581. private _viewportCached;
  30582. /** @hidden */
  30583. _viewport(x: number, y: number, width: number, height: number): void;
  30584. /**
  30585. * Set the WebGL's viewport
  30586. * @param viewport defines the viewport element to be used
  30587. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30588. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30589. */
  30590. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30591. /**
  30592. * Begin a new frame
  30593. */
  30594. beginFrame(): void;
  30595. /**
  30596. * Enf the current frame
  30597. */
  30598. endFrame(): void;
  30599. /**
  30600. * Resize the view according to the canvas' size
  30601. */
  30602. resize(): void;
  30603. /**
  30604. * Force a specific size of the canvas
  30605. * @param width defines the new canvas' width
  30606. * @param height defines the new canvas' height
  30607. */
  30608. setSize(width: number, height: number): void;
  30609. /**
  30610. * Binds the frame buffer to the specified texture.
  30611. * @param texture The texture to render to or null for the default canvas
  30612. * @param faceIndex The face of the texture to render to in case of cube texture
  30613. * @param requiredWidth The width of the target to render to
  30614. * @param requiredHeight The height of the target to render to
  30615. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30616. * @param depthStencilTexture The depth stencil texture to use to render
  30617. * @param lodLevel defines le lod level to bind to the frame buffer
  30618. */
  30619. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30620. /** @hidden */
  30621. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30622. /**
  30623. * Unbind the current render target texture from the webGL context
  30624. * @param texture defines the render target texture to unbind
  30625. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30626. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30627. */
  30628. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30629. /**
  30630. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30631. */
  30632. flushFramebuffer(): void;
  30633. /**
  30634. * Unbind the current render target and bind the default framebuffer
  30635. */
  30636. restoreDefaultFramebuffer(): void;
  30637. /** @hidden */
  30638. protected _resetVertexBufferBinding(): void;
  30639. /**
  30640. * Creates a vertex buffer
  30641. * @param data the data for the vertex buffer
  30642. * @returns the new WebGL static buffer
  30643. */
  30644. createVertexBuffer(data: DataArray): DataBuffer;
  30645. private _createVertexBuffer;
  30646. /**
  30647. * Creates a dynamic vertex buffer
  30648. * @param data the data for the dynamic vertex buffer
  30649. * @returns the new WebGL dynamic buffer
  30650. */
  30651. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30652. protected _resetIndexBufferBinding(): void;
  30653. /**
  30654. * Creates a new index buffer
  30655. * @param indices defines the content of the index buffer
  30656. * @param updatable defines if the index buffer must be updatable
  30657. * @returns a new webGL buffer
  30658. */
  30659. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30660. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30661. /**
  30662. * Bind a webGL buffer to the webGL context
  30663. * @param buffer defines the buffer to bind
  30664. */
  30665. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30666. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30667. private bindBuffer;
  30668. /**
  30669. * update the bound buffer with the given data
  30670. * @param data defines the data to update
  30671. */
  30672. updateArrayBuffer(data: Float32Array): void;
  30673. private _vertexAttribPointer;
  30674. private _bindIndexBufferWithCache;
  30675. private _bindVertexBuffersAttributes;
  30676. /**
  30677. * Records a vertex array object
  30678. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30679. * @param vertexBuffers defines the list of vertex buffers to store
  30680. * @param indexBuffer defines the index buffer to store
  30681. * @param effect defines the effect to store
  30682. * @returns the new vertex array object
  30683. */
  30684. recordVertexArrayObject(vertexBuffers: {
  30685. [key: string]: VertexBuffer;
  30686. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30687. /**
  30688. * Bind a specific vertex array object
  30689. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30690. * @param vertexArrayObject defines the vertex array object to bind
  30691. * @param indexBuffer defines the index buffer to bind
  30692. */
  30693. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30694. /**
  30695. * Bind webGl buffers directly to the webGL context
  30696. * @param vertexBuffer defines the vertex buffer to bind
  30697. * @param indexBuffer defines the index buffer to bind
  30698. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30699. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30700. * @param effect defines the effect associated with the vertex buffer
  30701. */
  30702. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30703. private _unbindVertexArrayObject;
  30704. /**
  30705. * Bind a list of vertex buffers to the webGL context
  30706. * @param vertexBuffers defines the list of vertex buffers to bind
  30707. * @param indexBuffer defines the index buffer to bind
  30708. * @param effect defines the effect associated with the vertex buffers
  30709. */
  30710. bindBuffers(vertexBuffers: {
  30711. [key: string]: Nullable<VertexBuffer>;
  30712. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30713. /**
  30714. * Unbind all instance attributes
  30715. */
  30716. unbindInstanceAttributes(): void;
  30717. /**
  30718. * Release and free the memory of a vertex array object
  30719. * @param vao defines the vertex array object to delete
  30720. */
  30721. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30722. /** @hidden */
  30723. _releaseBuffer(buffer: DataBuffer): boolean;
  30724. protected _deleteBuffer(buffer: DataBuffer): void;
  30725. /**
  30726. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30727. * @param instancesBuffer defines the webGL buffer to update and bind
  30728. * @param data defines the data to store in the buffer
  30729. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30730. */
  30731. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30732. /**
  30733. * Apply all cached states (depth, culling, stencil and alpha)
  30734. */
  30735. applyStates(): void;
  30736. /**
  30737. * Send a draw order
  30738. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30739. * @param indexStart defines the starting index
  30740. * @param indexCount defines the number of index to draw
  30741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30742. */
  30743. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30744. /**
  30745. * Draw a list of points
  30746. * @param verticesStart defines the index of first vertex to draw
  30747. * @param verticesCount defines the count of vertices to draw
  30748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30749. */
  30750. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30751. /**
  30752. * Draw a list of unindexed primitives
  30753. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30754. * @param verticesStart defines the index of first vertex to draw
  30755. * @param verticesCount defines the count of vertices to draw
  30756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30757. */
  30758. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30759. /**
  30760. * Draw a list of indexed primitives
  30761. * @param fillMode defines the primitive to use
  30762. * @param indexStart defines the starting index
  30763. * @param indexCount defines the number of index to draw
  30764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30765. */
  30766. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30767. /**
  30768. * Draw a list of unindexed primitives
  30769. * @param fillMode defines the primitive to use
  30770. * @param verticesStart defines the index of first vertex to draw
  30771. * @param verticesCount defines the count of vertices to draw
  30772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30773. */
  30774. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30775. private _drawMode;
  30776. /** @hidden */
  30777. protected _reportDrawCall(): void;
  30778. /** @hidden */
  30779. _releaseEffect(effect: Effect): void;
  30780. /** @hidden */
  30781. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30782. /**
  30783. * Create a new effect (used to store vertex/fragment shaders)
  30784. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30785. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30786. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30787. * @param samplers defines an array of string used to represent textures
  30788. * @param defines defines the string containing the defines to use to compile the shaders
  30789. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30790. * @param onCompiled defines a function to call when the effect creation is successful
  30791. * @param onError defines a function to call when the effect creation has failed
  30792. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30793. * @returns the new Effect
  30794. */
  30795. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30796. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30797. private _compileShader;
  30798. private _compileRawShader;
  30799. /**
  30800. * Directly creates a webGL program
  30801. * @param pipelineContext defines the pipeline context to attach to
  30802. * @param vertexCode defines the vertex shader code to use
  30803. * @param fragmentCode defines the fragment shader code to use
  30804. * @param context defines the webGL context to use (if not set, the current one will be used)
  30805. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30806. * @returns the new webGL program
  30807. */
  30808. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30809. /**
  30810. * Creates a webGL program
  30811. * @param pipelineContext defines the pipeline context to attach to
  30812. * @param vertexCode defines the vertex shader code to use
  30813. * @param fragmentCode defines the fragment shader code to use
  30814. * @param defines defines the string containing the defines to use to compile the shaders
  30815. * @param context defines the webGL context to use (if not set, the current one will be used)
  30816. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30817. * @returns the new webGL program
  30818. */
  30819. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30820. /**
  30821. * Creates a new pipeline context
  30822. * @returns the new pipeline
  30823. */
  30824. createPipelineContext(): IPipelineContext;
  30825. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30826. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30827. /** @hidden */
  30828. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30829. /** @hidden */
  30830. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30831. /** @hidden */
  30832. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30833. /**
  30834. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30835. * @param pipelineContext defines the pipeline context to use
  30836. * @param uniformsNames defines the list of uniform names
  30837. * @returns an array of webGL uniform locations
  30838. */
  30839. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30840. /**
  30841. * Gets the lsit of active attributes for a given webGL program
  30842. * @param pipelineContext defines the pipeline context to use
  30843. * @param attributesNames defines the list of attribute names to get
  30844. * @returns an array of indices indicating the offset of each attribute
  30845. */
  30846. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30847. /**
  30848. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30849. * @param effect defines the effect to activate
  30850. */
  30851. enableEffect(effect: Nullable<Effect>): void;
  30852. /**
  30853. * Set the value of an uniform to a number (int)
  30854. * @param uniform defines the webGL uniform location where to store the value
  30855. * @param value defines the int number to store
  30856. */
  30857. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30858. /**
  30859. * Set the value of an uniform to an array of int32
  30860. * @param uniform defines the webGL uniform location where to store the value
  30861. * @param array defines the array of int32 to store
  30862. */
  30863. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30864. /**
  30865. * Set the value of an uniform to an array of int32 (stored as vec2)
  30866. * @param uniform defines the webGL uniform location where to store the value
  30867. * @param array defines the array of int32 to store
  30868. */
  30869. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30870. /**
  30871. * Set the value of an uniform to an array of int32 (stored as vec3)
  30872. * @param uniform defines the webGL uniform location where to store the value
  30873. * @param array defines the array of int32 to store
  30874. */
  30875. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30876. /**
  30877. * Set the value of an uniform to an array of int32 (stored as vec4)
  30878. * @param uniform defines the webGL uniform location where to store the value
  30879. * @param array defines the array of int32 to store
  30880. */
  30881. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30882. /**
  30883. * Set the value of an uniform to an array of number
  30884. * @param uniform defines the webGL uniform location where to store the value
  30885. * @param array defines the array of number to store
  30886. */
  30887. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30888. /**
  30889. * Set the value of an uniform to an array of number (stored as vec2)
  30890. * @param uniform defines the webGL uniform location where to store the value
  30891. * @param array defines the array of number to store
  30892. */
  30893. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30894. /**
  30895. * Set the value of an uniform to an array of number (stored as vec3)
  30896. * @param uniform defines the webGL uniform location where to store the value
  30897. * @param array defines the array of number to store
  30898. */
  30899. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30900. /**
  30901. * Set the value of an uniform to an array of number (stored as vec4)
  30902. * @param uniform defines the webGL uniform location where to store the value
  30903. * @param array defines the array of number to store
  30904. */
  30905. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30906. /**
  30907. * Set the value of an uniform to an array of float32 (stored as matrices)
  30908. * @param uniform defines the webGL uniform location where to store the value
  30909. * @param matrices defines the array of float32 to store
  30910. */
  30911. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30912. /**
  30913. * Set the value of an uniform to a matrix (3x3)
  30914. * @param uniform defines the webGL uniform location where to store the value
  30915. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30916. */
  30917. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30918. /**
  30919. * Set the value of an uniform to a matrix (2x2)
  30920. * @param uniform defines the webGL uniform location where to store the value
  30921. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30922. */
  30923. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30924. /**
  30925. * Set the value of an uniform to a number (float)
  30926. * @param uniform defines the webGL uniform location where to store the value
  30927. * @param value defines the float number to store
  30928. */
  30929. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30930. /**
  30931. * Set the value of an uniform to a vec2
  30932. * @param uniform defines the webGL uniform location where to store the value
  30933. * @param x defines the 1st component of the value
  30934. * @param y defines the 2nd component of the value
  30935. */
  30936. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30937. /**
  30938. * Set the value of an uniform to a vec3
  30939. * @param uniform defines the webGL uniform location where to store the value
  30940. * @param x defines the 1st component of the value
  30941. * @param y defines the 2nd component of the value
  30942. * @param z defines the 3rd component of the value
  30943. */
  30944. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30945. /**
  30946. * Set the value of an uniform to a vec4
  30947. * @param uniform defines the webGL uniform location where to store the value
  30948. * @param x defines the 1st component of the value
  30949. * @param y defines the 2nd component of the value
  30950. * @param z defines the 3rd component of the value
  30951. * @param w defines the 4th component of the value
  30952. */
  30953. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30954. /**
  30955. * Gets the depth culling state manager
  30956. */
  30957. readonly depthCullingState: DepthCullingState;
  30958. /**
  30959. * Gets the alpha state manager
  30960. */
  30961. readonly alphaState: AlphaState;
  30962. /**
  30963. * Gets the stencil state manager
  30964. */
  30965. readonly stencilState: StencilState;
  30966. /**
  30967. * Clears the list of texture accessible through engine.
  30968. * This can help preventing texture load conflict due to name collision.
  30969. */
  30970. clearInternalTexturesCache(): void;
  30971. /**
  30972. * Force the entire cache to be cleared
  30973. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30974. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30975. */
  30976. wipeCaches(bruteForce?: boolean): void;
  30977. /** @hidden */
  30978. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30979. min: number;
  30980. mag: number;
  30981. };
  30982. /** @hidden */
  30983. _createTexture(): WebGLTexture;
  30984. /**
  30985. * Usually called from Texture.ts.
  30986. * Passed information to create a WebGLTexture
  30987. * @param urlArg defines a value which contains one of the following:
  30988. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30989. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30990. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30991. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30992. * @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)
  30993. * @param scene needed for loading to the correct scene
  30994. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30995. * @param onLoad optional callback to be called upon successful completion
  30996. * @param onError optional callback to be called upon failure
  30997. * @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
  30998. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30999. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31000. * @param forcedExtension defines the extension to use to pick the right loader
  31001. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31002. * @param mimeType defines an optional mime type
  31003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31004. */
  31005. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31006. /**
  31007. * @hidden
  31008. */
  31009. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31010. /**
  31011. * Creates a raw texture
  31012. * @param data defines the data to store in the texture
  31013. * @param width defines the width of the texture
  31014. * @param height defines the height of the texture
  31015. * @param format defines the format of the data
  31016. * @param generateMipMaps defines if the engine should generate the mip levels
  31017. * @param invertY defines if data must be stored with Y axis inverted
  31018. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31019. * @param compression defines the compression used (null by default)
  31020. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31021. * @returns the raw texture inside an InternalTexture
  31022. */
  31023. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31024. /**
  31025. * Creates a new raw cube texture
  31026. * @param data defines the array of data to use to create each face
  31027. * @param size defines the size of the textures
  31028. * @param format defines the format of the data
  31029. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31030. * @param generateMipMaps defines if the engine should generate the mip levels
  31031. * @param invertY defines if data must be stored with Y axis inverted
  31032. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31033. * @param compression defines the compression used (null by default)
  31034. * @returns the cube texture as an InternalTexture
  31035. */
  31036. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31037. /**
  31038. * Creates a new raw 3D texture
  31039. * @param data defines the data used to create the texture
  31040. * @param width defines the width of the texture
  31041. * @param height defines the height of the texture
  31042. * @param depth defines the depth of the texture
  31043. * @param format defines the format of the texture
  31044. * @param generateMipMaps defines if the engine must generate mip levels
  31045. * @param invertY defines if data must be stored with Y axis inverted
  31046. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31047. * @param compression defines the compressed used (can be null)
  31048. * @param textureType defines the compressed used (can be null)
  31049. * @returns a new raw 3D texture (stored in an InternalTexture)
  31050. */
  31051. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31052. /**
  31053. * Creates a new raw 2D array texture
  31054. * @param data defines the data used to create the texture
  31055. * @param width defines the width of the texture
  31056. * @param height defines the height of the texture
  31057. * @param depth defines the number of layers of the texture
  31058. * @param format defines the format of the texture
  31059. * @param generateMipMaps defines if the engine must generate mip levels
  31060. * @param invertY defines if data must be stored with Y axis inverted
  31061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31062. * @param compression defines the compressed used (can be null)
  31063. * @param textureType defines the compressed used (can be null)
  31064. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31065. */
  31066. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31067. private _unpackFlipYCached;
  31068. /**
  31069. * In case you are sharing the context with other applications, it might
  31070. * be interested to not cache the unpack flip y state to ensure a consistent
  31071. * value would be set.
  31072. */
  31073. enableUnpackFlipYCached: boolean;
  31074. /** @hidden */
  31075. _unpackFlipY(value: boolean): void;
  31076. /** @hidden */
  31077. _getUnpackAlignement(): number;
  31078. /**
  31079. * Update the sampling mode of a given texture
  31080. * @param samplingMode defines the required sampling mode
  31081. * @param texture defines the texture to update
  31082. */
  31083. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31084. /** @hidden */
  31085. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31086. width: number;
  31087. height: number;
  31088. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31089. /** @hidden */
  31090. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31091. /** @hidden */
  31092. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31093. /** @hidden */
  31094. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31095. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31096. private _prepareWebGLTexture;
  31097. /** @hidden */
  31098. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31099. /** @hidden */
  31100. _releaseFramebufferObjects(texture: InternalTexture): void;
  31101. /** @hidden */
  31102. _releaseTexture(texture: InternalTexture): void;
  31103. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31104. protected _setProgram(program: WebGLProgram): void;
  31105. protected _boundUniforms: {
  31106. [key: number]: WebGLUniformLocation;
  31107. };
  31108. /**
  31109. * Binds an effect to the webGL context
  31110. * @param effect defines the effect to bind
  31111. */
  31112. bindSamplers(effect: Effect): void;
  31113. private _activateCurrentTexture;
  31114. /** @hidden */
  31115. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31116. /** @hidden */
  31117. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31118. /**
  31119. * Unbind all textures from the webGL context
  31120. */
  31121. unbindAllTextures(): void;
  31122. /**
  31123. * Sets a texture to the according uniform.
  31124. * @param channel The texture channel
  31125. * @param uniform The uniform to set
  31126. * @param texture The texture to apply
  31127. */
  31128. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31129. private _bindSamplerUniformToChannel;
  31130. private _getTextureWrapMode;
  31131. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31132. /**
  31133. * Sets an array of texture to the webGL context
  31134. * @param channel defines the channel where the texture array must be set
  31135. * @param uniform defines the associated uniform location
  31136. * @param textures defines the array of textures to bind
  31137. */
  31138. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31139. /** @hidden */
  31140. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31141. private _setTextureParameterFloat;
  31142. private _setTextureParameterInteger;
  31143. /**
  31144. * Unbind all vertex attributes from the webGL context
  31145. */
  31146. unbindAllAttributes(): void;
  31147. /**
  31148. * 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
  31149. */
  31150. releaseEffects(): void;
  31151. /**
  31152. * Dispose and release all associated resources
  31153. */
  31154. dispose(): void;
  31155. /**
  31156. * Attach a new callback raised when context lost event is fired
  31157. * @param callback defines the callback to call
  31158. */
  31159. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31160. /**
  31161. * Attach a new callback raised when context restored event is fired
  31162. * @param callback defines the callback to call
  31163. */
  31164. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31165. /**
  31166. * Get the current error code of the webGL context
  31167. * @returns the error code
  31168. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31169. */
  31170. getError(): number;
  31171. private _canRenderToFloatFramebuffer;
  31172. private _canRenderToHalfFloatFramebuffer;
  31173. private _canRenderToFramebuffer;
  31174. /** @hidden */
  31175. _getWebGLTextureType(type: number): number;
  31176. /** @hidden */
  31177. _getInternalFormat(format: number): number;
  31178. /** @hidden */
  31179. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31180. /** @hidden */
  31181. _getRGBAMultiSampleBufferFormat(type: number): number;
  31182. /** @hidden */
  31183. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31184. /**
  31185. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31186. * @returns true if the engine can be created
  31187. * @ignorenaming
  31188. */
  31189. static isSupported(): boolean;
  31190. /**
  31191. * Find the next highest power of two.
  31192. * @param x Number to start search from.
  31193. * @return Next highest power of two.
  31194. */
  31195. static CeilingPOT(x: number): number;
  31196. /**
  31197. * Find the next lowest power of two.
  31198. * @param x Number to start search from.
  31199. * @return Next lowest power of two.
  31200. */
  31201. static FloorPOT(x: number): number;
  31202. /**
  31203. * Find the nearest power of two.
  31204. * @param x Number to start search from.
  31205. * @return Next nearest power of two.
  31206. */
  31207. static NearestPOT(x: number): number;
  31208. /**
  31209. * Get the closest exponent of two
  31210. * @param value defines the value to approximate
  31211. * @param max defines the maximum value to return
  31212. * @param mode defines how to define the closest value
  31213. * @returns closest exponent of two of the given value
  31214. */
  31215. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31216. /**
  31217. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31218. * @param func - the function to be called
  31219. * @param requester - the object that will request the next frame. Falls back to window.
  31220. * @returns frame number
  31221. */
  31222. static QueueNewFrame(func: () => void, requester?: any): number;
  31223. }
  31224. }
  31225. declare module "babylonjs/Maths/sphericalPolynomial" {
  31226. import { Vector3 } from "babylonjs/Maths/math.vector";
  31227. import { Color3 } from "babylonjs/Maths/math.color";
  31228. /**
  31229. * Class representing spherical harmonics coefficients to the 3rd degree
  31230. */
  31231. export class SphericalHarmonics {
  31232. /**
  31233. * Defines whether or not the harmonics have been prescaled for rendering.
  31234. */
  31235. preScaled: boolean;
  31236. /**
  31237. * The l0,0 coefficients of the spherical harmonics
  31238. */
  31239. l00: Vector3;
  31240. /**
  31241. * The l1,-1 coefficients of the spherical harmonics
  31242. */
  31243. l1_1: Vector3;
  31244. /**
  31245. * The l1,0 coefficients of the spherical harmonics
  31246. */
  31247. l10: Vector3;
  31248. /**
  31249. * The l1,1 coefficients of the spherical harmonics
  31250. */
  31251. l11: Vector3;
  31252. /**
  31253. * The l2,-2 coefficients of the spherical harmonics
  31254. */
  31255. l2_2: Vector3;
  31256. /**
  31257. * The l2,-1 coefficients of the spherical harmonics
  31258. */
  31259. l2_1: Vector3;
  31260. /**
  31261. * The l2,0 coefficients of the spherical harmonics
  31262. */
  31263. l20: Vector3;
  31264. /**
  31265. * The l2,1 coefficients of the spherical harmonics
  31266. */
  31267. l21: Vector3;
  31268. /**
  31269. * The l2,2 coefficients of the spherical harmonics
  31270. */
  31271. l22: Vector3;
  31272. /**
  31273. * Adds a light to the spherical harmonics
  31274. * @param direction the direction of the light
  31275. * @param color the color of the light
  31276. * @param deltaSolidAngle the delta solid angle of the light
  31277. */
  31278. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31279. /**
  31280. * Scales the spherical harmonics by the given amount
  31281. * @param scale the amount to scale
  31282. */
  31283. scaleInPlace(scale: number): void;
  31284. /**
  31285. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31286. *
  31287. * ```
  31288. * E_lm = A_l * L_lm
  31289. * ```
  31290. *
  31291. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31292. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31293. * the scaling factors are given in equation 9.
  31294. */
  31295. convertIncidentRadianceToIrradiance(): void;
  31296. /**
  31297. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31298. *
  31299. * ```
  31300. * L = (1/pi) * E * rho
  31301. * ```
  31302. *
  31303. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31304. */
  31305. convertIrradianceToLambertianRadiance(): void;
  31306. /**
  31307. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31308. * required operations at run time.
  31309. *
  31310. * This is simply done by scaling back the SH with Ylm constants parameter.
  31311. * The trigonometric part being applied by the shader at run time.
  31312. */
  31313. preScaleForRendering(): void;
  31314. /**
  31315. * Constructs a spherical harmonics from an array.
  31316. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31317. * @returns the spherical harmonics
  31318. */
  31319. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31320. /**
  31321. * Gets the spherical harmonics from polynomial
  31322. * @param polynomial the spherical polynomial
  31323. * @returns the spherical harmonics
  31324. */
  31325. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31326. }
  31327. /**
  31328. * Class representing spherical polynomial coefficients to the 3rd degree
  31329. */
  31330. export class SphericalPolynomial {
  31331. private _harmonics;
  31332. /**
  31333. * The spherical harmonics used to create the polynomials.
  31334. */
  31335. readonly preScaledHarmonics: SphericalHarmonics;
  31336. /**
  31337. * The x coefficients of the spherical polynomial
  31338. */
  31339. x: Vector3;
  31340. /**
  31341. * The y coefficients of the spherical polynomial
  31342. */
  31343. y: Vector3;
  31344. /**
  31345. * The z coefficients of the spherical polynomial
  31346. */
  31347. z: Vector3;
  31348. /**
  31349. * The xx coefficients of the spherical polynomial
  31350. */
  31351. xx: Vector3;
  31352. /**
  31353. * The yy coefficients of the spherical polynomial
  31354. */
  31355. yy: Vector3;
  31356. /**
  31357. * The zz coefficients of the spherical polynomial
  31358. */
  31359. zz: Vector3;
  31360. /**
  31361. * The xy coefficients of the spherical polynomial
  31362. */
  31363. xy: Vector3;
  31364. /**
  31365. * The yz coefficients of the spherical polynomial
  31366. */
  31367. yz: Vector3;
  31368. /**
  31369. * The zx coefficients of the spherical polynomial
  31370. */
  31371. zx: Vector3;
  31372. /**
  31373. * Adds an ambient color to the spherical polynomial
  31374. * @param color the color to add
  31375. */
  31376. addAmbient(color: Color3): void;
  31377. /**
  31378. * Scales the spherical polynomial by the given amount
  31379. * @param scale the amount to scale
  31380. */
  31381. scaleInPlace(scale: number): void;
  31382. /**
  31383. * Gets the spherical polynomial from harmonics
  31384. * @param harmonics the spherical harmonics
  31385. * @returns the spherical polynomial
  31386. */
  31387. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31388. /**
  31389. * Constructs a spherical polynomial from an array.
  31390. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31391. * @returns the spherical polynomial
  31392. */
  31393. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31394. }
  31395. }
  31396. declare module "babylonjs/Materials/Textures/internalTexture" {
  31397. import { Observable } from "babylonjs/Misc/observable";
  31398. import { Nullable, int } from "babylonjs/types";
  31399. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31401. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31402. /**
  31403. * Defines the source of the internal texture
  31404. */
  31405. export enum InternalTextureSource {
  31406. /**
  31407. * The source of the texture data is unknown
  31408. */
  31409. Unknown = 0,
  31410. /**
  31411. * Texture data comes from an URL
  31412. */
  31413. Url = 1,
  31414. /**
  31415. * Texture data is only used for temporary storage
  31416. */
  31417. Temp = 2,
  31418. /**
  31419. * Texture data comes from raw data (ArrayBuffer)
  31420. */
  31421. Raw = 3,
  31422. /**
  31423. * Texture content is dynamic (video or dynamic texture)
  31424. */
  31425. Dynamic = 4,
  31426. /**
  31427. * Texture content is generated by rendering to it
  31428. */
  31429. RenderTarget = 5,
  31430. /**
  31431. * Texture content is part of a multi render target process
  31432. */
  31433. MultiRenderTarget = 6,
  31434. /**
  31435. * Texture data comes from a cube data file
  31436. */
  31437. Cube = 7,
  31438. /**
  31439. * Texture data comes from a raw cube data
  31440. */
  31441. CubeRaw = 8,
  31442. /**
  31443. * Texture data come from a prefiltered cube data file
  31444. */
  31445. CubePrefiltered = 9,
  31446. /**
  31447. * Texture content is raw 3D data
  31448. */
  31449. Raw3D = 10,
  31450. /**
  31451. * Texture content is raw 2D array data
  31452. */
  31453. Raw2DArray = 11,
  31454. /**
  31455. * Texture content is a depth texture
  31456. */
  31457. Depth = 12,
  31458. /**
  31459. * Texture data comes from a raw cube data encoded with RGBD
  31460. */
  31461. CubeRawRGBD = 13
  31462. }
  31463. /**
  31464. * Class used to store data associated with WebGL texture data for the engine
  31465. * This class should not be used directly
  31466. */
  31467. export class InternalTexture {
  31468. /** @hidden */
  31469. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31470. /**
  31471. * Defines if the texture is ready
  31472. */
  31473. isReady: boolean;
  31474. /**
  31475. * Defines if the texture is a cube texture
  31476. */
  31477. isCube: boolean;
  31478. /**
  31479. * Defines if the texture contains 3D data
  31480. */
  31481. is3D: boolean;
  31482. /**
  31483. * Defines if the texture contains 2D array data
  31484. */
  31485. is2DArray: boolean;
  31486. /**
  31487. * Defines if the texture contains multiview data
  31488. */
  31489. isMultiview: boolean;
  31490. /**
  31491. * Gets the URL used to load this texture
  31492. */
  31493. url: string;
  31494. /**
  31495. * Gets the sampling mode of the texture
  31496. */
  31497. samplingMode: number;
  31498. /**
  31499. * Gets a boolean indicating if the texture needs mipmaps generation
  31500. */
  31501. generateMipMaps: boolean;
  31502. /**
  31503. * Gets the number of samples used by the texture (WebGL2+ only)
  31504. */
  31505. samples: number;
  31506. /**
  31507. * Gets the type of the texture (int, float...)
  31508. */
  31509. type: number;
  31510. /**
  31511. * Gets the format of the texture (RGB, RGBA...)
  31512. */
  31513. format: number;
  31514. /**
  31515. * Observable called when the texture is loaded
  31516. */
  31517. onLoadedObservable: Observable<InternalTexture>;
  31518. /**
  31519. * Gets the width of the texture
  31520. */
  31521. width: number;
  31522. /**
  31523. * Gets the height of the texture
  31524. */
  31525. height: number;
  31526. /**
  31527. * Gets the depth of the texture
  31528. */
  31529. depth: number;
  31530. /**
  31531. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31532. */
  31533. baseWidth: number;
  31534. /**
  31535. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31536. */
  31537. baseHeight: number;
  31538. /**
  31539. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31540. */
  31541. baseDepth: number;
  31542. /**
  31543. * Gets a boolean indicating if the texture is inverted on Y axis
  31544. */
  31545. invertY: boolean;
  31546. /** @hidden */
  31547. _invertVScale: boolean;
  31548. /** @hidden */
  31549. _associatedChannel: number;
  31550. /** @hidden */
  31551. _source: InternalTextureSource;
  31552. /** @hidden */
  31553. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31554. /** @hidden */
  31555. _bufferView: Nullable<ArrayBufferView>;
  31556. /** @hidden */
  31557. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31558. /** @hidden */
  31559. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31560. /** @hidden */
  31561. _size: number;
  31562. /** @hidden */
  31563. _extension: string;
  31564. /** @hidden */
  31565. _files: Nullable<string[]>;
  31566. /** @hidden */
  31567. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31568. /** @hidden */
  31569. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31570. /** @hidden */
  31571. _framebuffer: Nullable<WebGLFramebuffer>;
  31572. /** @hidden */
  31573. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31574. /** @hidden */
  31575. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31576. /** @hidden */
  31577. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31578. /** @hidden */
  31579. _attachments: Nullable<number[]>;
  31580. /** @hidden */
  31581. _cachedCoordinatesMode: Nullable<number>;
  31582. /** @hidden */
  31583. _cachedWrapU: Nullable<number>;
  31584. /** @hidden */
  31585. _cachedWrapV: Nullable<number>;
  31586. /** @hidden */
  31587. _cachedWrapR: Nullable<number>;
  31588. /** @hidden */
  31589. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31590. /** @hidden */
  31591. _isDisabled: boolean;
  31592. /** @hidden */
  31593. _compression: Nullable<string>;
  31594. /** @hidden */
  31595. _generateStencilBuffer: boolean;
  31596. /** @hidden */
  31597. _generateDepthBuffer: boolean;
  31598. /** @hidden */
  31599. _comparisonFunction: number;
  31600. /** @hidden */
  31601. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31602. /** @hidden */
  31603. _lodGenerationScale: number;
  31604. /** @hidden */
  31605. _lodGenerationOffset: number;
  31606. /** @hidden */
  31607. _colorTextureArray: Nullable<WebGLTexture>;
  31608. /** @hidden */
  31609. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31610. /** @hidden */
  31611. _lodTextureHigh: Nullable<BaseTexture>;
  31612. /** @hidden */
  31613. _lodTextureMid: Nullable<BaseTexture>;
  31614. /** @hidden */
  31615. _lodTextureLow: Nullable<BaseTexture>;
  31616. /** @hidden */
  31617. _isRGBD: boolean;
  31618. /** @hidden */
  31619. _linearSpecularLOD: boolean;
  31620. /** @hidden */
  31621. _irradianceTexture: Nullable<BaseTexture>;
  31622. /** @hidden */
  31623. _webGLTexture: Nullable<WebGLTexture>;
  31624. /** @hidden */
  31625. _references: number;
  31626. private _engine;
  31627. /**
  31628. * Gets the Engine the texture belongs to.
  31629. * @returns The babylon engine
  31630. */
  31631. getEngine(): ThinEngine;
  31632. /**
  31633. * Gets the data source type of the texture
  31634. */
  31635. readonly source: InternalTextureSource;
  31636. /**
  31637. * Creates a new InternalTexture
  31638. * @param engine defines the engine to use
  31639. * @param source defines the type of data that will be used
  31640. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31641. */
  31642. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31643. /**
  31644. * Increments the number of references (ie. the number of Texture that point to it)
  31645. */
  31646. incrementReferences(): void;
  31647. /**
  31648. * Change the size of the texture (not the size of the content)
  31649. * @param width defines the new width
  31650. * @param height defines the new height
  31651. * @param depth defines the new depth (1 by default)
  31652. */
  31653. updateSize(width: int, height: int, depth?: int): void;
  31654. /** @hidden */
  31655. _rebuild(): void;
  31656. /** @hidden */
  31657. _swapAndDie(target: InternalTexture): void;
  31658. /**
  31659. * Dispose the current allocated resources
  31660. */
  31661. dispose(): void;
  31662. }
  31663. }
  31664. declare module "babylonjs/Audio/analyser" {
  31665. import { Scene } from "babylonjs/scene";
  31666. /**
  31667. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31669. */
  31670. export class Analyser {
  31671. /**
  31672. * Gets or sets the smoothing
  31673. * @ignorenaming
  31674. */
  31675. SMOOTHING: number;
  31676. /**
  31677. * Gets or sets the FFT table size
  31678. * @ignorenaming
  31679. */
  31680. FFT_SIZE: number;
  31681. /**
  31682. * Gets or sets the bar graph amplitude
  31683. * @ignorenaming
  31684. */
  31685. BARGRAPHAMPLITUDE: number;
  31686. /**
  31687. * Gets or sets the position of the debug canvas
  31688. * @ignorenaming
  31689. */
  31690. DEBUGCANVASPOS: {
  31691. x: number;
  31692. y: number;
  31693. };
  31694. /**
  31695. * Gets or sets the debug canvas size
  31696. * @ignorenaming
  31697. */
  31698. DEBUGCANVASSIZE: {
  31699. width: number;
  31700. height: number;
  31701. };
  31702. private _byteFreqs;
  31703. private _byteTime;
  31704. private _floatFreqs;
  31705. private _webAudioAnalyser;
  31706. private _debugCanvas;
  31707. private _debugCanvasContext;
  31708. private _scene;
  31709. private _registerFunc;
  31710. private _audioEngine;
  31711. /**
  31712. * Creates a new analyser
  31713. * @param scene defines hosting scene
  31714. */
  31715. constructor(scene: Scene);
  31716. /**
  31717. * Get the number of data values you will have to play with for the visualization
  31718. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31719. * @returns a number
  31720. */
  31721. getFrequencyBinCount(): number;
  31722. /**
  31723. * Gets the current frequency data as a byte array
  31724. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31725. * @returns a Uint8Array
  31726. */
  31727. getByteFrequencyData(): Uint8Array;
  31728. /**
  31729. * Gets the current waveform as a byte array
  31730. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31731. * @returns a Uint8Array
  31732. */
  31733. getByteTimeDomainData(): Uint8Array;
  31734. /**
  31735. * Gets the current frequency data as a float array
  31736. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31737. * @returns a Float32Array
  31738. */
  31739. getFloatFrequencyData(): Float32Array;
  31740. /**
  31741. * Renders the debug canvas
  31742. */
  31743. drawDebugCanvas(): void;
  31744. /**
  31745. * Stops rendering the debug canvas and removes it
  31746. */
  31747. stopDebugCanvas(): void;
  31748. /**
  31749. * Connects two audio nodes
  31750. * @param inputAudioNode defines first node to connect
  31751. * @param outputAudioNode defines second node to connect
  31752. */
  31753. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31754. /**
  31755. * Releases all associated resources
  31756. */
  31757. dispose(): void;
  31758. }
  31759. }
  31760. declare module "babylonjs/Audio/audioEngine" {
  31761. import { IDisposable } from "babylonjs/scene";
  31762. import { Analyser } from "babylonjs/Audio/analyser";
  31763. import { Nullable } from "babylonjs/types";
  31764. import { Observable } from "babylonjs/Misc/observable";
  31765. /**
  31766. * This represents an audio engine and it is responsible
  31767. * to play, synchronize and analyse sounds throughout the application.
  31768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31769. */
  31770. export interface IAudioEngine extends IDisposable {
  31771. /**
  31772. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31773. */
  31774. readonly canUseWebAudio: boolean;
  31775. /**
  31776. * Gets the current AudioContext if available.
  31777. */
  31778. readonly audioContext: Nullable<AudioContext>;
  31779. /**
  31780. * The master gain node defines the global audio volume of your audio engine.
  31781. */
  31782. readonly masterGain: GainNode;
  31783. /**
  31784. * Gets whether or not mp3 are supported by your browser.
  31785. */
  31786. readonly isMP3supported: boolean;
  31787. /**
  31788. * Gets whether or not ogg are supported by your browser.
  31789. */
  31790. readonly isOGGsupported: boolean;
  31791. /**
  31792. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31793. * @ignoreNaming
  31794. */
  31795. WarnedWebAudioUnsupported: boolean;
  31796. /**
  31797. * Defines if the audio engine relies on a custom unlocked button.
  31798. * In this case, the embedded button will not be displayed.
  31799. */
  31800. useCustomUnlockedButton: boolean;
  31801. /**
  31802. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31803. */
  31804. readonly unlocked: boolean;
  31805. /**
  31806. * Event raised when audio has been unlocked on the browser.
  31807. */
  31808. onAudioUnlockedObservable: Observable<AudioEngine>;
  31809. /**
  31810. * Event raised when audio has been locked on the browser.
  31811. */
  31812. onAudioLockedObservable: Observable<AudioEngine>;
  31813. /**
  31814. * Flags the audio engine in Locked state.
  31815. * This happens due to new browser policies preventing audio to autoplay.
  31816. */
  31817. lock(): void;
  31818. /**
  31819. * Unlocks the audio engine once a user action has been done on the dom.
  31820. * This is helpful to resume play once browser policies have been satisfied.
  31821. */
  31822. unlock(): void;
  31823. }
  31824. /**
  31825. * This represents the default audio engine used in babylon.
  31826. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31828. */
  31829. export class AudioEngine implements IAudioEngine {
  31830. private _audioContext;
  31831. private _audioContextInitialized;
  31832. private _muteButton;
  31833. private _hostElement;
  31834. /**
  31835. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31836. */
  31837. canUseWebAudio: boolean;
  31838. /**
  31839. * The master gain node defines the global audio volume of your audio engine.
  31840. */
  31841. masterGain: GainNode;
  31842. /**
  31843. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31844. * @ignoreNaming
  31845. */
  31846. WarnedWebAudioUnsupported: boolean;
  31847. /**
  31848. * Gets whether or not mp3 are supported by your browser.
  31849. */
  31850. isMP3supported: boolean;
  31851. /**
  31852. * Gets whether or not ogg are supported by your browser.
  31853. */
  31854. isOGGsupported: boolean;
  31855. /**
  31856. * Gets whether audio has been unlocked on the device.
  31857. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31858. * a user interaction has happened.
  31859. */
  31860. unlocked: boolean;
  31861. /**
  31862. * Defines if the audio engine relies on a custom unlocked button.
  31863. * In this case, the embedded button will not be displayed.
  31864. */
  31865. useCustomUnlockedButton: boolean;
  31866. /**
  31867. * Event raised when audio has been unlocked on the browser.
  31868. */
  31869. onAudioUnlockedObservable: Observable<AudioEngine>;
  31870. /**
  31871. * Event raised when audio has been locked on the browser.
  31872. */
  31873. onAudioLockedObservable: Observable<AudioEngine>;
  31874. /**
  31875. * Gets the current AudioContext if available.
  31876. */
  31877. readonly audioContext: Nullable<AudioContext>;
  31878. private _connectedAnalyser;
  31879. /**
  31880. * Instantiates a new audio engine.
  31881. *
  31882. * There should be only one per page as some browsers restrict the number
  31883. * of audio contexts you can create.
  31884. * @param hostElement defines the host element where to display the mute icon if necessary
  31885. */
  31886. constructor(hostElement?: Nullable<HTMLElement>);
  31887. /**
  31888. * Flags the audio engine in Locked state.
  31889. * This happens due to new browser policies preventing audio to autoplay.
  31890. */
  31891. lock(): void;
  31892. /**
  31893. * Unlocks the audio engine once a user action has been done on the dom.
  31894. * This is helpful to resume play once browser policies have been satisfied.
  31895. */
  31896. unlock(): void;
  31897. private _resumeAudioContext;
  31898. private _initializeAudioContext;
  31899. private _tryToRun;
  31900. private _triggerRunningState;
  31901. private _triggerSuspendedState;
  31902. private _displayMuteButton;
  31903. private _moveButtonToTopLeft;
  31904. private _onResize;
  31905. private _hideMuteButton;
  31906. /**
  31907. * Destroy and release the resources associated with the audio ccontext.
  31908. */
  31909. dispose(): void;
  31910. /**
  31911. * Gets the global volume sets on the master gain.
  31912. * @returns the global volume if set or -1 otherwise
  31913. */
  31914. getGlobalVolume(): number;
  31915. /**
  31916. * Sets the global volume of your experience (sets on the master gain).
  31917. * @param newVolume Defines the new global volume of the application
  31918. */
  31919. setGlobalVolume(newVolume: number): void;
  31920. /**
  31921. * Connect the audio engine to an audio analyser allowing some amazing
  31922. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31924. * @param analyser The analyser to connect to the engine
  31925. */
  31926. connectToAnalyser(analyser: Analyser): void;
  31927. }
  31928. }
  31929. declare module "babylonjs/Loading/loadingScreen" {
  31930. /**
  31931. * Interface used to present a loading screen while loading a scene
  31932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31933. */
  31934. export interface ILoadingScreen {
  31935. /**
  31936. * Function called to display the loading screen
  31937. */
  31938. displayLoadingUI: () => void;
  31939. /**
  31940. * Function called to hide the loading screen
  31941. */
  31942. hideLoadingUI: () => void;
  31943. /**
  31944. * Gets or sets the color to use for the background
  31945. */
  31946. loadingUIBackgroundColor: string;
  31947. /**
  31948. * Gets or sets the text to display while loading
  31949. */
  31950. loadingUIText: string;
  31951. }
  31952. /**
  31953. * Class used for the default loading screen
  31954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31955. */
  31956. export class DefaultLoadingScreen implements ILoadingScreen {
  31957. private _renderingCanvas;
  31958. private _loadingText;
  31959. private _loadingDivBackgroundColor;
  31960. private _loadingDiv;
  31961. private _loadingTextDiv;
  31962. /** Gets or sets the logo url to use for the default loading screen */
  31963. static DefaultLogoUrl: string;
  31964. /** Gets or sets the spinner url to use for the default loading screen */
  31965. static DefaultSpinnerUrl: string;
  31966. /**
  31967. * Creates a new default loading screen
  31968. * @param _renderingCanvas defines the canvas used to render the scene
  31969. * @param _loadingText defines the default text to display
  31970. * @param _loadingDivBackgroundColor defines the default background color
  31971. */
  31972. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31973. /**
  31974. * Function called to display the loading screen
  31975. */
  31976. displayLoadingUI(): void;
  31977. /**
  31978. * Function called to hide the loading screen
  31979. */
  31980. hideLoadingUI(): void;
  31981. /**
  31982. * Gets or sets the text to display while loading
  31983. */
  31984. loadingUIText: string;
  31985. /**
  31986. * Gets or sets the color to use for the background
  31987. */
  31988. loadingUIBackgroundColor: string;
  31989. private _resizeLoadingUI;
  31990. }
  31991. }
  31992. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31993. /**
  31994. * Interface for any object that can request an animation frame
  31995. */
  31996. export interface ICustomAnimationFrameRequester {
  31997. /**
  31998. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31999. */
  32000. renderFunction?: Function;
  32001. /**
  32002. * Called to request the next frame to render to
  32003. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32004. */
  32005. requestAnimationFrame: Function;
  32006. /**
  32007. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32008. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32009. */
  32010. requestID?: number;
  32011. }
  32012. }
  32013. declare module "babylonjs/Misc/performanceMonitor" {
  32014. /**
  32015. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32016. */
  32017. export class PerformanceMonitor {
  32018. private _enabled;
  32019. private _rollingFrameTime;
  32020. private _lastFrameTimeMs;
  32021. /**
  32022. * constructor
  32023. * @param frameSampleSize The number of samples required to saturate the sliding window
  32024. */
  32025. constructor(frameSampleSize?: number);
  32026. /**
  32027. * Samples current frame
  32028. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32029. */
  32030. sampleFrame(timeMs?: number): void;
  32031. /**
  32032. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32033. */
  32034. readonly averageFrameTime: number;
  32035. /**
  32036. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32037. */
  32038. readonly averageFrameTimeVariance: number;
  32039. /**
  32040. * Returns the frame time of the most recent frame
  32041. */
  32042. readonly instantaneousFrameTime: number;
  32043. /**
  32044. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32045. */
  32046. readonly averageFPS: number;
  32047. /**
  32048. * Returns the average framerate in frames per second using the most recent frame time
  32049. */
  32050. readonly instantaneousFPS: number;
  32051. /**
  32052. * Returns true if enough samples have been taken to completely fill the sliding window
  32053. */
  32054. readonly isSaturated: boolean;
  32055. /**
  32056. * Enables contributions to the sliding window sample set
  32057. */
  32058. enable(): void;
  32059. /**
  32060. * Disables contributions to the sliding window sample set
  32061. * Samples will not be interpolated over the disabled period
  32062. */
  32063. disable(): void;
  32064. /**
  32065. * Returns true if sampling is enabled
  32066. */
  32067. readonly isEnabled: boolean;
  32068. /**
  32069. * Resets performance monitor
  32070. */
  32071. reset(): void;
  32072. }
  32073. /**
  32074. * RollingAverage
  32075. *
  32076. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32077. */
  32078. export class RollingAverage {
  32079. /**
  32080. * Current average
  32081. */
  32082. average: number;
  32083. /**
  32084. * Current variance
  32085. */
  32086. variance: number;
  32087. protected _samples: Array<number>;
  32088. protected _sampleCount: number;
  32089. protected _pos: number;
  32090. protected _m2: number;
  32091. /**
  32092. * constructor
  32093. * @param length The number of samples required to saturate the sliding window
  32094. */
  32095. constructor(length: number);
  32096. /**
  32097. * Adds a sample to the sample set
  32098. * @param v The sample value
  32099. */
  32100. add(v: number): void;
  32101. /**
  32102. * Returns previously added values or null if outside of history or outside the sliding window domain
  32103. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32104. * @return Value previously recorded with add() or null if outside of range
  32105. */
  32106. history(i: number): number;
  32107. /**
  32108. * Returns true if enough samples have been taken to completely fill the sliding window
  32109. * @return true if sample-set saturated
  32110. */
  32111. isSaturated(): boolean;
  32112. /**
  32113. * Resets the rolling average (equivalent to 0 samples taken so far)
  32114. */
  32115. reset(): void;
  32116. /**
  32117. * Wraps a value around the sample range boundaries
  32118. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32119. * @return Wrapped position in sample range
  32120. */
  32121. protected _wrapPosition(i: number): number;
  32122. }
  32123. }
  32124. declare module "babylonjs/Misc/perfCounter" {
  32125. /**
  32126. * This class is used to track a performance counter which is number based.
  32127. * The user has access to many properties which give statistics of different nature.
  32128. *
  32129. * The implementer can track two kinds of Performance Counter: time and count.
  32130. * 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.
  32131. * 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.
  32132. */
  32133. export class PerfCounter {
  32134. /**
  32135. * Gets or sets a global boolean to turn on and off all the counters
  32136. */
  32137. static Enabled: boolean;
  32138. /**
  32139. * Returns the smallest value ever
  32140. */
  32141. readonly min: number;
  32142. /**
  32143. * Returns the biggest value ever
  32144. */
  32145. readonly max: number;
  32146. /**
  32147. * Returns the average value since the performance counter is running
  32148. */
  32149. readonly average: number;
  32150. /**
  32151. * Returns the average value of the last second the counter was monitored
  32152. */
  32153. readonly lastSecAverage: number;
  32154. /**
  32155. * Returns the current value
  32156. */
  32157. readonly current: number;
  32158. /**
  32159. * Gets the accumulated total
  32160. */
  32161. readonly total: number;
  32162. /**
  32163. * Gets the total value count
  32164. */
  32165. readonly count: number;
  32166. /**
  32167. * Creates a new counter
  32168. */
  32169. constructor();
  32170. /**
  32171. * Call this method to start monitoring a new frame.
  32172. * 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.
  32173. */
  32174. fetchNewFrame(): void;
  32175. /**
  32176. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32177. * @param newCount the count value to add to the monitored count
  32178. * @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.
  32179. */
  32180. addCount(newCount: number, fetchResult: boolean): void;
  32181. /**
  32182. * Start monitoring this performance counter
  32183. */
  32184. beginMonitoring(): void;
  32185. /**
  32186. * Compute the time lapsed since the previous beginMonitoring() call.
  32187. * @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
  32188. */
  32189. endMonitoring(newFrame?: boolean): void;
  32190. private _fetchResult;
  32191. private _startMonitoringTime;
  32192. private _min;
  32193. private _max;
  32194. private _average;
  32195. private _current;
  32196. private _totalValueCount;
  32197. private _totalAccumulated;
  32198. private _lastSecAverage;
  32199. private _lastSecAccumulated;
  32200. private _lastSecTime;
  32201. private _lastSecValueCount;
  32202. }
  32203. }
  32204. declare module "babylonjs/Engines/engine" {
  32205. import { Observable } from "babylonjs/Misc/observable";
  32206. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32207. import { Scene } from "babylonjs/scene";
  32208. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32209. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32210. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32211. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32212. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32213. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32214. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32215. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32216. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32218. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32219. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32220. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32221. import { Material } from "babylonjs/Materials/material";
  32222. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32223. /**
  32224. * Defines the interface used by display changed events
  32225. */
  32226. export interface IDisplayChangedEventArgs {
  32227. /** Gets the vrDisplay object (if any) */
  32228. vrDisplay: Nullable<any>;
  32229. /** Gets a boolean indicating if webVR is supported */
  32230. vrSupported: boolean;
  32231. }
  32232. /**
  32233. * Defines the interface used by objects containing a viewport (like a camera)
  32234. */
  32235. interface IViewportOwnerLike {
  32236. /**
  32237. * Gets or sets the viewport
  32238. */
  32239. viewport: IViewportLike;
  32240. }
  32241. /**
  32242. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32243. */
  32244. export class Engine extends ThinEngine {
  32245. /** Defines that alpha blending is disabled */
  32246. static readonly ALPHA_DISABLE: number;
  32247. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32248. static readonly ALPHA_ADD: number;
  32249. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32250. static readonly ALPHA_COMBINE: number;
  32251. /** Defines that alpha blending to DEST - SRC * DEST */
  32252. static readonly ALPHA_SUBTRACT: number;
  32253. /** Defines that alpha blending to SRC * DEST */
  32254. static readonly ALPHA_MULTIPLY: number;
  32255. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32256. static readonly ALPHA_MAXIMIZED: number;
  32257. /** Defines that alpha blending to SRC + DEST */
  32258. static readonly ALPHA_ONEONE: number;
  32259. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32260. static readonly ALPHA_PREMULTIPLIED: number;
  32261. /**
  32262. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32263. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32264. */
  32265. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32266. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32267. static readonly ALPHA_INTERPOLATE: number;
  32268. /**
  32269. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32270. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32271. */
  32272. static readonly ALPHA_SCREENMODE: number;
  32273. /** Defines that the ressource is not delayed*/
  32274. static readonly DELAYLOADSTATE_NONE: number;
  32275. /** Defines that the ressource was successfully delay loaded */
  32276. static readonly DELAYLOADSTATE_LOADED: number;
  32277. /** Defines that the ressource is currently delay loading */
  32278. static readonly DELAYLOADSTATE_LOADING: number;
  32279. /** Defines that the ressource is delayed and has not started loading */
  32280. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32281. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32282. static readonly NEVER: number;
  32283. /** 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 */
  32284. static readonly ALWAYS: number;
  32285. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32286. static readonly LESS: number;
  32287. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32288. static readonly EQUAL: number;
  32289. /** 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 */
  32290. static readonly LEQUAL: number;
  32291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32292. static readonly GREATER: number;
  32293. /** 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 */
  32294. static readonly GEQUAL: number;
  32295. /** 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 */
  32296. static readonly NOTEQUAL: number;
  32297. /** Passed to stencilOperation to specify that stencil value must be kept */
  32298. static readonly KEEP: number;
  32299. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32300. static readonly REPLACE: number;
  32301. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32302. static readonly INCR: number;
  32303. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32304. static readonly DECR: number;
  32305. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32306. static readonly INVERT: number;
  32307. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32308. static readonly INCR_WRAP: number;
  32309. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32310. static readonly DECR_WRAP: number;
  32311. /** Texture is not repeating outside of 0..1 UVs */
  32312. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32313. /** Texture is repeating outside of 0..1 UVs */
  32314. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32315. /** Texture is repeating and mirrored */
  32316. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32317. /** ALPHA */
  32318. static readonly TEXTUREFORMAT_ALPHA: number;
  32319. /** LUMINANCE */
  32320. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32321. /** LUMINANCE_ALPHA */
  32322. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32323. /** RGB */
  32324. static readonly TEXTUREFORMAT_RGB: number;
  32325. /** RGBA */
  32326. static readonly TEXTUREFORMAT_RGBA: number;
  32327. /** RED */
  32328. static readonly TEXTUREFORMAT_RED: number;
  32329. /** RED (2nd reference) */
  32330. static readonly TEXTUREFORMAT_R: number;
  32331. /** RG */
  32332. static readonly TEXTUREFORMAT_RG: number;
  32333. /** RED_INTEGER */
  32334. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32335. /** RED_INTEGER (2nd reference) */
  32336. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32337. /** RG_INTEGER */
  32338. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32339. /** RGB_INTEGER */
  32340. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32341. /** RGBA_INTEGER */
  32342. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32343. /** UNSIGNED_BYTE */
  32344. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32345. /** UNSIGNED_BYTE (2nd reference) */
  32346. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32347. /** FLOAT */
  32348. static readonly TEXTURETYPE_FLOAT: number;
  32349. /** HALF_FLOAT */
  32350. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32351. /** BYTE */
  32352. static readonly TEXTURETYPE_BYTE: number;
  32353. /** SHORT */
  32354. static readonly TEXTURETYPE_SHORT: number;
  32355. /** UNSIGNED_SHORT */
  32356. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32357. /** INT */
  32358. static readonly TEXTURETYPE_INT: number;
  32359. /** UNSIGNED_INT */
  32360. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32361. /** UNSIGNED_SHORT_4_4_4_4 */
  32362. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32363. /** UNSIGNED_SHORT_5_5_5_1 */
  32364. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32365. /** UNSIGNED_SHORT_5_6_5 */
  32366. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32367. /** UNSIGNED_INT_2_10_10_10_REV */
  32368. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32369. /** UNSIGNED_INT_24_8 */
  32370. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32371. /** UNSIGNED_INT_10F_11F_11F_REV */
  32372. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32373. /** UNSIGNED_INT_5_9_9_9_REV */
  32374. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32375. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32376. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32377. /** nearest is mag = nearest and min = nearest and mip = linear */
  32378. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32379. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32380. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32381. /** Trilinear is mag = linear and min = linear and mip = linear */
  32382. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32383. /** nearest is mag = nearest and min = nearest and mip = linear */
  32384. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32385. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32386. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32387. /** Trilinear is mag = linear and min = linear and mip = linear */
  32388. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32389. /** mag = nearest and min = nearest and mip = nearest */
  32390. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32391. /** mag = nearest and min = linear and mip = nearest */
  32392. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32393. /** mag = nearest and min = linear and mip = linear */
  32394. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32395. /** mag = nearest and min = linear and mip = none */
  32396. static readonly TEXTURE_NEAREST_LINEAR: number;
  32397. /** mag = nearest and min = nearest and mip = none */
  32398. static readonly TEXTURE_NEAREST_NEAREST: number;
  32399. /** mag = linear and min = nearest and mip = nearest */
  32400. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32401. /** mag = linear and min = nearest and mip = linear */
  32402. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32403. /** mag = linear and min = linear and mip = none */
  32404. static readonly TEXTURE_LINEAR_LINEAR: number;
  32405. /** mag = linear and min = nearest and mip = none */
  32406. static readonly TEXTURE_LINEAR_NEAREST: number;
  32407. /** Explicit coordinates mode */
  32408. static readonly TEXTURE_EXPLICIT_MODE: number;
  32409. /** Spherical coordinates mode */
  32410. static readonly TEXTURE_SPHERICAL_MODE: number;
  32411. /** Planar coordinates mode */
  32412. static readonly TEXTURE_PLANAR_MODE: number;
  32413. /** Cubic coordinates mode */
  32414. static readonly TEXTURE_CUBIC_MODE: number;
  32415. /** Projection coordinates mode */
  32416. static readonly TEXTURE_PROJECTION_MODE: number;
  32417. /** Skybox coordinates mode */
  32418. static readonly TEXTURE_SKYBOX_MODE: number;
  32419. /** Inverse Cubic coordinates mode */
  32420. static readonly TEXTURE_INVCUBIC_MODE: number;
  32421. /** Equirectangular coordinates mode */
  32422. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32423. /** Equirectangular Fixed coordinates mode */
  32424. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32425. /** Equirectangular Fixed Mirrored coordinates mode */
  32426. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32427. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32428. static readonly SCALEMODE_FLOOR: number;
  32429. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32430. static readonly SCALEMODE_NEAREST: number;
  32431. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32432. static readonly SCALEMODE_CEILING: number;
  32433. /**
  32434. * Returns the current npm package of the sdk
  32435. */
  32436. static readonly NpmPackage: string;
  32437. /**
  32438. * Returns the current version of the framework
  32439. */
  32440. static readonly Version: string;
  32441. /** Gets the list of created engines */
  32442. static readonly Instances: Engine[];
  32443. /**
  32444. * Gets the latest created engine
  32445. */
  32446. static readonly LastCreatedEngine: Nullable<Engine>;
  32447. /**
  32448. * Gets the latest created scene
  32449. */
  32450. static readonly LastCreatedScene: Nullable<Scene>;
  32451. /**
  32452. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32453. * @param flag defines which part of the materials must be marked as dirty
  32454. * @param predicate defines a predicate used to filter which materials should be affected
  32455. */
  32456. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32457. /**
  32458. * Method called to create the default loading screen.
  32459. * This can be overriden in your own app.
  32460. * @param canvas The rendering canvas element
  32461. * @returns The loading screen
  32462. */
  32463. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32464. /**
  32465. * Method called to create the default rescale post process on each engine.
  32466. */
  32467. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32468. /**
  32469. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32470. **/
  32471. enableOfflineSupport: boolean;
  32472. /**
  32473. * 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)
  32474. **/
  32475. disableManifestCheck: boolean;
  32476. /**
  32477. * Gets the list of created scenes
  32478. */
  32479. scenes: Scene[];
  32480. /**
  32481. * Event raised when a new scene is created
  32482. */
  32483. onNewSceneAddedObservable: Observable<Scene>;
  32484. /**
  32485. * Gets the list of created postprocesses
  32486. */
  32487. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32488. /**
  32489. * Gets a boolean indicating if the pointer is currently locked
  32490. */
  32491. isPointerLock: boolean;
  32492. /**
  32493. * Observable event triggered each time the rendering canvas is resized
  32494. */
  32495. onResizeObservable: Observable<Engine>;
  32496. /**
  32497. * Observable event triggered each time the canvas loses focus
  32498. */
  32499. onCanvasBlurObservable: Observable<Engine>;
  32500. /**
  32501. * Observable event triggered each time the canvas gains focus
  32502. */
  32503. onCanvasFocusObservable: Observable<Engine>;
  32504. /**
  32505. * Observable event triggered each time the canvas receives pointerout event
  32506. */
  32507. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32508. /**
  32509. * Observable raised when the engine begins a new frame
  32510. */
  32511. onBeginFrameObservable: Observable<Engine>;
  32512. /**
  32513. * If set, will be used to request the next animation frame for the render loop
  32514. */
  32515. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32516. /**
  32517. * Observable raised when the engine ends the current frame
  32518. */
  32519. onEndFrameObservable: Observable<Engine>;
  32520. /**
  32521. * Observable raised when the engine is about to compile a shader
  32522. */
  32523. onBeforeShaderCompilationObservable: Observable<Engine>;
  32524. /**
  32525. * Observable raised when the engine has jsut compiled a shader
  32526. */
  32527. onAfterShaderCompilationObservable: Observable<Engine>;
  32528. /**
  32529. * Gets the audio engine
  32530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32531. * @ignorenaming
  32532. */
  32533. static audioEngine: IAudioEngine;
  32534. /**
  32535. * Default AudioEngine factory responsible of creating the Audio Engine.
  32536. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32537. */
  32538. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32539. /**
  32540. * Default offline support factory responsible of creating a tool used to store data locally.
  32541. * By default, this will create a Database object if the workload has been embedded.
  32542. */
  32543. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32544. private _loadingScreen;
  32545. private _pointerLockRequested;
  32546. private _dummyFramebuffer;
  32547. private _rescalePostProcess;
  32548. /** @hidden */
  32549. protected _alphaMode: number;
  32550. /** @hidden */
  32551. protected _alphaEquation: number;
  32552. private _deterministicLockstep;
  32553. private _lockstepMaxSteps;
  32554. protected readonly _supportsHardwareTextureRescaling: boolean;
  32555. private _fps;
  32556. private _deltaTime;
  32557. /** @hidden */
  32558. _drawCalls: PerfCounter;
  32559. /**
  32560. * Turn this value on if you want to pause FPS computation when in background
  32561. */
  32562. disablePerformanceMonitorInBackground: boolean;
  32563. private _performanceMonitor;
  32564. /**
  32565. * Gets the performance monitor attached to this engine
  32566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32567. */
  32568. readonly performanceMonitor: PerformanceMonitor;
  32569. private _onFocus;
  32570. private _onBlur;
  32571. private _onCanvasPointerOut;
  32572. private _onCanvasBlur;
  32573. private _onCanvasFocus;
  32574. private _onFullscreenChange;
  32575. private _onPointerLockChange;
  32576. /**
  32577. * Gets the HTML element used to attach event listeners
  32578. * @returns a HTML element
  32579. */
  32580. getInputElement(): Nullable<HTMLElement>;
  32581. /**
  32582. * Creates a new engine
  32583. * @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
  32584. * @param antialias defines enable antialiasing (default: false)
  32585. * @param options defines further options to be sent to the getContext() function
  32586. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32587. */
  32588. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32589. /**
  32590. * Gets current aspect ratio
  32591. * @param viewportOwner defines the camera to use to get the aspect ratio
  32592. * @param useScreen defines if screen size must be used (or the current render target if any)
  32593. * @returns a number defining the aspect ratio
  32594. */
  32595. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32596. /**
  32597. * Gets current screen aspect ratio
  32598. * @returns a number defining the aspect ratio
  32599. */
  32600. getScreenAspectRatio(): number;
  32601. /**
  32602. * Gets host document
  32603. * @returns the host document object
  32604. */
  32605. getHostDocument(): Document;
  32606. /**
  32607. * Gets the client rect of the HTML canvas attached with the current webGL context
  32608. * @returns a client rectanglee
  32609. */
  32610. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32611. /**
  32612. * Gets the client rect of the HTML element used for events
  32613. * @returns a client rectanglee
  32614. */
  32615. getInputElementClientRect(): Nullable<ClientRect>;
  32616. /**
  32617. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32619. * @returns true if engine is in deterministic lock step mode
  32620. */
  32621. isDeterministicLockStep(): boolean;
  32622. /**
  32623. * Gets the max steps when engine is running in deterministic lock step
  32624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32625. * @returns the max steps
  32626. */
  32627. getLockstepMaxSteps(): number;
  32628. /**
  32629. * Force the mipmap generation for the given render target texture
  32630. * @param texture defines the render target texture to use
  32631. */
  32632. generateMipMapsForCubemap(texture: InternalTexture): void;
  32633. /** States */
  32634. /**
  32635. * Set various states to the webGL context
  32636. * @param culling defines backface culling state
  32637. * @param zOffset defines the value to apply to zOffset (0 by default)
  32638. * @param force defines if states must be applied even if cache is up to date
  32639. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32640. */
  32641. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32642. /**
  32643. * Set the z offset to apply to current rendering
  32644. * @param value defines the offset to apply
  32645. */
  32646. setZOffset(value: number): void;
  32647. /**
  32648. * Gets the current value of the zOffset
  32649. * @returns the current zOffset state
  32650. */
  32651. getZOffset(): number;
  32652. /**
  32653. * Enable or disable depth buffering
  32654. * @param enable defines the state to set
  32655. */
  32656. setDepthBuffer(enable: boolean): void;
  32657. /**
  32658. * Gets a boolean indicating if depth writing is enabled
  32659. * @returns the current depth writing state
  32660. */
  32661. getDepthWrite(): boolean;
  32662. /**
  32663. * Enable or disable depth writing
  32664. * @param enable defines the state to set
  32665. */
  32666. setDepthWrite(enable: boolean): void;
  32667. /**
  32668. * Enable or disable color writing
  32669. * @param enable defines the state to set
  32670. */
  32671. setColorWrite(enable: boolean): void;
  32672. /**
  32673. * Gets a boolean indicating if color writing is enabled
  32674. * @returns the current color writing state
  32675. */
  32676. getColorWrite(): boolean;
  32677. /**
  32678. * Sets alpha constants used by some alpha blending modes
  32679. * @param r defines the red component
  32680. * @param g defines the green component
  32681. * @param b defines the blue component
  32682. * @param a defines the alpha component
  32683. */
  32684. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32685. /**
  32686. * Sets the current alpha mode
  32687. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32688. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32689. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32690. */
  32691. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32692. /**
  32693. * Gets the current alpha mode
  32694. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32695. * @returns the current alpha mode
  32696. */
  32697. getAlphaMode(): number;
  32698. /**
  32699. * Sets the current alpha equation
  32700. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32701. */
  32702. setAlphaEquation(equation: number): void;
  32703. /**
  32704. * Gets the current alpha equation.
  32705. * @returns the current alpha equation
  32706. */
  32707. getAlphaEquation(): number;
  32708. /**
  32709. * Gets a boolean indicating if stencil buffer is enabled
  32710. * @returns the current stencil buffer state
  32711. */
  32712. getStencilBuffer(): boolean;
  32713. /**
  32714. * Enable or disable the stencil buffer
  32715. * @param enable defines if the stencil buffer must be enabled or disabled
  32716. */
  32717. setStencilBuffer(enable: boolean): void;
  32718. /**
  32719. * Gets the current stencil mask
  32720. * @returns a number defining the new stencil mask to use
  32721. */
  32722. getStencilMask(): number;
  32723. /**
  32724. * Sets the current stencil mask
  32725. * @param mask defines the new stencil mask to use
  32726. */
  32727. setStencilMask(mask: number): void;
  32728. /**
  32729. * Gets the current stencil function
  32730. * @returns a number defining the stencil function to use
  32731. */
  32732. getStencilFunction(): number;
  32733. /**
  32734. * Gets the current stencil reference value
  32735. * @returns a number defining the stencil reference value to use
  32736. */
  32737. getStencilFunctionReference(): number;
  32738. /**
  32739. * Gets the current stencil mask
  32740. * @returns a number defining the stencil mask to use
  32741. */
  32742. getStencilFunctionMask(): number;
  32743. /**
  32744. * Sets the current stencil function
  32745. * @param stencilFunc defines the new stencil function to use
  32746. */
  32747. setStencilFunction(stencilFunc: number): void;
  32748. /**
  32749. * Sets the current stencil reference
  32750. * @param reference defines the new stencil reference to use
  32751. */
  32752. setStencilFunctionReference(reference: number): void;
  32753. /**
  32754. * Sets the current stencil mask
  32755. * @param mask defines the new stencil mask to use
  32756. */
  32757. setStencilFunctionMask(mask: number): void;
  32758. /**
  32759. * Gets the current stencil operation when stencil fails
  32760. * @returns a number defining stencil operation to use when stencil fails
  32761. */
  32762. getStencilOperationFail(): number;
  32763. /**
  32764. * Gets the current stencil operation when depth fails
  32765. * @returns a number defining stencil operation to use when depth fails
  32766. */
  32767. getStencilOperationDepthFail(): number;
  32768. /**
  32769. * Gets the current stencil operation when stencil passes
  32770. * @returns a number defining stencil operation to use when stencil passes
  32771. */
  32772. getStencilOperationPass(): number;
  32773. /**
  32774. * Sets the stencil operation to use when stencil fails
  32775. * @param operation defines the stencil operation to use when stencil fails
  32776. */
  32777. setStencilOperationFail(operation: number): void;
  32778. /**
  32779. * Sets the stencil operation to use when depth fails
  32780. * @param operation defines the stencil operation to use when depth fails
  32781. */
  32782. setStencilOperationDepthFail(operation: number): void;
  32783. /**
  32784. * Sets the stencil operation to use when stencil passes
  32785. * @param operation defines the stencil operation to use when stencil passes
  32786. */
  32787. setStencilOperationPass(operation: number): void;
  32788. /**
  32789. * Sets a boolean indicating if the dithering state is enabled or disabled
  32790. * @param value defines the dithering state
  32791. */
  32792. setDitheringState(value: boolean): void;
  32793. /**
  32794. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32795. * @param value defines the rasterizer state
  32796. */
  32797. setRasterizerState(value: boolean): void;
  32798. /**
  32799. * Gets the current depth function
  32800. * @returns a number defining the depth function
  32801. */
  32802. getDepthFunction(): Nullable<number>;
  32803. /**
  32804. * Sets the current depth function
  32805. * @param depthFunc defines the function to use
  32806. */
  32807. setDepthFunction(depthFunc: number): void;
  32808. /**
  32809. * Sets the current depth function to GREATER
  32810. */
  32811. setDepthFunctionToGreater(): void;
  32812. /**
  32813. * Sets the current depth function to GEQUAL
  32814. */
  32815. setDepthFunctionToGreaterOrEqual(): void;
  32816. /**
  32817. * Sets the current depth function to LESS
  32818. */
  32819. setDepthFunctionToLess(): void;
  32820. /**
  32821. * Sets the current depth function to LEQUAL
  32822. */
  32823. setDepthFunctionToLessOrEqual(): void;
  32824. private _cachedStencilBuffer;
  32825. private _cachedStencilFunction;
  32826. private _cachedStencilMask;
  32827. private _cachedStencilOperationPass;
  32828. private _cachedStencilOperationFail;
  32829. private _cachedStencilOperationDepthFail;
  32830. private _cachedStencilReference;
  32831. /**
  32832. * Caches the the state of the stencil buffer
  32833. */
  32834. cacheStencilState(): void;
  32835. /**
  32836. * Restores the state of the stencil buffer
  32837. */
  32838. restoreStencilState(): void;
  32839. /**
  32840. * Directly set the WebGL Viewport
  32841. * @param x defines the x coordinate of the viewport (in screen space)
  32842. * @param y defines the y coordinate of the viewport (in screen space)
  32843. * @param width defines the width of the viewport (in screen space)
  32844. * @param height defines the height of the viewport (in screen space)
  32845. * @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
  32846. */
  32847. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32848. /**
  32849. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32850. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32851. * @param y defines the y-coordinate of the corner of the clear rectangle
  32852. * @param width defines the width of the clear rectangle
  32853. * @param height defines the height of the clear rectangle
  32854. * @param clearColor defines the clear color
  32855. */
  32856. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32857. /**
  32858. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32859. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32860. * @param y defines the y-coordinate of the corner of the clear rectangle
  32861. * @param width defines the width of the clear rectangle
  32862. * @param height defines the height of the clear rectangle
  32863. */
  32864. enableScissor(x: number, y: number, width: number, height: number): void;
  32865. /**
  32866. * Disable previously set scissor test rectangle
  32867. */
  32868. disableScissor(): void;
  32869. protected _reportDrawCall(): void;
  32870. /**
  32871. * Initializes a webVR display and starts listening to display change events
  32872. * The onVRDisplayChangedObservable will be notified upon these changes
  32873. * @returns The onVRDisplayChangedObservable
  32874. */
  32875. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32876. /** @hidden */
  32877. _prepareVRComponent(): void;
  32878. /** @hidden */
  32879. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32880. /** @hidden */
  32881. _submitVRFrame(): void;
  32882. /**
  32883. * Call this function to leave webVR mode
  32884. * Will do nothing if webVR is not supported or if there is no webVR device
  32885. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32886. */
  32887. disableVR(): void;
  32888. /**
  32889. * Gets a boolean indicating that the system is in VR mode and is presenting
  32890. * @returns true if VR mode is engaged
  32891. */
  32892. isVRPresenting(): boolean;
  32893. /** @hidden */
  32894. _requestVRFrame(): void;
  32895. /** @hidden */
  32896. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32897. /**
  32898. * Gets the source code of the vertex shader associated with a specific webGL program
  32899. * @param program defines the program to use
  32900. * @returns a string containing the source code of the vertex shader associated with the program
  32901. */
  32902. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32903. /**
  32904. * Gets the source code of the fragment shader associated with a specific webGL program
  32905. * @param program defines the program to use
  32906. * @returns a string containing the source code of the fragment shader associated with the program
  32907. */
  32908. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32909. /**
  32910. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32911. * @param x defines the x coordinate of the rectangle where pixels must be read
  32912. * @param y defines the y coordinate of the rectangle where pixels must be read
  32913. * @param width defines the width of the rectangle where pixels must be read
  32914. * @param height defines the height of the rectangle where pixels must be read
  32915. * @returns a Uint8Array containing RGBA colors
  32916. */
  32917. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32918. /**
  32919. * Sets a depth stencil texture from a render target to the according uniform.
  32920. * @param channel The texture channel
  32921. * @param uniform The uniform to set
  32922. * @param texture The render target texture containing the depth stencil texture to apply
  32923. */
  32924. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32925. /**
  32926. * Sets a texture to the webGL context from a postprocess
  32927. * @param channel defines the channel to use
  32928. * @param postProcess defines the source postprocess
  32929. */
  32930. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32931. /**
  32932. * Binds the output of the passed in post process to the texture channel specified
  32933. * @param channel The channel the texture should be bound to
  32934. * @param postProcess The post process which's output should be bound
  32935. */
  32936. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32937. /** @hidden */
  32938. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32939. protected _rebuildBuffers(): void;
  32940. /** @hidden */
  32941. _renderFrame(): void;
  32942. _renderLoop(): void;
  32943. /** @hidden */
  32944. _renderViews(): boolean;
  32945. /**
  32946. * Toggle full screen mode
  32947. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32948. */
  32949. switchFullscreen(requestPointerLock: boolean): void;
  32950. /**
  32951. * Enters full screen mode
  32952. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32953. */
  32954. enterFullscreen(requestPointerLock: boolean): void;
  32955. /**
  32956. * Exits full screen mode
  32957. */
  32958. exitFullscreen(): void;
  32959. /**
  32960. * Enters Pointerlock mode
  32961. */
  32962. enterPointerlock(): void;
  32963. /**
  32964. * Exits Pointerlock mode
  32965. */
  32966. exitPointerlock(): void;
  32967. /**
  32968. * Begin a new frame
  32969. */
  32970. beginFrame(): void;
  32971. /**
  32972. * Enf the current frame
  32973. */
  32974. endFrame(): void;
  32975. resize(): void;
  32976. /**
  32977. * Set the compressed texture format to use, based on the formats you have, and the formats
  32978. * supported by the hardware / browser.
  32979. *
  32980. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32981. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32982. * to API arguments needed to compressed textures. This puts the burden on the container
  32983. * generator to house the arcane code for determining these for current & future formats.
  32984. *
  32985. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32986. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32987. *
  32988. * Note: The result of this call is not taken into account when a texture is base64.
  32989. *
  32990. * @param formatsAvailable defines the list of those format families you have created
  32991. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32992. *
  32993. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32994. * @returns The extension selected.
  32995. */
  32996. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32997. /**
  32998. * Force a specific size of the canvas
  32999. * @param width defines the new canvas' width
  33000. * @param height defines the new canvas' height
  33001. */
  33002. setSize(width: number, height: number): void;
  33003. /**
  33004. * Updates a dynamic vertex buffer.
  33005. * @param vertexBuffer the vertex buffer to update
  33006. * @param data the data used to update the vertex buffer
  33007. * @param byteOffset the byte offset of the data
  33008. * @param byteLength the byte length of the data
  33009. */
  33010. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33011. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33012. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33013. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33014. _releaseTexture(texture: InternalTexture): void;
  33015. /**
  33016. * @hidden
  33017. * Rescales a texture
  33018. * @param source input texutre
  33019. * @param destination destination texture
  33020. * @param scene scene to use to render the resize
  33021. * @param internalFormat format to use when resizing
  33022. * @param onComplete callback to be called when resize has completed
  33023. */
  33024. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33025. /**
  33026. * Gets the current framerate
  33027. * @returns a number representing the framerate
  33028. */
  33029. getFps(): number;
  33030. /**
  33031. * Gets the time spent between current and previous frame
  33032. * @returns a number representing the delta time in ms
  33033. */
  33034. getDeltaTime(): number;
  33035. private _measureFps;
  33036. /** @hidden */
  33037. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33038. /**
  33039. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33040. * @param renderTarget The render target to set the frame buffer for
  33041. */
  33042. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33043. /**
  33044. * Update a dynamic index buffer
  33045. * @param indexBuffer defines the target index buffer
  33046. * @param indices defines the data to update
  33047. * @param offset defines the offset in the target index buffer where update should start
  33048. */
  33049. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33050. /**
  33051. * Updates the sample count of a render target texture
  33052. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33053. * @param texture defines the texture to update
  33054. * @param samples defines the sample count to set
  33055. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33056. */
  33057. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33058. /**
  33059. * Updates a depth texture Comparison Mode and Function.
  33060. * If the comparison Function is equal to 0, the mode will be set to none.
  33061. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33062. * @param texture The texture to set the comparison function for
  33063. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33064. */
  33065. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33066. /**
  33067. * Creates a webGL buffer to use with instanciation
  33068. * @param capacity defines the size of the buffer
  33069. * @returns the webGL buffer
  33070. */
  33071. createInstancesBuffer(capacity: number): DataBuffer;
  33072. /**
  33073. * Delete a webGL buffer used with instanciation
  33074. * @param buffer defines the webGL buffer to delete
  33075. */
  33076. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33077. /** @hidden */
  33078. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33079. dispose(): void;
  33080. private _disableTouchAction;
  33081. /**
  33082. * Display the loading screen
  33083. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33084. */
  33085. displayLoadingUI(): void;
  33086. /**
  33087. * Hide the loading screen
  33088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33089. */
  33090. hideLoadingUI(): void;
  33091. /**
  33092. * Gets the current loading screen object
  33093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33094. */
  33095. /**
  33096. * Sets the current loading screen object
  33097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33098. */
  33099. loadingScreen: ILoadingScreen;
  33100. /**
  33101. * Sets the current loading screen text
  33102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33103. */
  33104. loadingUIText: string;
  33105. /**
  33106. * Sets the current loading screen background color
  33107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33108. */
  33109. loadingUIBackgroundColor: string;
  33110. /** Pointerlock and fullscreen */
  33111. /**
  33112. * Ask the browser to promote the current element to pointerlock mode
  33113. * @param element defines the DOM element to promote
  33114. */
  33115. static _RequestPointerlock(element: HTMLElement): void;
  33116. /**
  33117. * Asks the browser to exit pointerlock mode
  33118. */
  33119. static _ExitPointerlock(): void;
  33120. /**
  33121. * Ask the browser to promote the current element to fullscreen rendering mode
  33122. * @param element defines the DOM element to promote
  33123. */
  33124. static _RequestFullscreen(element: HTMLElement): void;
  33125. /**
  33126. * Asks the browser to exit fullscreen mode
  33127. */
  33128. static _ExitFullscreen(): void;
  33129. }
  33130. }
  33131. declare module "babylonjs/Engines/engineStore" {
  33132. import { Nullable } from "babylonjs/types";
  33133. import { Engine } from "babylonjs/Engines/engine";
  33134. import { Scene } from "babylonjs/scene";
  33135. /**
  33136. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33137. * during the life time of the application.
  33138. */
  33139. export class EngineStore {
  33140. /** Gets the list of created engines */
  33141. static Instances: import("babylonjs/Engines/engine").Engine[];
  33142. /** @hidden */
  33143. static _LastCreatedScene: Nullable<Scene>;
  33144. /**
  33145. * Gets the latest created engine
  33146. */
  33147. static readonly LastCreatedEngine: Nullable<Engine>;
  33148. /**
  33149. * Gets the latest created scene
  33150. */
  33151. static readonly LastCreatedScene: Nullable<Scene>;
  33152. /**
  33153. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33154. * @ignorenaming
  33155. */
  33156. static UseFallbackTexture: boolean;
  33157. /**
  33158. * Texture content used if a texture cannot loaded
  33159. * @ignorenaming
  33160. */
  33161. static FallbackTexture: string;
  33162. }
  33163. }
  33164. declare module "babylonjs/Misc/promise" {
  33165. /**
  33166. * Helper class that provides a small promise polyfill
  33167. */
  33168. export class PromisePolyfill {
  33169. /**
  33170. * Static function used to check if the polyfill is required
  33171. * If this is the case then the function will inject the polyfill to window.Promise
  33172. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33173. */
  33174. static Apply(force?: boolean): void;
  33175. }
  33176. }
  33177. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33178. /**
  33179. * Interface for screenshot methods with describe argument called `size` as object with options
  33180. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33181. */
  33182. export interface IScreenshotSize {
  33183. /**
  33184. * number in pixels for canvas height
  33185. */
  33186. height?: number;
  33187. /**
  33188. * multiplier allowing render at a higher or lower resolution
  33189. * If value is defined then height and width will be ignored and taken from camera
  33190. */
  33191. precision?: number;
  33192. /**
  33193. * number in pixels for canvas width
  33194. */
  33195. width?: number;
  33196. }
  33197. }
  33198. declare module "babylonjs/Misc/tools" {
  33199. import { Nullable, float } from "babylonjs/types";
  33200. import { DomManagement } from "babylonjs/Misc/domManagement";
  33201. import { WebRequest } from "babylonjs/Misc/webRequest";
  33202. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33203. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33204. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33205. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33206. import { Camera } from "babylonjs/Cameras/camera";
  33207. import { Engine } from "babylonjs/Engines/engine";
  33208. interface IColor4Like {
  33209. r: float;
  33210. g: float;
  33211. b: float;
  33212. a: float;
  33213. }
  33214. /**
  33215. * Class containing a set of static utilities functions
  33216. */
  33217. export class Tools {
  33218. /**
  33219. * Gets or sets the base URL to use to load assets
  33220. */
  33221. static BaseUrl: string;
  33222. /**
  33223. * Enable/Disable Custom HTTP Request Headers globally.
  33224. * default = false
  33225. * @see CustomRequestHeaders
  33226. */
  33227. static UseCustomRequestHeaders: boolean;
  33228. /**
  33229. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33230. * i.e. when loading files, where the server/service expects an Authorization header
  33231. */
  33232. static CustomRequestHeaders: {
  33233. [key: string]: string;
  33234. };
  33235. /**
  33236. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33237. */
  33238. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33239. /**
  33240. * Default behaviour for cors in the application.
  33241. * It can be a string if the expected behavior is identical in the entire app.
  33242. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33243. */
  33244. static CorsBehavior: string | ((url: string | string[]) => string);
  33245. /**
  33246. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33247. * @ignorenaming
  33248. */
  33249. static UseFallbackTexture: boolean;
  33250. /**
  33251. * Use this object to register external classes like custom textures or material
  33252. * to allow the laoders to instantiate them
  33253. */
  33254. static RegisteredExternalClasses: {
  33255. [key: string]: Object;
  33256. };
  33257. /**
  33258. * Texture content used if a texture cannot loaded
  33259. * @ignorenaming
  33260. */
  33261. static fallbackTexture: string;
  33262. /**
  33263. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33264. * @param u defines the coordinate on X axis
  33265. * @param v defines the coordinate on Y axis
  33266. * @param width defines the width of the source data
  33267. * @param height defines the height of the source data
  33268. * @param pixels defines the source byte array
  33269. * @param color defines the output color
  33270. */
  33271. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33272. /**
  33273. * Interpolates between a and b via alpha
  33274. * @param a The lower value (returned when alpha = 0)
  33275. * @param b The upper value (returned when alpha = 1)
  33276. * @param alpha The interpolation-factor
  33277. * @return The mixed value
  33278. */
  33279. static Mix(a: number, b: number, alpha: number): number;
  33280. /**
  33281. * Tries to instantiate a new object from a given class name
  33282. * @param className defines the class name to instantiate
  33283. * @returns the new object or null if the system was not able to do the instantiation
  33284. */
  33285. static Instantiate(className: string): any;
  33286. /**
  33287. * Provides a slice function that will work even on IE
  33288. * @param data defines the array to slice
  33289. * @param start defines the start of the data (optional)
  33290. * @param end defines the end of the data (optional)
  33291. * @returns the new sliced array
  33292. */
  33293. static Slice<T>(data: T, start?: number, end?: number): T;
  33294. /**
  33295. * Polyfill for setImmediate
  33296. * @param action defines the action to execute after the current execution block
  33297. */
  33298. static SetImmediate(action: () => void): void;
  33299. /**
  33300. * Function indicating if a number is an exponent of 2
  33301. * @param value defines the value to test
  33302. * @returns true if the value is an exponent of 2
  33303. */
  33304. static IsExponentOfTwo(value: number): boolean;
  33305. private static _tmpFloatArray;
  33306. /**
  33307. * Returns the nearest 32-bit single precision float representation of a Number
  33308. * @param value A Number. If the parameter is of a different type, it will get converted
  33309. * to a number or to NaN if it cannot be converted
  33310. * @returns number
  33311. */
  33312. static FloatRound(value: number): number;
  33313. /**
  33314. * Extracts the filename from a path
  33315. * @param path defines the path to use
  33316. * @returns the filename
  33317. */
  33318. static GetFilename(path: string): string;
  33319. /**
  33320. * Extracts the "folder" part of a path (everything before the filename).
  33321. * @param uri The URI to extract the info from
  33322. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33323. * @returns The "folder" part of the path
  33324. */
  33325. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33326. /**
  33327. * Extracts text content from a DOM element hierarchy
  33328. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33329. */
  33330. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33331. /**
  33332. * Convert an angle in radians to degrees
  33333. * @param angle defines the angle to convert
  33334. * @returns the angle in degrees
  33335. */
  33336. static ToDegrees(angle: number): number;
  33337. /**
  33338. * Convert an angle in degrees to radians
  33339. * @param angle defines the angle to convert
  33340. * @returns the angle in radians
  33341. */
  33342. static ToRadians(angle: number): number;
  33343. /**
  33344. * Returns an array if obj is not an array
  33345. * @param obj defines the object to evaluate as an array
  33346. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33347. * @returns either obj directly if obj is an array or a new array containing obj
  33348. */
  33349. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33350. /**
  33351. * Gets the pointer prefix to use
  33352. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33353. */
  33354. static GetPointerPrefix(): string;
  33355. /**
  33356. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33357. * @param url define the url we are trying
  33358. * @param element define the dom element where to configure the cors policy
  33359. */
  33360. static SetCorsBehavior(url: string | string[], element: {
  33361. crossOrigin: string | null;
  33362. }): void;
  33363. /**
  33364. * Removes unwanted characters from an url
  33365. * @param url defines the url to clean
  33366. * @returns the cleaned url
  33367. */
  33368. static CleanUrl(url: string): string;
  33369. /**
  33370. * Gets or sets a function used to pre-process url before using them to load assets
  33371. */
  33372. static PreprocessUrl: (url: string) => string;
  33373. /**
  33374. * Loads an image as an HTMLImageElement.
  33375. * @param input url string, ArrayBuffer, or Blob to load
  33376. * @param onLoad callback called when the image successfully loads
  33377. * @param onError callback called when the image fails to load
  33378. * @param offlineProvider offline provider for caching
  33379. * @param mimeType optional mime type
  33380. * @returns the HTMLImageElement of the loaded image
  33381. */
  33382. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33383. /**
  33384. * Loads a file from a url
  33385. * @param url url string, ArrayBuffer, or Blob to load
  33386. * @param onSuccess callback called when the file successfully loads
  33387. * @param onProgress callback called while file is loading (if the server supports this mode)
  33388. * @param offlineProvider defines the offline provider for caching
  33389. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33390. * @param onError callback called when the file fails to load
  33391. * @returns a file request object
  33392. */
  33393. 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;
  33394. /**
  33395. * Loads a file from a url
  33396. * @param url the file url to load
  33397. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33398. */
  33399. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33400. /**
  33401. * Load a script (identified by an url). When the url returns, the
  33402. * content of this file is added into a new script element, attached to the DOM (body element)
  33403. * @param scriptUrl defines the url of the script to laod
  33404. * @param onSuccess defines the callback called when the script is loaded
  33405. * @param onError defines the callback to call if an error occurs
  33406. * @param scriptId defines the id of the script element
  33407. */
  33408. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33409. /**
  33410. * Load an asynchronous script (identified by an url). When the url returns, the
  33411. * content of this file is added into a new script element, attached to the DOM (body element)
  33412. * @param scriptUrl defines the url of the script to laod
  33413. * @param scriptId defines the id of the script element
  33414. * @returns a promise request object
  33415. */
  33416. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33417. /**
  33418. * Loads a file from a blob
  33419. * @param fileToLoad defines the blob to use
  33420. * @param callback defines the callback to call when data is loaded
  33421. * @param progressCallback defines the callback to call during loading process
  33422. * @returns a file request object
  33423. */
  33424. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33425. /**
  33426. * Reads a file from a File object
  33427. * @param file defines the file to load
  33428. * @param onSuccess defines the callback to call when data is loaded
  33429. * @param onProgress defines the callback to call during loading process
  33430. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33431. * @param onError defines the callback to call when an error occurs
  33432. * @returns a file request object
  33433. */
  33434. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33435. /**
  33436. * Creates a data url from a given string content
  33437. * @param content defines the content to convert
  33438. * @returns the new data url link
  33439. */
  33440. static FileAsURL(content: string): string;
  33441. /**
  33442. * Format the given number to a specific decimal format
  33443. * @param value defines the number to format
  33444. * @param decimals defines the number of decimals to use
  33445. * @returns the formatted string
  33446. */
  33447. static Format(value: number, decimals?: number): string;
  33448. /**
  33449. * Tries to copy an object by duplicating every property
  33450. * @param source defines the source object
  33451. * @param destination defines the target object
  33452. * @param doNotCopyList defines a list of properties to avoid
  33453. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33454. */
  33455. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33456. /**
  33457. * Gets a boolean indicating if the given object has no own property
  33458. * @param obj defines the object to test
  33459. * @returns true if object has no own property
  33460. */
  33461. static IsEmpty(obj: any): boolean;
  33462. /**
  33463. * Function used to register events at window level
  33464. * @param windowElement defines the Window object to use
  33465. * @param events defines the events to register
  33466. */
  33467. static RegisterTopRootEvents(windowElement: Window, events: {
  33468. name: string;
  33469. handler: Nullable<(e: FocusEvent) => any>;
  33470. }[]): void;
  33471. /**
  33472. * Function used to unregister events from window level
  33473. * @param windowElement defines the Window object to use
  33474. * @param events defines the events to unregister
  33475. */
  33476. static UnregisterTopRootEvents(windowElement: Window, events: {
  33477. name: string;
  33478. handler: Nullable<(e: FocusEvent) => any>;
  33479. }[]): void;
  33480. /**
  33481. * @ignore
  33482. */
  33483. static _ScreenshotCanvas: HTMLCanvasElement;
  33484. /**
  33485. * Dumps the current bound framebuffer
  33486. * @param width defines the rendering width
  33487. * @param height defines the rendering height
  33488. * @param engine defines the hosting engine
  33489. * @param successCallback defines the callback triggered once the data are available
  33490. * @param mimeType defines the mime type of the result
  33491. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33492. */
  33493. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33494. /**
  33495. * Converts the canvas data to blob.
  33496. * This acts as a polyfill for browsers not supporting the to blob function.
  33497. * @param canvas Defines the canvas to extract the data from
  33498. * @param successCallback Defines the callback triggered once the data are available
  33499. * @param mimeType Defines the mime type of the result
  33500. */
  33501. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33502. /**
  33503. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33504. * @param successCallback defines the callback triggered once the data are available
  33505. * @param mimeType defines the mime type of the result
  33506. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33507. */
  33508. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33509. /**
  33510. * Downloads a blob in the browser
  33511. * @param blob defines the blob to download
  33512. * @param fileName defines the name of the downloaded file
  33513. */
  33514. static Download(blob: Blob, fileName: string): void;
  33515. /**
  33516. * Captures a screenshot of the current rendering
  33517. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33518. * @param engine defines the rendering engine
  33519. * @param camera defines the source camera
  33520. * @param size This parameter can be set to a single number or to an object with the
  33521. * following (optional) properties: precision, width, height. If a single number is passed,
  33522. * it will be used for both width and height. If an object is passed, the screenshot size
  33523. * will be derived from the parameters. The precision property is a multiplier allowing
  33524. * rendering at a higher or lower resolution
  33525. * @param successCallback defines the callback receives a single parameter which contains the
  33526. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33527. * src parameter of an <img> to display it
  33528. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33529. * Check your browser for supported MIME types
  33530. */
  33531. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33532. /**
  33533. * Captures a screenshot of the current rendering
  33534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33535. * @param engine defines the rendering engine
  33536. * @param camera defines the source camera
  33537. * @param size This parameter can be set to a single number or to an object with the
  33538. * following (optional) properties: precision, width, height. If a single number is passed,
  33539. * it will be used for both width and height. If an object is passed, the screenshot size
  33540. * will be derived from the parameters. The precision property is a multiplier allowing
  33541. * rendering at a higher or lower resolution
  33542. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33543. * Check your browser for supported MIME types
  33544. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33545. * to the src parameter of an <img> to display it
  33546. */
  33547. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33548. /**
  33549. * Generates an image screenshot from the specified camera.
  33550. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33551. * @param engine The engine to use for rendering
  33552. * @param camera The camera to use for rendering
  33553. * @param size This parameter can be set to a single number or to an object with the
  33554. * following (optional) properties: precision, width, height. If a single number is passed,
  33555. * it will be used for both width and height. If an object is passed, the screenshot size
  33556. * will be derived from the parameters. The precision property is a multiplier allowing
  33557. * rendering at a higher or lower resolution
  33558. * @param successCallback The callback receives a single parameter which contains the
  33559. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33560. * src parameter of an <img> to display it
  33561. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33562. * Check your browser for supported MIME types
  33563. * @param samples Texture samples (default: 1)
  33564. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33565. * @param fileName A name for for the downloaded file.
  33566. */
  33567. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33568. /**
  33569. * Generates an image screenshot from the specified camera.
  33570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33571. * @param engine The engine to use for rendering
  33572. * @param camera The camera to use for rendering
  33573. * @param size This parameter can be set to a single number or to an object with the
  33574. * following (optional) properties: precision, width, height. If a single number is passed,
  33575. * it will be used for both width and height. If an object is passed, the screenshot size
  33576. * will be derived from the parameters. The precision property is a multiplier allowing
  33577. * rendering at a higher or lower resolution
  33578. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33579. * Check your browser for supported MIME types
  33580. * @param samples Texture samples (default: 1)
  33581. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33582. * @param fileName A name for for the downloaded file.
  33583. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33584. * to the src parameter of an <img> to display it
  33585. */
  33586. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33587. /**
  33588. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33589. * Be aware Math.random() could cause collisions, but:
  33590. * "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"
  33591. * @returns a pseudo random id
  33592. */
  33593. static RandomId(): string;
  33594. /**
  33595. * Test if the given uri is a base64 string
  33596. * @param uri The uri to test
  33597. * @return True if the uri is a base64 string or false otherwise
  33598. */
  33599. static IsBase64(uri: string): boolean;
  33600. /**
  33601. * Decode the given base64 uri.
  33602. * @param uri The uri to decode
  33603. * @return The decoded base64 data.
  33604. */
  33605. static DecodeBase64(uri: string): ArrayBuffer;
  33606. /**
  33607. * Gets the absolute url.
  33608. * @param url the input url
  33609. * @return the absolute url
  33610. */
  33611. static GetAbsoluteUrl(url: string): string;
  33612. /**
  33613. * No log
  33614. */
  33615. static readonly NoneLogLevel: number;
  33616. /**
  33617. * Only message logs
  33618. */
  33619. static readonly MessageLogLevel: number;
  33620. /**
  33621. * Only warning logs
  33622. */
  33623. static readonly WarningLogLevel: number;
  33624. /**
  33625. * Only error logs
  33626. */
  33627. static readonly ErrorLogLevel: number;
  33628. /**
  33629. * All logs
  33630. */
  33631. static readonly AllLogLevel: number;
  33632. /**
  33633. * Gets a value indicating the number of loading errors
  33634. * @ignorenaming
  33635. */
  33636. static readonly errorsCount: number;
  33637. /**
  33638. * Callback called when a new log is added
  33639. */
  33640. static OnNewCacheEntry: (entry: string) => void;
  33641. /**
  33642. * Log a message to the console
  33643. * @param message defines the message to log
  33644. */
  33645. static Log(message: string): void;
  33646. /**
  33647. * Write a warning message to the console
  33648. * @param message defines the message to log
  33649. */
  33650. static Warn(message: string): void;
  33651. /**
  33652. * Write an error message to the console
  33653. * @param message defines the message to log
  33654. */
  33655. static Error(message: string): void;
  33656. /**
  33657. * Gets current log cache (list of logs)
  33658. */
  33659. static readonly LogCache: string;
  33660. /**
  33661. * Clears the log cache
  33662. */
  33663. static ClearLogCache(): void;
  33664. /**
  33665. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33666. */
  33667. static LogLevels: number;
  33668. /**
  33669. * Checks if the window object exists
  33670. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33671. */
  33672. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33673. /**
  33674. * No performance log
  33675. */
  33676. static readonly PerformanceNoneLogLevel: number;
  33677. /**
  33678. * Use user marks to log performance
  33679. */
  33680. static readonly PerformanceUserMarkLogLevel: number;
  33681. /**
  33682. * Log performance to the console
  33683. */
  33684. static readonly PerformanceConsoleLogLevel: number;
  33685. private static _performance;
  33686. /**
  33687. * Sets the current performance log level
  33688. */
  33689. static PerformanceLogLevel: number;
  33690. private static _StartPerformanceCounterDisabled;
  33691. private static _EndPerformanceCounterDisabled;
  33692. private static _StartUserMark;
  33693. private static _EndUserMark;
  33694. private static _StartPerformanceConsole;
  33695. private static _EndPerformanceConsole;
  33696. /**
  33697. * Starts a performance counter
  33698. */
  33699. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33700. /**
  33701. * Ends a specific performance coutner
  33702. */
  33703. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33704. /**
  33705. * Gets either window.performance.now() if supported or Date.now() else
  33706. */
  33707. static readonly Now: number;
  33708. /**
  33709. * This method will return the name of the class used to create the instance of the given object.
  33710. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33711. * @param object the object to get the class name from
  33712. * @param isType defines if the object is actually a type
  33713. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33714. */
  33715. static GetClassName(object: any, isType?: boolean): string;
  33716. /**
  33717. * Gets the first element of an array satisfying a given predicate
  33718. * @param array defines the array to browse
  33719. * @param predicate defines the predicate to use
  33720. * @returns null if not found or the element
  33721. */
  33722. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33723. /**
  33724. * This method will return the name of the full name of the class, including its owning module (if any).
  33725. * 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).
  33726. * @param object the object to get the class name from
  33727. * @param isType defines if the object is actually a type
  33728. * @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.
  33729. * @ignorenaming
  33730. */
  33731. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33732. /**
  33733. * Returns a promise that resolves after the given amount of time.
  33734. * @param delay Number of milliseconds to delay
  33735. * @returns Promise that resolves after the given amount of time
  33736. */
  33737. static DelayAsync(delay: number): Promise<void>;
  33738. }
  33739. /**
  33740. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33741. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33742. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33743. * @param name The name of the class, case should be preserved
  33744. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33745. */
  33746. export function className(name: string, module?: string): (target: Object) => void;
  33747. /**
  33748. * An implementation of a loop for asynchronous functions.
  33749. */
  33750. export class AsyncLoop {
  33751. /**
  33752. * Defines the number of iterations for the loop
  33753. */
  33754. iterations: number;
  33755. /**
  33756. * Defines the current index of the loop.
  33757. */
  33758. index: number;
  33759. private _done;
  33760. private _fn;
  33761. private _successCallback;
  33762. /**
  33763. * Constructor.
  33764. * @param iterations the number of iterations.
  33765. * @param func the function to run each iteration
  33766. * @param successCallback the callback that will be called upon succesful execution
  33767. * @param offset starting offset.
  33768. */
  33769. constructor(
  33770. /**
  33771. * Defines the number of iterations for the loop
  33772. */
  33773. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33774. /**
  33775. * Execute the next iteration. Must be called after the last iteration was finished.
  33776. */
  33777. executeNext(): void;
  33778. /**
  33779. * Break the loop and run the success callback.
  33780. */
  33781. breakLoop(): void;
  33782. /**
  33783. * Create and run an async loop.
  33784. * @param iterations the number of iterations.
  33785. * @param fn the function to run each iteration
  33786. * @param successCallback the callback that will be called upon succesful execution
  33787. * @param offset starting offset.
  33788. * @returns the created async loop object
  33789. */
  33790. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33791. /**
  33792. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33793. * @param iterations total number of iterations
  33794. * @param syncedIterations number of synchronous iterations in each async iteration.
  33795. * @param fn the function to call each iteration.
  33796. * @param callback a success call back that will be called when iterating stops.
  33797. * @param breakFunction a break condition (optional)
  33798. * @param timeout timeout settings for the setTimeout function. default - 0.
  33799. * @returns the created async loop object
  33800. */
  33801. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33802. }
  33803. }
  33804. declare module "babylonjs/Misc/stringDictionary" {
  33805. import { Nullable } from "babylonjs/types";
  33806. /**
  33807. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33808. * The underlying implementation relies on an associative array to ensure the best performances.
  33809. * The value can be anything including 'null' but except 'undefined'
  33810. */
  33811. export class StringDictionary<T> {
  33812. /**
  33813. * This will clear this dictionary and copy the content from the 'source' one.
  33814. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33815. * @param source the dictionary to take the content from and copy to this dictionary
  33816. */
  33817. copyFrom(source: StringDictionary<T>): void;
  33818. /**
  33819. * Get a value based from its key
  33820. * @param key the given key to get the matching value from
  33821. * @return the value if found, otherwise undefined is returned
  33822. */
  33823. get(key: string): T | undefined;
  33824. /**
  33825. * Get a value from its key or add it if it doesn't exist.
  33826. * This method will ensure you that a given key/data will be present in the dictionary.
  33827. * @param key the given key to get the matching value from
  33828. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33829. * The factory will only be invoked if there's no data for the given key.
  33830. * @return the value corresponding to the key.
  33831. */
  33832. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33833. /**
  33834. * Get a value from its key if present in the dictionary otherwise add it
  33835. * @param key the key to get the value from
  33836. * @param val if there's no such key/value pair in the dictionary add it with this value
  33837. * @return the value corresponding to the key
  33838. */
  33839. getOrAdd(key: string, val: T): T;
  33840. /**
  33841. * Check if there's a given key in the dictionary
  33842. * @param key the key to check for
  33843. * @return true if the key is present, false otherwise
  33844. */
  33845. contains(key: string): boolean;
  33846. /**
  33847. * Add a new key and its corresponding value
  33848. * @param key the key to add
  33849. * @param value the value corresponding to the key
  33850. * @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
  33851. */
  33852. add(key: string, value: T): boolean;
  33853. /**
  33854. * Update a specific value associated to a key
  33855. * @param key defines the key to use
  33856. * @param value defines the value to store
  33857. * @returns true if the value was updated (or false if the key was not found)
  33858. */
  33859. set(key: string, value: T): boolean;
  33860. /**
  33861. * Get the element of the given key and remove it from the dictionary
  33862. * @param key defines the key to search
  33863. * @returns the value associated with the key or null if not found
  33864. */
  33865. getAndRemove(key: string): Nullable<T>;
  33866. /**
  33867. * Remove a key/value from the dictionary.
  33868. * @param key the key to remove
  33869. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33870. */
  33871. remove(key: string): boolean;
  33872. /**
  33873. * Clear the whole content of the dictionary
  33874. */
  33875. clear(): void;
  33876. /**
  33877. * Gets the current count
  33878. */
  33879. readonly count: number;
  33880. /**
  33881. * Execute a callback on each key/val of the dictionary.
  33882. * Note that you can remove any element in this dictionary in the callback implementation
  33883. * @param callback the callback to execute on a given key/value pair
  33884. */
  33885. forEach(callback: (key: string, val: T) => void): void;
  33886. /**
  33887. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33888. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33889. * Note that you can remove any element in this dictionary in the callback implementation
  33890. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33891. * @returns the first item
  33892. */
  33893. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33894. private _count;
  33895. private _data;
  33896. }
  33897. }
  33898. declare module "babylonjs/Collisions/collisionCoordinator" {
  33899. import { Nullable } from "babylonjs/types";
  33900. import { Scene } from "babylonjs/scene";
  33901. import { Vector3 } from "babylonjs/Maths/math.vector";
  33902. import { Collider } from "babylonjs/Collisions/collider";
  33903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33904. /** @hidden */
  33905. export interface ICollisionCoordinator {
  33906. createCollider(): Collider;
  33907. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33908. init(scene: Scene): void;
  33909. }
  33910. /** @hidden */
  33911. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33912. private _scene;
  33913. private _scaledPosition;
  33914. private _scaledVelocity;
  33915. private _finalPosition;
  33916. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33917. createCollider(): Collider;
  33918. init(scene: Scene): void;
  33919. private _collideWithWorld;
  33920. }
  33921. }
  33922. declare module "babylonjs/Inputs/scene.inputManager" {
  33923. import { Nullable } from "babylonjs/types";
  33924. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33925. import { Vector2 } from "babylonjs/Maths/math.vector";
  33926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33927. import { Scene } from "babylonjs/scene";
  33928. /**
  33929. * Class used to manage all inputs for the scene.
  33930. */
  33931. export class InputManager {
  33932. /** The distance in pixel that you have to move to prevent some events */
  33933. static DragMovementThreshold: number;
  33934. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33935. static LongPressDelay: number;
  33936. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33937. static DoubleClickDelay: number;
  33938. /** If you need to check double click without raising a single click at first click, enable this flag */
  33939. static ExclusiveDoubleClickMode: boolean;
  33940. private _wheelEventName;
  33941. private _onPointerMove;
  33942. private _onPointerDown;
  33943. private _onPointerUp;
  33944. private _initClickEvent;
  33945. private _initActionManager;
  33946. private _delayedSimpleClick;
  33947. private _delayedSimpleClickTimeout;
  33948. private _previousDelayedSimpleClickTimeout;
  33949. private _meshPickProceed;
  33950. private _previousButtonPressed;
  33951. private _currentPickResult;
  33952. private _previousPickResult;
  33953. private _totalPointersPressed;
  33954. private _doubleClickOccured;
  33955. private _pointerOverMesh;
  33956. private _pickedDownMesh;
  33957. private _pickedUpMesh;
  33958. private _pointerX;
  33959. private _pointerY;
  33960. private _unTranslatedPointerX;
  33961. private _unTranslatedPointerY;
  33962. private _startingPointerPosition;
  33963. private _previousStartingPointerPosition;
  33964. private _startingPointerTime;
  33965. private _previousStartingPointerTime;
  33966. private _pointerCaptures;
  33967. private _onKeyDown;
  33968. private _onKeyUp;
  33969. private _onCanvasFocusObserver;
  33970. private _onCanvasBlurObserver;
  33971. private _scene;
  33972. /**
  33973. * Creates a new InputManager
  33974. * @param scene defines the hosting scene
  33975. */
  33976. constructor(scene: Scene);
  33977. /**
  33978. * Gets the mesh that is currently under the pointer
  33979. */
  33980. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33981. /**
  33982. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33983. */
  33984. readonly unTranslatedPointer: Vector2;
  33985. /**
  33986. * Gets or sets the current on-screen X position of the pointer
  33987. */
  33988. pointerX: number;
  33989. /**
  33990. * Gets or sets the current on-screen Y position of the pointer
  33991. */
  33992. pointerY: number;
  33993. private _updatePointerPosition;
  33994. private _processPointerMove;
  33995. private _setRayOnPointerInfo;
  33996. private _checkPrePointerObservable;
  33997. /**
  33998. * Use this method to simulate a pointer move on a mesh
  33999. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34000. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34001. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34002. */
  34003. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34004. /**
  34005. * Use this method to simulate a pointer down on a mesh
  34006. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34007. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34008. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34009. */
  34010. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34011. private _processPointerDown;
  34012. /** @hidden */
  34013. _isPointerSwiping(): boolean;
  34014. /**
  34015. * Use this method to simulate a pointer up on a mesh
  34016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34019. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34020. */
  34021. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34022. private _processPointerUp;
  34023. /**
  34024. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34025. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34026. * @returns true if the pointer was captured
  34027. */
  34028. isPointerCaptured(pointerId?: number): boolean;
  34029. /**
  34030. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34031. * @param attachUp defines if you want to attach events to pointerup
  34032. * @param attachDown defines if you want to attach events to pointerdown
  34033. * @param attachMove defines if you want to attach events to pointermove
  34034. */
  34035. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34036. /**
  34037. * Detaches all event handlers
  34038. */
  34039. detachControl(): void;
  34040. /**
  34041. * Force the value of meshUnderPointer
  34042. * @param mesh defines the mesh to use
  34043. */
  34044. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34045. /**
  34046. * Gets the mesh under the pointer
  34047. * @returns a Mesh or null if no mesh is under the pointer
  34048. */
  34049. getPointerOverMesh(): Nullable<AbstractMesh>;
  34050. }
  34051. }
  34052. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34053. /**
  34054. * Helper class used to generate session unique ID
  34055. */
  34056. export class UniqueIdGenerator {
  34057. private static _UniqueIdCounter;
  34058. /**
  34059. * Gets an unique (relatively to the current scene) Id
  34060. */
  34061. static readonly UniqueId: number;
  34062. }
  34063. }
  34064. declare module "babylonjs/Animations/animationGroup" {
  34065. import { Animatable } from "babylonjs/Animations/animatable";
  34066. import { Animation } from "babylonjs/Animations/animation";
  34067. import { Scene, IDisposable } from "babylonjs/scene";
  34068. import { Observable } from "babylonjs/Misc/observable";
  34069. import { Nullable } from "babylonjs/types";
  34070. import "babylonjs/Animations/animatable";
  34071. /**
  34072. * This class defines the direct association between an animation and a target
  34073. */
  34074. export class TargetedAnimation {
  34075. /**
  34076. * Animation to perform
  34077. */
  34078. animation: Animation;
  34079. /**
  34080. * Target to animate
  34081. */
  34082. target: any;
  34083. /**
  34084. * Serialize the object
  34085. * @returns the JSON object representing the current entity
  34086. */
  34087. serialize(): any;
  34088. }
  34089. /**
  34090. * Use this class to create coordinated animations on multiple targets
  34091. */
  34092. export class AnimationGroup implements IDisposable {
  34093. /** The name of the animation group */
  34094. name: string;
  34095. private _scene;
  34096. private _targetedAnimations;
  34097. private _animatables;
  34098. private _from;
  34099. private _to;
  34100. private _isStarted;
  34101. private _isPaused;
  34102. private _speedRatio;
  34103. private _loopAnimation;
  34104. /**
  34105. * Gets or sets the unique id of the node
  34106. */
  34107. uniqueId: number;
  34108. /**
  34109. * This observable will notify when one animation have ended
  34110. */
  34111. onAnimationEndObservable: Observable<TargetedAnimation>;
  34112. /**
  34113. * Observer raised when one animation loops
  34114. */
  34115. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34116. /**
  34117. * Observer raised when all animations have looped
  34118. */
  34119. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34120. /**
  34121. * This observable will notify when all animations have ended.
  34122. */
  34123. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34124. /**
  34125. * This observable will notify when all animations have paused.
  34126. */
  34127. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34128. /**
  34129. * This observable will notify when all animations are playing.
  34130. */
  34131. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34132. /**
  34133. * Gets the first frame
  34134. */
  34135. readonly from: number;
  34136. /**
  34137. * Gets the last frame
  34138. */
  34139. readonly to: number;
  34140. /**
  34141. * Define if the animations are started
  34142. */
  34143. readonly isStarted: boolean;
  34144. /**
  34145. * Gets a value indicating that the current group is playing
  34146. */
  34147. readonly isPlaying: boolean;
  34148. /**
  34149. * Gets or sets the speed ratio to use for all animations
  34150. */
  34151. /**
  34152. * Gets or sets the speed ratio to use for all animations
  34153. */
  34154. speedRatio: number;
  34155. /**
  34156. * Gets or sets if all animations should loop or not
  34157. */
  34158. loopAnimation: boolean;
  34159. /**
  34160. * Gets the targeted animations for this animation group
  34161. */
  34162. readonly targetedAnimations: Array<TargetedAnimation>;
  34163. /**
  34164. * returning the list of animatables controlled by this animation group.
  34165. */
  34166. readonly animatables: Array<Animatable>;
  34167. /**
  34168. * Instantiates a new Animation Group.
  34169. * This helps managing several animations at once.
  34170. * @see http://doc.babylonjs.com/how_to/group
  34171. * @param name Defines the name of the group
  34172. * @param scene Defines the scene the group belongs to
  34173. */
  34174. constructor(
  34175. /** The name of the animation group */
  34176. name: string, scene?: Nullable<Scene>);
  34177. /**
  34178. * Add an animation (with its target) in the group
  34179. * @param animation defines the animation we want to add
  34180. * @param target defines the target of the animation
  34181. * @returns the TargetedAnimation object
  34182. */
  34183. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34184. /**
  34185. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34186. * It can add constant keys at begin or end
  34187. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34188. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34189. * @returns the animation group
  34190. */
  34191. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34192. private _animationLoopCount;
  34193. private _animationLoopFlags;
  34194. private _processLoop;
  34195. /**
  34196. * Start all animations on given targets
  34197. * @param loop defines if animations must loop
  34198. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34199. * @param from defines the from key (optional)
  34200. * @param to defines the to key (optional)
  34201. * @returns the current animation group
  34202. */
  34203. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34204. /**
  34205. * Pause all animations
  34206. * @returns the animation group
  34207. */
  34208. pause(): AnimationGroup;
  34209. /**
  34210. * Play all animations to initial state
  34211. * This function will start() the animations if they were not started or will restart() them if they were paused
  34212. * @param loop defines if animations must loop
  34213. * @returns the animation group
  34214. */
  34215. play(loop?: boolean): AnimationGroup;
  34216. /**
  34217. * Reset all animations to initial state
  34218. * @returns the animation group
  34219. */
  34220. reset(): AnimationGroup;
  34221. /**
  34222. * Restart animations from key 0
  34223. * @returns the animation group
  34224. */
  34225. restart(): AnimationGroup;
  34226. /**
  34227. * Stop all animations
  34228. * @returns the animation group
  34229. */
  34230. stop(): AnimationGroup;
  34231. /**
  34232. * Set animation weight for all animatables
  34233. * @param weight defines the weight to use
  34234. * @return the animationGroup
  34235. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34236. */
  34237. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34238. /**
  34239. * Synchronize and normalize all animatables with a source animatable
  34240. * @param root defines the root animatable to synchronize with
  34241. * @return the animationGroup
  34242. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34243. */
  34244. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34245. /**
  34246. * Goes to a specific frame in this animation group
  34247. * @param frame the frame number to go to
  34248. * @return the animationGroup
  34249. */
  34250. goToFrame(frame: number): AnimationGroup;
  34251. /**
  34252. * Dispose all associated resources
  34253. */
  34254. dispose(): void;
  34255. private _checkAnimationGroupEnded;
  34256. /**
  34257. * Clone the current animation group and returns a copy
  34258. * @param newName defines the name of the new group
  34259. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34260. * @returns the new aniamtion group
  34261. */
  34262. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34263. /**
  34264. * Serializes the animationGroup to an object
  34265. * @returns Serialized object
  34266. */
  34267. serialize(): any;
  34268. /**
  34269. * Returns a new AnimationGroup object parsed from the source provided.
  34270. * @param parsedAnimationGroup defines the source
  34271. * @param scene defines the scene that will receive the animationGroup
  34272. * @returns a new AnimationGroup
  34273. */
  34274. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34275. /**
  34276. * Returns the string "AnimationGroup"
  34277. * @returns "AnimationGroup"
  34278. */
  34279. getClassName(): string;
  34280. /**
  34281. * Creates a detailled string about the object
  34282. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34283. * @returns a string representing the object
  34284. */
  34285. toString(fullDetails?: boolean): string;
  34286. }
  34287. }
  34288. declare module "babylonjs/scene" {
  34289. import { Nullable } from "babylonjs/types";
  34290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34291. import { Observable } from "babylonjs/Misc/observable";
  34292. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34293. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34294. import { Geometry } from "babylonjs/Meshes/geometry";
  34295. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34298. import { Mesh } from "babylonjs/Meshes/mesh";
  34299. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34300. import { Bone } from "babylonjs/Bones/bone";
  34301. import { Skeleton } from "babylonjs/Bones/skeleton";
  34302. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34303. import { Camera } from "babylonjs/Cameras/camera";
  34304. import { AbstractScene } from "babylonjs/abstractScene";
  34305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34306. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34307. import { Material } from "babylonjs/Materials/material";
  34308. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34309. import { Effect } from "babylonjs/Materials/effect";
  34310. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34311. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34312. import { Light } from "babylonjs/Lights/light";
  34313. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34314. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34315. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34316. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34318. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34319. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34320. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34321. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34322. import { Engine } from "babylonjs/Engines/engine";
  34323. import { Node } from "babylonjs/node";
  34324. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34325. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34326. import { WebRequest } from "babylonjs/Misc/webRequest";
  34327. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34328. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34329. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34331. import { Plane } from "babylonjs/Maths/math.plane";
  34332. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34333. import { Ray } from "babylonjs/Culling/ray";
  34334. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34335. import { Animation } from "babylonjs/Animations/animation";
  34336. import { Animatable } from "babylonjs/Animations/animatable";
  34337. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34338. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34339. import { Collider } from "babylonjs/Collisions/collider";
  34340. /**
  34341. * Define an interface for all classes that will hold resources
  34342. */
  34343. export interface IDisposable {
  34344. /**
  34345. * Releases all held resources
  34346. */
  34347. dispose(): void;
  34348. }
  34349. /** Interface defining initialization parameters for Scene class */
  34350. export interface SceneOptions {
  34351. /**
  34352. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34353. * It will improve performance when the number of geometries becomes important.
  34354. */
  34355. useGeometryUniqueIdsMap?: boolean;
  34356. /**
  34357. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34358. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34359. */
  34360. useMaterialMeshMap?: boolean;
  34361. /**
  34362. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34363. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34364. */
  34365. useClonedMeshhMap?: boolean;
  34366. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34367. virtual?: boolean;
  34368. }
  34369. /**
  34370. * Represents a scene to be rendered by the engine.
  34371. * @see http://doc.babylonjs.com/features/scene
  34372. */
  34373. export class Scene extends AbstractScene implements IAnimatable {
  34374. /** The fog is deactivated */
  34375. static readonly FOGMODE_NONE: number;
  34376. /** The fog density is following an exponential function */
  34377. static readonly FOGMODE_EXP: number;
  34378. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34379. static readonly FOGMODE_EXP2: number;
  34380. /** The fog density is following a linear function. */
  34381. static readonly FOGMODE_LINEAR: number;
  34382. /**
  34383. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34385. */
  34386. static MinDeltaTime: number;
  34387. /**
  34388. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34389. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34390. */
  34391. static MaxDeltaTime: number;
  34392. /**
  34393. * Factory used to create the default material.
  34394. * @param name The name of the material to create
  34395. * @param scene The scene to create the material for
  34396. * @returns The default material
  34397. */
  34398. static DefaultMaterialFactory(scene: Scene): Material;
  34399. /**
  34400. * Factory used to create the a collision coordinator.
  34401. * @returns The collision coordinator
  34402. */
  34403. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34404. /** @hidden */
  34405. _inputManager: InputManager;
  34406. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34407. cameraToUseForPointers: Nullable<Camera>;
  34408. /** @hidden */
  34409. readonly _isScene: boolean;
  34410. /**
  34411. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34412. */
  34413. autoClear: boolean;
  34414. /**
  34415. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34416. */
  34417. autoClearDepthAndStencil: boolean;
  34418. /**
  34419. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34420. */
  34421. clearColor: Color4;
  34422. /**
  34423. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34424. */
  34425. ambientColor: Color3;
  34426. /**
  34427. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34428. * It should only be one of the following (if not the default embedded one):
  34429. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34430. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34431. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34432. * The material properties need to be setup according to the type of texture in use.
  34433. */
  34434. environmentBRDFTexture: BaseTexture;
  34435. /** @hidden */
  34436. protected _environmentTexture: Nullable<BaseTexture>;
  34437. /**
  34438. * Texture used in all pbr material as the reflection texture.
  34439. * As in the majority of the scene they are the same (exception for multi room and so on),
  34440. * this is easier to reference from here than from all the materials.
  34441. */
  34442. /**
  34443. * Texture used in all pbr material as the reflection texture.
  34444. * As in the majority of the scene they are the same (exception for multi room and so on),
  34445. * this is easier to set here than in all the materials.
  34446. */
  34447. environmentTexture: Nullable<BaseTexture>;
  34448. /** @hidden */
  34449. protected _environmentIntensity: number;
  34450. /**
  34451. * Intensity of the environment in all pbr material.
  34452. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34453. * As in the majority of the scene they are the same (exception for multi room and so on),
  34454. * this is easier to reference from here than from all the materials.
  34455. */
  34456. /**
  34457. * Intensity of the environment in all pbr material.
  34458. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34459. * As in the majority of the scene they are the same (exception for multi room and so on),
  34460. * this is easier to set here than in all the materials.
  34461. */
  34462. environmentIntensity: number;
  34463. /** @hidden */
  34464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34465. /**
  34466. * Default image processing configuration used either in the rendering
  34467. * Forward main pass or through the imageProcessingPostProcess if present.
  34468. * As in the majority of the scene they are the same (exception for multi camera),
  34469. * this is easier to reference from here than from all the materials and post process.
  34470. *
  34471. * No setter as we it is a shared configuration, you can set the values instead.
  34472. */
  34473. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34474. private _forceWireframe;
  34475. /**
  34476. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34477. */
  34478. forceWireframe: boolean;
  34479. private _forcePointsCloud;
  34480. /**
  34481. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34482. */
  34483. forcePointsCloud: boolean;
  34484. /**
  34485. * Gets or sets the active clipplane 1
  34486. */
  34487. clipPlane: Nullable<Plane>;
  34488. /**
  34489. * Gets or sets the active clipplane 2
  34490. */
  34491. clipPlane2: Nullable<Plane>;
  34492. /**
  34493. * Gets or sets the active clipplane 3
  34494. */
  34495. clipPlane3: Nullable<Plane>;
  34496. /**
  34497. * Gets or sets the active clipplane 4
  34498. */
  34499. clipPlane4: Nullable<Plane>;
  34500. /**
  34501. * Gets or sets a boolean indicating if animations are enabled
  34502. */
  34503. animationsEnabled: boolean;
  34504. private _animationPropertiesOverride;
  34505. /**
  34506. * Gets or sets the animation properties override
  34507. */
  34508. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34509. /**
  34510. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34511. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34512. */
  34513. useConstantAnimationDeltaTime: boolean;
  34514. /**
  34515. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34516. * Please note that it requires to run a ray cast through the scene on every frame
  34517. */
  34518. constantlyUpdateMeshUnderPointer: boolean;
  34519. /**
  34520. * Defines the HTML cursor to use when hovering over interactive elements
  34521. */
  34522. hoverCursor: string;
  34523. /**
  34524. * Defines the HTML default cursor to use (empty by default)
  34525. */
  34526. defaultCursor: string;
  34527. /**
  34528. * Defines wether cursors are handled by the scene.
  34529. */
  34530. doNotHandleCursors: boolean;
  34531. /**
  34532. * This is used to call preventDefault() on pointer down
  34533. * in order to block unwanted artifacts like system double clicks
  34534. */
  34535. preventDefaultOnPointerDown: boolean;
  34536. /**
  34537. * This is used to call preventDefault() on pointer up
  34538. * in order to block unwanted artifacts like system double clicks
  34539. */
  34540. preventDefaultOnPointerUp: boolean;
  34541. /**
  34542. * Gets or sets user defined metadata
  34543. */
  34544. metadata: any;
  34545. /**
  34546. * For internal use only. Please do not use.
  34547. */
  34548. reservedDataStore: any;
  34549. /**
  34550. * Gets the name of the plugin used to load this scene (null by default)
  34551. */
  34552. loadingPluginName: string;
  34553. /**
  34554. * Use this array to add regular expressions used to disable offline support for specific urls
  34555. */
  34556. disableOfflineSupportExceptionRules: RegExp[];
  34557. /**
  34558. * An event triggered when the scene is disposed.
  34559. */
  34560. onDisposeObservable: Observable<Scene>;
  34561. private _onDisposeObserver;
  34562. /** Sets a function to be executed when this scene is disposed. */
  34563. onDispose: () => void;
  34564. /**
  34565. * An event triggered before rendering the scene (right after animations and physics)
  34566. */
  34567. onBeforeRenderObservable: Observable<Scene>;
  34568. private _onBeforeRenderObserver;
  34569. /** Sets a function to be executed before rendering this scene */
  34570. beforeRender: Nullable<() => void>;
  34571. /**
  34572. * An event triggered after rendering the scene
  34573. */
  34574. onAfterRenderObservable: Observable<Scene>;
  34575. /**
  34576. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34577. */
  34578. onAfterRenderCameraObservable: Observable<Camera>;
  34579. private _onAfterRenderObserver;
  34580. /** Sets a function to be executed after rendering this scene */
  34581. afterRender: Nullable<() => void>;
  34582. /**
  34583. * An event triggered before animating the scene
  34584. */
  34585. onBeforeAnimationsObservable: Observable<Scene>;
  34586. /**
  34587. * An event triggered after animations processing
  34588. */
  34589. onAfterAnimationsObservable: Observable<Scene>;
  34590. /**
  34591. * An event triggered before draw calls are ready to be sent
  34592. */
  34593. onBeforeDrawPhaseObservable: Observable<Scene>;
  34594. /**
  34595. * An event triggered after draw calls have been sent
  34596. */
  34597. onAfterDrawPhaseObservable: Observable<Scene>;
  34598. /**
  34599. * An event triggered when the scene is ready
  34600. */
  34601. onReadyObservable: Observable<Scene>;
  34602. /**
  34603. * An event triggered before rendering a camera
  34604. */
  34605. onBeforeCameraRenderObservable: Observable<Camera>;
  34606. private _onBeforeCameraRenderObserver;
  34607. /** Sets a function to be executed before rendering a camera*/
  34608. beforeCameraRender: () => void;
  34609. /**
  34610. * An event triggered after rendering a camera
  34611. */
  34612. onAfterCameraRenderObservable: Observable<Camera>;
  34613. private _onAfterCameraRenderObserver;
  34614. /** Sets a function to be executed after rendering a camera*/
  34615. afterCameraRender: () => void;
  34616. /**
  34617. * An event triggered when active meshes evaluation is about to start
  34618. */
  34619. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34620. /**
  34621. * An event triggered when active meshes evaluation is done
  34622. */
  34623. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34624. /**
  34625. * An event triggered when particles rendering is about to start
  34626. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34627. */
  34628. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34629. /**
  34630. * An event triggered when particles rendering is done
  34631. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34632. */
  34633. onAfterParticlesRenderingObservable: Observable<Scene>;
  34634. /**
  34635. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34636. */
  34637. onDataLoadedObservable: Observable<Scene>;
  34638. /**
  34639. * An event triggered when a camera is created
  34640. */
  34641. onNewCameraAddedObservable: Observable<Camera>;
  34642. /**
  34643. * An event triggered when a camera is removed
  34644. */
  34645. onCameraRemovedObservable: Observable<Camera>;
  34646. /**
  34647. * An event triggered when a light is created
  34648. */
  34649. onNewLightAddedObservable: Observable<Light>;
  34650. /**
  34651. * An event triggered when a light is removed
  34652. */
  34653. onLightRemovedObservable: Observable<Light>;
  34654. /**
  34655. * An event triggered when a geometry is created
  34656. */
  34657. onNewGeometryAddedObservable: Observable<Geometry>;
  34658. /**
  34659. * An event triggered when a geometry is removed
  34660. */
  34661. onGeometryRemovedObservable: Observable<Geometry>;
  34662. /**
  34663. * An event triggered when a transform node is created
  34664. */
  34665. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34666. /**
  34667. * An event triggered when a transform node is removed
  34668. */
  34669. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34670. /**
  34671. * An event triggered when a mesh is created
  34672. */
  34673. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34674. /**
  34675. * An event triggered when a mesh is removed
  34676. */
  34677. onMeshRemovedObservable: Observable<AbstractMesh>;
  34678. /**
  34679. * An event triggered when a skeleton is created
  34680. */
  34681. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34682. /**
  34683. * An event triggered when a skeleton is removed
  34684. */
  34685. onSkeletonRemovedObservable: Observable<Skeleton>;
  34686. /**
  34687. * An event triggered when a material is created
  34688. */
  34689. onNewMaterialAddedObservable: Observable<Material>;
  34690. /**
  34691. * An event triggered when a material is removed
  34692. */
  34693. onMaterialRemovedObservable: Observable<Material>;
  34694. /**
  34695. * An event triggered when a texture is created
  34696. */
  34697. onNewTextureAddedObservable: Observable<BaseTexture>;
  34698. /**
  34699. * An event triggered when a texture is removed
  34700. */
  34701. onTextureRemovedObservable: Observable<BaseTexture>;
  34702. /**
  34703. * An event triggered when render targets are about to be rendered
  34704. * Can happen multiple times per frame.
  34705. */
  34706. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34707. /**
  34708. * An event triggered when render targets were rendered.
  34709. * Can happen multiple times per frame.
  34710. */
  34711. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34712. /**
  34713. * An event triggered before calculating deterministic simulation step
  34714. */
  34715. onBeforeStepObservable: Observable<Scene>;
  34716. /**
  34717. * An event triggered after calculating deterministic simulation step
  34718. */
  34719. onAfterStepObservable: Observable<Scene>;
  34720. /**
  34721. * An event triggered when the activeCamera property is updated
  34722. */
  34723. onActiveCameraChanged: Observable<Scene>;
  34724. /**
  34725. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34726. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34727. * 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)
  34728. */
  34729. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34730. /**
  34731. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34732. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34733. * 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)
  34734. */
  34735. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34736. /**
  34737. * This Observable will when a mesh has been imported into the scene.
  34738. */
  34739. onMeshImportedObservable: Observable<AbstractMesh>;
  34740. /**
  34741. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34742. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34743. */
  34744. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34745. /** @hidden */
  34746. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34747. /**
  34748. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34749. */
  34750. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34751. /**
  34752. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34753. */
  34754. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34755. /**
  34756. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34757. */
  34758. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34759. /** Callback called when a pointer move is detected */
  34760. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34761. /** Callback called when a pointer down is detected */
  34762. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34763. /** Callback called when a pointer up is detected */
  34764. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34765. /** Callback called when a pointer pick is detected */
  34766. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34767. /**
  34768. * 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).
  34769. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34770. */
  34771. onPrePointerObservable: Observable<PointerInfoPre>;
  34772. /**
  34773. * Observable event triggered each time an input event is received from the rendering canvas
  34774. */
  34775. onPointerObservable: Observable<PointerInfo>;
  34776. /**
  34777. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34778. */
  34779. readonly unTranslatedPointer: Vector2;
  34780. /**
  34781. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34782. */
  34783. static DragMovementThreshold: number;
  34784. /**
  34785. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34786. */
  34787. static LongPressDelay: number;
  34788. /**
  34789. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34790. */
  34791. static DoubleClickDelay: number;
  34792. /** If you need to check double click without raising a single click at first click, enable this flag */
  34793. static ExclusiveDoubleClickMode: boolean;
  34794. /** @hidden */
  34795. _mirroredCameraPosition: Nullable<Vector3>;
  34796. /**
  34797. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34798. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34799. */
  34800. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34801. /**
  34802. * Observable event triggered each time an keyboard event is received from the hosting window
  34803. */
  34804. onKeyboardObservable: Observable<KeyboardInfo>;
  34805. private _useRightHandedSystem;
  34806. /**
  34807. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34808. */
  34809. useRightHandedSystem: boolean;
  34810. private _timeAccumulator;
  34811. private _currentStepId;
  34812. private _currentInternalStep;
  34813. /**
  34814. * Sets the step Id used by deterministic lock step
  34815. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34816. * @param newStepId defines the step Id
  34817. */
  34818. setStepId(newStepId: number): void;
  34819. /**
  34820. * Gets the step Id used by deterministic lock step
  34821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34822. * @returns the step Id
  34823. */
  34824. getStepId(): number;
  34825. /**
  34826. * Gets the internal step used by deterministic lock step
  34827. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34828. * @returns the internal step
  34829. */
  34830. getInternalStep(): number;
  34831. private _fogEnabled;
  34832. /**
  34833. * Gets or sets a boolean indicating if fog is enabled on this scene
  34834. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34835. * (Default is true)
  34836. */
  34837. fogEnabled: boolean;
  34838. private _fogMode;
  34839. /**
  34840. * Gets or sets the fog mode to use
  34841. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34842. * | mode | value |
  34843. * | --- | --- |
  34844. * | FOGMODE_NONE | 0 |
  34845. * | FOGMODE_EXP | 1 |
  34846. * | FOGMODE_EXP2 | 2 |
  34847. * | FOGMODE_LINEAR | 3 |
  34848. */
  34849. fogMode: number;
  34850. /**
  34851. * Gets or sets the fog color to use
  34852. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34853. * (Default is Color3(0.2, 0.2, 0.3))
  34854. */
  34855. fogColor: Color3;
  34856. /**
  34857. * Gets or sets the fog density to use
  34858. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34859. * (Default is 0.1)
  34860. */
  34861. fogDensity: number;
  34862. /**
  34863. * Gets or sets the fog start distance to use
  34864. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34865. * (Default is 0)
  34866. */
  34867. fogStart: number;
  34868. /**
  34869. * Gets or sets the fog end distance to use
  34870. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34871. * (Default is 1000)
  34872. */
  34873. fogEnd: number;
  34874. private _shadowsEnabled;
  34875. /**
  34876. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34877. */
  34878. shadowsEnabled: boolean;
  34879. private _lightsEnabled;
  34880. /**
  34881. * Gets or sets a boolean indicating if lights are enabled on this scene
  34882. */
  34883. lightsEnabled: boolean;
  34884. /** All of the active cameras added to this scene. */
  34885. activeCameras: Camera[];
  34886. /** @hidden */
  34887. _activeCamera: Nullable<Camera>;
  34888. /** Gets or sets the current active camera */
  34889. activeCamera: Nullable<Camera>;
  34890. private _defaultMaterial;
  34891. /** The default material used on meshes when no material is affected */
  34892. /** The default material used on meshes when no material is affected */
  34893. defaultMaterial: Material;
  34894. private _texturesEnabled;
  34895. /**
  34896. * Gets or sets a boolean indicating if textures are enabled on this scene
  34897. */
  34898. texturesEnabled: boolean;
  34899. /**
  34900. * Gets or sets a boolean indicating if particles are enabled on this scene
  34901. */
  34902. particlesEnabled: boolean;
  34903. /**
  34904. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34905. */
  34906. spritesEnabled: boolean;
  34907. private _skeletonsEnabled;
  34908. /**
  34909. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34910. */
  34911. skeletonsEnabled: boolean;
  34912. /**
  34913. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34914. */
  34915. lensFlaresEnabled: boolean;
  34916. /**
  34917. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34919. */
  34920. collisionsEnabled: boolean;
  34921. private _collisionCoordinator;
  34922. /** @hidden */
  34923. readonly collisionCoordinator: ICollisionCoordinator;
  34924. /**
  34925. * Defines the gravity applied to this scene (used only for collisions)
  34926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34927. */
  34928. gravity: Vector3;
  34929. /**
  34930. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34931. */
  34932. postProcessesEnabled: boolean;
  34933. /**
  34934. * The list of postprocesses added to the scene
  34935. */
  34936. postProcesses: PostProcess[];
  34937. /**
  34938. * Gets the current postprocess manager
  34939. */
  34940. postProcessManager: PostProcessManager;
  34941. /**
  34942. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34943. */
  34944. renderTargetsEnabled: boolean;
  34945. /**
  34946. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34947. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34948. */
  34949. dumpNextRenderTargets: boolean;
  34950. /**
  34951. * The list of user defined render targets added to the scene
  34952. */
  34953. customRenderTargets: RenderTargetTexture[];
  34954. /**
  34955. * Defines if texture loading must be delayed
  34956. * If true, textures will only be loaded when they need to be rendered
  34957. */
  34958. useDelayedTextureLoading: boolean;
  34959. /**
  34960. * Gets the list of meshes imported to the scene through SceneLoader
  34961. */
  34962. importedMeshesFiles: String[];
  34963. /**
  34964. * Gets or sets a boolean indicating if probes are enabled on this scene
  34965. */
  34966. probesEnabled: boolean;
  34967. /**
  34968. * Gets or sets the current offline provider to use to store scene data
  34969. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34970. */
  34971. offlineProvider: IOfflineProvider;
  34972. /**
  34973. * Gets or sets the action manager associated with the scene
  34974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34975. */
  34976. actionManager: AbstractActionManager;
  34977. private _meshesForIntersections;
  34978. /**
  34979. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34980. */
  34981. proceduralTexturesEnabled: boolean;
  34982. private _engine;
  34983. private _totalVertices;
  34984. /** @hidden */
  34985. _activeIndices: PerfCounter;
  34986. /** @hidden */
  34987. _activeParticles: PerfCounter;
  34988. /** @hidden */
  34989. _activeBones: PerfCounter;
  34990. private _animationRatio;
  34991. /** @hidden */
  34992. _animationTimeLast: number;
  34993. /** @hidden */
  34994. _animationTime: number;
  34995. /**
  34996. * Gets or sets a general scale for animation speed
  34997. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34998. */
  34999. animationTimeScale: number;
  35000. /** @hidden */
  35001. _cachedMaterial: Nullable<Material>;
  35002. /** @hidden */
  35003. _cachedEffect: Nullable<Effect>;
  35004. /** @hidden */
  35005. _cachedVisibility: Nullable<number>;
  35006. private _renderId;
  35007. private _frameId;
  35008. private _executeWhenReadyTimeoutId;
  35009. private _intermediateRendering;
  35010. private _viewUpdateFlag;
  35011. private _projectionUpdateFlag;
  35012. /** @hidden */
  35013. _toBeDisposed: Nullable<IDisposable>[];
  35014. private _activeRequests;
  35015. /** @hidden */
  35016. _pendingData: any[];
  35017. private _isDisposed;
  35018. /**
  35019. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35020. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35021. */
  35022. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35023. private _activeMeshes;
  35024. private _processedMaterials;
  35025. private _renderTargets;
  35026. /** @hidden */
  35027. _activeParticleSystems: SmartArray<IParticleSystem>;
  35028. private _activeSkeletons;
  35029. private _softwareSkinnedMeshes;
  35030. private _renderingManager;
  35031. /** @hidden */
  35032. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35033. private _transformMatrix;
  35034. private _sceneUbo;
  35035. /** @hidden */
  35036. _viewMatrix: Matrix;
  35037. private _projectionMatrix;
  35038. /** @hidden */
  35039. _forcedViewPosition: Nullable<Vector3>;
  35040. /** @hidden */
  35041. _frustumPlanes: Plane[];
  35042. /**
  35043. * Gets the list of frustum planes (built from the active camera)
  35044. */
  35045. readonly frustumPlanes: Plane[];
  35046. /**
  35047. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35048. * This is useful if there are more lights that the maximum simulteanous authorized
  35049. */
  35050. requireLightSorting: boolean;
  35051. /** @hidden */
  35052. readonly useMaterialMeshMap: boolean;
  35053. /** @hidden */
  35054. readonly useClonedMeshhMap: boolean;
  35055. private _externalData;
  35056. private _uid;
  35057. /**
  35058. * @hidden
  35059. * Backing store of defined scene components.
  35060. */
  35061. _components: ISceneComponent[];
  35062. /**
  35063. * @hidden
  35064. * Backing store of defined scene components.
  35065. */
  35066. _serializableComponents: ISceneSerializableComponent[];
  35067. /**
  35068. * List of components to register on the next registration step.
  35069. */
  35070. private _transientComponents;
  35071. /**
  35072. * Registers the transient components if needed.
  35073. */
  35074. private _registerTransientComponents;
  35075. /**
  35076. * @hidden
  35077. * Add a component to the scene.
  35078. * Note that the ccomponent could be registered on th next frame if this is called after
  35079. * the register component stage.
  35080. * @param component Defines the component to add to the scene
  35081. */
  35082. _addComponent(component: ISceneComponent): void;
  35083. /**
  35084. * @hidden
  35085. * Gets a component from the scene.
  35086. * @param name defines the name of the component to retrieve
  35087. * @returns the component or null if not present
  35088. */
  35089. _getComponent(name: string): Nullable<ISceneComponent>;
  35090. /**
  35091. * @hidden
  35092. * Defines the actions happening before camera updates.
  35093. */
  35094. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35095. /**
  35096. * @hidden
  35097. * Defines the actions happening before clear the canvas.
  35098. */
  35099. _beforeClearStage: Stage<SimpleStageAction>;
  35100. /**
  35101. * @hidden
  35102. * Defines the actions when collecting render targets for the frame.
  35103. */
  35104. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35105. /**
  35106. * @hidden
  35107. * Defines the actions happening for one camera in the frame.
  35108. */
  35109. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35110. /**
  35111. * @hidden
  35112. * Defines the actions happening during the per mesh ready checks.
  35113. */
  35114. _isReadyForMeshStage: Stage<MeshStageAction>;
  35115. /**
  35116. * @hidden
  35117. * Defines the actions happening before evaluate active mesh checks.
  35118. */
  35119. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35120. /**
  35121. * @hidden
  35122. * Defines the actions happening during the evaluate sub mesh checks.
  35123. */
  35124. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35125. /**
  35126. * @hidden
  35127. * Defines the actions happening during the active mesh stage.
  35128. */
  35129. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35130. /**
  35131. * @hidden
  35132. * Defines the actions happening during the per camera render target step.
  35133. */
  35134. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35135. /**
  35136. * @hidden
  35137. * Defines the actions happening just before the active camera is drawing.
  35138. */
  35139. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35140. /**
  35141. * @hidden
  35142. * Defines the actions happening just before a render target is drawing.
  35143. */
  35144. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35145. /**
  35146. * @hidden
  35147. * Defines the actions happening just before a rendering group is drawing.
  35148. */
  35149. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35150. /**
  35151. * @hidden
  35152. * Defines the actions happening just before a mesh is drawing.
  35153. */
  35154. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35155. /**
  35156. * @hidden
  35157. * Defines the actions happening just after a mesh has been drawn.
  35158. */
  35159. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35160. /**
  35161. * @hidden
  35162. * Defines the actions happening just after a rendering group has been drawn.
  35163. */
  35164. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35165. /**
  35166. * @hidden
  35167. * Defines the actions happening just after the active camera has been drawn.
  35168. */
  35169. _afterCameraDrawStage: Stage<CameraStageAction>;
  35170. /**
  35171. * @hidden
  35172. * Defines the actions happening just after a render target has been drawn.
  35173. */
  35174. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35175. /**
  35176. * @hidden
  35177. * Defines the actions happening just after rendering all cameras and computing intersections.
  35178. */
  35179. _afterRenderStage: Stage<SimpleStageAction>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions happening when a pointer move event happens.
  35183. */
  35184. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening when a pointer down event happens.
  35188. */
  35189. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions happening when a pointer up event happens.
  35193. */
  35194. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35195. /**
  35196. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35197. */
  35198. private geometriesByUniqueId;
  35199. /**
  35200. * Creates a new Scene
  35201. * @param engine defines the engine to use to render this scene
  35202. * @param options defines the scene options
  35203. */
  35204. constructor(engine: Engine, options?: SceneOptions);
  35205. /**
  35206. * Gets a string idenfifying the name of the class
  35207. * @returns "Scene" string
  35208. */
  35209. getClassName(): string;
  35210. private _defaultMeshCandidates;
  35211. /**
  35212. * @hidden
  35213. */
  35214. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35215. private _defaultSubMeshCandidates;
  35216. /**
  35217. * @hidden
  35218. */
  35219. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35220. /**
  35221. * Sets the default candidate providers for the scene.
  35222. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35223. * and getCollidingSubMeshCandidates to their default function
  35224. */
  35225. setDefaultCandidateProviders(): void;
  35226. /**
  35227. * Gets the mesh that is currently under the pointer
  35228. */
  35229. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35230. /**
  35231. * Gets or sets the current on-screen X position of the pointer
  35232. */
  35233. pointerX: number;
  35234. /**
  35235. * Gets or sets the current on-screen Y position of the pointer
  35236. */
  35237. pointerY: number;
  35238. /**
  35239. * Gets the cached material (ie. the latest rendered one)
  35240. * @returns the cached material
  35241. */
  35242. getCachedMaterial(): Nullable<Material>;
  35243. /**
  35244. * Gets the cached effect (ie. the latest rendered one)
  35245. * @returns the cached effect
  35246. */
  35247. getCachedEffect(): Nullable<Effect>;
  35248. /**
  35249. * Gets the cached visibility state (ie. the latest rendered one)
  35250. * @returns the cached visibility state
  35251. */
  35252. getCachedVisibility(): Nullable<number>;
  35253. /**
  35254. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35255. * @param material defines the current material
  35256. * @param effect defines the current effect
  35257. * @param visibility defines the current visibility state
  35258. * @returns true if one parameter is not cached
  35259. */
  35260. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35261. /**
  35262. * Gets the engine associated with the scene
  35263. * @returns an Engine
  35264. */
  35265. getEngine(): Engine;
  35266. /**
  35267. * Gets the total number of vertices rendered per frame
  35268. * @returns the total number of vertices rendered per frame
  35269. */
  35270. getTotalVertices(): number;
  35271. /**
  35272. * Gets the performance counter for total vertices
  35273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35274. */
  35275. readonly totalVerticesPerfCounter: PerfCounter;
  35276. /**
  35277. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35278. * @returns the total number of active indices rendered per frame
  35279. */
  35280. getActiveIndices(): number;
  35281. /**
  35282. * Gets the performance counter for active indices
  35283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35284. */
  35285. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35286. /**
  35287. * Gets the total number of active particles rendered per frame
  35288. * @returns the total number of active particles rendered per frame
  35289. */
  35290. getActiveParticles(): number;
  35291. /**
  35292. * Gets the performance counter for active particles
  35293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35294. */
  35295. readonly activeParticlesPerfCounter: PerfCounter;
  35296. /**
  35297. * Gets the total number of active bones rendered per frame
  35298. * @returns the total number of active bones rendered per frame
  35299. */
  35300. getActiveBones(): number;
  35301. /**
  35302. * Gets the performance counter for active bones
  35303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35304. */
  35305. readonly activeBonesPerfCounter: PerfCounter;
  35306. /**
  35307. * Gets the array of active meshes
  35308. * @returns an array of AbstractMesh
  35309. */
  35310. getActiveMeshes(): SmartArray<AbstractMesh>;
  35311. /**
  35312. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35313. * @returns a number
  35314. */
  35315. getAnimationRatio(): number;
  35316. /**
  35317. * Gets an unique Id for the current render phase
  35318. * @returns a number
  35319. */
  35320. getRenderId(): number;
  35321. /**
  35322. * Gets an unique Id for the current frame
  35323. * @returns a number
  35324. */
  35325. getFrameId(): number;
  35326. /** Call this function if you want to manually increment the render Id*/
  35327. incrementRenderId(): void;
  35328. private _createUbo;
  35329. /**
  35330. * Use this method to simulate a pointer move on a mesh
  35331. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35332. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35333. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35334. * @returns the current scene
  35335. */
  35336. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35337. /**
  35338. * Use this method to simulate a pointer down on a mesh
  35339. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35340. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35341. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35342. * @returns the current scene
  35343. */
  35344. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35345. /**
  35346. * Use this method to simulate a pointer up on a mesh
  35347. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35348. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35349. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35350. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35351. * @returns the current scene
  35352. */
  35353. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35354. /**
  35355. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35356. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35357. * @returns true if the pointer was captured
  35358. */
  35359. isPointerCaptured(pointerId?: number): boolean;
  35360. /**
  35361. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35362. * @param attachUp defines if you want to attach events to pointerup
  35363. * @param attachDown defines if you want to attach events to pointerdown
  35364. * @param attachMove defines if you want to attach events to pointermove
  35365. */
  35366. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35367. /** Detaches all event handlers*/
  35368. detachControl(): void;
  35369. /**
  35370. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35371. * Delay loaded resources are not taking in account
  35372. * @return true if all required resources are ready
  35373. */
  35374. isReady(): boolean;
  35375. /** Resets all cached information relative to material (including effect and visibility) */
  35376. resetCachedMaterial(): void;
  35377. /**
  35378. * Registers a function to be called before every frame render
  35379. * @param func defines the function to register
  35380. */
  35381. registerBeforeRender(func: () => void): void;
  35382. /**
  35383. * Unregisters a function called before every frame render
  35384. * @param func defines the function to unregister
  35385. */
  35386. unregisterBeforeRender(func: () => void): void;
  35387. /**
  35388. * Registers a function to be called after every frame render
  35389. * @param func defines the function to register
  35390. */
  35391. registerAfterRender(func: () => void): void;
  35392. /**
  35393. * Unregisters a function called after every frame render
  35394. * @param func defines the function to unregister
  35395. */
  35396. unregisterAfterRender(func: () => void): void;
  35397. private _executeOnceBeforeRender;
  35398. /**
  35399. * The provided function will run before render once and will be disposed afterwards.
  35400. * A timeout delay can be provided so that the function will be executed in N ms.
  35401. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35402. * @param func The function to be executed.
  35403. * @param timeout optional delay in ms
  35404. */
  35405. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35406. /** @hidden */
  35407. _addPendingData(data: any): void;
  35408. /** @hidden */
  35409. _removePendingData(data: any): void;
  35410. /**
  35411. * Returns the number of items waiting to be loaded
  35412. * @returns the number of items waiting to be loaded
  35413. */
  35414. getWaitingItemsCount(): number;
  35415. /**
  35416. * Returns a boolean indicating if the scene is still loading data
  35417. */
  35418. readonly isLoading: boolean;
  35419. /**
  35420. * Registers a function to be executed when the scene is ready
  35421. * @param {Function} func - the function to be executed
  35422. */
  35423. executeWhenReady(func: () => void): void;
  35424. /**
  35425. * Returns a promise that resolves when the scene is ready
  35426. * @returns A promise that resolves when the scene is ready
  35427. */
  35428. whenReadyAsync(): Promise<void>;
  35429. /** @hidden */
  35430. _checkIsReady(): void;
  35431. /**
  35432. * Gets all animatable attached to the scene
  35433. */
  35434. readonly animatables: Animatable[];
  35435. /**
  35436. * Resets the last animation time frame.
  35437. * Useful to override when animations start running when loading a scene for the first time.
  35438. */
  35439. resetLastAnimationTimeFrame(): void;
  35440. /**
  35441. * Gets the current view matrix
  35442. * @returns a Matrix
  35443. */
  35444. getViewMatrix(): Matrix;
  35445. /**
  35446. * Gets the current projection matrix
  35447. * @returns a Matrix
  35448. */
  35449. getProjectionMatrix(): Matrix;
  35450. /**
  35451. * Gets the current transform matrix
  35452. * @returns a Matrix made of View * Projection
  35453. */
  35454. getTransformMatrix(): Matrix;
  35455. /**
  35456. * Sets the current transform matrix
  35457. * @param viewL defines the View matrix to use
  35458. * @param projectionL defines the Projection matrix to use
  35459. * @param viewR defines the right View matrix to use (if provided)
  35460. * @param projectionR defines the right Projection matrix to use (if provided)
  35461. */
  35462. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35463. /**
  35464. * Gets the uniform buffer used to store scene data
  35465. * @returns a UniformBuffer
  35466. */
  35467. getSceneUniformBuffer(): UniformBuffer;
  35468. /**
  35469. * Gets an unique (relatively to the current scene) Id
  35470. * @returns an unique number for the scene
  35471. */
  35472. getUniqueId(): number;
  35473. /**
  35474. * Add a mesh to the list of scene's meshes
  35475. * @param newMesh defines the mesh to add
  35476. * @param recursive if all child meshes should also be added to the scene
  35477. */
  35478. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35479. /**
  35480. * Remove a mesh for the list of scene's meshes
  35481. * @param toRemove defines the mesh to remove
  35482. * @param recursive if all child meshes should also be removed from the scene
  35483. * @returns the index where the mesh was in the mesh list
  35484. */
  35485. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35486. /**
  35487. * Add a transform node to the list of scene's transform nodes
  35488. * @param newTransformNode defines the transform node to add
  35489. */
  35490. addTransformNode(newTransformNode: TransformNode): void;
  35491. /**
  35492. * Remove a transform node for the list of scene's transform nodes
  35493. * @param toRemove defines the transform node to remove
  35494. * @returns the index where the transform node was in the transform node list
  35495. */
  35496. removeTransformNode(toRemove: TransformNode): number;
  35497. /**
  35498. * Remove a skeleton for the list of scene's skeletons
  35499. * @param toRemove defines the skeleton to remove
  35500. * @returns the index where the skeleton was in the skeleton list
  35501. */
  35502. removeSkeleton(toRemove: Skeleton): number;
  35503. /**
  35504. * Remove a morph target for the list of scene's morph targets
  35505. * @param toRemove defines the morph target to remove
  35506. * @returns the index where the morph target was in the morph target list
  35507. */
  35508. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35509. /**
  35510. * Remove a light for the list of scene's lights
  35511. * @param toRemove defines the light to remove
  35512. * @returns the index where the light was in the light list
  35513. */
  35514. removeLight(toRemove: Light): number;
  35515. /**
  35516. * Remove a camera for the list of scene's cameras
  35517. * @param toRemove defines the camera to remove
  35518. * @returns the index where the camera was in the camera list
  35519. */
  35520. removeCamera(toRemove: Camera): number;
  35521. /**
  35522. * Remove a particle system for the list of scene's particle systems
  35523. * @param toRemove defines the particle system to remove
  35524. * @returns the index where the particle system was in the particle system list
  35525. */
  35526. removeParticleSystem(toRemove: IParticleSystem): number;
  35527. /**
  35528. * Remove a animation for the list of scene's animations
  35529. * @param toRemove defines the animation to remove
  35530. * @returns the index where the animation was in the animation list
  35531. */
  35532. removeAnimation(toRemove: Animation): number;
  35533. /**
  35534. * Will stop the animation of the given target
  35535. * @param target - the target
  35536. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35537. * @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)
  35538. */
  35539. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35540. /**
  35541. * Removes the given animation group from this scene.
  35542. * @param toRemove The animation group to remove
  35543. * @returns The index of the removed animation group
  35544. */
  35545. removeAnimationGroup(toRemove: AnimationGroup): number;
  35546. /**
  35547. * Removes the given multi-material from this scene.
  35548. * @param toRemove The multi-material to remove
  35549. * @returns The index of the removed multi-material
  35550. */
  35551. removeMultiMaterial(toRemove: MultiMaterial): number;
  35552. /**
  35553. * Removes the given material from this scene.
  35554. * @param toRemove The material to remove
  35555. * @returns The index of the removed material
  35556. */
  35557. removeMaterial(toRemove: Material): number;
  35558. /**
  35559. * Removes the given action manager from this scene.
  35560. * @param toRemove The action manager to remove
  35561. * @returns The index of the removed action manager
  35562. */
  35563. removeActionManager(toRemove: AbstractActionManager): number;
  35564. /**
  35565. * Removes the given texture from this scene.
  35566. * @param toRemove The texture to remove
  35567. * @returns The index of the removed texture
  35568. */
  35569. removeTexture(toRemove: BaseTexture): number;
  35570. /**
  35571. * Adds the given light to this scene
  35572. * @param newLight The light to add
  35573. */
  35574. addLight(newLight: Light): void;
  35575. /**
  35576. * Sorts the list list based on light priorities
  35577. */
  35578. sortLightsByPriority(): void;
  35579. /**
  35580. * Adds the given camera to this scene
  35581. * @param newCamera The camera to add
  35582. */
  35583. addCamera(newCamera: Camera): void;
  35584. /**
  35585. * Adds the given skeleton to this scene
  35586. * @param newSkeleton The skeleton to add
  35587. */
  35588. addSkeleton(newSkeleton: Skeleton): void;
  35589. /**
  35590. * Adds the given particle system to this scene
  35591. * @param newParticleSystem The particle system to add
  35592. */
  35593. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35594. /**
  35595. * Adds the given animation to this scene
  35596. * @param newAnimation The animation to add
  35597. */
  35598. addAnimation(newAnimation: Animation): void;
  35599. /**
  35600. * Adds the given animation group to this scene.
  35601. * @param newAnimationGroup The animation group to add
  35602. */
  35603. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35604. /**
  35605. * Adds the given multi-material to this scene
  35606. * @param newMultiMaterial The multi-material to add
  35607. */
  35608. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35609. /**
  35610. * Adds the given material to this scene
  35611. * @param newMaterial The material to add
  35612. */
  35613. addMaterial(newMaterial: Material): void;
  35614. /**
  35615. * Adds the given morph target to this scene
  35616. * @param newMorphTargetManager The morph target to add
  35617. */
  35618. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35619. /**
  35620. * Adds the given geometry to this scene
  35621. * @param newGeometry The geometry to add
  35622. */
  35623. addGeometry(newGeometry: Geometry): void;
  35624. /**
  35625. * Adds the given action manager to this scene
  35626. * @param newActionManager The action manager to add
  35627. */
  35628. addActionManager(newActionManager: AbstractActionManager): void;
  35629. /**
  35630. * Adds the given texture to this scene.
  35631. * @param newTexture The texture to add
  35632. */
  35633. addTexture(newTexture: BaseTexture): void;
  35634. /**
  35635. * Switch active camera
  35636. * @param newCamera defines the new active camera
  35637. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35638. */
  35639. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35640. /**
  35641. * sets the active camera of the scene using its ID
  35642. * @param id defines the camera's ID
  35643. * @return the new active camera or null if none found.
  35644. */
  35645. setActiveCameraByID(id: string): Nullable<Camera>;
  35646. /**
  35647. * sets the active camera of the scene using its name
  35648. * @param name defines the camera's name
  35649. * @returns the new active camera or null if none found.
  35650. */
  35651. setActiveCameraByName(name: string): Nullable<Camera>;
  35652. /**
  35653. * get an animation group using its name
  35654. * @param name defines the material's name
  35655. * @return the animation group or null if none found.
  35656. */
  35657. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35658. /**
  35659. * Get a material using its unique id
  35660. * @param uniqueId defines the material's unique id
  35661. * @return the material or null if none found.
  35662. */
  35663. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35664. /**
  35665. * get a material using its id
  35666. * @param id defines the material's ID
  35667. * @return the material or null if none found.
  35668. */
  35669. getMaterialByID(id: string): Nullable<Material>;
  35670. /**
  35671. * Gets a the last added material using a given id
  35672. * @param id defines the material's ID
  35673. * @return the last material with the given id or null if none found.
  35674. */
  35675. getLastMaterialByID(id: string): Nullable<Material>;
  35676. /**
  35677. * Gets a material using its name
  35678. * @param name defines the material's name
  35679. * @return the material or null if none found.
  35680. */
  35681. getMaterialByName(name: string): Nullable<Material>;
  35682. /**
  35683. * Get a texture using its unique id
  35684. * @param uniqueId defines the texture's unique id
  35685. * @return the texture or null if none found.
  35686. */
  35687. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35688. /**
  35689. * Gets a camera using its id
  35690. * @param id defines the id to look for
  35691. * @returns the camera or null if not found
  35692. */
  35693. getCameraByID(id: string): Nullable<Camera>;
  35694. /**
  35695. * Gets a camera using its unique id
  35696. * @param uniqueId defines the unique id to look for
  35697. * @returns the camera or null if not found
  35698. */
  35699. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35700. /**
  35701. * Gets a camera using its name
  35702. * @param name defines the camera's name
  35703. * @return the camera or null if none found.
  35704. */
  35705. getCameraByName(name: string): Nullable<Camera>;
  35706. /**
  35707. * Gets a bone using its id
  35708. * @param id defines the bone's id
  35709. * @return the bone or null if not found
  35710. */
  35711. getBoneByID(id: string): Nullable<Bone>;
  35712. /**
  35713. * Gets a bone using its id
  35714. * @param name defines the bone's name
  35715. * @return the bone or null if not found
  35716. */
  35717. getBoneByName(name: string): Nullable<Bone>;
  35718. /**
  35719. * Gets a light node using its name
  35720. * @param name defines the the light's name
  35721. * @return the light or null if none found.
  35722. */
  35723. getLightByName(name: string): Nullable<Light>;
  35724. /**
  35725. * Gets a light node using its id
  35726. * @param id defines the light's id
  35727. * @return the light or null if none found.
  35728. */
  35729. getLightByID(id: string): Nullable<Light>;
  35730. /**
  35731. * Gets a light node using its scene-generated unique ID
  35732. * @param uniqueId defines the light's unique id
  35733. * @return the light or null if none found.
  35734. */
  35735. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35736. /**
  35737. * Gets a particle system by id
  35738. * @param id defines the particle system id
  35739. * @return the corresponding system or null if none found
  35740. */
  35741. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35742. /**
  35743. * Gets a geometry using its ID
  35744. * @param id defines the geometry's id
  35745. * @return the geometry or null if none found.
  35746. */
  35747. getGeometryByID(id: string): Nullable<Geometry>;
  35748. private _getGeometryByUniqueID;
  35749. /**
  35750. * Add a new geometry to this scene
  35751. * @param geometry defines the geometry to be added to the scene.
  35752. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35753. * @return a boolean defining if the geometry was added or not
  35754. */
  35755. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35756. /**
  35757. * Removes an existing geometry
  35758. * @param geometry defines the geometry to be removed from the scene
  35759. * @return a boolean defining if the geometry was removed or not
  35760. */
  35761. removeGeometry(geometry: Geometry): boolean;
  35762. /**
  35763. * Gets the list of geometries attached to the scene
  35764. * @returns an array of Geometry
  35765. */
  35766. getGeometries(): Geometry[];
  35767. /**
  35768. * Gets the first added mesh found of a given ID
  35769. * @param id defines the id to search for
  35770. * @return the mesh found or null if not found at all
  35771. */
  35772. getMeshByID(id: string): Nullable<AbstractMesh>;
  35773. /**
  35774. * Gets a list of meshes using their id
  35775. * @param id defines the id to search for
  35776. * @returns a list of meshes
  35777. */
  35778. getMeshesByID(id: string): Array<AbstractMesh>;
  35779. /**
  35780. * Gets the first added transform node found of a given ID
  35781. * @param id defines the id to search for
  35782. * @return the found transform node or null if not found at all.
  35783. */
  35784. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35785. /**
  35786. * Gets a transform node with its auto-generated unique id
  35787. * @param uniqueId efines the unique id to search for
  35788. * @return the found transform node or null if not found at all.
  35789. */
  35790. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35791. /**
  35792. * Gets a list of transform nodes using their id
  35793. * @param id defines the id to search for
  35794. * @returns a list of transform nodes
  35795. */
  35796. getTransformNodesByID(id: string): Array<TransformNode>;
  35797. /**
  35798. * Gets a mesh with its auto-generated unique id
  35799. * @param uniqueId defines the unique id to search for
  35800. * @return the found mesh or null if not found at all.
  35801. */
  35802. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35803. /**
  35804. * Gets a the last added mesh using a given id
  35805. * @param id defines the id to search for
  35806. * @return the found mesh or null if not found at all.
  35807. */
  35808. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35809. /**
  35810. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35811. * @param id defines the id to search for
  35812. * @return the found node or null if not found at all
  35813. */
  35814. getLastEntryByID(id: string): Nullable<Node>;
  35815. /**
  35816. * Gets a node (Mesh, Camera, Light) using a given id
  35817. * @param id defines the id to search for
  35818. * @return the found node or null if not found at all
  35819. */
  35820. getNodeByID(id: string): Nullable<Node>;
  35821. /**
  35822. * Gets a node (Mesh, Camera, Light) using a given name
  35823. * @param name defines the name to search for
  35824. * @return the found node or null if not found at all.
  35825. */
  35826. getNodeByName(name: string): Nullable<Node>;
  35827. /**
  35828. * Gets a mesh using a given name
  35829. * @param name defines the name to search for
  35830. * @return the found mesh or null if not found at all.
  35831. */
  35832. getMeshByName(name: string): Nullable<AbstractMesh>;
  35833. /**
  35834. * Gets a transform node using a given name
  35835. * @param name defines the name to search for
  35836. * @return the found transform node or null if not found at all.
  35837. */
  35838. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35839. /**
  35840. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35841. * @param id defines the id to search for
  35842. * @return the found skeleton or null if not found at all.
  35843. */
  35844. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35845. /**
  35846. * Gets a skeleton using a given auto generated unique id
  35847. * @param uniqueId defines the unique id to search for
  35848. * @return the found skeleton or null if not found at all.
  35849. */
  35850. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35851. /**
  35852. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35853. * @param id defines the id to search for
  35854. * @return the found skeleton or null if not found at all.
  35855. */
  35856. getSkeletonById(id: string): Nullable<Skeleton>;
  35857. /**
  35858. * Gets a skeleton using a given name
  35859. * @param name defines the name to search for
  35860. * @return the found skeleton or null if not found at all.
  35861. */
  35862. getSkeletonByName(name: string): Nullable<Skeleton>;
  35863. /**
  35864. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35865. * @param id defines the id to search for
  35866. * @return the found morph target manager or null if not found at all.
  35867. */
  35868. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35869. /**
  35870. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35871. * @param id defines the id to search for
  35872. * @return the found morph target or null if not found at all.
  35873. */
  35874. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35875. /**
  35876. * Gets a boolean indicating if the given mesh is active
  35877. * @param mesh defines the mesh to look for
  35878. * @returns true if the mesh is in the active list
  35879. */
  35880. isActiveMesh(mesh: AbstractMesh): boolean;
  35881. /**
  35882. * Return a unique id as a string which can serve as an identifier for the scene
  35883. */
  35884. readonly uid: string;
  35885. /**
  35886. * Add an externaly attached data from its key.
  35887. * This method call will fail and return false, if such key already exists.
  35888. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35889. * @param key the unique key that identifies the data
  35890. * @param data the data object to associate to the key for this Engine instance
  35891. * @return true if no such key were already present and the data was added successfully, false otherwise
  35892. */
  35893. addExternalData<T>(key: string, data: T): boolean;
  35894. /**
  35895. * Get an externaly attached data from its key
  35896. * @param key the unique key that identifies the data
  35897. * @return the associated data, if present (can be null), or undefined if not present
  35898. */
  35899. getExternalData<T>(key: string): Nullable<T>;
  35900. /**
  35901. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35902. * @param key the unique key that identifies the data
  35903. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35904. * @return the associated data, can be null if the factory returned null.
  35905. */
  35906. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35907. /**
  35908. * Remove an externaly attached data from the Engine instance
  35909. * @param key the unique key that identifies the data
  35910. * @return true if the data was successfully removed, false if it doesn't exist
  35911. */
  35912. removeExternalData(key: string): boolean;
  35913. private _evaluateSubMesh;
  35914. /**
  35915. * Clear the processed materials smart array preventing retention point in material dispose.
  35916. */
  35917. freeProcessedMaterials(): void;
  35918. private _preventFreeActiveMeshesAndRenderingGroups;
  35919. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35920. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35921. * when disposing several meshes in a row or a hierarchy of meshes.
  35922. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35923. */
  35924. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35925. /**
  35926. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35927. */
  35928. freeActiveMeshes(): void;
  35929. /**
  35930. * Clear the info related to rendering groups preventing retention points during dispose.
  35931. */
  35932. freeRenderingGroups(): void;
  35933. /** @hidden */
  35934. _isInIntermediateRendering(): boolean;
  35935. /**
  35936. * Lambda returning the list of potentially active meshes.
  35937. */
  35938. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35939. /**
  35940. * Lambda returning the list of potentially active sub meshes.
  35941. */
  35942. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35943. /**
  35944. * Lambda returning the list of potentially intersecting sub meshes.
  35945. */
  35946. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35947. /**
  35948. * Lambda returning the list of potentially colliding sub meshes.
  35949. */
  35950. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35951. private _activeMeshesFrozen;
  35952. private _skipEvaluateActiveMeshesCompletely;
  35953. /**
  35954. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35955. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35956. * @returns the current scene
  35957. */
  35958. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35959. /**
  35960. * Use this function to restart evaluating active meshes on every frame
  35961. * @returns the current scene
  35962. */
  35963. unfreezeActiveMeshes(): Scene;
  35964. private _evaluateActiveMeshes;
  35965. private _activeMesh;
  35966. /**
  35967. * Update the transform matrix to update from the current active camera
  35968. * @param force defines a boolean used to force the update even if cache is up to date
  35969. */
  35970. updateTransformMatrix(force?: boolean): void;
  35971. private _bindFrameBuffer;
  35972. /** @hidden */
  35973. _allowPostProcessClearColor: boolean;
  35974. /** @hidden */
  35975. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35976. private _processSubCameras;
  35977. private _checkIntersections;
  35978. /** @hidden */
  35979. _advancePhysicsEngineStep(step: number): void;
  35980. /**
  35981. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35982. */
  35983. getDeterministicFrameTime: () => number;
  35984. /** @hidden */
  35985. _animate(): void;
  35986. /** Execute all animations (for a frame) */
  35987. animate(): void;
  35988. /**
  35989. * Render the scene
  35990. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35991. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35992. */
  35993. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35994. /**
  35995. * Freeze all materials
  35996. * A frozen material will not be updatable but should be faster to render
  35997. */
  35998. freezeMaterials(): void;
  35999. /**
  36000. * Unfreeze all materials
  36001. * A frozen material will not be updatable but should be faster to render
  36002. */
  36003. unfreezeMaterials(): void;
  36004. /**
  36005. * Releases all held ressources
  36006. */
  36007. dispose(): void;
  36008. /**
  36009. * Gets if the scene is already disposed
  36010. */
  36011. readonly isDisposed: boolean;
  36012. /**
  36013. * Call this function to reduce memory footprint of the scene.
  36014. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36015. */
  36016. clearCachedVertexData(): void;
  36017. /**
  36018. * This function will remove the local cached buffer data from texture.
  36019. * It will save memory but will prevent the texture from being rebuilt
  36020. */
  36021. cleanCachedTextureBuffer(): void;
  36022. /**
  36023. * Get the world extend vectors with an optional filter
  36024. *
  36025. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36026. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36027. */
  36028. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36029. min: Vector3;
  36030. max: Vector3;
  36031. };
  36032. /**
  36033. * Creates a ray that can be used to pick in the scene
  36034. * @param x defines the x coordinate of the origin (on-screen)
  36035. * @param y defines the y coordinate of the origin (on-screen)
  36036. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36037. * @param camera defines the camera to use for the picking
  36038. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36039. * @returns a Ray
  36040. */
  36041. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36042. /**
  36043. * Creates a ray that can be used to pick in the scene
  36044. * @param x defines the x coordinate of the origin (on-screen)
  36045. * @param y defines the y coordinate of the origin (on-screen)
  36046. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36047. * @param result defines the ray where to store the picking ray
  36048. * @param camera defines the camera to use for the picking
  36049. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36050. * @returns the current scene
  36051. */
  36052. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36053. /**
  36054. * Creates a ray that can be used to pick in the scene
  36055. * @param x defines the x coordinate of the origin (on-screen)
  36056. * @param y defines the y coordinate of the origin (on-screen)
  36057. * @param camera defines the camera to use for the picking
  36058. * @returns a Ray
  36059. */
  36060. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36061. /**
  36062. * Creates a ray that can be used to pick in the scene
  36063. * @param x defines the x coordinate of the origin (on-screen)
  36064. * @param y defines the y coordinate of the origin (on-screen)
  36065. * @param result defines the ray where to store the picking ray
  36066. * @param camera defines the camera to use for the picking
  36067. * @returns the current scene
  36068. */
  36069. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36070. /** Launch a ray to try to pick a mesh in the scene
  36071. * @param x position on screen
  36072. * @param y position on screen
  36073. * @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
  36074. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36075. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36076. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36077. * @returns a PickingInfo
  36078. */
  36079. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36080. /** Use the given ray to pick a mesh in the scene
  36081. * @param ray The ray to use to pick meshes
  36082. * @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
  36083. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36084. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36085. * @returns a PickingInfo
  36086. */
  36087. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36088. /**
  36089. * Launch a ray to try to pick a mesh in the scene
  36090. * @param x X position on screen
  36091. * @param y Y position on screen
  36092. * @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
  36093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36095. * @returns an array of PickingInfo
  36096. */
  36097. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36098. /**
  36099. * Launch a ray to try to pick a mesh in the scene
  36100. * @param ray Ray to use
  36101. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  36102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36103. * @returns an array of PickingInfo
  36104. */
  36105. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36106. /**
  36107. * Force the value of meshUnderPointer
  36108. * @param mesh defines the mesh to use
  36109. */
  36110. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36111. /**
  36112. * Gets the mesh under the pointer
  36113. * @returns a Mesh or null if no mesh is under the pointer
  36114. */
  36115. getPointerOverMesh(): Nullable<AbstractMesh>;
  36116. /** @hidden */
  36117. _rebuildGeometries(): void;
  36118. /** @hidden */
  36119. _rebuildTextures(): void;
  36120. private _getByTags;
  36121. /**
  36122. * Get a list of meshes by tags
  36123. * @param tagsQuery defines the tags query to use
  36124. * @param forEach defines a predicate used to filter results
  36125. * @returns an array of Mesh
  36126. */
  36127. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36128. /**
  36129. * Get a list of cameras by tags
  36130. * @param tagsQuery defines the tags query to use
  36131. * @param forEach defines a predicate used to filter results
  36132. * @returns an array of Camera
  36133. */
  36134. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36135. /**
  36136. * Get a list of lights by tags
  36137. * @param tagsQuery defines the tags query to use
  36138. * @param forEach defines a predicate used to filter results
  36139. * @returns an array of Light
  36140. */
  36141. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36142. /**
  36143. * Get a list of materials by tags
  36144. * @param tagsQuery defines the tags query to use
  36145. * @param forEach defines a predicate used to filter results
  36146. * @returns an array of Material
  36147. */
  36148. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36149. /**
  36150. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36151. * This allowed control for front to back rendering or reversly depending of the special needs.
  36152. *
  36153. * @param renderingGroupId The rendering group id corresponding to its index
  36154. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36155. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36156. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36157. */
  36158. 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;
  36159. /**
  36160. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36161. *
  36162. * @param renderingGroupId The rendering group id corresponding to its index
  36163. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36164. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36165. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36166. */
  36167. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36168. /**
  36169. * Gets the current auto clear configuration for one rendering group of the rendering
  36170. * manager.
  36171. * @param index the rendering group index to get the information for
  36172. * @returns The auto clear setup for the requested rendering group
  36173. */
  36174. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36175. private _blockMaterialDirtyMechanism;
  36176. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36177. blockMaterialDirtyMechanism: boolean;
  36178. /**
  36179. * Will flag all materials as dirty to trigger new shader compilation
  36180. * @param flag defines the flag used to specify which material part must be marked as dirty
  36181. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36182. */
  36183. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36184. /** @hidden */
  36185. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  36186. /** @hidden */
  36187. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36188. /** @hidden */
  36189. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  36190. /** @hidden */
  36191. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36192. /** @hidden */
  36193. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36194. /** @hidden */
  36195. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36196. }
  36197. }
  36198. declare module "babylonjs/assetContainer" {
  36199. import { AbstractScene } from "babylonjs/abstractScene";
  36200. import { Scene } from "babylonjs/scene";
  36201. import { Mesh } from "babylonjs/Meshes/mesh";
  36202. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36203. import { Skeleton } from "babylonjs/Bones/skeleton";
  36204. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36205. /**
  36206. * Set of assets to keep when moving a scene into an asset container.
  36207. */
  36208. export class KeepAssets extends AbstractScene {
  36209. }
  36210. /**
  36211. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36212. */
  36213. export class InstantiatedEntries {
  36214. /**
  36215. * List of new root nodes (eg. nodes with no parent)
  36216. */
  36217. rootNodes: TransformNode[];
  36218. /**
  36219. * List of new skeletons
  36220. */
  36221. skeletons: Skeleton[];
  36222. /**
  36223. * List of new animation groups
  36224. */
  36225. animationGroups: AnimationGroup[];
  36226. }
  36227. /**
  36228. * Container with a set of assets that can be added or removed from a scene.
  36229. */
  36230. export class AssetContainer extends AbstractScene {
  36231. /**
  36232. * The scene the AssetContainer belongs to.
  36233. */
  36234. scene: Scene;
  36235. /**
  36236. * Instantiates an AssetContainer.
  36237. * @param scene The scene the AssetContainer belongs to.
  36238. */
  36239. constructor(scene: Scene);
  36240. /**
  36241. * Instantiate or clone all meshes and add the new ones to the scene.
  36242. * Skeletons and animation groups will all be cloned
  36243. * @param nameFunction defines an optional function used to get new names for clones
  36244. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36245. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36246. */
  36247. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36248. /**
  36249. * Adds all the assets from the container to the scene.
  36250. */
  36251. addAllToScene(): void;
  36252. /**
  36253. * Removes all the assets in the container from the scene
  36254. */
  36255. removeAllFromScene(): void;
  36256. /**
  36257. * Disposes all the assets in the container
  36258. */
  36259. dispose(): void;
  36260. private _moveAssets;
  36261. /**
  36262. * Removes all the assets contained in the scene and adds them to the container.
  36263. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36264. */
  36265. moveAllFromScene(keepAssets?: KeepAssets): void;
  36266. /**
  36267. * 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.
  36268. * @returns the root mesh
  36269. */
  36270. createRootMesh(): Mesh;
  36271. }
  36272. }
  36273. declare module "babylonjs/abstractScene" {
  36274. import { Scene } from "babylonjs/scene";
  36275. import { Nullable } from "babylonjs/types";
  36276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36277. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36278. import { Geometry } from "babylonjs/Meshes/geometry";
  36279. import { Skeleton } from "babylonjs/Bones/skeleton";
  36280. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36281. import { AssetContainer } from "babylonjs/assetContainer";
  36282. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36283. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36285. import { Material } from "babylonjs/Materials/material";
  36286. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36287. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36288. import { Camera } from "babylonjs/Cameras/camera";
  36289. import { Light } from "babylonjs/Lights/light";
  36290. import { Node } from "babylonjs/node";
  36291. import { Animation } from "babylonjs/Animations/animation";
  36292. /**
  36293. * Defines how the parser contract is defined.
  36294. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36295. */
  36296. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36297. /**
  36298. * Defines how the individual parser contract is defined.
  36299. * These parser can parse an individual asset
  36300. */
  36301. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36302. /**
  36303. * Base class of the scene acting as a container for the different elements composing a scene.
  36304. * This class is dynamically extended by the different components of the scene increasing
  36305. * flexibility and reducing coupling
  36306. */
  36307. export abstract class AbstractScene {
  36308. /**
  36309. * Stores the list of available parsers in the application.
  36310. */
  36311. private static _BabylonFileParsers;
  36312. /**
  36313. * Stores the list of available individual parsers in the application.
  36314. */
  36315. private static _IndividualBabylonFileParsers;
  36316. /**
  36317. * Adds a parser in the list of available ones
  36318. * @param name Defines the name of the parser
  36319. * @param parser Defines the parser to add
  36320. */
  36321. static AddParser(name: string, parser: BabylonFileParser): void;
  36322. /**
  36323. * Gets a general parser from the list of avaialble ones
  36324. * @param name Defines the name of the parser
  36325. * @returns the requested parser or null
  36326. */
  36327. static GetParser(name: string): Nullable<BabylonFileParser>;
  36328. /**
  36329. * Adds n individual parser in the list of available ones
  36330. * @param name Defines the name of the parser
  36331. * @param parser Defines the parser to add
  36332. */
  36333. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36334. /**
  36335. * Gets an individual parser from the list of avaialble ones
  36336. * @param name Defines the name of the parser
  36337. * @returns the requested parser or null
  36338. */
  36339. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36340. /**
  36341. * Parser json data and populate both a scene and its associated container object
  36342. * @param jsonData Defines the data to parse
  36343. * @param scene Defines the scene to parse the data for
  36344. * @param container Defines the container attached to the parsing sequence
  36345. * @param rootUrl Defines the root url of the data
  36346. */
  36347. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36348. /**
  36349. * Gets the list of root nodes (ie. nodes with no parent)
  36350. */
  36351. rootNodes: Node[];
  36352. /** All of the cameras added to this scene
  36353. * @see http://doc.babylonjs.com/babylon101/cameras
  36354. */
  36355. cameras: Camera[];
  36356. /**
  36357. * All of the lights added to this scene
  36358. * @see http://doc.babylonjs.com/babylon101/lights
  36359. */
  36360. lights: Light[];
  36361. /**
  36362. * All of the (abstract) meshes added to this scene
  36363. */
  36364. meshes: AbstractMesh[];
  36365. /**
  36366. * The list of skeletons added to the scene
  36367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36368. */
  36369. skeletons: Skeleton[];
  36370. /**
  36371. * All of the particle systems added to this scene
  36372. * @see http://doc.babylonjs.com/babylon101/particles
  36373. */
  36374. particleSystems: IParticleSystem[];
  36375. /**
  36376. * Gets a list of Animations associated with the scene
  36377. */
  36378. animations: Animation[];
  36379. /**
  36380. * All of the animation groups added to this scene
  36381. * @see http://doc.babylonjs.com/how_to/group
  36382. */
  36383. animationGroups: AnimationGroup[];
  36384. /**
  36385. * All of the multi-materials added to this scene
  36386. * @see http://doc.babylonjs.com/how_to/multi_materials
  36387. */
  36388. multiMaterials: MultiMaterial[];
  36389. /**
  36390. * All of the materials added to this scene
  36391. * In the context of a Scene, it is not supposed to be modified manually.
  36392. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36393. * Note also that the order of the Material within the array is not significant and might change.
  36394. * @see http://doc.babylonjs.com/babylon101/materials
  36395. */
  36396. materials: Material[];
  36397. /**
  36398. * The list of morph target managers added to the scene
  36399. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36400. */
  36401. morphTargetManagers: MorphTargetManager[];
  36402. /**
  36403. * The list of geometries used in the scene.
  36404. */
  36405. geometries: Geometry[];
  36406. /**
  36407. * All of the tranform nodes added to this scene
  36408. * In the context of a Scene, it is not supposed to be modified manually.
  36409. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36410. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36411. * @see http://doc.babylonjs.com/how_to/transformnode
  36412. */
  36413. transformNodes: TransformNode[];
  36414. /**
  36415. * ActionManagers available on the scene.
  36416. */
  36417. actionManagers: AbstractActionManager[];
  36418. /**
  36419. * Textures to keep.
  36420. */
  36421. textures: BaseTexture[];
  36422. /**
  36423. * Environment texture for the scene
  36424. */
  36425. environmentTexture: Nullable<BaseTexture>;
  36426. }
  36427. }
  36428. declare module "babylonjs/Audio/sound" {
  36429. import { Observable } from "babylonjs/Misc/observable";
  36430. import { Vector3 } from "babylonjs/Maths/math.vector";
  36431. import { Nullable } from "babylonjs/types";
  36432. import { Scene } from "babylonjs/scene";
  36433. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36434. /**
  36435. * Interface used to define options for Sound class
  36436. */
  36437. export interface ISoundOptions {
  36438. /**
  36439. * Does the sound autoplay once loaded.
  36440. */
  36441. autoplay?: boolean;
  36442. /**
  36443. * Does the sound loop after it finishes playing once.
  36444. */
  36445. loop?: boolean;
  36446. /**
  36447. * Sound's volume
  36448. */
  36449. volume?: number;
  36450. /**
  36451. * Is it a spatial sound?
  36452. */
  36453. spatialSound?: boolean;
  36454. /**
  36455. * Maximum distance to hear that sound
  36456. */
  36457. maxDistance?: number;
  36458. /**
  36459. * Uses user defined attenuation function
  36460. */
  36461. useCustomAttenuation?: boolean;
  36462. /**
  36463. * Define the roll off factor of spatial sounds.
  36464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36465. */
  36466. rolloffFactor?: number;
  36467. /**
  36468. * Define the reference distance the sound should be heard perfectly.
  36469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36470. */
  36471. refDistance?: number;
  36472. /**
  36473. * Define the distance attenuation model the sound will follow.
  36474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36475. */
  36476. distanceModel?: string;
  36477. /**
  36478. * Defines the playback speed (1 by default)
  36479. */
  36480. playbackRate?: number;
  36481. /**
  36482. * Defines if the sound is from a streaming source
  36483. */
  36484. streaming?: boolean;
  36485. /**
  36486. * Defines an optional length (in seconds) inside the sound file
  36487. */
  36488. length?: number;
  36489. /**
  36490. * Defines an optional offset (in seconds) inside the sound file
  36491. */
  36492. offset?: number;
  36493. /**
  36494. * If true, URLs will not be required to state the audio file codec to use.
  36495. */
  36496. skipCodecCheck?: boolean;
  36497. }
  36498. /**
  36499. * Defines a sound that can be played in the application.
  36500. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36502. */
  36503. export class Sound {
  36504. /**
  36505. * The name of the sound in the scene.
  36506. */
  36507. name: string;
  36508. /**
  36509. * Does the sound autoplay once loaded.
  36510. */
  36511. autoplay: boolean;
  36512. /**
  36513. * Does the sound loop after it finishes playing once.
  36514. */
  36515. loop: boolean;
  36516. /**
  36517. * Does the sound use a custom attenuation curve to simulate the falloff
  36518. * happening when the source gets further away from the camera.
  36519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36520. */
  36521. useCustomAttenuation: boolean;
  36522. /**
  36523. * The sound track id this sound belongs to.
  36524. */
  36525. soundTrackId: number;
  36526. /**
  36527. * Is this sound currently played.
  36528. */
  36529. isPlaying: boolean;
  36530. /**
  36531. * Is this sound currently paused.
  36532. */
  36533. isPaused: boolean;
  36534. /**
  36535. * Does this sound enables spatial sound.
  36536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36537. */
  36538. spatialSound: boolean;
  36539. /**
  36540. * Define the reference distance the sound should be heard perfectly.
  36541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36542. */
  36543. refDistance: number;
  36544. /**
  36545. * Define the roll off factor of spatial sounds.
  36546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36547. */
  36548. rolloffFactor: number;
  36549. /**
  36550. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36552. */
  36553. maxDistance: number;
  36554. /**
  36555. * Define the distance attenuation model the sound will follow.
  36556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36557. */
  36558. distanceModel: string;
  36559. /**
  36560. * @hidden
  36561. * Back Compat
  36562. **/
  36563. onended: () => any;
  36564. /**
  36565. * Observable event when the current playing sound finishes.
  36566. */
  36567. onEndedObservable: Observable<Sound>;
  36568. private _panningModel;
  36569. private _playbackRate;
  36570. private _streaming;
  36571. private _startTime;
  36572. private _startOffset;
  36573. private _position;
  36574. /** @hidden */
  36575. _positionInEmitterSpace: boolean;
  36576. private _localDirection;
  36577. private _volume;
  36578. private _isReadyToPlay;
  36579. private _isDirectional;
  36580. private _readyToPlayCallback;
  36581. private _audioBuffer;
  36582. private _soundSource;
  36583. private _streamingSource;
  36584. private _soundPanner;
  36585. private _soundGain;
  36586. private _inputAudioNode;
  36587. private _outputAudioNode;
  36588. private _coneInnerAngle;
  36589. private _coneOuterAngle;
  36590. private _coneOuterGain;
  36591. private _scene;
  36592. private _connectedTransformNode;
  36593. private _customAttenuationFunction;
  36594. private _registerFunc;
  36595. private _isOutputConnected;
  36596. private _htmlAudioElement;
  36597. private _urlType;
  36598. private _length?;
  36599. private _offset?;
  36600. /** @hidden */
  36601. static _SceneComponentInitialization: (scene: Scene) => void;
  36602. /**
  36603. * Create a sound and attach it to a scene
  36604. * @param name Name of your sound
  36605. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36606. * @param scene defines the scene the sound belongs to
  36607. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36608. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36609. */
  36610. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36611. /**
  36612. * Release the sound and its associated resources
  36613. */
  36614. dispose(): void;
  36615. /**
  36616. * Gets if the sounds is ready to be played or not.
  36617. * @returns true if ready, otherwise false
  36618. */
  36619. isReady(): boolean;
  36620. private _soundLoaded;
  36621. /**
  36622. * Sets the data of the sound from an audiobuffer
  36623. * @param audioBuffer The audioBuffer containing the data
  36624. */
  36625. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36626. /**
  36627. * Updates the current sounds options such as maxdistance, loop...
  36628. * @param options A JSON object containing values named as the object properties
  36629. */
  36630. updateOptions(options: ISoundOptions): void;
  36631. private _createSpatialParameters;
  36632. private _updateSpatialParameters;
  36633. /**
  36634. * Switch the panning model to HRTF:
  36635. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36637. */
  36638. switchPanningModelToHRTF(): void;
  36639. /**
  36640. * Switch the panning model to Equal Power:
  36641. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36643. */
  36644. switchPanningModelToEqualPower(): void;
  36645. private _switchPanningModel;
  36646. /**
  36647. * Connect this sound to a sound track audio node like gain...
  36648. * @param soundTrackAudioNode the sound track audio node to connect to
  36649. */
  36650. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36651. /**
  36652. * Transform this sound into a directional source
  36653. * @param coneInnerAngle Size of the inner cone in degree
  36654. * @param coneOuterAngle Size of the outer cone in degree
  36655. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36656. */
  36657. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36658. /**
  36659. * Gets or sets the inner angle for the directional cone.
  36660. */
  36661. /**
  36662. * Gets or sets the inner angle for the directional cone.
  36663. */
  36664. directionalConeInnerAngle: number;
  36665. /**
  36666. * Gets or sets the outer angle for the directional cone.
  36667. */
  36668. /**
  36669. * Gets or sets the outer angle for the directional cone.
  36670. */
  36671. directionalConeOuterAngle: number;
  36672. /**
  36673. * Sets the position of the emitter if spatial sound is enabled
  36674. * @param newPosition Defines the new posisiton
  36675. */
  36676. setPosition(newPosition: Vector3): void;
  36677. /**
  36678. * Sets the local direction of the emitter if spatial sound is enabled
  36679. * @param newLocalDirection Defines the new local direction
  36680. */
  36681. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36682. private _updateDirection;
  36683. /** @hidden */
  36684. updateDistanceFromListener(): void;
  36685. /**
  36686. * Sets a new custom attenuation function for the sound.
  36687. * @param callback Defines the function used for the attenuation
  36688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36689. */
  36690. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36691. /**
  36692. * Play the sound
  36693. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36694. * @param offset (optional) Start the sound at a specific time in seconds
  36695. * @param length (optional) Sound duration (in seconds)
  36696. */
  36697. play(time?: number, offset?: number, length?: number): void;
  36698. private _onended;
  36699. /**
  36700. * Stop the sound
  36701. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36702. */
  36703. stop(time?: number): void;
  36704. /**
  36705. * Put the sound in pause
  36706. */
  36707. pause(): void;
  36708. /**
  36709. * Sets a dedicated volume for this sounds
  36710. * @param newVolume Define the new volume of the sound
  36711. * @param time Define time for gradual change to new volume
  36712. */
  36713. setVolume(newVolume: number, time?: number): void;
  36714. /**
  36715. * Set the sound play back rate
  36716. * @param newPlaybackRate Define the playback rate the sound should be played at
  36717. */
  36718. setPlaybackRate(newPlaybackRate: number): void;
  36719. /**
  36720. * Gets the volume of the sound.
  36721. * @returns the volume of the sound
  36722. */
  36723. getVolume(): number;
  36724. /**
  36725. * Attach the sound to a dedicated mesh
  36726. * @param transformNode The transform node to connect the sound with
  36727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36728. */
  36729. attachToMesh(transformNode: TransformNode): void;
  36730. /**
  36731. * Detach the sound from the previously attached mesh
  36732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36733. */
  36734. detachFromMesh(): void;
  36735. private _onRegisterAfterWorldMatrixUpdate;
  36736. /**
  36737. * Clone the current sound in the scene.
  36738. * @returns the new sound clone
  36739. */
  36740. clone(): Nullable<Sound>;
  36741. /**
  36742. * Gets the current underlying audio buffer containing the data
  36743. * @returns the audio buffer
  36744. */
  36745. getAudioBuffer(): Nullable<AudioBuffer>;
  36746. /**
  36747. * Serializes the Sound in a JSON representation
  36748. * @returns the JSON representation of the sound
  36749. */
  36750. serialize(): any;
  36751. /**
  36752. * Parse a JSON representation of a sound to innstantiate in a given scene
  36753. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36754. * @param scene Define the scene the new parsed sound should be created in
  36755. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36756. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36757. * @returns the newly parsed sound
  36758. */
  36759. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36760. }
  36761. }
  36762. declare module "babylonjs/Actions/directAudioActions" {
  36763. import { Action } from "babylonjs/Actions/action";
  36764. import { Condition } from "babylonjs/Actions/condition";
  36765. import { Sound } from "babylonjs/Audio/sound";
  36766. /**
  36767. * This defines an action helpful to play a defined sound on a triggered action.
  36768. */
  36769. export class PlaySoundAction extends Action {
  36770. private _sound;
  36771. /**
  36772. * Instantiate the action
  36773. * @param triggerOptions defines the trigger options
  36774. * @param sound defines the sound to play
  36775. * @param condition defines the trigger related conditions
  36776. */
  36777. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36778. /** @hidden */
  36779. _prepare(): void;
  36780. /**
  36781. * Execute the action and play the sound.
  36782. */
  36783. execute(): void;
  36784. /**
  36785. * Serializes the actions and its related information.
  36786. * @param parent defines the object to serialize in
  36787. * @returns the serialized object
  36788. */
  36789. serialize(parent: any): any;
  36790. }
  36791. /**
  36792. * This defines an action helpful to stop a defined sound on a triggered action.
  36793. */
  36794. export class StopSoundAction extends Action {
  36795. private _sound;
  36796. /**
  36797. * Instantiate the action
  36798. * @param triggerOptions defines the trigger options
  36799. * @param sound defines the sound to stop
  36800. * @param condition defines the trigger related conditions
  36801. */
  36802. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36803. /** @hidden */
  36804. _prepare(): void;
  36805. /**
  36806. * Execute the action and stop the sound.
  36807. */
  36808. execute(): void;
  36809. /**
  36810. * Serializes the actions and its related information.
  36811. * @param parent defines the object to serialize in
  36812. * @returns the serialized object
  36813. */
  36814. serialize(parent: any): any;
  36815. }
  36816. }
  36817. declare module "babylonjs/Actions/interpolateValueAction" {
  36818. import { Action } from "babylonjs/Actions/action";
  36819. import { Condition } from "babylonjs/Actions/condition";
  36820. import { Observable } from "babylonjs/Misc/observable";
  36821. /**
  36822. * This defines an action responsible to change the value of a property
  36823. * by interpolating between its current value and the newly set one once triggered.
  36824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36825. */
  36826. export class InterpolateValueAction extends Action {
  36827. /**
  36828. * Defines the path of the property where the value should be interpolated
  36829. */
  36830. propertyPath: string;
  36831. /**
  36832. * Defines the target value at the end of the interpolation.
  36833. */
  36834. value: any;
  36835. /**
  36836. * Defines the time it will take for the property to interpolate to the value.
  36837. */
  36838. duration: number;
  36839. /**
  36840. * Defines if the other scene animations should be stopped when the action has been triggered
  36841. */
  36842. stopOtherAnimations?: boolean;
  36843. /**
  36844. * Defines a callback raised once the interpolation animation has been done.
  36845. */
  36846. onInterpolationDone?: () => void;
  36847. /**
  36848. * Observable triggered once the interpolation animation has been done.
  36849. */
  36850. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36851. private _target;
  36852. private _effectiveTarget;
  36853. private _property;
  36854. /**
  36855. * Instantiate the action
  36856. * @param triggerOptions defines the trigger options
  36857. * @param target defines the object containing the value to interpolate
  36858. * @param propertyPath defines the path to the property in the target object
  36859. * @param value defines the target value at the end of the interpolation
  36860. * @param duration deines the time it will take for the property to interpolate to the value.
  36861. * @param condition defines the trigger related conditions
  36862. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36863. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36864. */
  36865. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36866. /** @hidden */
  36867. _prepare(): void;
  36868. /**
  36869. * Execute the action starts the value interpolation.
  36870. */
  36871. execute(): void;
  36872. /**
  36873. * Serializes the actions and its related information.
  36874. * @param parent defines the object to serialize in
  36875. * @returns the serialized object
  36876. */
  36877. serialize(parent: any): any;
  36878. }
  36879. }
  36880. declare module "babylonjs/Actions/index" {
  36881. export * from "babylonjs/Actions/abstractActionManager";
  36882. export * from "babylonjs/Actions/action";
  36883. export * from "babylonjs/Actions/actionEvent";
  36884. export * from "babylonjs/Actions/actionManager";
  36885. export * from "babylonjs/Actions/condition";
  36886. export * from "babylonjs/Actions/directActions";
  36887. export * from "babylonjs/Actions/directAudioActions";
  36888. export * from "babylonjs/Actions/interpolateValueAction";
  36889. }
  36890. declare module "babylonjs/Animations/index" {
  36891. export * from "babylonjs/Animations/animatable";
  36892. export * from "babylonjs/Animations/animation";
  36893. export * from "babylonjs/Animations/animationGroup";
  36894. export * from "babylonjs/Animations/animationPropertiesOverride";
  36895. export * from "babylonjs/Animations/easing";
  36896. export * from "babylonjs/Animations/runtimeAnimation";
  36897. export * from "babylonjs/Animations/animationEvent";
  36898. export * from "babylonjs/Animations/animationGroup";
  36899. export * from "babylonjs/Animations/animationKey";
  36900. export * from "babylonjs/Animations/animationRange";
  36901. export * from "babylonjs/Animations/animatable.interface";
  36902. }
  36903. declare module "babylonjs/Audio/soundTrack" {
  36904. import { Sound } from "babylonjs/Audio/sound";
  36905. import { Analyser } from "babylonjs/Audio/analyser";
  36906. import { Scene } from "babylonjs/scene";
  36907. /**
  36908. * Options allowed during the creation of a sound track.
  36909. */
  36910. export interface ISoundTrackOptions {
  36911. /**
  36912. * The volume the sound track should take during creation
  36913. */
  36914. volume?: number;
  36915. /**
  36916. * Define if the sound track is the main sound track of the scene
  36917. */
  36918. mainTrack?: boolean;
  36919. }
  36920. /**
  36921. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36922. * It will be also used in a future release to apply effects on a specific track.
  36923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36924. */
  36925. export class SoundTrack {
  36926. /**
  36927. * The unique identifier of the sound track in the scene.
  36928. */
  36929. id: number;
  36930. /**
  36931. * The list of sounds included in the sound track.
  36932. */
  36933. soundCollection: Array<Sound>;
  36934. private _outputAudioNode;
  36935. private _scene;
  36936. private _connectedAnalyser;
  36937. private _options;
  36938. private _isInitialized;
  36939. /**
  36940. * Creates a new sound track.
  36941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36942. * @param scene Define the scene the sound track belongs to
  36943. * @param options
  36944. */
  36945. constructor(scene: Scene, options?: ISoundTrackOptions);
  36946. private _initializeSoundTrackAudioGraph;
  36947. /**
  36948. * Release the sound track and its associated resources
  36949. */
  36950. dispose(): void;
  36951. /**
  36952. * Adds a sound to this sound track
  36953. * @param sound define the cound to add
  36954. * @ignoreNaming
  36955. */
  36956. AddSound(sound: Sound): void;
  36957. /**
  36958. * Removes a sound to this sound track
  36959. * @param sound define the cound to remove
  36960. * @ignoreNaming
  36961. */
  36962. RemoveSound(sound: Sound): void;
  36963. /**
  36964. * Set a global volume for the full sound track.
  36965. * @param newVolume Define the new volume of the sound track
  36966. */
  36967. setVolume(newVolume: number): void;
  36968. /**
  36969. * Switch the panning model to HRTF:
  36970. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36972. */
  36973. switchPanningModelToHRTF(): void;
  36974. /**
  36975. * Switch the panning model to Equal Power:
  36976. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36978. */
  36979. switchPanningModelToEqualPower(): void;
  36980. /**
  36981. * Connect the sound track to an audio analyser allowing some amazing
  36982. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36984. * @param analyser The analyser to connect to the engine
  36985. */
  36986. connectToAnalyser(analyser: Analyser): void;
  36987. }
  36988. }
  36989. declare module "babylonjs/Audio/audioSceneComponent" {
  36990. import { Sound } from "babylonjs/Audio/sound";
  36991. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36992. import { Nullable } from "babylonjs/types";
  36993. import { Vector3 } from "babylonjs/Maths/math.vector";
  36994. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36995. import { Scene } from "babylonjs/scene";
  36996. import { AbstractScene } from "babylonjs/abstractScene";
  36997. import "babylonjs/Audio/audioEngine";
  36998. module "babylonjs/abstractScene" {
  36999. interface AbstractScene {
  37000. /**
  37001. * The list of sounds used in the scene.
  37002. */
  37003. sounds: Nullable<Array<Sound>>;
  37004. }
  37005. }
  37006. module "babylonjs/scene" {
  37007. interface Scene {
  37008. /**
  37009. * @hidden
  37010. * Backing field
  37011. */
  37012. _mainSoundTrack: SoundTrack;
  37013. /**
  37014. * The main sound track played by the scene.
  37015. * It cotains your primary collection of sounds.
  37016. */
  37017. mainSoundTrack: SoundTrack;
  37018. /**
  37019. * The list of sound tracks added to the scene
  37020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37021. */
  37022. soundTracks: Nullable<Array<SoundTrack>>;
  37023. /**
  37024. * Gets a sound using a given name
  37025. * @param name defines the name to search for
  37026. * @return the found sound or null if not found at all.
  37027. */
  37028. getSoundByName(name: string): Nullable<Sound>;
  37029. /**
  37030. * Gets or sets if audio support is enabled
  37031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37032. */
  37033. audioEnabled: boolean;
  37034. /**
  37035. * Gets or sets if audio will be output to headphones
  37036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37037. */
  37038. headphone: boolean;
  37039. /**
  37040. * Gets or sets custom audio listener position provider
  37041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37042. */
  37043. audioListenerPositionProvider: Nullable<() => Vector3>;
  37044. /**
  37045. * Gets or sets a refresh rate when using 3D audio positioning
  37046. */
  37047. audioPositioningRefreshRate: number;
  37048. }
  37049. }
  37050. /**
  37051. * Defines the sound scene component responsible to manage any sounds
  37052. * in a given scene.
  37053. */
  37054. export class AudioSceneComponent implements ISceneSerializableComponent {
  37055. /**
  37056. * The component name helpfull to identify the component in the list of scene components.
  37057. */
  37058. readonly name: string;
  37059. /**
  37060. * The scene the component belongs to.
  37061. */
  37062. scene: Scene;
  37063. private _audioEnabled;
  37064. /**
  37065. * Gets whether audio is enabled or not.
  37066. * Please use related enable/disable method to switch state.
  37067. */
  37068. readonly audioEnabled: boolean;
  37069. private _headphone;
  37070. /**
  37071. * Gets whether audio is outputing to headphone or not.
  37072. * Please use the according Switch methods to change output.
  37073. */
  37074. readonly headphone: boolean;
  37075. /**
  37076. * Gets or sets a refresh rate when using 3D audio positioning
  37077. */
  37078. audioPositioningRefreshRate: number;
  37079. private _audioListenerPositionProvider;
  37080. /**
  37081. * Gets the current audio listener position provider
  37082. */
  37083. /**
  37084. * Sets a custom listener position for all sounds in the scene
  37085. * By default, this is the position of the first active camera
  37086. */
  37087. audioListenerPositionProvider: Nullable<() => Vector3>;
  37088. /**
  37089. * Creates a new instance of the component for the given scene
  37090. * @param scene Defines the scene to register the component in
  37091. */
  37092. constructor(scene: Scene);
  37093. /**
  37094. * Registers the component in a given scene
  37095. */
  37096. register(): void;
  37097. /**
  37098. * Rebuilds the elements related to this component in case of
  37099. * context lost for instance.
  37100. */
  37101. rebuild(): void;
  37102. /**
  37103. * Serializes the component data to the specified json object
  37104. * @param serializationObject The object to serialize to
  37105. */
  37106. serialize(serializationObject: any): void;
  37107. /**
  37108. * Adds all the elements from the container to the scene
  37109. * @param container the container holding the elements
  37110. */
  37111. addFromContainer(container: AbstractScene): void;
  37112. /**
  37113. * Removes all the elements in the container from the scene
  37114. * @param container contains the elements to remove
  37115. * @param dispose if the removed element should be disposed (default: false)
  37116. */
  37117. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37118. /**
  37119. * Disposes the component and the associated ressources.
  37120. */
  37121. dispose(): void;
  37122. /**
  37123. * Disables audio in the associated scene.
  37124. */
  37125. disableAudio(): void;
  37126. /**
  37127. * Enables audio in the associated scene.
  37128. */
  37129. enableAudio(): void;
  37130. /**
  37131. * Switch audio to headphone output.
  37132. */
  37133. switchAudioModeForHeadphones(): void;
  37134. /**
  37135. * Switch audio to normal speakers.
  37136. */
  37137. switchAudioModeForNormalSpeakers(): void;
  37138. private _cachedCameraDirection;
  37139. private _cachedCameraPosition;
  37140. private _lastCheck;
  37141. private _afterRender;
  37142. }
  37143. }
  37144. declare module "babylonjs/Audio/weightedsound" {
  37145. import { Sound } from "babylonjs/Audio/sound";
  37146. /**
  37147. * Wraps one or more Sound objects and selects one with random weight for playback.
  37148. */
  37149. export class WeightedSound {
  37150. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37151. loop: boolean;
  37152. private _coneInnerAngle;
  37153. private _coneOuterAngle;
  37154. private _volume;
  37155. /** A Sound is currently playing. */
  37156. isPlaying: boolean;
  37157. /** A Sound is currently paused. */
  37158. isPaused: boolean;
  37159. private _sounds;
  37160. private _weights;
  37161. private _currentIndex?;
  37162. /**
  37163. * Creates a new WeightedSound from the list of sounds given.
  37164. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37165. * @param sounds Array of Sounds that will be selected from.
  37166. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37167. */
  37168. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37169. /**
  37170. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37171. */
  37172. /**
  37173. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37174. */
  37175. directionalConeInnerAngle: number;
  37176. /**
  37177. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37178. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37179. */
  37180. /**
  37181. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37182. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37183. */
  37184. directionalConeOuterAngle: number;
  37185. /**
  37186. * Playback volume.
  37187. */
  37188. /**
  37189. * Playback volume.
  37190. */
  37191. volume: number;
  37192. private _onended;
  37193. /**
  37194. * Suspend playback
  37195. */
  37196. pause(): void;
  37197. /**
  37198. * Stop playback
  37199. */
  37200. stop(): void;
  37201. /**
  37202. * Start playback.
  37203. * @param startOffset Position the clip head at a specific time in seconds.
  37204. */
  37205. play(startOffset?: number): void;
  37206. }
  37207. }
  37208. declare module "babylonjs/Audio/index" {
  37209. export * from "babylonjs/Audio/analyser";
  37210. export * from "babylonjs/Audio/audioEngine";
  37211. export * from "babylonjs/Audio/audioSceneComponent";
  37212. export * from "babylonjs/Audio/sound";
  37213. export * from "babylonjs/Audio/soundTrack";
  37214. export * from "babylonjs/Audio/weightedsound";
  37215. }
  37216. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37217. import { Behavior } from "babylonjs/Behaviors/behavior";
  37218. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37219. import { BackEase } from "babylonjs/Animations/easing";
  37220. /**
  37221. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37222. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37223. */
  37224. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37225. /**
  37226. * Gets the name of the behavior.
  37227. */
  37228. readonly name: string;
  37229. /**
  37230. * The easing function used by animations
  37231. */
  37232. static EasingFunction: BackEase;
  37233. /**
  37234. * The easing mode used by animations
  37235. */
  37236. static EasingMode: number;
  37237. /**
  37238. * The duration of the animation, in milliseconds
  37239. */
  37240. transitionDuration: number;
  37241. /**
  37242. * Length of the distance animated by the transition when lower radius is reached
  37243. */
  37244. lowerRadiusTransitionRange: number;
  37245. /**
  37246. * Length of the distance animated by the transition when upper radius is reached
  37247. */
  37248. upperRadiusTransitionRange: number;
  37249. private _autoTransitionRange;
  37250. /**
  37251. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37252. */
  37253. /**
  37254. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37255. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37256. */
  37257. autoTransitionRange: boolean;
  37258. private _attachedCamera;
  37259. private _onAfterCheckInputsObserver;
  37260. private _onMeshTargetChangedObserver;
  37261. /**
  37262. * Initializes the behavior.
  37263. */
  37264. init(): void;
  37265. /**
  37266. * Attaches the behavior to its arc rotate camera.
  37267. * @param camera Defines the camera to attach the behavior to
  37268. */
  37269. attach(camera: ArcRotateCamera): void;
  37270. /**
  37271. * Detaches the behavior from its current arc rotate camera.
  37272. */
  37273. detach(): void;
  37274. private _radiusIsAnimating;
  37275. private _radiusBounceTransition;
  37276. private _animatables;
  37277. private _cachedWheelPrecision;
  37278. /**
  37279. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37280. * @param radiusLimit The limit to check against.
  37281. * @return Bool to indicate if at limit.
  37282. */
  37283. private _isRadiusAtLimit;
  37284. /**
  37285. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37286. * @param radiusDelta The delta by which to animate to. Can be negative.
  37287. */
  37288. private _applyBoundRadiusAnimation;
  37289. /**
  37290. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37291. */
  37292. protected _clearAnimationLocks(): void;
  37293. /**
  37294. * Stops and removes all animations that have been applied to the camera
  37295. */
  37296. stopAllAnimations(): void;
  37297. }
  37298. }
  37299. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37300. import { Behavior } from "babylonjs/Behaviors/behavior";
  37301. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37302. import { ExponentialEase } from "babylonjs/Animations/easing";
  37303. import { Nullable } from "babylonjs/types";
  37304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37305. import { Vector3 } from "babylonjs/Maths/math.vector";
  37306. /**
  37307. * 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.
  37308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37309. */
  37310. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37311. /**
  37312. * Gets the name of the behavior.
  37313. */
  37314. readonly name: string;
  37315. private _mode;
  37316. private _radiusScale;
  37317. private _positionScale;
  37318. private _defaultElevation;
  37319. private _elevationReturnTime;
  37320. private _elevationReturnWaitTime;
  37321. private _zoomStopsAnimation;
  37322. private _framingTime;
  37323. /**
  37324. * The easing function used by animations
  37325. */
  37326. static EasingFunction: ExponentialEase;
  37327. /**
  37328. * The easing mode used by animations
  37329. */
  37330. static EasingMode: number;
  37331. /**
  37332. * Sets the current mode used by the behavior
  37333. */
  37334. /**
  37335. * Gets current mode used by the behavior.
  37336. */
  37337. mode: number;
  37338. /**
  37339. * Sets the scale applied to the radius (1 by default)
  37340. */
  37341. /**
  37342. * Gets the scale applied to the radius
  37343. */
  37344. radiusScale: number;
  37345. /**
  37346. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37347. */
  37348. /**
  37349. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37350. */
  37351. positionScale: number;
  37352. /**
  37353. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37354. * behaviour is triggered, in radians.
  37355. */
  37356. /**
  37357. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37358. * behaviour is triggered, in radians.
  37359. */
  37360. defaultElevation: number;
  37361. /**
  37362. * Sets the time (in milliseconds) taken to return to the default beta position.
  37363. * Negative value indicates camera should not return to default.
  37364. */
  37365. /**
  37366. * Gets the time (in milliseconds) taken to return to the default beta position.
  37367. * Negative value indicates camera should not return to default.
  37368. */
  37369. elevationReturnTime: number;
  37370. /**
  37371. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37372. */
  37373. /**
  37374. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37375. */
  37376. elevationReturnWaitTime: number;
  37377. /**
  37378. * Sets the flag that indicates if user zooming should stop animation.
  37379. */
  37380. /**
  37381. * Gets the flag that indicates if user zooming should stop animation.
  37382. */
  37383. zoomStopsAnimation: boolean;
  37384. /**
  37385. * Sets the transition time when framing the mesh, in milliseconds
  37386. */
  37387. /**
  37388. * Gets the transition time when framing the mesh, in milliseconds
  37389. */
  37390. framingTime: number;
  37391. /**
  37392. * Define if the behavior should automatically change the configured
  37393. * camera limits and sensibilities.
  37394. */
  37395. autoCorrectCameraLimitsAndSensibility: boolean;
  37396. private _onPrePointerObservableObserver;
  37397. private _onAfterCheckInputsObserver;
  37398. private _onMeshTargetChangedObserver;
  37399. private _attachedCamera;
  37400. private _isPointerDown;
  37401. private _lastInteractionTime;
  37402. /**
  37403. * Initializes the behavior.
  37404. */
  37405. init(): void;
  37406. /**
  37407. * Attaches the behavior to its arc rotate camera.
  37408. * @param camera Defines the camera to attach the behavior to
  37409. */
  37410. attach(camera: ArcRotateCamera): void;
  37411. /**
  37412. * Detaches the behavior from its current arc rotate camera.
  37413. */
  37414. detach(): void;
  37415. private _animatables;
  37416. private _betaIsAnimating;
  37417. private _betaTransition;
  37418. private _radiusTransition;
  37419. private _vectorTransition;
  37420. /**
  37421. * Targets the given mesh and updates zoom level accordingly.
  37422. * @param mesh The mesh to target.
  37423. * @param radius Optional. If a cached radius position already exists, overrides default.
  37424. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37427. */
  37428. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37429. /**
  37430. * Targets the given mesh with its children and updates zoom level accordingly.
  37431. * @param mesh The mesh to target.
  37432. * @param radius Optional. If a cached radius position already exists, overrides default.
  37433. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37434. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37435. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37436. */
  37437. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37438. /**
  37439. * Targets the given meshes with their children and updates zoom level accordingly.
  37440. * @param meshes The mesh to target.
  37441. * @param radius Optional. If a cached radius position already exists, overrides default.
  37442. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37443. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37444. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37445. */
  37446. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37447. /**
  37448. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37449. * @param minimumWorld Determines the smaller position of the bounding box extend
  37450. * @param maximumWorld Determines the bigger position of the bounding box extend
  37451. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37452. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37453. */
  37454. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37455. /**
  37456. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37457. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37458. * frustum width.
  37459. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37460. * to fully enclose the mesh in the viewing frustum.
  37461. */
  37462. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37463. /**
  37464. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37465. * is automatically returned to its default position (expected to be above ground plane).
  37466. */
  37467. private _maintainCameraAboveGround;
  37468. /**
  37469. * Returns the frustum slope based on the canvas ratio and camera FOV
  37470. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37471. */
  37472. private _getFrustumSlope;
  37473. /**
  37474. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37475. */
  37476. private _clearAnimationLocks;
  37477. /**
  37478. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37479. */
  37480. private _applyUserInteraction;
  37481. /**
  37482. * Stops and removes all animations that have been applied to the camera
  37483. */
  37484. stopAllAnimations(): void;
  37485. /**
  37486. * Gets a value indicating if the user is moving the camera
  37487. */
  37488. readonly isUserIsMoving: boolean;
  37489. /**
  37490. * The camera can move all the way towards the mesh.
  37491. */
  37492. static IgnoreBoundsSizeMode: number;
  37493. /**
  37494. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37495. */
  37496. static FitFrustumSidesMode: number;
  37497. }
  37498. }
  37499. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37500. import { Nullable } from "babylonjs/types";
  37501. import { Camera } from "babylonjs/Cameras/camera";
  37502. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37503. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37504. /**
  37505. * Base class for Camera Pointer Inputs.
  37506. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37507. * for example usage.
  37508. */
  37509. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37510. /**
  37511. * Defines the camera the input is attached to.
  37512. */
  37513. abstract camera: Camera;
  37514. /**
  37515. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37516. */
  37517. protected _altKey: boolean;
  37518. protected _ctrlKey: boolean;
  37519. protected _metaKey: boolean;
  37520. protected _shiftKey: boolean;
  37521. /**
  37522. * Which mouse buttons were pressed at time of last mouse event.
  37523. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37524. */
  37525. protected _buttonsPressed: number;
  37526. /**
  37527. * Defines the buttons associated with the input to handle camera move.
  37528. */
  37529. buttons: number[];
  37530. /**
  37531. * Attach the input controls to a specific dom element to get the input from.
  37532. * @param element Defines the element the controls should be listened from
  37533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37534. */
  37535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37536. /**
  37537. * Detach the current controls from the specified dom element.
  37538. * @param element Defines the element to stop listening the inputs from
  37539. */
  37540. detachControl(element: Nullable<HTMLElement>): void;
  37541. /**
  37542. * Gets the class name of the current input.
  37543. * @returns the class name
  37544. */
  37545. getClassName(): string;
  37546. /**
  37547. * Get the friendly name associated with the input class.
  37548. * @returns the input friendly name
  37549. */
  37550. getSimpleName(): string;
  37551. /**
  37552. * Called on pointer POINTERDOUBLETAP event.
  37553. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37554. */
  37555. protected onDoubleTap(type: string): void;
  37556. /**
  37557. * Called on pointer POINTERMOVE event if only a single touch is active.
  37558. * Override this method to provide functionality.
  37559. */
  37560. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37561. /**
  37562. * Called on pointer POINTERMOVE event if multiple touches are active.
  37563. * Override this method to provide functionality.
  37564. */
  37565. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37566. /**
  37567. * Called on JS contextmenu event.
  37568. * Override this method to provide functionality.
  37569. */
  37570. protected onContextMenu(evt: PointerEvent): void;
  37571. /**
  37572. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37573. * press.
  37574. * Override this method to provide functionality.
  37575. */
  37576. protected onButtonDown(evt: PointerEvent): void;
  37577. /**
  37578. * Called each time a new POINTERUP event occurs. Ie, for each button
  37579. * release.
  37580. * Override this method to provide functionality.
  37581. */
  37582. protected onButtonUp(evt: PointerEvent): void;
  37583. /**
  37584. * Called when window becomes inactive.
  37585. * Override this method to provide functionality.
  37586. */
  37587. protected onLostFocus(): void;
  37588. private _pointerInput;
  37589. private _observer;
  37590. private _onLostFocus;
  37591. private pointA;
  37592. private pointB;
  37593. }
  37594. }
  37595. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37596. import { Nullable } from "babylonjs/types";
  37597. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37598. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37599. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37600. /**
  37601. * Manage the pointers inputs to control an arc rotate camera.
  37602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37603. */
  37604. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37605. /**
  37606. * Defines the camera the input is attached to.
  37607. */
  37608. camera: ArcRotateCamera;
  37609. /**
  37610. * Gets the class name of the current input.
  37611. * @returns the class name
  37612. */
  37613. getClassName(): string;
  37614. /**
  37615. * Defines the buttons associated with the input to handle camera move.
  37616. */
  37617. buttons: number[];
  37618. /**
  37619. * Defines the pointer angular sensibility along the X axis or how fast is
  37620. * the camera rotating.
  37621. */
  37622. angularSensibilityX: number;
  37623. /**
  37624. * Defines the pointer angular sensibility along the Y axis or how fast is
  37625. * the camera rotating.
  37626. */
  37627. angularSensibilityY: number;
  37628. /**
  37629. * Defines the pointer pinch precision or how fast is the camera zooming.
  37630. */
  37631. pinchPrecision: number;
  37632. /**
  37633. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37634. * from 0.
  37635. * It defines the percentage of current camera.radius to use as delta when
  37636. * pinch zoom is used.
  37637. */
  37638. pinchDeltaPercentage: number;
  37639. /**
  37640. * Defines the pointer panning sensibility or how fast is the camera moving.
  37641. */
  37642. panningSensibility: number;
  37643. /**
  37644. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37645. */
  37646. multiTouchPanning: boolean;
  37647. /**
  37648. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37649. * zoom (pinch) through multitouch.
  37650. */
  37651. multiTouchPanAndZoom: boolean;
  37652. /**
  37653. * Revers pinch action direction.
  37654. */
  37655. pinchInwards: boolean;
  37656. private _isPanClick;
  37657. private _twoFingerActivityCount;
  37658. private _isPinching;
  37659. /**
  37660. * Called on pointer POINTERMOVE event if only a single touch is active.
  37661. */
  37662. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37663. /**
  37664. * Called on pointer POINTERDOUBLETAP event.
  37665. */
  37666. protected onDoubleTap(type: string): void;
  37667. /**
  37668. * Called on pointer POINTERMOVE event if multiple touches are active.
  37669. */
  37670. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37671. /**
  37672. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37673. * press.
  37674. */
  37675. protected onButtonDown(evt: PointerEvent): void;
  37676. /**
  37677. * Called each time a new POINTERUP event occurs. Ie, for each button
  37678. * release.
  37679. */
  37680. protected onButtonUp(evt: PointerEvent): void;
  37681. /**
  37682. * Called when window becomes inactive.
  37683. */
  37684. protected onLostFocus(): void;
  37685. }
  37686. }
  37687. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37688. import { Nullable } from "babylonjs/types";
  37689. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37690. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37691. /**
  37692. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37694. */
  37695. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37696. /**
  37697. * Defines the camera the input is attached to.
  37698. */
  37699. camera: ArcRotateCamera;
  37700. /**
  37701. * Defines the list of key codes associated with the up action (increase alpha)
  37702. */
  37703. keysUp: number[];
  37704. /**
  37705. * Defines the list of key codes associated with the down action (decrease alpha)
  37706. */
  37707. keysDown: number[];
  37708. /**
  37709. * Defines the list of key codes associated with the left action (increase beta)
  37710. */
  37711. keysLeft: number[];
  37712. /**
  37713. * Defines the list of key codes associated with the right action (decrease beta)
  37714. */
  37715. keysRight: number[];
  37716. /**
  37717. * Defines the list of key codes associated with the reset action.
  37718. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37719. */
  37720. keysReset: number[];
  37721. /**
  37722. * Defines the panning sensibility of the inputs.
  37723. * (How fast is the camera paning)
  37724. */
  37725. panningSensibility: number;
  37726. /**
  37727. * Defines the zooming sensibility of the inputs.
  37728. * (How fast is the camera zooming)
  37729. */
  37730. zoomingSensibility: number;
  37731. /**
  37732. * Defines wether maintaining the alt key down switch the movement mode from
  37733. * orientation to zoom.
  37734. */
  37735. useAltToZoom: boolean;
  37736. /**
  37737. * Rotation speed of the camera
  37738. */
  37739. angularSpeed: number;
  37740. private _keys;
  37741. private _ctrlPressed;
  37742. private _altPressed;
  37743. private _onCanvasBlurObserver;
  37744. private _onKeyboardObserver;
  37745. private _engine;
  37746. private _scene;
  37747. /**
  37748. * Attach the input controls to a specific dom element to get the input from.
  37749. * @param element Defines the element the controls should be listened from
  37750. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37751. */
  37752. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37753. /**
  37754. * Detach the current controls from the specified dom element.
  37755. * @param element Defines the element to stop listening the inputs from
  37756. */
  37757. detachControl(element: Nullable<HTMLElement>): void;
  37758. /**
  37759. * Update the current camera state depending on the inputs that have been used this frame.
  37760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37761. */
  37762. checkInputs(): void;
  37763. /**
  37764. * Gets the class name of the current intput.
  37765. * @returns the class name
  37766. */
  37767. getClassName(): string;
  37768. /**
  37769. * Get the friendly name associated with the input class.
  37770. * @returns the input friendly name
  37771. */
  37772. getSimpleName(): string;
  37773. }
  37774. }
  37775. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37776. import { Nullable } from "babylonjs/types";
  37777. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37778. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37779. /**
  37780. * Manage the mouse wheel inputs to control an arc rotate camera.
  37781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37782. */
  37783. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37784. /**
  37785. * Defines the camera the input is attached to.
  37786. */
  37787. camera: ArcRotateCamera;
  37788. /**
  37789. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37790. */
  37791. wheelPrecision: number;
  37792. /**
  37793. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37794. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37795. */
  37796. wheelDeltaPercentage: number;
  37797. private _wheel;
  37798. private _observer;
  37799. private computeDeltaFromMouseWheelLegacyEvent;
  37800. /**
  37801. * Attach the input controls to a specific dom element to get the input from.
  37802. * @param element Defines the element the controls should be listened from
  37803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37804. */
  37805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37806. /**
  37807. * Detach the current controls from the specified dom element.
  37808. * @param element Defines the element to stop listening the inputs from
  37809. */
  37810. detachControl(element: Nullable<HTMLElement>): void;
  37811. /**
  37812. * Gets the class name of the current intput.
  37813. * @returns the class name
  37814. */
  37815. getClassName(): string;
  37816. /**
  37817. * Get the friendly name associated with the input class.
  37818. * @returns the input friendly name
  37819. */
  37820. getSimpleName(): string;
  37821. }
  37822. }
  37823. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37825. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37826. /**
  37827. * Default Inputs manager for the ArcRotateCamera.
  37828. * It groups all the default supported inputs for ease of use.
  37829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37830. */
  37831. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37832. /**
  37833. * Instantiates a new ArcRotateCameraInputsManager.
  37834. * @param camera Defines the camera the inputs belong to
  37835. */
  37836. constructor(camera: ArcRotateCamera);
  37837. /**
  37838. * Add mouse wheel input support to the input manager.
  37839. * @returns the current input manager
  37840. */
  37841. addMouseWheel(): ArcRotateCameraInputsManager;
  37842. /**
  37843. * Add pointers input support to the input manager.
  37844. * @returns the current input manager
  37845. */
  37846. addPointers(): ArcRotateCameraInputsManager;
  37847. /**
  37848. * Add keyboard input support to the input manager.
  37849. * @returns the current input manager
  37850. */
  37851. addKeyboard(): ArcRotateCameraInputsManager;
  37852. }
  37853. }
  37854. declare module "babylonjs/Cameras/arcRotateCamera" {
  37855. import { Observable } from "babylonjs/Misc/observable";
  37856. import { Nullable } from "babylonjs/types";
  37857. import { Scene } from "babylonjs/scene";
  37858. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37860. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37861. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37862. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37863. import { Camera } from "babylonjs/Cameras/camera";
  37864. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37865. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37866. import { Collider } from "babylonjs/Collisions/collider";
  37867. /**
  37868. * This represents an orbital type of camera.
  37869. *
  37870. * 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.
  37871. * 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.
  37872. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37873. */
  37874. export class ArcRotateCamera extends TargetCamera {
  37875. /**
  37876. * Defines the rotation angle of the camera along the longitudinal axis.
  37877. */
  37878. alpha: number;
  37879. /**
  37880. * Defines the rotation angle of the camera along the latitudinal axis.
  37881. */
  37882. beta: number;
  37883. /**
  37884. * Defines the radius of the camera from it s target point.
  37885. */
  37886. radius: number;
  37887. protected _target: Vector3;
  37888. protected _targetHost: Nullable<AbstractMesh>;
  37889. /**
  37890. * Defines the target point of the camera.
  37891. * The camera looks towards it form the radius distance.
  37892. */
  37893. target: Vector3;
  37894. /**
  37895. * Define the current local position of the camera in the scene
  37896. */
  37897. position: Vector3;
  37898. protected _upVector: Vector3;
  37899. protected _upToYMatrix: Matrix;
  37900. protected _YToUpMatrix: Matrix;
  37901. /**
  37902. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37903. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37904. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37905. */
  37906. upVector: Vector3;
  37907. /**
  37908. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37909. */
  37910. setMatUp(): void;
  37911. /**
  37912. * Current inertia value on the longitudinal axis.
  37913. * The bigger this number the longer it will take for the camera to stop.
  37914. */
  37915. inertialAlphaOffset: number;
  37916. /**
  37917. * Current inertia value on the latitudinal axis.
  37918. * The bigger this number the longer it will take for the camera to stop.
  37919. */
  37920. inertialBetaOffset: number;
  37921. /**
  37922. * Current inertia value on the radius axis.
  37923. * The bigger this number the longer it will take for the camera to stop.
  37924. */
  37925. inertialRadiusOffset: number;
  37926. /**
  37927. * Minimum allowed angle on the longitudinal axis.
  37928. * This can help limiting how the Camera is able to move in the scene.
  37929. */
  37930. lowerAlphaLimit: Nullable<number>;
  37931. /**
  37932. * Maximum allowed angle on the longitudinal axis.
  37933. * This can help limiting how the Camera is able to move in the scene.
  37934. */
  37935. upperAlphaLimit: Nullable<number>;
  37936. /**
  37937. * Minimum allowed angle on the latitudinal axis.
  37938. * This can help limiting how the Camera is able to move in the scene.
  37939. */
  37940. lowerBetaLimit: number;
  37941. /**
  37942. * Maximum allowed angle on the latitudinal axis.
  37943. * This can help limiting how the Camera is able to move in the scene.
  37944. */
  37945. upperBetaLimit: number;
  37946. /**
  37947. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37948. * This can help limiting how the Camera is able to move in the scene.
  37949. */
  37950. lowerRadiusLimit: Nullable<number>;
  37951. /**
  37952. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37953. * This can help limiting how the Camera is able to move in the scene.
  37954. */
  37955. upperRadiusLimit: Nullable<number>;
  37956. /**
  37957. * Defines the current inertia value used during panning of the camera along the X axis.
  37958. */
  37959. inertialPanningX: number;
  37960. /**
  37961. * Defines the current inertia value used during panning of the camera along the Y axis.
  37962. */
  37963. inertialPanningY: number;
  37964. /**
  37965. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37966. * Basically if your fingers moves away from more than this distance you will be considered
  37967. * in pinch mode.
  37968. */
  37969. pinchToPanMaxDistance: number;
  37970. /**
  37971. * Defines the maximum distance the camera can pan.
  37972. * This could help keeping the cammera always in your scene.
  37973. */
  37974. panningDistanceLimit: Nullable<number>;
  37975. /**
  37976. * Defines the target of the camera before paning.
  37977. */
  37978. panningOriginTarget: Vector3;
  37979. /**
  37980. * Defines the value of the inertia used during panning.
  37981. * 0 would mean stop inertia and one would mean no decelleration at all.
  37982. */
  37983. panningInertia: number;
  37984. /**
  37985. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37986. */
  37987. angularSensibilityX: number;
  37988. /**
  37989. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37990. */
  37991. angularSensibilityY: number;
  37992. /**
  37993. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37994. */
  37995. pinchPrecision: number;
  37996. /**
  37997. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37998. * It will be used instead of pinchDeltaPrecision if different from 0.
  37999. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38000. */
  38001. pinchDeltaPercentage: number;
  38002. /**
  38003. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38004. */
  38005. panningSensibility: number;
  38006. /**
  38007. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38008. */
  38009. keysUp: number[];
  38010. /**
  38011. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38012. */
  38013. keysDown: number[];
  38014. /**
  38015. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38016. */
  38017. keysLeft: number[];
  38018. /**
  38019. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38020. */
  38021. keysRight: number[];
  38022. /**
  38023. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38024. */
  38025. wheelPrecision: number;
  38026. /**
  38027. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38028. * It will be used instead of pinchDeltaPrecision if different from 0.
  38029. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38030. */
  38031. wheelDeltaPercentage: number;
  38032. /**
  38033. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38034. */
  38035. zoomOnFactor: number;
  38036. /**
  38037. * Defines a screen offset for the camera position.
  38038. */
  38039. targetScreenOffset: Vector2;
  38040. /**
  38041. * Allows the camera to be completely reversed.
  38042. * If false the camera can not arrive upside down.
  38043. */
  38044. allowUpsideDown: boolean;
  38045. /**
  38046. * Define if double tap/click is used to restore the previously saved state of the camera.
  38047. */
  38048. useInputToRestoreState: boolean;
  38049. /** @hidden */
  38050. _viewMatrix: Matrix;
  38051. /** @hidden */
  38052. _useCtrlForPanning: boolean;
  38053. /** @hidden */
  38054. _panningMouseButton: number;
  38055. /**
  38056. * Defines the input associated to the camera.
  38057. */
  38058. inputs: ArcRotateCameraInputsManager;
  38059. /** @hidden */
  38060. _reset: () => void;
  38061. /**
  38062. * Defines the allowed panning axis.
  38063. */
  38064. panningAxis: Vector3;
  38065. protected _localDirection: Vector3;
  38066. protected _transformedDirection: Vector3;
  38067. private _bouncingBehavior;
  38068. /**
  38069. * Gets the bouncing behavior of the camera if it has been enabled.
  38070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38071. */
  38072. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38073. /**
  38074. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38075. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38076. */
  38077. useBouncingBehavior: boolean;
  38078. private _framingBehavior;
  38079. /**
  38080. * Gets the framing behavior of the camera if it has been enabled.
  38081. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38082. */
  38083. readonly framingBehavior: Nullable<FramingBehavior>;
  38084. /**
  38085. * Defines if the framing behavior of the camera is enabled on the camera.
  38086. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38087. */
  38088. useFramingBehavior: boolean;
  38089. private _autoRotationBehavior;
  38090. /**
  38091. * Gets the auto rotation behavior of the camera if it has been enabled.
  38092. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38093. */
  38094. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38095. /**
  38096. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38097. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38098. */
  38099. useAutoRotationBehavior: boolean;
  38100. /**
  38101. * Observable triggered when the mesh target has been changed on the camera.
  38102. */
  38103. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38104. /**
  38105. * Event raised when the camera is colliding with a mesh.
  38106. */
  38107. onCollide: (collidedMesh: AbstractMesh) => void;
  38108. /**
  38109. * Defines whether the camera should check collision with the objects oh the scene.
  38110. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38111. */
  38112. checkCollisions: boolean;
  38113. /**
  38114. * Defines the collision radius of the camera.
  38115. * This simulates a sphere around the camera.
  38116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38117. */
  38118. collisionRadius: Vector3;
  38119. protected _collider: Collider;
  38120. protected _previousPosition: Vector3;
  38121. protected _collisionVelocity: Vector3;
  38122. protected _newPosition: Vector3;
  38123. protected _previousAlpha: number;
  38124. protected _previousBeta: number;
  38125. protected _previousRadius: number;
  38126. protected _collisionTriggered: boolean;
  38127. protected _targetBoundingCenter: Nullable<Vector3>;
  38128. private _computationVector;
  38129. /**
  38130. * Instantiates a new ArcRotateCamera in a given scene
  38131. * @param name Defines the name of the camera
  38132. * @param alpha Defines the camera rotation along the logitudinal axis
  38133. * @param beta Defines the camera rotation along the latitudinal axis
  38134. * @param radius Defines the camera distance from its target
  38135. * @param target Defines the camera target
  38136. * @param scene Defines the scene the camera belongs to
  38137. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38138. */
  38139. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38140. /** @hidden */
  38141. _initCache(): void;
  38142. /** @hidden */
  38143. _updateCache(ignoreParentClass?: boolean): void;
  38144. protected _getTargetPosition(): Vector3;
  38145. private _storedAlpha;
  38146. private _storedBeta;
  38147. private _storedRadius;
  38148. private _storedTarget;
  38149. private _storedTargetScreenOffset;
  38150. /**
  38151. * Stores the current state of the camera (alpha, beta, radius and target)
  38152. * @returns the camera itself
  38153. */
  38154. storeState(): Camera;
  38155. /**
  38156. * @hidden
  38157. * Restored camera state. You must call storeState() first
  38158. */
  38159. _restoreStateValues(): boolean;
  38160. /** @hidden */
  38161. _isSynchronizedViewMatrix(): boolean;
  38162. /**
  38163. * Attached controls to the current camera.
  38164. * @param element Defines the element the controls should be listened from
  38165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38166. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38167. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38168. */
  38169. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38170. /**
  38171. * Detach the current controls from the camera.
  38172. * The camera will stop reacting to inputs.
  38173. * @param element Defines the element to stop listening the inputs from
  38174. */
  38175. detachControl(element: HTMLElement): void;
  38176. /** @hidden */
  38177. _checkInputs(): void;
  38178. protected _checkLimits(): void;
  38179. /**
  38180. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38181. */
  38182. rebuildAnglesAndRadius(): void;
  38183. /**
  38184. * Use a position to define the current camera related information like alpha, beta and radius
  38185. * @param position Defines the position to set the camera at
  38186. */
  38187. setPosition(position: Vector3): void;
  38188. /**
  38189. * Defines the target the camera should look at.
  38190. * This will automatically adapt alpha beta and radius to fit within the new target.
  38191. * @param target Defines the new target as a Vector or a mesh
  38192. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38193. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38194. */
  38195. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38196. /** @hidden */
  38197. _getViewMatrix(): Matrix;
  38198. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38199. /**
  38200. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38201. * @param meshes Defines the mesh to zoom on
  38202. * @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)
  38203. */
  38204. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38205. /**
  38206. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38207. * The target will be changed but the radius
  38208. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38209. * @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)
  38210. */
  38211. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38212. min: Vector3;
  38213. max: Vector3;
  38214. distance: number;
  38215. }, doNotUpdateMaxZ?: boolean): void;
  38216. /**
  38217. * @override
  38218. * Override Camera.createRigCamera
  38219. */
  38220. createRigCamera(name: string, cameraIndex: number): Camera;
  38221. /**
  38222. * @hidden
  38223. * @override
  38224. * Override Camera._updateRigCameras
  38225. */
  38226. _updateRigCameras(): void;
  38227. /**
  38228. * Destroy the camera and release the current resources hold by it.
  38229. */
  38230. dispose(): void;
  38231. /**
  38232. * Gets the current object class name.
  38233. * @return the class name
  38234. */
  38235. getClassName(): string;
  38236. }
  38237. }
  38238. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38239. import { Behavior } from "babylonjs/Behaviors/behavior";
  38240. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38241. /**
  38242. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38244. */
  38245. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38246. /**
  38247. * Gets the name of the behavior.
  38248. */
  38249. readonly name: string;
  38250. private _zoomStopsAnimation;
  38251. private _idleRotationSpeed;
  38252. private _idleRotationWaitTime;
  38253. private _idleRotationSpinupTime;
  38254. /**
  38255. * Sets the flag that indicates if user zooming should stop animation.
  38256. */
  38257. /**
  38258. * Gets the flag that indicates if user zooming should stop animation.
  38259. */
  38260. zoomStopsAnimation: boolean;
  38261. /**
  38262. * Sets the default speed at which the camera rotates around the model.
  38263. */
  38264. /**
  38265. * Gets the default speed at which the camera rotates around the model.
  38266. */
  38267. idleRotationSpeed: number;
  38268. /**
  38269. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38270. */
  38271. /**
  38272. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38273. */
  38274. idleRotationWaitTime: number;
  38275. /**
  38276. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38277. */
  38278. /**
  38279. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38280. */
  38281. idleRotationSpinupTime: number;
  38282. /**
  38283. * Gets a value indicating if the camera is currently rotating because of this behavior
  38284. */
  38285. readonly rotationInProgress: boolean;
  38286. private _onPrePointerObservableObserver;
  38287. private _onAfterCheckInputsObserver;
  38288. private _attachedCamera;
  38289. private _isPointerDown;
  38290. private _lastFrameTime;
  38291. private _lastInteractionTime;
  38292. private _cameraRotationSpeed;
  38293. /**
  38294. * Initializes the behavior.
  38295. */
  38296. init(): void;
  38297. /**
  38298. * Attaches the behavior to its arc rotate camera.
  38299. * @param camera Defines the camera to attach the behavior to
  38300. */
  38301. attach(camera: ArcRotateCamera): void;
  38302. /**
  38303. * Detaches the behavior from its current arc rotate camera.
  38304. */
  38305. detach(): void;
  38306. /**
  38307. * Returns true if user is scrolling.
  38308. * @return true if user is scrolling.
  38309. */
  38310. private _userIsZooming;
  38311. private _lastFrameRadius;
  38312. private _shouldAnimationStopForInteraction;
  38313. /**
  38314. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38315. */
  38316. private _applyUserInteraction;
  38317. private _userIsMoving;
  38318. }
  38319. }
  38320. declare module "babylonjs/Behaviors/Cameras/index" {
  38321. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38322. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38323. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38324. }
  38325. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38326. import { Mesh } from "babylonjs/Meshes/mesh";
  38327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38328. import { Behavior } from "babylonjs/Behaviors/behavior";
  38329. /**
  38330. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38331. */
  38332. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38333. private ui;
  38334. /**
  38335. * The name of the behavior
  38336. */
  38337. name: string;
  38338. /**
  38339. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38340. */
  38341. distanceAwayFromFace: number;
  38342. /**
  38343. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38344. */
  38345. distanceAwayFromBottomOfFace: number;
  38346. private _faceVectors;
  38347. private _target;
  38348. private _scene;
  38349. private _onRenderObserver;
  38350. private _tmpMatrix;
  38351. private _tmpVector;
  38352. /**
  38353. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38354. * @param ui The transform node that should be attched to the mesh
  38355. */
  38356. constructor(ui: TransformNode);
  38357. /**
  38358. * Initializes the behavior
  38359. */
  38360. init(): void;
  38361. private _closestFace;
  38362. private _zeroVector;
  38363. private _lookAtTmpMatrix;
  38364. private _lookAtToRef;
  38365. /**
  38366. * Attaches the AttachToBoxBehavior to the passed in mesh
  38367. * @param target The mesh that the specified node will be attached to
  38368. */
  38369. attach(target: Mesh): void;
  38370. /**
  38371. * Detaches the behavior from the mesh
  38372. */
  38373. detach(): void;
  38374. }
  38375. }
  38376. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38377. import { Behavior } from "babylonjs/Behaviors/behavior";
  38378. import { Mesh } from "babylonjs/Meshes/mesh";
  38379. /**
  38380. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38381. */
  38382. export class FadeInOutBehavior implements Behavior<Mesh> {
  38383. /**
  38384. * Time in milliseconds to delay before fading in (Default: 0)
  38385. */
  38386. delay: number;
  38387. /**
  38388. * Time in milliseconds for the mesh to fade in (Default: 300)
  38389. */
  38390. fadeInTime: number;
  38391. private _millisecondsPerFrame;
  38392. private _hovered;
  38393. private _hoverValue;
  38394. private _ownerNode;
  38395. /**
  38396. * Instatiates the FadeInOutBehavior
  38397. */
  38398. constructor();
  38399. /**
  38400. * The name of the behavior
  38401. */
  38402. readonly name: string;
  38403. /**
  38404. * Initializes the behavior
  38405. */
  38406. init(): void;
  38407. /**
  38408. * Attaches the fade behavior on the passed in mesh
  38409. * @param ownerNode The mesh that will be faded in/out once attached
  38410. */
  38411. attach(ownerNode: Mesh): void;
  38412. /**
  38413. * Detaches the behavior from the mesh
  38414. */
  38415. detach(): void;
  38416. /**
  38417. * Triggers the mesh to begin fading in or out
  38418. * @param value if the object should fade in or out (true to fade in)
  38419. */
  38420. fadeIn(value: boolean): void;
  38421. private _update;
  38422. private _setAllVisibility;
  38423. }
  38424. }
  38425. declare module "babylonjs/Misc/pivotTools" {
  38426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38427. /**
  38428. * Class containing a set of static utilities functions for managing Pivots
  38429. * @hidden
  38430. */
  38431. export class PivotTools {
  38432. private static _PivotCached;
  38433. private static _OldPivotPoint;
  38434. private static _PivotTranslation;
  38435. private static _PivotTmpVector;
  38436. /** @hidden */
  38437. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38438. /** @hidden */
  38439. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38440. }
  38441. }
  38442. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38443. import { Scene } from "babylonjs/scene";
  38444. import { Vector4 } from "babylonjs/Maths/math.vector";
  38445. import { Mesh } from "babylonjs/Meshes/mesh";
  38446. import { Nullable } from "babylonjs/types";
  38447. import { Plane } from "babylonjs/Maths/math.plane";
  38448. /**
  38449. * Class containing static functions to help procedurally build meshes
  38450. */
  38451. export class PlaneBuilder {
  38452. /**
  38453. * Creates a plane mesh
  38454. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38455. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38456. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38460. * @param name defines the name of the mesh
  38461. * @param options defines the options used to create the mesh
  38462. * @param scene defines the hosting scene
  38463. * @returns the plane mesh
  38464. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38465. */
  38466. static CreatePlane(name: string, options: {
  38467. size?: number;
  38468. width?: number;
  38469. height?: number;
  38470. sideOrientation?: number;
  38471. frontUVs?: Vector4;
  38472. backUVs?: Vector4;
  38473. updatable?: boolean;
  38474. sourcePlane?: Plane;
  38475. }, scene?: Nullable<Scene>): Mesh;
  38476. }
  38477. }
  38478. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38479. import { Behavior } from "babylonjs/Behaviors/behavior";
  38480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38481. import { Observable } from "babylonjs/Misc/observable";
  38482. import { Vector3 } from "babylonjs/Maths/math.vector";
  38483. import { Ray } from "babylonjs/Culling/ray";
  38484. import "babylonjs/Meshes/Builders/planeBuilder";
  38485. /**
  38486. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38487. */
  38488. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38489. private static _AnyMouseID;
  38490. /**
  38491. * Abstract mesh the behavior is set on
  38492. */
  38493. attachedNode: AbstractMesh;
  38494. private _dragPlane;
  38495. private _scene;
  38496. private _pointerObserver;
  38497. private _beforeRenderObserver;
  38498. private static _planeScene;
  38499. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38500. /**
  38501. * 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)
  38502. */
  38503. maxDragAngle: number;
  38504. /**
  38505. * @hidden
  38506. */
  38507. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38508. /**
  38509. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38510. */
  38511. currentDraggingPointerID: number;
  38512. /**
  38513. * The last position where the pointer hit the drag plane in world space
  38514. */
  38515. lastDragPosition: Vector3;
  38516. /**
  38517. * If the behavior is currently in a dragging state
  38518. */
  38519. dragging: boolean;
  38520. /**
  38521. * 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)
  38522. */
  38523. dragDeltaRatio: number;
  38524. /**
  38525. * If the drag plane orientation should be updated during the dragging (Default: true)
  38526. */
  38527. updateDragPlane: boolean;
  38528. private _debugMode;
  38529. private _moving;
  38530. /**
  38531. * Fires each time the attached mesh is dragged with the pointer
  38532. * * delta between last drag position and current drag position in world space
  38533. * * dragDistance along the drag axis
  38534. * * dragPlaneNormal normal of the current drag plane used during the drag
  38535. * * dragPlanePoint in world space where the drag intersects the drag plane
  38536. */
  38537. onDragObservable: Observable<{
  38538. delta: Vector3;
  38539. dragPlanePoint: Vector3;
  38540. dragPlaneNormal: Vector3;
  38541. dragDistance: number;
  38542. pointerId: number;
  38543. }>;
  38544. /**
  38545. * Fires each time a drag begins (eg. mouse down on mesh)
  38546. */
  38547. onDragStartObservable: Observable<{
  38548. dragPlanePoint: Vector3;
  38549. pointerId: number;
  38550. }>;
  38551. /**
  38552. * Fires each time a drag ends (eg. mouse release after drag)
  38553. */
  38554. onDragEndObservable: Observable<{
  38555. dragPlanePoint: Vector3;
  38556. pointerId: number;
  38557. }>;
  38558. /**
  38559. * If the attached mesh should be moved when dragged
  38560. */
  38561. moveAttached: boolean;
  38562. /**
  38563. * If the drag behavior will react to drag events (Default: true)
  38564. */
  38565. enabled: boolean;
  38566. /**
  38567. * If pointer events should start and release the drag (Default: true)
  38568. */
  38569. startAndReleaseDragOnPointerEvents: boolean;
  38570. /**
  38571. * If camera controls should be detached during the drag
  38572. */
  38573. detachCameraControls: boolean;
  38574. /**
  38575. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38576. */
  38577. useObjectOrienationForDragging: boolean;
  38578. private _options;
  38579. /**
  38580. * Creates a pointer drag behavior that can be attached to a mesh
  38581. * @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)
  38582. */
  38583. constructor(options?: {
  38584. dragAxis?: Vector3;
  38585. dragPlaneNormal?: Vector3;
  38586. });
  38587. /**
  38588. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38589. */
  38590. validateDrag: (targetPosition: Vector3) => boolean;
  38591. /**
  38592. * The name of the behavior
  38593. */
  38594. readonly name: string;
  38595. /**
  38596. * Initializes the behavior
  38597. */
  38598. init(): void;
  38599. private _tmpVector;
  38600. private _alternatePickedPoint;
  38601. private _worldDragAxis;
  38602. private _targetPosition;
  38603. private _attachedElement;
  38604. /**
  38605. * Attaches the drag behavior the passed in mesh
  38606. * @param ownerNode The mesh that will be dragged around once attached
  38607. * @param predicate Predicate to use for pick filtering
  38608. */
  38609. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38610. /**
  38611. * Force relase the drag action by code.
  38612. */
  38613. releaseDrag(): void;
  38614. private _startDragRay;
  38615. private _lastPointerRay;
  38616. /**
  38617. * Simulates the start of a pointer drag event on the behavior
  38618. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38619. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38620. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38621. */
  38622. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38623. private _startDrag;
  38624. private _dragDelta;
  38625. private _moveDrag;
  38626. private _pickWithRayOnDragPlane;
  38627. private _pointA;
  38628. private _pointB;
  38629. private _pointC;
  38630. private _lineA;
  38631. private _lineB;
  38632. private _localAxis;
  38633. private _lookAt;
  38634. private _updateDragPlanePosition;
  38635. /**
  38636. * Detaches the behavior from the mesh
  38637. */
  38638. detach(): void;
  38639. }
  38640. }
  38641. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38642. import { Mesh } from "babylonjs/Meshes/mesh";
  38643. import { Behavior } from "babylonjs/Behaviors/behavior";
  38644. /**
  38645. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38646. */
  38647. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38648. private _dragBehaviorA;
  38649. private _dragBehaviorB;
  38650. private _startDistance;
  38651. private _initialScale;
  38652. private _targetScale;
  38653. private _ownerNode;
  38654. private _sceneRenderObserver;
  38655. /**
  38656. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38657. */
  38658. constructor();
  38659. /**
  38660. * The name of the behavior
  38661. */
  38662. readonly name: string;
  38663. /**
  38664. * Initializes the behavior
  38665. */
  38666. init(): void;
  38667. private _getCurrentDistance;
  38668. /**
  38669. * Attaches the scale behavior the passed in mesh
  38670. * @param ownerNode The mesh that will be scaled around once attached
  38671. */
  38672. attach(ownerNode: Mesh): void;
  38673. /**
  38674. * Detaches the behavior from the mesh
  38675. */
  38676. detach(): void;
  38677. }
  38678. }
  38679. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38680. import { Behavior } from "babylonjs/Behaviors/behavior";
  38681. import { Mesh } from "babylonjs/Meshes/mesh";
  38682. import { Observable } from "babylonjs/Misc/observable";
  38683. /**
  38684. * 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
  38685. */
  38686. export class SixDofDragBehavior implements Behavior<Mesh> {
  38687. private static _virtualScene;
  38688. private _ownerNode;
  38689. private _sceneRenderObserver;
  38690. private _scene;
  38691. private _targetPosition;
  38692. private _virtualOriginMesh;
  38693. private _virtualDragMesh;
  38694. private _pointerObserver;
  38695. private _moving;
  38696. private _startingOrientation;
  38697. /**
  38698. * 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)
  38699. */
  38700. private zDragFactor;
  38701. /**
  38702. * If the object should rotate to face the drag origin
  38703. */
  38704. rotateDraggedObject: boolean;
  38705. /**
  38706. * If the behavior is currently in a dragging state
  38707. */
  38708. dragging: boolean;
  38709. /**
  38710. * 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)
  38711. */
  38712. dragDeltaRatio: number;
  38713. /**
  38714. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38715. */
  38716. currentDraggingPointerID: number;
  38717. /**
  38718. * If camera controls should be detached during the drag
  38719. */
  38720. detachCameraControls: boolean;
  38721. /**
  38722. * Fires each time a drag starts
  38723. */
  38724. onDragStartObservable: Observable<{}>;
  38725. /**
  38726. * Fires each time a drag ends (eg. mouse release after drag)
  38727. */
  38728. onDragEndObservable: Observable<{}>;
  38729. /**
  38730. * 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
  38731. */
  38732. constructor();
  38733. /**
  38734. * The name of the behavior
  38735. */
  38736. readonly name: string;
  38737. /**
  38738. * Initializes the behavior
  38739. */
  38740. init(): void;
  38741. /**
  38742. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38743. */
  38744. private readonly _pointerCamera;
  38745. /**
  38746. * Attaches the scale behavior the passed in mesh
  38747. * @param ownerNode The mesh that will be scaled around once attached
  38748. */
  38749. attach(ownerNode: Mesh): void;
  38750. /**
  38751. * Detaches the behavior from the mesh
  38752. */
  38753. detach(): void;
  38754. }
  38755. }
  38756. declare module "babylonjs/Behaviors/Meshes/index" {
  38757. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38758. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38759. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38760. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38761. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38762. }
  38763. declare module "babylonjs/Behaviors/index" {
  38764. export * from "babylonjs/Behaviors/behavior";
  38765. export * from "babylonjs/Behaviors/Cameras/index";
  38766. export * from "babylonjs/Behaviors/Meshes/index";
  38767. }
  38768. declare module "babylonjs/Bones/boneIKController" {
  38769. import { Bone } from "babylonjs/Bones/bone";
  38770. import { Vector3 } from "babylonjs/Maths/math.vector";
  38771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38772. import { Nullable } from "babylonjs/types";
  38773. /**
  38774. * Class used to apply inverse kinematics to bones
  38775. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38776. */
  38777. export class BoneIKController {
  38778. private static _tmpVecs;
  38779. private static _tmpQuat;
  38780. private static _tmpMats;
  38781. /**
  38782. * Gets or sets the target mesh
  38783. */
  38784. targetMesh: AbstractMesh;
  38785. /** Gets or sets the mesh used as pole */
  38786. poleTargetMesh: AbstractMesh;
  38787. /**
  38788. * Gets or sets the bone used as pole
  38789. */
  38790. poleTargetBone: Nullable<Bone>;
  38791. /**
  38792. * Gets or sets the target position
  38793. */
  38794. targetPosition: Vector3;
  38795. /**
  38796. * Gets or sets the pole target position
  38797. */
  38798. poleTargetPosition: Vector3;
  38799. /**
  38800. * Gets or sets the pole target local offset
  38801. */
  38802. poleTargetLocalOffset: Vector3;
  38803. /**
  38804. * Gets or sets the pole angle
  38805. */
  38806. poleAngle: number;
  38807. /**
  38808. * Gets or sets the mesh associated with the controller
  38809. */
  38810. mesh: AbstractMesh;
  38811. /**
  38812. * 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)
  38813. */
  38814. slerpAmount: number;
  38815. private _bone1Quat;
  38816. private _bone1Mat;
  38817. private _bone2Ang;
  38818. private _bone1;
  38819. private _bone2;
  38820. private _bone1Length;
  38821. private _bone2Length;
  38822. private _maxAngle;
  38823. private _maxReach;
  38824. private _rightHandedSystem;
  38825. private _bendAxis;
  38826. private _slerping;
  38827. private _adjustRoll;
  38828. /**
  38829. * Gets or sets maximum allowed angle
  38830. */
  38831. maxAngle: number;
  38832. /**
  38833. * Creates a new BoneIKController
  38834. * @param mesh defines the mesh to control
  38835. * @param bone defines the bone to control
  38836. * @param options defines options to set up the controller
  38837. */
  38838. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38839. targetMesh?: AbstractMesh;
  38840. poleTargetMesh?: AbstractMesh;
  38841. poleTargetBone?: Bone;
  38842. poleTargetLocalOffset?: Vector3;
  38843. poleAngle?: number;
  38844. bendAxis?: Vector3;
  38845. maxAngle?: number;
  38846. slerpAmount?: number;
  38847. });
  38848. private _setMaxAngle;
  38849. /**
  38850. * Force the controller to update the bones
  38851. */
  38852. update(): void;
  38853. }
  38854. }
  38855. declare module "babylonjs/Bones/boneLookController" {
  38856. import { Vector3 } from "babylonjs/Maths/math.vector";
  38857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38858. import { Bone } from "babylonjs/Bones/bone";
  38859. import { Space } from "babylonjs/Maths/math.axis";
  38860. /**
  38861. * Class used to make a bone look toward a point in space
  38862. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38863. */
  38864. export class BoneLookController {
  38865. private static _tmpVecs;
  38866. private static _tmpQuat;
  38867. private static _tmpMats;
  38868. /**
  38869. * The target Vector3 that the bone will look at
  38870. */
  38871. target: Vector3;
  38872. /**
  38873. * The mesh that the bone is attached to
  38874. */
  38875. mesh: AbstractMesh;
  38876. /**
  38877. * The bone that will be looking to the target
  38878. */
  38879. bone: Bone;
  38880. /**
  38881. * The up axis of the coordinate system that is used when the bone is rotated
  38882. */
  38883. upAxis: Vector3;
  38884. /**
  38885. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38886. */
  38887. upAxisSpace: Space;
  38888. /**
  38889. * Used to make an adjustment to the yaw of the bone
  38890. */
  38891. adjustYaw: number;
  38892. /**
  38893. * Used to make an adjustment to the pitch of the bone
  38894. */
  38895. adjustPitch: number;
  38896. /**
  38897. * Used to make an adjustment to the roll of the bone
  38898. */
  38899. adjustRoll: number;
  38900. /**
  38901. * 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)
  38902. */
  38903. slerpAmount: number;
  38904. private _minYaw;
  38905. private _maxYaw;
  38906. private _minPitch;
  38907. private _maxPitch;
  38908. private _minYawSin;
  38909. private _minYawCos;
  38910. private _maxYawSin;
  38911. private _maxYawCos;
  38912. private _midYawConstraint;
  38913. private _minPitchTan;
  38914. private _maxPitchTan;
  38915. private _boneQuat;
  38916. private _slerping;
  38917. private _transformYawPitch;
  38918. private _transformYawPitchInv;
  38919. private _firstFrameSkipped;
  38920. private _yawRange;
  38921. private _fowardAxis;
  38922. /**
  38923. * Gets or sets the minimum yaw angle that the bone can look to
  38924. */
  38925. minYaw: number;
  38926. /**
  38927. * Gets or sets the maximum yaw angle that the bone can look to
  38928. */
  38929. maxYaw: number;
  38930. /**
  38931. * Gets or sets the minimum pitch angle that the bone can look to
  38932. */
  38933. minPitch: number;
  38934. /**
  38935. * Gets or sets the maximum pitch angle that the bone can look to
  38936. */
  38937. maxPitch: number;
  38938. /**
  38939. * Create a BoneLookController
  38940. * @param mesh the mesh that the bone belongs to
  38941. * @param bone the bone that will be looking to the target
  38942. * @param target the target Vector3 to look at
  38943. * @param options optional settings:
  38944. * * maxYaw: the maximum angle the bone will yaw to
  38945. * * minYaw: the minimum angle the bone will yaw to
  38946. * * maxPitch: the maximum angle the bone will pitch to
  38947. * * minPitch: the minimum angle the bone will yaw to
  38948. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38949. * * upAxis: the up axis of the coordinate system
  38950. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38951. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38952. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38953. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38954. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38955. * * adjustRoll: used to make an adjustment to the roll of the bone
  38956. **/
  38957. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38958. maxYaw?: number;
  38959. minYaw?: number;
  38960. maxPitch?: number;
  38961. minPitch?: number;
  38962. slerpAmount?: number;
  38963. upAxis?: Vector3;
  38964. upAxisSpace?: Space;
  38965. yawAxis?: Vector3;
  38966. pitchAxis?: Vector3;
  38967. adjustYaw?: number;
  38968. adjustPitch?: number;
  38969. adjustRoll?: number;
  38970. });
  38971. /**
  38972. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38973. */
  38974. update(): void;
  38975. private _getAngleDiff;
  38976. private _getAngleBetween;
  38977. private _isAngleBetween;
  38978. }
  38979. }
  38980. declare module "babylonjs/Bones/index" {
  38981. export * from "babylonjs/Bones/bone";
  38982. export * from "babylonjs/Bones/boneIKController";
  38983. export * from "babylonjs/Bones/boneLookController";
  38984. export * from "babylonjs/Bones/skeleton";
  38985. }
  38986. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38987. import { Nullable } from "babylonjs/types";
  38988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38990. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38991. /**
  38992. * Manage the gamepad inputs to control an arc rotate camera.
  38993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38994. */
  38995. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38996. /**
  38997. * Defines the camera the input is attached to.
  38998. */
  38999. camera: ArcRotateCamera;
  39000. /**
  39001. * Defines the gamepad the input is gathering event from.
  39002. */
  39003. gamepad: Nullable<Gamepad>;
  39004. /**
  39005. * Defines the gamepad rotation sensiblity.
  39006. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39007. */
  39008. gamepadRotationSensibility: number;
  39009. /**
  39010. * Defines the gamepad move sensiblity.
  39011. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39012. */
  39013. gamepadMoveSensibility: number;
  39014. private _yAxisScale;
  39015. /**
  39016. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39017. */
  39018. invertYAxis: boolean;
  39019. private _onGamepadConnectedObserver;
  39020. private _onGamepadDisconnectedObserver;
  39021. /**
  39022. * Attach the input controls to a specific dom element to get the input from.
  39023. * @param element Defines the element the controls should be listened from
  39024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39025. */
  39026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39027. /**
  39028. * Detach the current controls from the specified dom element.
  39029. * @param element Defines the element to stop listening the inputs from
  39030. */
  39031. detachControl(element: Nullable<HTMLElement>): void;
  39032. /**
  39033. * Update the current camera state depending on the inputs that have been used this frame.
  39034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39035. */
  39036. checkInputs(): void;
  39037. /**
  39038. * Gets the class name of the current intput.
  39039. * @returns the class name
  39040. */
  39041. getClassName(): string;
  39042. /**
  39043. * Get the friendly name associated with the input class.
  39044. * @returns the input friendly name
  39045. */
  39046. getSimpleName(): string;
  39047. }
  39048. }
  39049. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39050. import { Nullable } from "babylonjs/types";
  39051. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39052. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39053. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39054. interface ArcRotateCameraInputsManager {
  39055. /**
  39056. * Add orientation input support to the input manager.
  39057. * @returns the current input manager
  39058. */
  39059. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39060. }
  39061. }
  39062. /**
  39063. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39065. */
  39066. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39067. /**
  39068. * Defines the camera the input is attached to.
  39069. */
  39070. camera: ArcRotateCamera;
  39071. /**
  39072. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39073. */
  39074. alphaCorrection: number;
  39075. /**
  39076. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39077. */
  39078. gammaCorrection: number;
  39079. private _alpha;
  39080. private _gamma;
  39081. private _dirty;
  39082. private _deviceOrientationHandler;
  39083. /**
  39084. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39085. */
  39086. constructor();
  39087. /**
  39088. * Attach the input controls to a specific dom element to get the input from.
  39089. * @param element Defines the element the controls should be listened from
  39090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39091. */
  39092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39093. /** @hidden */
  39094. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39095. /**
  39096. * Update the current camera state depending on the inputs that have been used this frame.
  39097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39098. */
  39099. checkInputs(): void;
  39100. /**
  39101. * Detach the current controls from the specified dom element.
  39102. * @param element Defines the element to stop listening the inputs from
  39103. */
  39104. detachControl(element: Nullable<HTMLElement>): void;
  39105. /**
  39106. * Gets the class name of the current intput.
  39107. * @returns the class name
  39108. */
  39109. getClassName(): string;
  39110. /**
  39111. * Get the friendly name associated with the input class.
  39112. * @returns the input friendly name
  39113. */
  39114. getSimpleName(): string;
  39115. }
  39116. }
  39117. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39118. import { Nullable } from "babylonjs/types";
  39119. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39120. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39121. /**
  39122. * Listen to mouse events to control the camera.
  39123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39124. */
  39125. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39126. /**
  39127. * Defines the camera the input is attached to.
  39128. */
  39129. camera: FlyCamera;
  39130. /**
  39131. * Defines if touch is enabled. (Default is true.)
  39132. */
  39133. touchEnabled: boolean;
  39134. /**
  39135. * Defines the buttons associated with the input to handle camera rotation.
  39136. */
  39137. buttons: number[];
  39138. /**
  39139. * Assign buttons for Yaw control.
  39140. */
  39141. buttonsYaw: number[];
  39142. /**
  39143. * Assign buttons for Pitch control.
  39144. */
  39145. buttonsPitch: number[];
  39146. /**
  39147. * Assign buttons for Roll control.
  39148. */
  39149. buttonsRoll: number[];
  39150. /**
  39151. * Detect if any button is being pressed while mouse is moved.
  39152. * -1 = Mouse locked.
  39153. * 0 = Left button.
  39154. * 1 = Middle Button.
  39155. * 2 = Right Button.
  39156. */
  39157. activeButton: number;
  39158. /**
  39159. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39160. * Higher values reduce its sensitivity.
  39161. */
  39162. angularSensibility: number;
  39163. private _mousemoveCallback;
  39164. private _observer;
  39165. private _rollObserver;
  39166. private previousPosition;
  39167. private noPreventDefault;
  39168. private element;
  39169. /**
  39170. * Listen to mouse events to control the camera.
  39171. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39173. */
  39174. constructor(touchEnabled?: boolean);
  39175. /**
  39176. * Attach the mouse control to the HTML DOM element.
  39177. * @param element Defines the element that listens to the input events.
  39178. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39179. */
  39180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39181. /**
  39182. * Detach the current controls from the specified dom element.
  39183. * @param element Defines the element to stop listening the inputs from
  39184. */
  39185. detachControl(element: Nullable<HTMLElement>): void;
  39186. /**
  39187. * Gets the class name of the current input.
  39188. * @returns the class name.
  39189. */
  39190. getClassName(): string;
  39191. /**
  39192. * Get the friendly name associated with the input class.
  39193. * @returns the input's friendly name.
  39194. */
  39195. getSimpleName(): string;
  39196. private _pointerInput;
  39197. private _onMouseMove;
  39198. /**
  39199. * Rotate camera by mouse offset.
  39200. */
  39201. private rotateCamera;
  39202. }
  39203. }
  39204. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39205. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39206. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39207. /**
  39208. * Default Inputs manager for the FlyCamera.
  39209. * It groups all the default supported inputs for ease of use.
  39210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39211. */
  39212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39213. /**
  39214. * Instantiates a new FlyCameraInputsManager.
  39215. * @param camera Defines the camera the inputs belong to.
  39216. */
  39217. constructor(camera: FlyCamera);
  39218. /**
  39219. * Add keyboard input support to the input manager.
  39220. * @returns the new FlyCameraKeyboardMoveInput().
  39221. */
  39222. addKeyboard(): FlyCameraInputsManager;
  39223. /**
  39224. * Add mouse input support to the input manager.
  39225. * @param touchEnabled Enable touch screen support.
  39226. * @returns the new FlyCameraMouseInput().
  39227. */
  39228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39229. }
  39230. }
  39231. declare module "babylonjs/Cameras/flyCamera" {
  39232. import { Scene } from "babylonjs/scene";
  39233. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39235. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39236. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39237. /**
  39238. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39239. * such as in a 3D Space Shooter or a Flight Simulator.
  39240. */
  39241. export class FlyCamera extends TargetCamera {
  39242. /**
  39243. * Define the collision ellipsoid of the camera.
  39244. * This is helpful for simulating a camera body, like a player's body.
  39245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39246. */
  39247. ellipsoid: Vector3;
  39248. /**
  39249. * Define an offset for the position of the ellipsoid around the camera.
  39250. * This can be helpful if the camera is attached away from the player's body center,
  39251. * such as at its head.
  39252. */
  39253. ellipsoidOffset: Vector3;
  39254. /**
  39255. * Enable or disable collisions of the camera with the rest of the scene objects.
  39256. */
  39257. checkCollisions: boolean;
  39258. /**
  39259. * Enable or disable gravity on the camera.
  39260. */
  39261. applyGravity: boolean;
  39262. /**
  39263. * Define the current direction the camera is moving to.
  39264. */
  39265. cameraDirection: Vector3;
  39266. /**
  39267. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39268. * This overrides and empties cameraRotation.
  39269. */
  39270. rotationQuaternion: Quaternion;
  39271. /**
  39272. * Track Roll to maintain the wanted Rolling when looking around.
  39273. */
  39274. _trackRoll: number;
  39275. /**
  39276. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39277. */
  39278. rollCorrect: number;
  39279. /**
  39280. * Mimic a banked turn, Rolling the camera when Yawing.
  39281. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39282. */
  39283. bankedTurn: boolean;
  39284. /**
  39285. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39286. */
  39287. bankedTurnLimit: number;
  39288. /**
  39289. * Value of 0 disables the banked Roll.
  39290. * Value of 1 is equal to the Yaw angle in radians.
  39291. */
  39292. bankedTurnMultiplier: number;
  39293. /**
  39294. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39295. */
  39296. inputs: FlyCameraInputsManager;
  39297. /**
  39298. * Gets the input sensibility for mouse input.
  39299. * Higher values reduce sensitivity.
  39300. */
  39301. /**
  39302. * Sets the input sensibility for a mouse input.
  39303. * Higher values reduce sensitivity.
  39304. */
  39305. angularSensibility: number;
  39306. /**
  39307. * Get the keys for camera movement forward.
  39308. */
  39309. /**
  39310. * Set the keys for camera movement forward.
  39311. */
  39312. keysForward: number[];
  39313. /**
  39314. * Get the keys for camera movement backward.
  39315. */
  39316. keysBackward: number[];
  39317. /**
  39318. * Get the keys for camera movement up.
  39319. */
  39320. /**
  39321. * Set the keys for camera movement up.
  39322. */
  39323. keysUp: number[];
  39324. /**
  39325. * Get the keys for camera movement down.
  39326. */
  39327. /**
  39328. * Set the keys for camera movement down.
  39329. */
  39330. keysDown: number[];
  39331. /**
  39332. * Get the keys for camera movement left.
  39333. */
  39334. /**
  39335. * Set the keys for camera movement left.
  39336. */
  39337. keysLeft: number[];
  39338. /**
  39339. * Set the keys for camera movement right.
  39340. */
  39341. /**
  39342. * Set the keys for camera movement right.
  39343. */
  39344. keysRight: number[];
  39345. /**
  39346. * Event raised when the camera collides with a mesh in the scene.
  39347. */
  39348. onCollide: (collidedMesh: AbstractMesh) => void;
  39349. private _collider;
  39350. private _needMoveForGravity;
  39351. private _oldPosition;
  39352. private _diffPosition;
  39353. private _newPosition;
  39354. /** @hidden */
  39355. _localDirection: Vector3;
  39356. /** @hidden */
  39357. _transformedDirection: Vector3;
  39358. /**
  39359. * Instantiates a FlyCamera.
  39360. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39361. * such as in a 3D Space Shooter or a Flight Simulator.
  39362. * @param name Define the name of the camera in the scene.
  39363. * @param position Define the starting position of the camera in the scene.
  39364. * @param scene Define the scene the camera belongs to.
  39365. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39366. */
  39367. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39368. /**
  39369. * Attach a control to the HTML DOM element.
  39370. * @param element Defines the element that listens to the input events.
  39371. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39372. */
  39373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39374. /**
  39375. * Detach a control from the HTML DOM element.
  39376. * The camera will stop reacting to that input.
  39377. * @param element Defines the element that listens to the input events.
  39378. */
  39379. detachControl(element: HTMLElement): void;
  39380. private _collisionMask;
  39381. /**
  39382. * Get the mask that the camera ignores in collision events.
  39383. */
  39384. /**
  39385. * Set the mask that the camera ignores in collision events.
  39386. */
  39387. collisionMask: number;
  39388. /** @hidden */
  39389. _collideWithWorld(displacement: Vector3): void;
  39390. /** @hidden */
  39391. private _onCollisionPositionChange;
  39392. /** @hidden */
  39393. _checkInputs(): void;
  39394. /** @hidden */
  39395. _decideIfNeedsToMove(): boolean;
  39396. /** @hidden */
  39397. _updatePosition(): void;
  39398. /**
  39399. * Restore the Roll to its target value at the rate specified.
  39400. * @param rate - Higher means slower restoring.
  39401. * @hidden
  39402. */
  39403. restoreRoll(rate: number): void;
  39404. /**
  39405. * Destroy the camera and release the current resources held by it.
  39406. */
  39407. dispose(): void;
  39408. /**
  39409. * Get the current object class name.
  39410. * @returns the class name.
  39411. */
  39412. getClassName(): string;
  39413. }
  39414. }
  39415. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39416. import { Nullable } from "babylonjs/types";
  39417. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39418. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39419. /**
  39420. * Listen to keyboard events to control the camera.
  39421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39422. */
  39423. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39424. /**
  39425. * Defines the camera the input is attached to.
  39426. */
  39427. camera: FlyCamera;
  39428. /**
  39429. * The list of keyboard keys used to control the forward move of the camera.
  39430. */
  39431. keysForward: number[];
  39432. /**
  39433. * The list of keyboard keys used to control the backward move of the camera.
  39434. */
  39435. keysBackward: number[];
  39436. /**
  39437. * The list of keyboard keys used to control the forward move of the camera.
  39438. */
  39439. keysUp: number[];
  39440. /**
  39441. * The list of keyboard keys used to control the backward move of the camera.
  39442. */
  39443. keysDown: number[];
  39444. /**
  39445. * The list of keyboard keys used to control the right strafe move of the camera.
  39446. */
  39447. keysRight: number[];
  39448. /**
  39449. * The list of keyboard keys used to control the left strafe move of the camera.
  39450. */
  39451. keysLeft: number[];
  39452. private _keys;
  39453. private _onCanvasBlurObserver;
  39454. private _onKeyboardObserver;
  39455. private _engine;
  39456. private _scene;
  39457. /**
  39458. * Attach the input controls to a specific dom element to get the input from.
  39459. * @param element Defines the element the controls should be listened from
  39460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39461. */
  39462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39463. /**
  39464. * Detach the current controls from the specified dom element.
  39465. * @param element Defines the element to stop listening the inputs from
  39466. */
  39467. detachControl(element: Nullable<HTMLElement>): void;
  39468. /**
  39469. * Gets the class name of the current intput.
  39470. * @returns the class name
  39471. */
  39472. getClassName(): string;
  39473. /** @hidden */
  39474. _onLostFocus(e: FocusEvent): void;
  39475. /**
  39476. * Get the friendly name associated with the input class.
  39477. * @returns the input friendly name
  39478. */
  39479. getSimpleName(): string;
  39480. /**
  39481. * Update the current camera state depending on the inputs that have been used this frame.
  39482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39483. */
  39484. checkInputs(): void;
  39485. }
  39486. }
  39487. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39488. import { Nullable } from "babylonjs/types";
  39489. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39490. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39491. /**
  39492. * Manage the mouse wheel inputs to control a follow camera.
  39493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39494. */
  39495. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39496. /**
  39497. * Defines the camera the input is attached to.
  39498. */
  39499. camera: FollowCamera;
  39500. /**
  39501. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39502. */
  39503. axisControlRadius: boolean;
  39504. /**
  39505. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39506. */
  39507. axisControlHeight: boolean;
  39508. /**
  39509. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39510. */
  39511. axisControlRotation: boolean;
  39512. /**
  39513. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39514. * relation to mouseWheel events.
  39515. */
  39516. wheelPrecision: number;
  39517. /**
  39518. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39519. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39520. */
  39521. wheelDeltaPercentage: number;
  39522. private _wheel;
  39523. private _observer;
  39524. /**
  39525. * Attach the input controls to a specific dom element to get the input from.
  39526. * @param element Defines the element the controls should be listened from
  39527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39528. */
  39529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39530. /**
  39531. * Detach the current controls from the specified dom element.
  39532. * @param element Defines the element to stop listening the inputs from
  39533. */
  39534. detachControl(element: Nullable<HTMLElement>): void;
  39535. /**
  39536. * Gets the class name of the current intput.
  39537. * @returns the class name
  39538. */
  39539. getClassName(): string;
  39540. /**
  39541. * Get the friendly name associated with the input class.
  39542. * @returns the input friendly name
  39543. */
  39544. getSimpleName(): string;
  39545. }
  39546. }
  39547. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39548. import { Nullable } from "babylonjs/types";
  39549. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39550. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39551. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39552. /**
  39553. * Manage the pointers inputs to control an follow camera.
  39554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39555. */
  39556. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39557. /**
  39558. * Defines the camera the input is attached to.
  39559. */
  39560. camera: FollowCamera;
  39561. /**
  39562. * Gets the class name of the current input.
  39563. * @returns the class name
  39564. */
  39565. getClassName(): string;
  39566. /**
  39567. * Defines the pointer angular sensibility along the X axis or how fast is
  39568. * the camera rotating.
  39569. * A negative number will reverse the axis direction.
  39570. */
  39571. angularSensibilityX: number;
  39572. /**
  39573. * Defines the pointer angular sensibility along the Y axis or how fast is
  39574. * the camera rotating.
  39575. * A negative number will reverse the axis direction.
  39576. */
  39577. angularSensibilityY: number;
  39578. /**
  39579. * Defines the pointer pinch precision or how fast is the camera zooming.
  39580. * A negative number will reverse the axis direction.
  39581. */
  39582. pinchPrecision: number;
  39583. /**
  39584. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39585. * from 0.
  39586. * It defines the percentage of current camera.radius to use as delta when
  39587. * pinch zoom is used.
  39588. */
  39589. pinchDeltaPercentage: number;
  39590. /**
  39591. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39592. */
  39593. axisXControlRadius: boolean;
  39594. /**
  39595. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39596. */
  39597. axisXControlHeight: boolean;
  39598. /**
  39599. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39600. */
  39601. axisXControlRotation: boolean;
  39602. /**
  39603. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39604. */
  39605. axisYControlRadius: boolean;
  39606. /**
  39607. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39608. */
  39609. axisYControlHeight: boolean;
  39610. /**
  39611. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39612. */
  39613. axisYControlRotation: boolean;
  39614. /**
  39615. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39616. */
  39617. axisPinchControlRadius: boolean;
  39618. /**
  39619. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39620. */
  39621. axisPinchControlHeight: boolean;
  39622. /**
  39623. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39624. */
  39625. axisPinchControlRotation: boolean;
  39626. /**
  39627. * Log error messages if basic misconfiguration has occurred.
  39628. */
  39629. warningEnable: boolean;
  39630. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39631. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39632. private _warningCounter;
  39633. private _warning;
  39634. }
  39635. }
  39636. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39637. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39638. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39639. /**
  39640. * Default Inputs manager for the FollowCamera.
  39641. * It groups all the default supported inputs for ease of use.
  39642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39643. */
  39644. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39645. /**
  39646. * Instantiates a new FollowCameraInputsManager.
  39647. * @param camera Defines the camera the inputs belong to
  39648. */
  39649. constructor(camera: FollowCamera);
  39650. /**
  39651. * Add keyboard input support to the input manager.
  39652. * @returns the current input manager
  39653. */
  39654. addKeyboard(): FollowCameraInputsManager;
  39655. /**
  39656. * Add mouse wheel input support to the input manager.
  39657. * @returns the current input manager
  39658. */
  39659. addMouseWheel(): FollowCameraInputsManager;
  39660. /**
  39661. * Add pointers input support to the input manager.
  39662. * @returns the current input manager
  39663. */
  39664. addPointers(): FollowCameraInputsManager;
  39665. /**
  39666. * Add orientation input support to the input manager.
  39667. * @returns the current input manager
  39668. */
  39669. addVRDeviceOrientation(): FollowCameraInputsManager;
  39670. }
  39671. }
  39672. declare module "babylonjs/Cameras/followCamera" {
  39673. import { Nullable } from "babylonjs/types";
  39674. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39675. import { Scene } from "babylonjs/scene";
  39676. import { Vector3 } from "babylonjs/Maths/math.vector";
  39677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39678. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39679. /**
  39680. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39681. * an arc rotate version arcFollowCamera are available.
  39682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39683. */
  39684. export class FollowCamera extends TargetCamera {
  39685. /**
  39686. * Distance the follow camera should follow an object at
  39687. */
  39688. radius: number;
  39689. /**
  39690. * Minimum allowed distance of the camera to the axis of rotation
  39691. * (The camera can not get closer).
  39692. * This can help limiting how the Camera is able to move in the scene.
  39693. */
  39694. lowerRadiusLimit: Nullable<number>;
  39695. /**
  39696. * Maximum allowed distance of the camera to the axis of rotation
  39697. * (The camera can not get further).
  39698. * This can help limiting how the Camera is able to move in the scene.
  39699. */
  39700. upperRadiusLimit: Nullable<number>;
  39701. /**
  39702. * Define a rotation offset between the camera and the object it follows
  39703. */
  39704. rotationOffset: number;
  39705. /**
  39706. * Minimum allowed angle to camera position relative to target object.
  39707. * This can help limiting how the Camera is able to move in the scene.
  39708. */
  39709. lowerRotationOffsetLimit: Nullable<number>;
  39710. /**
  39711. * Maximum allowed angle to camera position relative to target object.
  39712. * This can help limiting how the Camera is able to move in the scene.
  39713. */
  39714. upperRotationOffsetLimit: Nullable<number>;
  39715. /**
  39716. * Define a height offset between the camera and the object it follows.
  39717. * It can help following an object from the top (like a car chaing a plane)
  39718. */
  39719. heightOffset: number;
  39720. /**
  39721. * Minimum allowed height of camera position relative to target object.
  39722. * This can help limiting how the Camera is able to move in the scene.
  39723. */
  39724. lowerHeightOffsetLimit: Nullable<number>;
  39725. /**
  39726. * Maximum allowed height of camera position relative to target object.
  39727. * This can help limiting how the Camera is able to move in the scene.
  39728. */
  39729. upperHeightOffsetLimit: Nullable<number>;
  39730. /**
  39731. * Define how fast the camera can accelerate to follow it s target.
  39732. */
  39733. cameraAcceleration: number;
  39734. /**
  39735. * Define the speed limit of the camera following an object.
  39736. */
  39737. maxCameraSpeed: number;
  39738. /**
  39739. * Define the target of the camera.
  39740. */
  39741. lockedTarget: Nullable<AbstractMesh>;
  39742. /**
  39743. * Defines the input associated with the camera.
  39744. */
  39745. inputs: FollowCameraInputsManager;
  39746. /**
  39747. * Instantiates the follow camera.
  39748. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39749. * @param name Define the name of the camera in the scene
  39750. * @param position Define the position of the camera
  39751. * @param scene Define the scene the camera belong to
  39752. * @param lockedTarget Define the target of the camera
  39753. */
  39754. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39755. private _follow;
  39756. /**
  39757. * Attached controls to the current camera.
  39758. * @param element Defines the element the controls should be listened from
  39759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39760. */
  39761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39762. /**
  39763. * Detach the current controls from the camera.
  39764. * The camera will stop reacting to inputs.
  39765. * @param element Defines the element to stop listening the inputs from
  39766. */
  39767. detachControl(element: HTMLElement): void;
  39768. /** @hidden */
  39769. _checkInputs(): void;
  39770. private _checkLimits;
  39771. /**
  39772. * Gets the camera class name.
  39773. * @returns the class name
  39774. */
  39775. getClassName(): string;
  39776. }
  39777. /**
  39778. * Arc Rotate version of the follow camera.
  39779. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39780. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39781. */
  39782. export class ArcFollowCamera extends TargetCamera {
  39783. /** The longitudinal angle of the camera */
  39784. alpha: number;
  39785. /** The latitudinal angle of the camera */
  39786. beta: number;
  39787. /** The radius of the camera from its target */
  39788. radius: number;
  39789. /** Define the camera target (the messh it should follow) */
  39790. target: Nullable<AbstractMesh>;
  39791. private _cartesianCoordinates;
  39792. /**
  39793. * Instantiates a new ArcFollowCamera
  39794. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39795. * @param name Define the name of the camera
  39796. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39797. * @param beta Define the rotation angle of the camera around the elevation axis
  39798. * @param radius Define the radius of the camera from its target point
  39799. * @param target Define the target of the camera
  39800. * @param scene Define the scene the camera belongs to
  39801. */
  39802. constructor(name: string,
  39803. /** The longitudinal angle of the camera */
  39804. alpha: number,
  39805. /** The latitudinal angle of the camera */
  39806. beta: number,
  39807. /** The radius of the camera from its target */
  39808. radius: number,
  39809. /** Define the camera target (the messh it should follow) */
  39810. target: Nullable<AbstractMesh>, scene: Scene);
  39811. private _follow;
  39812. /** @hidden */
  39813. _checkInputs(): void;
  39814. /**
  39815. * Returns the class name of the object.
  39816. * It is mostly used internally for serialization purposes.
  39817. */
  39818. getClassName(): string;
  39819. }
  39820. }
  39821. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39823. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39824. import { Nullable } from "babylonjs/types";
  39825. /**
  39826. * Manage the keyboard inputs to control the movement of a follow camera.
  39827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39828. */
  39829. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39830. /**
  39831. * Defines the camera the input is attached to.
  39832. */
  39833. camera: FollowCamera;
  39834. /**
  39835. * Defines the list of key codes associated with the up action (increase heightOffset)
  39836. */
  39837. keysHeightOffsetIncr: number[];
  39838. /**
  39839. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39840. */
  39841. keysHeightOffsetDecr: number[];
  39842. /**
  39843. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39844. */
  39845. keysHeightOffsetModifierAlt: boolean;
  39846. /**
  39847. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39848. */
  39849. keysHeightOffsetModifierCtrl: boolean;
  39850. /**
  39851. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39852. */
  39853. keysHeightOffsetModifierShift: boolean;
  39854. /**
  39855. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39856. */
  39857. keysRotationOffsetIncr: number[];
  39858. /**
  39859. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39860. */
  39861. keysRotationOffsetDecr: number[];
  39862. /**
  39863. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39864. */
  39865. keysRotationOffsetModifierAlt: boolean;
  39866. /**
  39867. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39868. */
  39869. keysRotationOffsetModifierCtrl: boolean;
  39870. /**
  39871. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39872. */
  39873. keysRotationOffsetModifierShift: boolean;
  39874. /**
  39875. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39876. */
  39877. keysRadiusIncr: number[];
  39878. /**
  39879. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39880. */
  39881. keysRadiusDecr: number[];
  39882. /**
  39883. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39884. */
  39885. keysRadiusModifierAlt: boolean;
  39886. /**
  39887. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39888. */
  39889. keysRadiusModifierCtrl: boolean;
  39890. /**
  39891. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39892. */
  39893. keysRadiusModifierShift: boolean;
  39894. /**
  39895. * Defines the rate of change of heightOffset.
  39896. */
  39897. heightSensibility: number;
  39898. /**
  39899. * Defines the rate of change of rotationOffset.
  39900. */
  39901. rotationSensibility: number;
  39902. /**
  39903. * Defines the rate of change of radius.
  39904. */
  39905. radiusSensibility: number;
  39906. private _keys;
  39907. private _ctrlPressed;
  39908. private _altPressed;
  39909. private _shiftPressed;
  39910. private _onCanvasBlurObserver;
  39911. private _onKeyboardObserver;
  39912. private _engine;
  39913. private _scene;
  39914. /**
  39915. * Attach the input controls to a specific dom element to get the input from.
  39916. * @param element Defines the element the controls should be listened from
  39917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39918. */
  39919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39920. /**
  39921. * Detach the current controls from the specified dom element.
  39922. * @param element Defines the element to stop listening the inputs from
  39923. */
  39924. detachControl(element: Nullable<HTMLElement>): void;
  39925. /**
  39926. * Update the current camera state depending on the inputs that have been used this frame.
  39927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39928. */
  39929. checkInputs(): void;
  39930. /**
  39931. * Gets the class name of the current input.
  39932. * @returns the class name
  39933. */
  39934. getClassName(): string;
  39935. /**
  39936. * Get the friendly name associated with the input class.
  39937. * @returns the input friendly name
  39938. */
  39939. getSimpleName(): string;
  39940. /**
  39941. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39942. * allow modification of the heightOffset value.
  39943. */
  39944. private _modifierHeightOffset;
  39945. /**
  39946. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39947. * allow modification of the rotationOffset value.
  39948. */
  39949. private _modifierRotationOffset;
  39950. /**
  39951. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39952. * allow modification of the radius value.
  39953. */
  39954. private _modifierRadius;
  39955. }
  39956. }
  39957. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39958. import { Nullable } from "babylonjs/types";
  39959. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39961. import { Observable } from "babylonjs/Misc/observable";
  39962. module "babylonjs/Cameras/freeCameraInputsManager" {
  39963. interface FreeCameraInputsManager {
  39964. /**
  39965. * @hidden
  39966. */
  39967. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39968. /**
  39969. * Add orientation input support to the input manager.
  39970. * @returns the current input manager
  39971. */
  39972. addDeviceOrientation(): FreeCameraInputsManager;
  39973. }
  39974. }
  39975. /**
  39976. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39977. * Screen rotation is taken into account.
  39978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39979. */
  39980. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39981. private _camera;
  39982. private _screenOrientationAngle;
  39983. private _constantTranform;
  39984. private _screenQuaternion;
  39985. private _alpha;
  39986. private _beta;
  39987. private _gamma;
  39988. /**
  39989. * Can be used to detect if a device orientation sensor is availible on a device
  39990. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39991. * @returns a promise that will resolve on orientation change
  39992. */
  39993. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39994. /**
  39995. * @hidden
  39996. */
  39997. _onDeviceOrientationChangedObservable: Observable<void>;
  39998. /**
  39999. * Instantiates a new input
  40000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40001. */
  40002. constructor();
  40003. /**
  40004. * Define the camera controlled by the input.
  40005. */
  40006. camera: FreeCamera;
  40007. /**
  40008. * Attach the input controls to a specific dom element to get the input from.
  40009. * @param element Defines the element the controls should be listened from
  40010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40011. */
  40012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40013. private _orientationChanged;
  40014. private _deviceOrientation;
  40015. /**
  40016. * Detach the current controls from the specified dom element.
  40017. * @param element Defines the element to stop listening the inputs from
  40018. */
  40019. detachControl(element: Nullable<HTMLElement>): void;
  40020. /**
  40021. * Update the current camera state depending on the inputs that have been used this frame.
  40022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40023. */
  40024. checkInputs(): void;
  40025. /**
  40026. * Gets the class name of the current intput.
  40027. * @returns the class name
  40028. */
  40029. getClassName(): string;
  40030. /**
  40031. * Get the friendly name associated with the input class.
  40032. * @returns the input friendly name
  40033. */
  40034. getSimpleName(): string;
  40035. }
  40036. }
  40037. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40038. import { Nullable } from "babylonjs/types";
  40039. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40041. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40042. /**
  40043. * Manage the gamepad inputs to control a free camera.
  40044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40045. */
  40046. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40047. /**
  40048. * Define the camera the input is attached to.
  40049. */
  40050. camera: FreeCamera;
  40051. /**
  40052. * Define the Gamepad controlling the input
  40053. */
  40054. gamepad: Nullable<Gamepad>;
  40055. /**
  40056. * Defines the gamepad rotation sensiblity.
  40057. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40058. */
  40059. gamepadAngularSensibility: number;
  40060. /**
  40061. * Defines the gamepad move sensiblity.
  40062. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40063. */
  40064. gamepadMoveSensibility: number;
  40065. private _yAxisScale;
  40066. /**
  40067. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40068. */
  40069. invertYAxis: boolean;
  40070. private _onGamepadConnectedObserver;
  40071. private _onGamepadDisconnectedObserver;
  40072. private _cameraTransform;
  40073. private _deltaTransform;
  40074. private _vector3;
  40075. private _vector2;
  40076. /**
  40077. * Attach the input controls to a specific dom element to get the input from.
  40078. * @param element Defines the element the controls should be listened from
  40079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40080. */
  40081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40082. /**
  40083. * Detach the current controls from the specified dom element.
  40084. * @param element Defines the element to stop listening the inputs from
  40085. */
  40086. detachControl(element: Nullable<HTMLElement>): void;
  40087. /**
  40088. * Update the current camera state depending on the inputs that have been used this frame.
  40089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40090. */
  40091. checkInputs(): void;
  40092. /**
  40093. * Gets the class name of the current intput.
  40094. * @returns the class name
  40095. */
  40096. getClassName(): string;
  40097. /**
  40098. * Get the friendly name associated with the input class.
  40099. * @returns the input friendly name
  40100. */
  40101. getSimpleName(): string;
  40102. }
  40103. }
  40104. declare module "babylonjs/Misc/virtualJoystick" {
  40105. import { Nullable } from "babylonjs/types";
  40106. import { Vector3 } from "babylonjs/Maths/math.vector";
  40107. /**
  40108. * Defines the potential axis of a Joystick
  40109. */
  40110. export enum JoystickAxis {
  40111. /** X axis */
  40112. X = 0,
  40113. /** Y axis */
  40114. Y = 1,
  40115. /** Z axis */
  40116. Z = 2
  40117. }
  40118. /**
  40119. * Class used to define virtual joystick (used in touch mode)
  40120. */
  40121. export class VirtualJoystick {
  40122. /**
  40123. * Gets or sets a boolean indicating that left and right values must be inverted
  40124. */
  40125. reverseLeftRight: boolean;
  40126. /**
  40127. * Gets or sets a boolean indicating that up and down values must be inverted
  40128. */
  40129. reverseUpDown: boolean;
  40130. /**
  40131. * Gets the offset value for the position (ie. the change of the position value)
  40132. */
  40133. deltaPosition: Vector3;
  40134. /**
  40135. * Gets a boolean indicating if the virtual joystick was pressed
  40136. */
  40137. pressed: boolean;
  40138. /**
  40139. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40140. */
  40141. static Canvas: Nullable<HTMLCanvasElement>;
  40142. private static _globalJoystickIndex;
  40143. private static vjCanvasContext;
  40144. private static vjCanvasWidth;
  40145. private static vjCanvasHeight;
  40146. private static halfWidth;
  40147. private _action;
  40148. private _axisTargetedByLeftAndRight;
  40149. private _axisTargetedByUpAndDown;
  40150. private _joystickSensibility;
  40151. private _inversedSensibility;
  40152. private _joystickPointerID;
  40153. private _joystickColor;
  40154. private _joystickPointerPos;
  40155. private _joystickPreviousPointerPos;
  40156. private _joystickPointerStartPos;
  40157. private _deltaJoystickVector;
  40158. private _leftJoystick;
  40159. private _touches;
  40160. private _onPointerDownHandlerRef;
  40161. private _onPointerMoveHandlerRef;
  40162. private _onPointerUpHandlerRef;
  40163. private _onResize;
  40164. /**
  40165. * Creates a new virtual joystick
  40166. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40167. */
  40168. constructor(leftJoystick?: boolean);
  40169. /**
  40170. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40171. * @param newJoystickSensibility defines the new sensibility
  40172. */
  40173. setJoystickSensibility(newJoystickSensibility: number): void;
  40174. private _onPointerDown;
  40175. private _onPointerMove;
  40176. private _onPointerUp;
  40177. /**
  40178. * Change the color of the virtual joystick
  40179. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40180. */
  40181. setJoystickColor(newColor: string): void;
  40182. /**
  40183. * Defines a callback to call when the joystick is touched
  40184. * @param action defines the callback
  40185. */
  40186. setActionOnTouch(action: () => any): void;
  40187. /**
  40188. * Defines which axis you'd like to control for left & right
  40189. * @param axis defines the axis to use
  40190. */
  40191. setAxisForLeftRight(axis: JoystickAxis): void;
  40192. /**
  40193. * Defines which axis you'd like to control for up & down
  40194. * @param axis defines the axis to use
  40195. */
  40196. setAxisForUpDown(axis: JoystickAxis): void;
  40197. private _drawVirtualJoystick;
  40198. /**
  40199. * Release internal HTML canvas
  40200. */
  40201. releaseCanvas(): void;
  40202. }
  40203. }
  40204. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40205. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40206. import { Nullable } from "babylonjs/types";
  40207. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40208. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40209. module "babylonjs/Cameras/freeCameraInputsManager" {
  40210. interface FreeCameraInputsManager {
  40211. /**
  40212. * Add virtual joystick input support to the input manager.
  40213. * @returns the current input manager
  40214. */
  40215. addVirtualJoystick(): FreeCameraInputsManager;
  40216. }
  40217. }
  40218. /**
  40219. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40221. */
  40222. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40223. /**
  40224. * Defines the camera the input is attached to.
  40225. */
  40226. camera: FreeCamera;
  40227. private _leftjoystick;
  40228. private _rightjoystick;
  40229. /**
  40230. * Gets the left stick of the virtual joystick.
  40231. * @returns The virtual Joystick
  40232. */
  40233. getLeftJoystick(): VirtualJoystick;
  40234. /**
  40235. * Gets the right stick of the virtual joystick.
  40236. * @returns The virtual Joystick
  40237. */
  40238. getRightJoystick(): VirtualJoystick;
  40239. /**
  40240. * Update the current camera state depending on the inputs that have been used this frame.
  40241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40242. */
  40243. checkInputs(): void;
  40244. /**
  40245. * Attach the input controls to a specific dom element to get the input from.
  40246. * @param element Defines the element the controls should be listened from
  40247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40248. */
  40249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40250. /**
  40251. * Detach the current controls from the specified dom element.
  40252. * @param element Defines the element to stop listening the inputs from
  40253. */
  40254. detachControl(element: Nullable<HTMLElement>): void;
  40255. /**
  40256. * Gets the class name of the current intput.
  40257. * @returns the class name
  40258. */
  40259. getClassName(): string;
  40260. /**
  40261. * Get the friendly name associated with the input class.
  40262. * @returns the input friendly name
  40263. */
  40264. getSimpleName(): string;
  40265. }
  40266. }
  40267. declare module "babylonjs/Cameras/Inputs/index" {
  40268. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40269. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40270. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40271. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40272. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40273. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40274. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40275. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40276. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40277. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40278. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40279. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40280. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40281. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40282. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40283. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40284. }
  40285. declare module "babylonjs/Cameras/touchCamera" {
  40286. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40287. import { Scene } from "babylonjs/scene";
  40288. import { Vector3 } from "babylonjs/Maths/math.vector";
  40289. /**
  40290. * This represents a FPS type of camera controlled by touch.
  40291. * This is like a universal camera minus the Gamepad controls.
  40292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40293. */
  40294. export class TouchCamera extends FreeCamera {
  40295. /**
  40296. * Defines the touch sensibility for rotation.
  40297. * The higher the faster.
  40298. */
  40299. touchAngularSensibility: number;
  40300. /**
  40301. * Defines the touch sensibility for move.
  40302. * The higher the faster.
  40303. */
  40304. touchMoveSensibility: number;
  40305. /**
  40306. * Instantiates a new touch camera.
  40307. * This represents a FPS type of camera controlled by touch.
  40308. * This is like a universal camera minus the Gamepad controls.
  40309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40310. * @param name Define the name of the camera in the scene
  40311. * @param position Define the start position of the camera in the scene
  40312. * @param scene Define the scene the camera belongs to
  40313. */
  40314. constructor(name: string, position: Vector3, scene: Scene);
  40315. /**
  40316. * Gets the current object class name.
  40317. * @return the class name
  40318. */
  40319. getClassName(): string;
  40320. /** @hidden */
  40321. _setupInputs(): void;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40325. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40329. import { Axis } from "babylonjs/Maths/math.axis";
  40330. /**
  40331. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40332. * being tilted forward or back and left or right.
  40333. */
  40334. export class DeviceOrientationCamera extends FreeCamera {
  40335. private _initialQuaternion;
  40336. private _quaternionCache;
  40337. private _tmpDragQuaternion;
  40338. private _disablePointerInputWhenUsingDeviceOrientation;
  40339. /**
  40340. * Creates a new device orientation camera
  40341. * @param name The name of the camera
  40342. * @param position The start position camera
  40343. * @param scene The scene the camera belongs to
  40344. */
  40345. constructor(name: string, position: Vector3, scene: Scene);
  40346. /**
  40347. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40348. */
  40349. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40350. private _dragFactor;
  40351. /**
  40352. * Enabled turning on the y axis when the orientation sensor is active
  40353. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40354. */
  40355. enableHorizontalDragging(dragFactor?: number): void;
  40356. /**
  40357. * Gets the current instance class name ("DeviceOrientationCamera").
  40358. * This helps avoiding instanceof at run time.
  40359. * @returns the class name
  40360. */
  40361. getClassName(): string;
  40362. /**
  40363. * @hidden
  40364. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40365. */
  40366. _checkInputs(): void;
  40367. /**
  40368. * Reset the camera to its default orientation on the specified axis only.
  40369. * @param axis The axis to reset
  40370. */
  40371. resetToCurrentRotation(axis?: Axis): void;
  40372. }
  40373. }
  40374. declare module "babylonjs/Gamepads/xboxGamepad" {
  40375. import { Observable } from "babylonjs/Misc/observable";
  40376. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40377. /**
  40378. * Defines supported buttons for XBox360 compatible gamepads
  40379. */
  40380. export enum Xbox360Button {
  40381. /** A */
  40382. A = 0,
  40383. /** B */
  40384. B = 1,
  40385. /** X */
  40386. X = 2,
  40387. /** Y */
  40388. Y = 3,
  40389. /** Start */
  40390. Start = 4,
  40391. /** Back */
  40392. Back = 5,
  40393. /** Left button */
  40394. LB = 6,
  40395. /** Right button */
  40396. RB = 7,
  40397. /** Left stick */
  40398. LeftStick = 8,
  40399. /** Right stick */
  40400. RightStick = 9
  40401. }
  40402. /** Defines values for XBox360 DPad */
  40403. export enum Xbox360Dpad {
  40404. /** Up */
  40405. Up = 0,
  40406. /** Down */
  40407. Down = 1,
  40408. /** Left */
  40409. Left = 2,
  40410. /** Right */
  40411. Right = 3
  40412. }
  40413. /**
  40414. * Defines a XBox360 gamepad
  40415. */
  40416. export class Xbox360Pad extends Gamepad {
  40417. private _leftTrigger;
  40418. private _rightTrigger;
  40419. private _onlefttriggerchanged;
  40420. private _onrighttriggerchanged;
  40421. private _onbuttondown;
  40422. private _onbuttonup;
  40423. private _ondpaddown;
  40424. private _ondpadup;
  40425. /** Observable raised when a button is pressed */
  40426. onButtonDownObservable: Observable<Xbox360Button>;
  40427. /** Observable raised when a button is released */
  40428. onButtonUpObservable: Observable<Xbox360Button>;
  40429. /** Observable raised when a pad is pressed */
  40430. onPadDownObservable: Observable<Xbox360Dpad>;
  40431. /** Observable raised when a pad is released */
  40432. onPadUpObservable: Observable<Xbox360Dpad>;
  40433. private _buttonA;
  40434. private _buttonB;
  40435. private _buttonX;
  40436. private _buttonY;
  40437. private _buttonBack;
  40438. private _buttonStart;
  40439. private _buttonLB;
  40440. private _buttonRB;
  40441. private _buttonLeftStick;
  40442. private _buttonRightStick;
  40443. private _dPadUp;
  40444. private _dPadDown;
  40445. private _dPadLeft;
  40446. private _dPadRight;
  40447. private _isXboxOnePad;
  40448. /**
  40449. * Creates a new XBox360 gamepad object
  40450. * @param id defines the id of this gamepad
  40451. * @param index defines its index
  40452. * @param gamepad defines the internal HTML gamepad object
  40453. * @param xboxOne defines if it is a XBox One gamepad
  40454. */
  40455. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40456. /**
  40457. * Defines the callback to call when left trigger is pressed
  40458. * @param callback defines the callback to use
  40459. */
  40460. onlefttriggerchanged(callback: (value: number) => void): void;
  40461. /**
  40462. * Defines the callback to call when right trigger is pressed
  40463. * @param callback defines the callback to use
  40464. */
  40465. onrighttriggerchanged(callback: (value: number) => void): void;
  40466. /**
  40467. * Gets the left trigger value
  40468. */
  40469. /**
  40470. * Sets the left trigger value
  40471. */
  40472. leftTrigger: number;
  40473. /**
  40474. * Gets the right trigger value
  40475. */
  40476. /**
  40477. * Sets the right trigger value
  40478. */
  40479. rightTrigger: number;
  40480. /**
  40481. * Defines the callback to call when a button is pressed
  40482. * @param callback defines the callback to use
  40483. */
  40484. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40485. /**
  40486. * Defines the callback to call when a button is released
  40487. * @param callback defines the callback to use
  40488. */
  40489. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40490. /**
  40491. * Defines the callback to call when a pad is pressed
  40492. * @param callback defines the callback to use
  40493. */
  40494. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40495. /**
  40496. * Defines the callback to call when a pad is released
  40497. * @param callback defines the callback to use
  40498. */
  40499. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40500. private _setButtonValue;
  40501. private _setDPadValue;
  40502. /**
  40503. * Gets the value of the `A` button
  40504. */
  40505. /**
  40506. * Sets the value of the `A` button
  40507. */
  40508. buttonA: number;
  40509. /**
  40510. * Gets the value of the `B` button
  40511. */
  40512. /**
  40513. * Sets the value of the `B` button
  40514. */
  40515. buttonB: number;
  40516. /**
  40517. * Gets the value of the `X` button
  40518. */
  40519. /**
  40520. * Sets the value of the `X` button
  40521. */
  40522. buttonX: number;
  40523. /**
  40524. * Gets the value of the `Y` button
  40525. */
  40526. /**
  40527. * Sets the value of the `Y` button
  40528. */
  40529. buttonY: number;
  40530. /**
  40531. * Gets the value of the `Start` button
  40532. */
  40533. /**
  40534. * Sets the value of the `Start` button
  40535. */
  40536. buttonStart: number;
  40537. /**
  40538. * Gets the value of the `Back` button
  40539. */
  40540. /**
  40541. * Sets the value of the `Back` button
  40542. */
  40543. buttonBack: number;
  40544. /**
  40545. * Gets the value of the `Left` button
  40546. */
  40547. /**
  40548. * Sets the value of the `Left` button
  40549. */
  40550. buttonLB: number;
  40551. /**
  40552. * Gets the value of the `Right` button
  40553. */
  40554. /**
  40555. * Sets the value of the `Right` button
  40556. */
  40557. buttonRB: number;
  40558. /**
  40559. * Gets the value of the Left joystick
  40560. */
  40561. /**
  40562. * Sets the value of the Left joystick
  40563. */
  40564. buttonLeftStick: number;
  40565. /**
  40566. * Gets the value of the Right joystick
  40567. */
  40568. /**
  40569. * Sets the value of the Right joystick
  40570. */
  40571. buttonRightStick: number;
  40572. /**
  40573. * Gets the value of D-pad up
  40574. */
  40575. /**
  40576. * Sets the value of D-pad up
  40577. */
  40578. dPadUp: number;
  40579. /**
  40580. * Gets the value of D-pad down
  40581. */
  40582. /**
  40583. * Sets the value of D-pad down
  40584. */
  40585. dPadDown: number;
  40586. /**
  40587. * Gets the value of D-pad left
  40588. */
  40589. /**
  40590. * Sets the value of D-pad left
  40591. */
  40592. dPadLeft: number;
  40593. /**
  40594. * Gets the value of D-pad right
  40595. */
  40596. /**
  40597. * Sets the value of D-pad right
  40598. */
  40599. dPadRight: number;
  40600. /**
  40601. * Force the gamepad to synchronize with device values
  40602. */
  40603. update(): void;
  40604. /**
  40605. * Disposes the gamepad
  40606. */
  40607. dispose(): void;
  40608. }
  40609. }
  40610. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40611. import { Observable } from "babylonjs/Misc/observable";
  40612. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40613. /**
  40614. * Defines supported buttons for DualShock compatible gamepads
  40615. */
  40616. export enum DualShockButton {
  40617. /** Cross */
  40618. Cross = 0,
  40619. /** Circle */
  40620. Circle = 1,
  40621. /** Square */
  40622. Square = 2,
  40623. /** Triangle */
  40624. Triangle = 3,
  40625. /** Options */
  40626. Options = 4,
  40627. /** Share */
  40628. Share = 5,
  40629. /** L1 */
  40630. L1 = 6,
  40631. /** R1 */
  40632. R1 = 7,
  40633. /** Left stick */
  40634. LeftStick = 8,
  40635. /** Right stick */
  40636. RightStick = 9
  40637. }
  40638. /** Defines values for DualShock DPad */
  40639. export enum DualShockDpad {
  40640. /** Up */
  40641. Up = 0,
  40642. /** Down */
  40643. Down = 1,
  40644. /** Left */
  40645. Left = 2,
  40646. /** Right */
  40647. Right = 3
  40648. }
  40649. /**
  40650. * Defines a DualShock gamepad
  40651. */
  40652. export class DualShockPad extends Gamepad {
  40653. private _leftTrigger;
  40654. private _rightTrigger;
  40655. private _onlefttriggerchanged;
  40656. private _onrighttriggerchanged;
  40657. private _onbuttondown;
  40658. private _onbuttonup;
  40659. private _ondpaddown;
  40660. private _ondpadup;
  40661. /** Observable raised when a button is pressed */
  40662. onButtonDownObservable: Observable<DualShockButton>;
  40663. /** Observable raised when a button is released */
  40664. onButtonUpObservable: Observable<DualShockButton>;
  40665. /** Observable raised when a pad is pressed */
  40666. onPadDownObservable: Observable<DualShockDpad>;
  40667. /** Observable raised when a pad is released */
  40668. onPadUpObservable: Observable<DualShockDpad>;
  40669. private _buttonCross;
  40670. private _buttonCircle;
  40671. private _buttonSquare;
  40672. private _buttonTriangle;
  40673. private _buttonShare;
  40674. private _buttonOptions;
  40675. private _buttonL1;
  40676. private _buttonR1;
  40677. private _buttonLeftStick;
  40678. private _buttonRightStick;
  40679. private _dPadUp;
  40680. private _dPadDown;
  40681. private _dPadLeft;
  40682. private _dPadRight;
  40683. /**
  40684. * Creates a new DualShock gamepad object
  40685. * @param id defines the id of this gamepad
  40686. * @param index defines its index
  40687. * @param gamepad defines the internal HTML gamepad object
  40688. */
  40689. constructor(id: string, index: number, gamepad: any);
  40690. /**
  40691. * Defines the callback to call when left trigger is pressed
  40692. * @param callback defines the callback to use
  40693. */
  40694. onlefttriggerchanged(callback: (value: number) => void): void;
  40695. /**
  40696. * Defines the callback to call when right trigger is pressed
  40697. * @param callback defines the callback to use
  40698. */
  40699. onrighttriggerchanged(callback: (value: number) => void): void;
  40700. /**
  40701. * Gets the left trigger value
  40702. */
  40703. /**
  40704. * Sets the left trigger value
  40705. */
  40706. leftTrigger: number;
  40707. /**
  40708. * Gets the right trigger value
  40709. */
  40710. /**
  40711. * Sets the right trigger value
  40712. */
  40713. rightTrigger: number;
  40714. /**
  40715. * Defines the callback to call when a button is pressed
  40716. * @param callback defines the callback to use
  40717. */
  40718. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40719. /**
  40720. * Defines the callback to call when a button is released
  40721. * @param callback defines the callback to use
  40722. */
  40723. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40724. /**
  40725. * Defines the callback to call when a pad is pressed
  40726. * @param callback defines the callback to use
  40727. */
  40728. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40729. /**
  40730. * Defines the callback to call when a pad is released
  40731. * @param callback defines the callback to use
  40732. */
  40733. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40734. private _setButtonValue;
  40735. private _setDPadValue;
  40736. /**
  40737. * Gets the value of the `Cross` button
  40738. */
  40739. /**
  40740. * Sets the value of the `Cross` button
  40741. */
  40742. buttonCross: number;
  40743. /**
  40744. * Gets the value of the `Circle` button
  40745. */
  40746. /**
  40747. * Sets the value of the `Circle` button
  40748. */
  40749. buttonCircle: number;
  40750. /**
  40751. * Gets the value of the `Square` button
  40752. */
  40753. /**
  40754. * Sets the value of the `Square` button
  40755. */
  40756. buttonSquare: number;
  40757. /**
  40758. * Gets the value of the `Triangle` button
  40759. */
  40760. /**
  40761. * Sets the value of the `Triangle` button
  40762. */
  40763. buttonTriangle: number;
  40764. /**
  40765. * Gets the value of the `Options` button
  40766. */
  40767. /**
  40768. * Sets the value of the `Options` button
  40769. */
  40770. buttonOptions: number;
  40771. /**
  40772. * Gets the value of the `Share` button
  40773. */
  40774. /**
  40775. * Sets the value of the `Share` button
  40776. */
  40777. buttonShare: number;
  40778. /**
  40779. * Gets the value of the `L1` button
  40780. */
  40781. /**
  40782. * Sets the value of the `L1` button
  40783. */
  40784. buttonL1: number;
  40785. /**
  40786. * Gets the value of the `R1` button
  40787. */
  40788. /**
  40789. * Sets the value of the `R1` button
  40790. */
  40791. buttonR1: number;
  40792. /**
  40793. * Gets the value of the Left joystick
  40794. */
  40795. /**
  40796. * Sets the value of the Left joystick
  40797. */
  40798. buttonLeftStick: number;
  40799. /**
  40800. * Gets the value of the Right joystick
  40801. */
  40802. /**
  40803. * Sets the value of the Right joystick
  40804. */
  40805. buttonRightStick: number;
  40806. /**
  40807. * Gets the value of D-pad up
  40808. */
  40809. /**
  40810. * Sets the value of D-pad up
  40811. */
  40812. dPadUp: number;
  40813. /**
  40814. * Gets the value of D-pad down
  40815. */
  40816. /**
  40817. * Sets the value of D-pad down
  40818. */
  40819. dPadDown: number;
  40820. /**
  40821. * Gets the value of D-pad left
  40822. */
  40823. /**
  40824. * Sets the value of D-pad left
  40825. */
  40826. dPadLeft: number;
  40827. /**
  40828. * Gets the value of D-pad right
  40829. */
  40830. /**
  40831. * Sets the value of D-pad right
  40832. */
  40833. dPadRight: number;
  40834. /**
  40835. * Force the gamepad to synchronize with device values
  40836. */
  40837. update(): void;
  40838. /**
  40839. * Disposes the gamepad
  40840. */
  40841. dispose(): void;
  40842. }
  40843. }
  40844. declare module "babylonjs/Gamepads/gamepadManager" {
  40845. import { Observable } from "babylonjs/Misc/observable";
  40846. import { Nullable } from "babylonjs/types";
  40847. import { Scene } from "babylonjs/scene";
  40848. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40849. /**
  40850. * Manager for handling gamepads
  40851. */
  40852. export class GamepadManager {
  40853. private _scene?;
  40854. private _babylonGamepads;
  40855. private _oneGamepadConnected;
  40856. /** @hidden */
  40857. _isMonitoring: boolean;
  40858. private _gamepadEventSupported;
  40859. private _gamepadSupport;
  40860. /**
  40861. * observable to be triggered when the gamepad controller has been connected
  40862. */
  40863. onGamepadConnectedObservable: Observable<Gamepad>;
  40864. /**
  40865. * observable to be triggered when the gamepad controller has been disconnected
  40866. */
  40867. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40868. private _onGamepadConnectedEvent;
  40869. private _onGamepadDisconnectedEvent;
  40870. /**
  40871. * Initializes the gamepad manager
  40872. * @param _scene BabylonJS scene
  40873. */
  40874. constructor(_scene?: Scene | undefined);
  40875. /**
  40876. * The gamepads in the game pad manager
  40877. */
  40878. readonly gamepads: Gamepad[];
  40879. /**
  40880. * Get the gamepad controllers based on type
  40881. * @param type The type of gamepad controller
  40882. * @returns Nullable gamepad
  40883. */
  40884. getGamepadByType(type?: number): Nullable<Gamepad>;
  40885. /**
  40886. * Disposes the gamepad manager
  40887. */
  40888. dispose(): void;
  40889. private _addNewGamepad;
  40890. private _startMonitoringGamepads;
  40891. private _stopMonitoringGamepads;
  40892. /** @hidden */
  40893. _checkGamepadsStatus(): void;
  40894. private _updateGamepadObjects;
  40895. }
  40896. }
  40897. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40898. import { Nullable } from "babylonjs/types";
  40899. import { Scene } from "babylonjs/scene";
  40900. import { ISceneComponent } from "babylonjs/sceneComponent";
  40901. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40902. module "babylonjs/scene" {
  40903. interface Scene {
  40904. /** @hidden */
  40905. _gamepadManager: Nullable<GamepadManager>;
  40906. /**
  40907. * Gets the gamepad manager associated with the scene
  40908. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40909. */
  40910. gamepadManager: GamepadManager;
  40911. }
  40912. }
  40913. module "babylonjs/Cameras/freeCameraInputsManager" {
  40914. /**
  40915. * Interface representing a free camera inputs manager
  40916. */
  40917. interface FreeCameraInputsManager {
  40918. /**
  40919. * Adds gamepad input support to the FreeCameraInputsManager.
  40920. * @returns the FreeCameraInputsManager
  40921. */
  40922. addGamepad(): FreeCameraInputsManager;
  40923. }
  40924. }
  40925. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40926. /**
  40927. * Interface representing an arc rotate camera inputs manager
  40928. */
  40929. interface ArcRotateCameraInputsManager {
  40930. /**
  40931. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40932. * @returns the camera inputs manager
  40933. */
  40934. addGamepad(): ArcRotateCameraInputsManager;
  40935. }
  40936. }
  40937. /**
  40938. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40939. */
  40940. export class GamepadSystemSceneComponent implements ISceneComponent {
  40941. /**
  40942. * The component name helpfull to identify the component in the list of scene components.
  40943. */
  40944. readonly name: string;
  40945. /**
  40946. * The scene the component belongs to.
  40947. */
  40948. scene: Scene;
  40949. /**
  40950. * Creates a new instance of the component for the given scene
  40951. * @param scene Defines the scene to register the component in
  40952. */
  40953. constructor(scene: Scene);
  40954. /**
  40955. * Registers the component in a given scene
  40956. */
  40957. register(): void;
  40958. /**
  40959. * Rebuilds the elements related to this component in case of
  40960. * context lost for instance.
  40961. */
  40962. rebuild(): void;
  40963. /**
  40964. * Disposes the component and the associated ressources
  40965. */
  40966. dispose(): void;
  40967. private _beforeCameraUpdate;
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/universalCamera" {
  40971. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40972. import { Scene } from "babylonjs/scene";
  40973. import { Vector3 } from "babylonjs/Maths/math.vector";
  40974. import "babylonjs/Gamepads/gamepadSceneComponent";
  40975. /**
  40976. * 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,
  40977. * which still works and will still be found in many Playgrounds.
  40978. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40979. */
  40980. export class UniversalCamera extends TouchCamera {
  40981. /**
  40982. * Defines the gamepad rotation sensiblity.
  40983. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40984. */
  40985. gamepadAngularSensibility: number;
  40986. /**
  40987. * Defines the gamepad move sensiblity.
  40988. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40989. */
  40990. gamepadMoveSensibility: number;
  40991. /**
  40992. * 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,
  40993. * which still works and will still be found in many Playgrounds.
  40994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40995. * @param name Define the name of the camera in the scene
  40996. * @param position Define the start position of the camera in the scene
  40997. * @param scene Define the scene the camera belongs to
  40998. */
  40999. constructor(name: string, position: Vector3, scene: Scene);
  41000. /**
  41001. * Gets the current object class name.
  41002. * @return the class name
  41003. */
  41004. getClassName(): string;
  41005. }
  41006. }
  41007. declare module "babylonjs/Cameras/gamepadCamera" {
  41008. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41009. import { Scene } from "babylonjs/scene";
  41010. import { Vector3 } from "babylonjs/Maths/math.vector";
  41011. /**
  41012. * This represents a FPS type of camera. This is only here for back compat purpose.
  41013. * Please use the UniversalCamera instead as both are identical.
  41014. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41015. */
  41016. export class GamepadCamera extends UniversalCamera {
  41017. /**
  41018. * Instantiates a new Gamepad Camera
  41019. * This represents a FPS type of camera. This is only here for back compat purpose.
  41020. * Please use the UniversalCamera instead as both are identical.
  41021. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41022. * @param name Define the name of the camera in the scene
  41023. * @param position Define the start position of the camera in the scene
  41024. * @param scene Define the scene the camera belongs to
  41025. */
  41026. constructor(name: string, position: Vector3, scene: Scene);
  41027. /**
  41028. * Gets the current object class name.
  41029. * @return the class name
  41030. */
  41031. getClassName(): string;
  41032. }
  41033. }
  41034. declare module "babylonjs/Shaders/pass.fragment" {
  41035. /** @hidden */
  41036. export var passPixelShader: {
  41037. name: string;
  41038. shader: string;
  41039. };
  41040. }
  41041. declare module "babylonjs/Shaders/passCube.fragment" {
  41042. /** @hidden */
  41043. export var passCubePixelShader: {
  41044. name: string;
  41045. shader: string;
  41046. };
  41047. }
  41048. declare module "babylonjs/PostProcesses/passPostProcess" {
  41049. import { Nullable } from "babylonjs/types";
  41050. import { Camera } from "babylonjs/Cameras/camera";
  41051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41052. import { Engine } from "babylonjs/Engines/engine";
  41053. import "babylonjs/Shaders/pass.fragment";
  41054. import "babylonjs/Shaders/passCube.fragment";
  41055. /**
  41056. * PassPostProcess which produces an output the same as it's input
  41057. */
  41058. export class PassPostProcess extends PostProcess {
  41059. /**
  41060. * Creates the PassPostProcess
  41061. * @param name The name of the effect.
  41062. * @param options The required width/height ratio to downsize to before computing the render pass.
  41063. * @param camera The camera to apply the render pass to.
  41064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41065. * @param engine The engine which the post process will be applied. (default: current engine)
  41066. * @param reusable If the post process can be reused on the same frame. (default: false)
  41067. * @param textureType The type of texture to be used when performing the post processing.
  41068. * @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)
  41069. */
  41070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41071. }
  41072. /**
  41073. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41074. */
  41075. export class PassCubePostProcess extends PostProcess {
  41076. private _face;
  41077. /**
  41078. * Gets or sets the cube face to display.
  41079. * * 0 is +X
  41080. * * 1 is -X
  41081. * * 2 is +Y
  41082. * * 3 is -Y
  41083. * * 4 is +Z
  41084. * * 5 is -Z
  41085. */
  41086. face: number;
  41087. /**
  41088. * Creates the PassCubePostProcess
  41089. * @param name The name of the effect.
  41090. * @param options The required width/height ratio to downsize to before computing the render pass.
  41091. * @param camera The camera to apply the render pass to.
  41092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41093. * @param engine The engine which the post process will be applied. (default: current engine)
  41094. * @param reusable If the post process can be reused on the same frame. (default: false)
  41095. * @param textureType The type of texture to be used when performing the post processing.
  41096. * @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)
  41097. */
  41098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41099. }
  41100. }
  41101. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41102. /** @hidden */
  41103. export var anaglyphPixelShader: {
  41104. name: string;
  41105. shader: string;
  41106. };
  41107. }
  41108. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41109. import { Engine } from "babylonjs/Engines/engine";
  41110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41111. import { Camera } from "babylonjs/Cameras/camera";
  41112. import "babylonjs/Shaders/anaglyph.fragment";
  41113. /**
  41114. * Postprocess used to generate anaglyphic rendering
  41115. */
  41116. export class AnaglyphPostProcess extends PostProcess {
  41117. private _passedProcess;
  41118. /**
  41119. * Creates a new AnaglyphPostProcess
  41120. * @param name defines postprocess name
  41121. * @param options defines creation options or target ratio scale
  41122. * @param rigCameras defines cameras using this postprocess
  41123. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41124. * @param engine defines hosting engine
  41125. * @param reusable defines if the postprocess will be reused multiple times per frame
  41126. */
  41127. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41128. }
  41129. }
  41130. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41131. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41132. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41133. import { Scene } from "babylonjs/scene";
  41134. import { Vector3 } from "babylonjs/Maths/math.vector";
  41135. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41136. /**
  41137. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41139. */
  41140. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41141. /**
  41142. * Creates a new AnaglyphArcRotateCamera
  41143. * @param name defines camera name
  41144. * @param alpha defines alpha angle (in radians)
  41145. * @param beta defines beta angle (in radians)
  41146. * @param radius defines radius
  41147. * @param target defines camera target
  41148. * @param interaxialDistance defines distance between each color axis
  41149. * @param scene defines the hosting scene
  41150. */
  41151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41152. /**
  41153. * Gets camera class name
  41154. * @returns AnaglyphArcRotateCamera
  41155. */
  41156. getClassName(): string;
  41157. }
  41158. }
  41159. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41160. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41161. import { Scene } from "babylonjs/scene";
  41162. import { Vector3 } from "babylonjs/Maths/math.vector";
  41163. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41164. /**
  41165. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41166. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41167. */
  41168. export class AnaglyphFreeCamera extends FreeCamera {
  41169. /**
  41170. * Creates a new AnaglyphFreeCamera
  41171. * @param name defines camera name
  41172. * @param position defines initial position
  41173. * @param interaxialDistance defines distance between each color axis
  41174. * @param scene defines the hosting scene
  41175. */
  41176. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41177. /**
  41178. * Gets camera class name
  41179. * @returns AnaglyphFreeCamera
  41180. */
  41181. getClassName(): string;
  41182. }
  41183. }
  41184. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41185. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41186. import { Scene } from "babylonjs/scene";
  41187. import { Vector3 } from "babylonjs/Maths/math.vector";
  41188. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41189. /**
  41190. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41191. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41192. */
  41193. export class AnaglyphGamepadCamera extends GamepadCamera {
  41194. /**
  41195. * Creates a new AnaglyphGamepadCamera
  41196. * @param name defines camera name
  41197. * @param position defines initial position
  41198. * @param interaxialDistance defines distance between each color axis
  41199. * @param scene defines the hosting scene
  41200. */
  41201. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41202. /**
  41203. * Gets camera class name
  41204. * @returns AnaglyphGamepadCamera
  41205. */
  41206. getClassName(): string;
  41207. }
  41208. }
  41209. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41210. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41211. import { Scene } from "babylonjs/scene";
  41212. import { Vector3 } from "babylonjs/Maths/math.vector";
  41213. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41214. /**
  41215. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41216. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41217. */
  41218. export class AnaglyphUniversalCamera extends UniversalCamera {
  41219. /**
  41220. * Creates a new AnaglyphUniversalCamera
  41221. * @param name defines camera name
  41222. * @param position defines initial position
  41223. * @param interaxialDistance defines distance between each color axis
  41224. * @param scene defines the hosting scene
  41225. */
  41226. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41227. /**
  41228. * Gets camera class name
  41229. * @returns AnaglyphUniversalCamera
  41230. */
  41231. getClassName(): string;
  41232. }
  41233. }
  41234. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41235. /** @hidden */
  41236. export var stereoscopicInterlacePixelShader: {
  41237. name: string;
  41238. shader: string;
  41239. };
  41240. }
  41241. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41242. import { Camera } from "babylonjs/Cameras/camera";
  41243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41244. import { Engine } from "babylonjs/Engines/engine";
  41245. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41246. /**
  41247. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41248. */
  41249. export class StereoscopicInterlacePostProcess extends PostProcess {
  41250. private _stepSize;
  41251. private _passedProcess;
  41252. /**
  41253. * Initializes a StereoscopicInterlacePostProcess
  41254. * @param name The name of the effect.
  41255. * @param rigCameras The rig cameras to be appled to the post process
  41256. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41258. * @param engine The engine which the post process will be applied. (default: current engine)
  41259. * @param reusable If the post process can be reused on the same frame. (default: false)
  41260. */
  41261. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41262. }
  41263. }
  41264. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41265. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41266. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41267. import { Scene } from "babylonjs/scene";
  41268. import { Vector3 } from "babylonjs/Maths/math.vector";
  41269. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41270. /**
  41271. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41272. * @see http://doc.babylonjs.com/features/cameras
  41273. */
  41274. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41275. /**
  41276. * Creates a new StereoscopicArcRotateCamera
  41277. * @param name defines camera name
  41278. * @param alpha defines alpha angle (in radians)
  41279. * @param beta defines beta angle (in radians)
  41280. * @param radius defines radius
  41281. * @param target defines camera target
  41282. * @param interaxialDistance defines distance between each color axis
  41283. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41284. * @param scene defines the hosting scene
  41285. */
  41286. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41287. /**
  41288. * Gets camera class name
  41289. * @returns StereoscopicArcRotateCamera
  41290. */
  41291. getClassName(): string;
  41292. }
  41293. }
  41294. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41295. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41296. import { Scene } from "babylonjs/scene";
  41297. import { Vector3 } from "babylonjs/Maths/math.vector";
  41298. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41299. /**
  41300. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41301. * @see http://doc.babylonjs.com/features/cameras
  41302. */
  41303. export class StereoscopicFreeCamera extends FreeCamera {
  41304. /**
  41305. * Creates a new StereoscopicFreeCamera
  41306. * @param name defines camera name
  41307. * @param position defines initial position
  41308. * @param interaxialDistance defines distance between each color axis
  41309. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41310. * @param scene defines the hosting scene
  41311. */
  41312. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41313. /**
  41314. * Gets camera class name
  41315. * @returns StereoscopicFreeCamera
  41316. */
  41317. getClassName(): string;
  41318. }
  41319. }
  41320. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41321. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41322. import { Scene } from "babylonjs/scene";
  41323. import { Vector3 } from "babylonjs/Maths/math.vector";
  41324. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41325. /**
  41326. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41327. * @see http://doc.babylonjs.com/features/cameras
  41328. */
  41329. export class StereoscopicGamepadCamera extends GamepadCamera {
  41330. /**
  41331. * Creates a new StereoscopicGamepadCamera
  41332. * @param name defines camera name
  41333. * @param position defines initial position
  41334. * @param interaxialDistance defines distance between each color axis
  41335. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41336. * @param scene defines the hosting scene
  41337. */
  41338. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41339. /**
  41340. * Gets camera class name
  41341. * @returns StereoscopicGamepadCamera
  41342. */
  41343. getClassName(): string;
  41344. }
  41345. }
  41346. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41347. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41348. import { Scene } from "babylonjs/scene";
  41349. import { Vector3 } from "babylonjs/Maths/math.vector";
  41350. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41351. /**
  41352. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41353. * @see http://doc.babylonjs.com/features/cameras
  41354. */
  41355. export class StereoscopicUniversalCamera extends UniversalCamera {
  41356. /**
  41357. * Creates a new StereoscopicUniversalCamera
  41358. * @param name defines camera name
  41359. * @param position defines initial position
  41360. * @param interaxialDistance defines distance between each color axis
  41361. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41362. * @param scene defines the hosting scene
  41363. */
  41364. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41365. /**
  41366. * Gets camera class name
  41367. * @returns StereoscopicUniversalCamera
  41368. */
  41369. getClassName(): string;
  41370. }
  41371. }
  41372. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41373. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41374. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41375. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41376. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41377. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41378. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41379. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41380. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41381. }
  41382. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41383. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41384. import { Scene } from "babylonjs/scene";
  41385. import { Vector3 } from "babylonjs/Maths/math.vector";
  41386. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41387. /**
  41388. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41389. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41390. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41391. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41392. */
  41393. export class VirtualJoysticksCamera extends FreeCamera {
  41394. /**
  41395. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41396. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41397. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41398. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41399. * @param name Define the name of the camera in the scene
  41400. * @param position Define the start position of the camera in the scene
  41401. * @param scene Define the scene the camera belongs to
  41402. */
  41403. constructor(name: string, position: Vector3, scene: Scene);
  41404. /**
  41405. * Gets the current object class name.
  41406. * @return the class name
  41407. */
  41408. getClassName(): string;
  41409. }
  41410. }
  41411. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41412. import { Matrix } from "babylonjs/Maths/math.vector";
  41413. /**
  41414. * This represents all the required metrics to create a VR camera.
  41415. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41416. */
  41417. export class VRCameraMetrics {
  41418. /**
  41419. * Define the horizontal resolution off the screen.
  41420. */
  41421. hResolution: number;
  41422. /**
  41423. * Define the vertical resolution off the screen.
  41424. */
  41425. vResolution: number;
  41426. /**
  41427. * Define the horizontal screen size.
  41428. */
  41429. hScreenSize: number;
  41430. /**
  41431. * Define the vertical screen size.
  41432. */
  41433. vScreenSize: number;
  41434. /**
  41435. * Define the vertical screen center position.
  41436. */
  41437. vScreenCenter: number;
  41438. /**
  41439. * Define the distance of the eyes to the screen.
  41440. */
  41441. eyeToScreenDistance: number;
  41442. /**
  41443. * Define the distance between both lenses
  41444. */
  41445. lensSeparationDistance: number;
  41446. /**
  41447. * Define the distance between both viewer's eyes.
  41448. */
  41449. interpupillaryDistance: number;
  41450. /**
  41451. * Define the distortion factor of the VR postprocess.
  41452. * Please, touch with care.
  41453. */
  41454. distortionK: number[];
  41455. /**
  41456. * Define the chromatic aberration correction factors for the VR post process.
  41457. */
  41458. chromaAbCorrection: number[];
  41459. /**
  41460. * Define the scale factor of the post process.
  41461. * The smaller the better but the slower.
  41462. */
  41463. postProcessScaleFactor: number;
  41464. /**
  41465. * Define an offset for the lens center.
  41466. */
  41467. lensCenterOffset: number;
  41468. /**
  41469. * Define if the current vr camera should compensate the distortion of the lense or not.
  41470. */
  41471. compensateDistortion: boolean;
  41472. /**
  41473. * Defines if multiview should be enabled when rendering (Default: false)
  41474. */
  41475. multiviewEnabled: boolean;
  41476. /**
  41477. * Gets the rendering aspect ratio based on the provided resolutions.
  41478. */
  41479. readonly aspectRatio: number;
  41480. /**
  41481. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41482. */
  41483. readonly aspectRatioFov: number;
  41484. /**
  41485. * @hidden
  41486. */
  41487. readonly leftHMatrix: Matrix;
  41488. /**
  41489. * @hidden
  41490. */
  41491. readonly rightHMatrix: Matrix;
  41492. /**
  41493. * @hidden
  41494. */
  41495. readonly leftPreViewMatrix: Matrix;
  41496. /**
  41497. * @hidden
  41498. */
  41499. readonly rightPreViewMatrix: Matrix;
  41500. /**
  41501. * Get the default VRMetrics based on the most generic setup.
  41502. * @returns the default vr metrics
  41503. */
  41504. static GetDefault(): VRCameraMetrics;
  41505. }
  41506. }
  41507. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41508. /** @hidden */
  41509. export var vrDistortionCorrectionPixelShader: {
  41510. name: string;
  41511. shader: string;
  41512. };
  41513. }
  41514. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41515. import { Camera } from "babylonjs/Cameras/camera";
  41516. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41517. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41518. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41519. /**
  41520. * VRDistortionCorrectionPostProcess used for mobile VR
  41521. */
  41522. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41523. private _isRightEye;
  41524. private _distortionFactors;
  41525. private _postProcessScaleFactor;
  41526. private _lensCenterOffset;
  41527. private _scaleIn;
  41528. private _scaleFactor;
  41529. private _lensCenter;
  41530. /**
  41531. * Initializes the VRDistortionCorrectionPostProcess
  41532. * @param name The name of the effect.
  41533. * @param camera The camera to apply the render pass to.
  41534. * @param isRightEye If this is for the right eye distortion
  41535. * @param vrMetrics All the required metrics for the VR camera
  41536. */
  41537. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41538. }
  41539. }
  41540. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41541. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41542. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41543. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41544. import { Scene } from "babylonjs/scene";
  41545. import { Vector3 } from "babylonjs/Maths/math.vector";
  41546. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41547. import "babylonjs/Cameras/RigModes/vrRigMode";
  41548. /**
  41549. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41550. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41551. */
  41552. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41553. /**
  41554. * Creates a new VRDeviceOrientationArcRotateCamera
  41555. * @param name defines camera name
  41556. * @param alpha defines the camera rotation along the logitudinal axis
  41557. * @param beta defines the camera rotation along the latitudinal axis
  41558. * @param radius defines the camera distance from its target
  41559. * @param target defines the camera target
  41560. * @param scene defines the scene the camera belongs to
  41561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41563. */
  41564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41565. /**
  41566. * Gets camera class name
  41567. * @returns VRDeviceOrientationArcRotateCamera
  41568. */
  41569. getClassName(): string;
  41570. }
  41571. }
  41572. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41573. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41574. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41575. import { Scene } from "babylonjs/scene";
  41576. import { Vector3 } from "babylonjs/Maths/math.vector";
  41577. import "babylonjs/Cameras/RigModes/vrRigMode";
  41578. /**
  41579. * Camera used to simulate VR rendering (based on FreeCamera)
  41580. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41581. */
  41582. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41583. /**
  41584. * Creates a new VRDeviceOrientationFreeCamera
  41585. * @param name defines camera name
  41586. * @param position defines the start position of the camera
  41587. * @param scene defines the scene the camera belongs to
  41588. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41589. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41590. */
  41591. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41592. /**
  41593. * Gets camera class name
  41594. * @returns VRDeviceOrientationFreeCamera
  41595. */
  41596. getClassName(): string;
  41597. }
  41598. }
  41599. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41600. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41601. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41602. import { Scene } from "babylonjs/scene";
  41603. import { Vector3 } from "babylonjs/Maths/math.vector";
  41604. import "babylonjs/Gamepads/gamepadSceneComponent";
  41605. /**
  41606. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41607. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41608. */
  41609. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41610. /**
  41611. * Creates a new VRDeviceOrientationGamepadCamera
  41612. * @param name defines camera name
  41613. * @param position defines the start position of the camera
  41614. * @param scene defines the scene the camera belongs to
  41615. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41616. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41617. */
  41618. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41619. /**
  41620. * Gets camera class name
  41621. * @returns VRDeviceOrientationGamepadCamera
  41622. */
  41623. getClassName(): string;
  41624. }
  41625. }
  41626. declare module "babylonjs/Materials/pushMaterial" {
  41627. import { Nullable } from "babylonjs/types";
  41628. import { Scene } from "babylonjs/scene";
  41629. import { Matrix } from "babylonjs/Maths/math.vector";
  41630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41631. import { Mesh } from "babylonjs/Meshes/mesh";
  41632. import { Material } from "babylonjs/Materials/material";
  41633. import { Effect } from "babylonjs/Materials/effect";
  41634. /**
  41635. * Base class of materials working in push mode in babylon JS
  41636. * @hidden
  41637. */
  41638. export class PushMaterial extends Material {
  41639. protected _activeEffect: Effect;
  41640. protected _normalMatrix: Matrix;
  41641. /**
  41642. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41643. * This means that the material can keep using a previous shader while a new one is being compiled.
  41644. * This is mostly used when shader parallel compilation is supported (true by default)
  41645. */
  41646. allowShaderHotSwapping: boolean;
  41647. constructor(name: string, scene: Scene);
  41648. getEffect(): Effect;
  41649. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41650. /**
  41651. * Binds the given world matrix to the active effect
  41652. *
  41653. * @param world the matrix to bind
  41654. */
  41655. bindOnlyWorldMatrix(world: Matrix): void;
  41656. /**
  41657. * Binds the given normal matrix to the active effect
  41658. *
  41659. * @param normalMatrix the matrix to bind
  41660. */
  41661. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41662. bind(world: Matrix, mesh?: Mesh): void;
  41663. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41664. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41665. }
  41666. }
  41667. declare module "babylonjs/Materials/materialFlags" {
  41668. /**
  41669. * This groups all the flags used to control the materials channel.
  41670. */
  41671. export class MaterialFlags {
  41672. private static _DiffuseTextureEnabled;
  41673. /**
  41674. * Are diffuse textures enabled in the application.
  41675. */
  41676. static DiffuseTextureEnabled: boolean;
  41677. private static _AmbientTextureEnabled;
  41678. /**
  41679. * Are ambient textures enabled in the application.
  41680. */
  41681. static AmbientTextureEnabled: boolean;
  41682. private static _OpacityTextureEnabled;
  41683. /**
  41684. * Are opacity textures enabled in the application.
  41685. */
  41686. static OpacityTextureEnabled: boolean;
  41687. private static _ReflectionTextureEnabled;
  41688. /**
  41689. * Are reflection textures enabled in the application.
  41690. */
  41691. static ReflectionTextureEnabled: boolean;
  41692. private static _EmissiveTextureEnabled;
  41693. /**
  41694. * Are emissive textures enabled in the application.
  41695. */
  41696. static EmissiveTextureEnabled: boolean;
  41697. private static _SpecularTextureEnabled;
  41698. /**
  41699. * Are specular textures enabled in the application.
  41700. */
  41701. static SpecularTextureEnabled: boolean;
  41702. private static _BumpTextureEnabled;
  41703. /**
  41704. * Are bump textures enabled in the application.
  41705. */
  41706. static BumpTextureEnabled: boolean;
  41707. private static _LightmapTextureEnabled;
  41708. /**
  41709. * Are lightmap textures enabled in the application.
  41710. */
  41711. static LightmapTextureEnabled: boolean;
  41712. private static _RefractionTextureEnabled;
  41713. /**
  41714. * Are refraction textures enabled in the application.
  41715. */
  41716. static RefractionTextureEnabled: boolean;
  41717. private static _ColorGradingTextureEnabled;
  41718. /**
  41719. * Are color grading textures enabled in the application.
  41720. */
  41721. static ColorGradingTextureEnabled: boolean;
  41722. private static _FresnelEnabled;
  41723. /**
  41724. * Are fresnels enabled in the application.
  41725. */
  41726. static FresnelEnabled: boolean;
  41727. private static _ClearCoatTextureEnabled;
  41728. /**
  41729. * Are clear coat textures enabled in the application.
  41730. */
  41731. static ClearCoatTextureEnabled: boolean;
  41732. private static _ClearCoatBumpTextureEnabled;
  41733. /**
  41734. * Are clear coat bump textures enabled in the application.
  41735. */
  41736. static ClearCoatBumpTextureEnabled: boolean;
  41737. private static _ClearCoatTintTextureEnabled;
  41738. /**
  41739. * Are clear coat tint textures enabled in the application.
  41740. */
  41741. static ClearCoatTintTextureEnabled: boolean;
  41742. private static _SheenTextureEnabled;
  41743. /**
  41744. * Are sheen textures enabled in the application.
  41745. */
  41746. static SheenTextureEnabled: boolean;
  41747. private static _AnisotropicTextureEnabled;
  41748. /**
  41749. * Are anisotropic textures enabled in the application.
  41750. */
  41751. static AnisotropicTextureEnabled: boolean;
  41752. private static _ThicknessTextureEnabled;
  41753. /**
  41754. * Are thickness textures enabled in the application.
  41755. */
  41756. static ThicknessTextureEnabled: boolean;
  41757. }
  41758. }
  41759. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41760. /** @hidden */
  41761. export var defaultFragmentDeclaration: {
  41762. name: string;
  41763. shader: string;
  41764. };
  41765. }
  41766. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41767. /** @hidden */
  41768. export var defaultUboDeclaration: {
  41769. name: string;
  41770. shader: string;
  41771. };
  41772. }
  41773. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41774. /** @hidden */
  41775. export var lightFragmentDeclaration: {
  41776. name: string;
  41777. shader: string;
  41778. };
  41779. }
  41780. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41781. /** @hidden */
  41782. export var lightUboDeclaration: {
  41783. name: string;
  41784. shader: string;
  41785. };
  41786. }
  41787. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41788. /** @hidden */
  41789. export var lightsFragmentFunctions: {
  41790. name: string;
  41791. shader: string;
  41792. };
  41793. }
  41794. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41795. /** @hidden */
  41796. export var shadowsFragmentFunctions: {
  41797. name: string;
  41798. shader: string;
  41799. };
  41800. }
  41801. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41802. /** @hidden */
  41803. export var fresnelFunction: {
  41804. name: string;
  41805. shader: string;
  41806. };
  41807. }
  41808. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41809. /** @hidden */
  41810. export var reflectionFunction: {
  41811. name: string;
  41812. shader: string;
  41813. };
  41814. }
  41815. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41816. /** @hidden */
  41817. export var bumpFragmentFunctions: {
  41818. name: string;
  41819. shader: string;
  41820. };
  41821. }
  41822. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41823. /** @hidden */
  41824. export var logDepthDeclaration: {
  41825. name: string;
  41826. shader: string;
  41827. };
  41828. }
  41829. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41830. /** @hidden */
  41831. export var bumpFragment: {
  41832. name: string;
  41833. shader: string;
  41834. };
  41835. }
  41836. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41837. /** @hidden */
  41838. export var depthPrePass: {
  41839. name: string;
  41840. shader: string;
  41841. };
  41842. }
  41843. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41844. /** @hidden */
  41845. export var lightFragment: {
  41846. name: string;
  41847. shader: string;
  41848. };
  41849. }
  41850. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41851. /** @hidden */
  41852. export var logDepthFragment: {
  41853. name: string;
  41854. shader: string;
  41855. };
  41856. }
  41857. declare module "babylonjs/Shaders/default.fragment" {
  41858. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41859. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41860. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41861. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41862. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41863. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41864. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41865. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41866. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41867. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41868. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41869. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41870. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41871. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41872. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41874. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41875. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41876. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41877. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41878. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41879. /** @hidden */
  41880. export var defaultPixelShader: {
  41881. name: string;
  41882. shader: string;
  41883. };
  41884. }
  41885. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41886. /** @hidden */
  41887. export var defaultVertexDeclaration: {
  41888. name: string;
  41889. shader: string;
  41890. };
  41891. }
  41892. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41893. /** @hidden */
  41894. export var bumpVertexDeclaration: {
  41895. name: string;
  41896. shader: string;
  41897. };
  41898. }
  41899. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41900. /** @hidden */
  41901. export var bumpVertex: {
  41902. name: string;
  41903. shader: string;
  41904. };
  41905. }
  41906. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41907. /** @hidden */
  41908. export var fogVertex: {
  41909. name: string;
  41910. shader: string;
  41911. };
  41912. }
  41913. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41914. /** @hidden */
  41915. export var shadowsVertex: {
  41916. name: string;
  41917. shader: string;
  41918. };
  41919. }
  41920. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41921. /** @hidden */
  41922. export var pointCloudVertex: {
  41923. name: string;
  41924. shader: string;
  41925. };
  41926. }
  41927. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41928. /** @hidden */
  41929. export var logDepthVertex: {
  41930. name: string;
  41931. shader: string;
  41932. };
  41933. }
  41934. declare module "babylonjs/Shaders/default.vertex" {
  41935. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41936. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41937. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41938. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41939. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41940. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41942. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41943. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41944. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41947. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41948. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41949. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41950. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41951. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41952. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41953. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41954. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41955. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41956. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41957. /** @hidden */
  41958. export var defaultVertexShader: {
  41959. name: string;
  41960. shader: string;
  41961. };
  41962. }
  41963. declare module "babylonjs/Materials/standardMaterial" {
  41964. import { SmartArray } from "babylonjs/Misc/smartArray";
  41965. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41966. import { Nullable } from "babylonjs/types";
  41967. import { Scene } from "babylonjs/scene";
  41968. import { Matrix } from "babylonjs/Maths/math.vector";
  41969. import { Color3 } from "babylonjs/Maths/math.color";
  41970. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41972. import { Mesh } from "babylonjs/Meshes/mesh";
  41973. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41974. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41975. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41976. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41977. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41979. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41980. import "babylonjs/Shaders/default.fragment";
  41981. import "babylonjs/Shaders/default.vertex";
  41982. /** @hidden */
  41983. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41984. MAINUV1: boolean;
  41985. MAINUV2: boolean;
  41986. DIFFUSE: boolean;
  41987. DIFFUSEDIRECTUV: number;
  41988. AMBIENT: boolean;
  41989. AMBIENTDIRECTUV: number;
  41990. OPACITY: boolean;
  41991. OPACITYDIRECTUV: number;
  41992. OPACITYRGB: boolean;
  41993. REFLECTION: boolean;
  41994. EMISSIVE: boolean;
  41995. EMISSIVEDIRECTUV: number;
  41996. SPECULAR: boolean;
  41997. SPECULARDIRECTUV: number;
  41998. BUMP: boolean;
  41999. BUMPDIRECTUV: number;
  42000. PARALLAX: boolean;
  42001. PARALLAXOCCLUSION: boolean;
  42002. SPECULAROVERALPHA: boolean;
  42003. CLIPPLANE: boolean;
  42004. CLIPPLANE2: boolean;
  42005. CLIPPLANE3: boolean;
  42006. CLIPPLANE4: boolean;
  42007. ALPHATEST: boolean;
  42008. DEPTHPREPASS: boolean;
  42009. ALPHAFROMDIFFUSE: boolean;
  42010. POINTSIZE: boolean;
  42011. FOG: boolean;
  42012. SPECULARTERM: boolean;
  42013. DIFFUSEFRESNEL: boolean;
  42014. OPACITYFRESNEL: boolean;
  42015. REFLECTIONFRESNEL: boolean;
  42016. REFRACTIONFRESNEL: boolean;
  42017. EMISSIVEFRESNEL: boolean;
  42018. FRESNEL: boolean;
  42019. NORMAL: boolean;
  42020. UV1: boolean;
  42021. UV2: boolean;
  42022. VERTEXCOLOR: boolean;
  42023. VERTEXALPHA: boolean;
  42024. NUM_BONE_INFLUENCERS: number;
  42025. BonesPerMesh: number;
  42026. BONETEXTURE: boolean;
  42027. INSTANCES: boolean;
  42028. GLOSSINESS: boolean;
  42029. ROUGHNESS: boolean;
  42030. EMISSIVEASILLUMINATION: boolean;
  42031. LINKEMISSIVEWITHDIFFUSE: boolean;
  42032. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42033. LIGHTMAP: boolean;
  42034. LIGHTMAPDIRECTUV: number;
  42035. OBJECTSPACE_NORMALMAP: boolean;
  42036. USELIGHTMAPASSHADOWMAP: boolean;
  42037. REFLECTIONMAP_3D: boolean;
  42038. REFLECTIONMAP_SPHERICAL: boolean;
  42039. REFLECTIONMAP_PLANAR: boolean;
  42040. REFLECTIONMAP_CUBIC: boolean;
  42041. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42042. REFLECTIONMAP_PROJECTION: boolean;
  42043. REFLECTIONMAP_SKYBOX: boolean;
  42044. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42045. REFLECTIONMAP_EXPLICIT: boolean;
  42046. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42047. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42048. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42049. INVERTCUBICMAP: boolean;
  42050. LOGARITHMICDEPTH: boolean;
  42051. REFRACTION: boolean;
  42052. REFRACTIONMAP_3D: boolean;
  42053. REFLECTIONOVERALPHA: boolean;
  42054. TWOSIDEDLIGHTING: boolean;
  42055. SHADOWFLOAT: boolean;
  42056. MORPHTARGETS: boolean;
  42057. MORPHTARGETS_NORMAL: boolean;
  42058. MORPHTARGETS_TANGENT: boolean;
  42059. MORPHTARGETS_UV: boolean;
  42060. NUM_MORPH_INFLUENCERS: number;
  42061. NONUNIFORMSCALING: boolean;
  42062. PREMULTIPLYALPHA: boolean;
  42063. IMAGEPROCESSING: boolean;
  42064. VIGNETTE: boolean;
  42065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42066. VIGNETTEBLENDMODEOPAQUE: boolean;
  42067. TONEMAPPING: boolean;
  42068. TONEMAPPING_ACES: boolean;
  42069. CONTRAST: boolean;
  42070. COLORCURVES: boolean;
  42071. COLORGRADING: boolean;
  42072. COLORGRADING3D: boolean;
  42073. SAMPLER3DGREENDEPTH: boolean;
  42074. SAMPLER3DBGRMAP: boolean;
  42075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42076. MULTIVIEW: boolean;
  42077. /**
  42078. * If the reflection texture on this material is in linear color space
  42079. * @hidden
  42080. */
  42081. IS_REFLECTION_LINEAR: boolean;
  42082. /**
  42083. * If the refraction texture on this material is in linear color space
  42084. * @hidden
  42085. */
  42086. IS_REFRACTION_LINEAR: boolean;
  42087. EXPOSURE: boolean;
  42088. constructor();
  42089. setReflectionMode(modeToEnable: string): void;
  42090. }
  42091. /**
  42092. * This is the default material used in Babylon. It is the best trade off between quality
  42093. * and performances.
  42094. * @see http://doc.babylonjs.com/babylon101/materials
  42095. */
  42096. export class StandardMaterial extends PushMaterial {
  42097. private _diffuseTexture;
  42098. /**
  42099. * The basic texture of the material as viewed under a light.
  42100. */
  42101. diffuseTexture: Nullable<BaseTexture>;
  42102. private _ambientTexture;
  42103. /**
  42104. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42105. */
  42106. ambientTexture: Nullable<BaseTexture>;
  42107. private _opacityTexture;
  42108. /**
  42109. * Define the transparency of the material from a texture.
  42110. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42111. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42112. */
  42113. opacityTexture: Nullable<BaseTexture>;
  42114. private _reflectionTexture;
  42115. /**
  42116. * Define the texture used to display the reflection.
  42117. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42118. */
  42119. reflectionTexture: Nullable<BaseTexture>;
  42120. private _emissiveTexture;
  42121. /**
  42122. * Define texture of the material as if self lit.
  42123. * This will be mixed in the final result even in the absence of light.
  42124. */
  42125. emissiveTexture: Nullable<BaseTexture>;
  42126. private _specularTexture;
  42127. /**
  42128. * Define how the color and intensity of the highlight given by the light in the material.
  42129. */
  42130. specularTexture: Nullable<BaseTexture>;
  42131. private _bumpTexture;
  42132. /**
  42133. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42134. * 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.
  42135. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42136. */
  42137. bumpTexture: Nullable<BaseTexture>;
  42138. private _lightmapTexture;
  42139. /**
  42140. * Complex lighting can be computationally expensive to compute at runtime.
  42141. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42142. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42143. */
  42144. lightmapTexture: Nullable<BaseTexture>;
  42145. private _refractionTexture;
  42146. /**
  42147. * Define the texture used to display the refraction.
  42148. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42149. */
  42150. refractionTexture: Nullable<BaseTexture>;
  42151. /**
  42152. * The color of the material lit by the environmental background lighting.
  42153. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42154. */
  42155. ambientColor: Color3;
  42156. /**
  42157. * The basic color of the material as viewed under a light.
  42158. */
  42159. diffuseColor: Color3;
  42160. /**
  42161. * Define how the color and intensity of the highlight given by the light in the material.
  42162. */
  42163. specularColor: Color3;
  42164. /**
  42165. * Define the color of the material as if self lit.
  42166. * This will be mixed in the final result even in the absence of light.
  42167. */
  42168. emissiveColor: Color3;
  42169. /**
  42170. * Defines how sharp are the highlights in the material.
  42171. * The bigger the value the sharper giving a more glossy feeling to the result.
  42172. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42173. */
  42174. specularPower: number;
  42175. private _useAlphaFromDiffuseTexture;
  42176. /**
  42177. * Does the transparency come from the diffuse texture alpha channel.
  42178. */
  42179. useAlphaFromDiffuseTexture: boolean;
  42180. private _useEmissiveAsIllumination;
  42181. /**
  42182. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42183. */
  42184. useEmissiveAsIllumination: boolean;
  42185. private _linkEmissiveWithDiffuse;
  42186. /**
  42187. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42188. * the emissive level when the final color is close to one.
  42189. */
  42190. linkEmissiveWithDiffuse: boolean;
  42191. private _useSpecularOverAlpha;
  42192. /**
  42193. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42194. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42195. */
  42196. useSpecularOverAlpha: boolean;
  42197. private _useReflectionOverAlpha;
  42198. /**
  42199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42201. */
  42202. useReflectionOverAlpha: boolean;
  42203. private _disableLighting;
  42204. /**
  42205. * Does lights from the scene impacts this material.
  42206. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42207. */
  42208. disableLighting: boolean;
  42209. private _useObjectSpaceNormalMap;
  42210. /**
  42211. * Allows using an object space normal map (instead of tangent space).
  42212. */
  42213. useObjectSpaceNormalMap: boolean;
  42214. private _useParallax;
  42215. /**
  42216. * Is parallax enabled or not.
  42217. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42218. */
  42219. useParallax: boolean;
  42220. private _useParallaxOcclusion;
  42221. /**
  42222. * Is parallax occlusion enabled or not.
  42223. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42224. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42225. */
  42226. useParallaxOcclusion: boolean;
  42227. /**
  42228. * 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.
  42229. */
  42230. parallaxScaleBias: number;
  42231. private _roughness;
  42232. /**
  42233. * Helps to define how blurry the reflections should appears in the material.
  42234. */
  42235. roughness: number;
  42236. /**
  42237. * In case of refraction, define the value of the index of refraction.
  42238. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42239. */
  42240. indexOfRefraction: number;
  42241. /**
  42242. * Invert the refraction texture alongside the y axis.
  42243. * It can be useful with procedural textures or probe for instance.
  42244. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42245. */
  42246. invertRefractionY: boolean;
  42247. /**
  42248. * Defines the alpha limits in alpha test mode.
  42249. */
  42250. alphaCutOff: number;
  42251. private _useLightmapAsShadowmap;
  42252. /**
  42253. * In case of light mapping, define whether the map contains light or shadow informations.
  42254. */
  42255. useLightmapAsShadowmap: boolean;
  42256. private _diffuseFresnelParameters;
  42257. /**
  42258. * Define the diffuse fresnel parameters of the material.
  42259. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42260. */
  42261. diffuseFresnelParameters: FresnelParameters;
  42262. private _opacityFresnelParameters;
  42263. /**
  42264. * Define the opacity fresnel parameters of the material.
  42265. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42266. */
  42267. opacityFresnelParameters: FresnelParameters;
  42268. private _reflectionFresnelParameters;
  42269. /**
  42270. * Define the reflection fresnel parameters of the material.
  42271. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42272. */
  42273. reflectionFresnelParameters: FresnelParameters;
  42274. private _refractionFresnelParameters;
  42275. /**
  42276. * Define the refraction fresnel parameters of the material.
  42277. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42278. */
  42279. refractionFresnelParameters: FresnelParameters;
  42280. private _emissiveFresnelParameters;
  42281. /**
  42282. * Define the emissive fresnel parameters of the material.
  42283. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42284. */
  42285. emissiveFresnelParameters: FresnelParameters;
  42286. private _useReflectionFresnelFromSpecular;
  42287. /**
  42288. * If true automatically deducts the fresnels values from the material specularity.
  42289. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42290. */
  42291. useReflectionFresnelFromSpecular: boolean;
  42292. private _useGlossinessFromSpecularMapAlpha;
  42293. /**
  42294. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42295. */
  42296. useGlossinessFromSpecularMapAlpha: boolean;
  42297. private _maxSimultaneousLights;
  42298. /**
  42299. * Defines the maximum number of lights that can be used in the material
  42300. */
  42301. maxSimultaneousLights: number;
  42302. private _invertNormalMapX;
  42303. /**
  42304. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42305. */
  42306. invertNormalMapX: boolean;
  42307. private _invertNormalMapY;
  42308. /**
  42309. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42310. */
  42311. invertNormalMapY: boolean;
  42312. private _twoSidedLighting;
  42313. /**
  42314. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42315. */
  42316. twoSidedLighting: boolean;
  42317. /**
  42318. * Default configuration related to image processing available in the standard Material.
  42319. */
  42320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42321. /**
  42322. * Gets the image processing configuration used either in this material.
  42323. */
  42324. /**
  42325. * Sets the Default image processing configuration used either in the this material.
  42326. *
  42327. * If sets to null, the scene one is in use.
  42328. */
  42329. imageProcessingConfiguration: ImageProcessingConfiguration;
  42330. /**
  42331. * Keep track of the image processing observer to allow dispose and replace.
  42332. */
  42333. private _imageProcessingObserver;
  42334. /**
  42335. * Attaches a new image processing configuration to the Standard Material.
  42336. * @param configuration
  42337. */
  42338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42339. /**
  42340. * Gets wether the color curves effect is enabled.
  42341. */
  42342. /**
  42343. * Sets wether the color curves effect is enabled.
  42344. */
  42345. cameraColorCurvesEnabled: boolean;
  42346. /**
  42347. * Gets wether the color grading effect is enabled.
  42348. */
  42349. /**
  42350. * Gets wether the color grading effect is enabled.
  42351. */
  42352. cameraColorGradingEnabled: boolean;
  42353. /**
  42354. * Gets wether tonemapping is enabled or not.
  42355. */
  42356. /**
  42357. * Sets wether tonemapping is enabled or not
  42358. */
  42359. cameraToneMappingEnabled: boolean;
  42360. /**
  42361. * The camera exposure used on this material.
  42362. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42363. * This corresponds to a photographic exposure.
  42364. */
  42365. /**
  42366. * The camera exposure used on this material.
  42367. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42368. * This corresponds to a photographic exposure.
  42369. */
  42370. cameraExposure: number;
  42371. /**
  42372. * Gets The camera contrast used on this material.
  42373. */
  42374. /**
  42375. * Sets The camera contrast used on this material.
  42376. */
  42377. cameraContrast: number;
  42378. /**
  42379. * Gets the Color Grading 2D Lookup Texture.
  42380. */
  42381. /**
  42382. * Sets the Color Grading 2D Lookup Texture.
  42383. */
  42384. cameraColorGradingTexture: Nullable<BaseTexture>;
  42385. /**
  42386. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42387. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42388. * 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;
  42389. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42390. */
  42391. /**
  42392. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42393. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42394. * 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;
  42395. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42396. */
  42397. cameraColorCurves: Nullable<ColorCurves>;
  42398. /**
  42399. * Custom callback helping to override the default shader used in the material.
  42400. */
  42401. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42402. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42403. protected _worldViewProjectionMatrix: Matrix;
  42404. protected _globalAmbientColor: Color3;
  42405. protected _useLogarithmicDepth: boolean;
  42406. protected _rebuildInParallel: boolean;
  42407. /**
  42408. * Instantiates a new standard material.
  42409. * This is the default material used in Babylon. It is the best trade off between quality
  42410. * and performances.
  42411. * @see http://doc.babylonjs.com/babylon101/materials
  42412. * @param name Define the name of the material in the scene
  42413. * @param scene Define the scene the material belong to
  42414. */
  42415. constructor(name: string, scene: Scene);
  42416. /**
  42417. * Gets a boolean indicating that current material needs to register RTT
  42418. */
  42419. readonly hasRenderTargetTextures: boolean;
  42420. /**
  42421. * Gets the current class name of the material e.g. "StandardMaterial"
  42422. * Mainly use in serialization.
  42423. * @returns the class name
  42424. */
  42425. getClassName(): string;
  42426. /**
  42427. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42428. * You can try switching to logarithmic depth.
  42429. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42430. */
  42431. useLogarithmicDepth: boolean;
  42432. /**
  42433. * Specifies if the material will require alpha blending
  42434. * @returns a boolean specifying if alpha blending is needed
  42435. */
  42436. needAlphaBlending(): boolean;
  42437. /**
  42438. * Specifies if this material should be rendered in alpha test mode
  42439. * @returns a boolean specifying if an alpha test is needed.
  42440. */
  42441. needAlphaTesting(): boolean;
  42442. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42443. /**
  42444. * Get the texture used for alpha test purpose.
  42445. * @returns the diffuse texture in case of the standard material.
  42446. */
  42447. getAlphaTestTexture(): Nullable<BaseTexture>;
  42448. /**
  42449. * Get if the submesh is ready to be used and all its information available.
  42450. * Child classes can use it to update shaders
  42451. * @param mesh defines the mesh to check
  42452. * @param subMesh defines which submesh to check
  42453. * @param useInstances specifies that instances should be used
  42454. * @returns a boolean indicating that the submesh is ready or not
  42455. */
  42456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42457. /**
  42458. * Builds the material UBO layouts.
  42459. * Used internally during the effect preparation.
  42460. */
  42461. buildUniformLayout(): void;
  42462. /**
  42463. * Unbinds the material from the mesh
  42464. */
  42465. unbind(): void;
  42466. /**
  42467. * Binds the submesh to this material by preparing the effect and shader to draw
  42468. * @param world defines the world transformation matrix
  42469. * @param mesh defines the mesh containing the submesh
  42470. * @param subMesh defines the submesh to bind the material to
  42471. */
  42472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42473. /**
  42474. * Get the list of animatables in the material.
  42475. * @returns the list of animatables object used in the material
  42476. */
  42477. getAnimatables(): IAnimatable[];
  42478. /**
  42479. * Gets the active textures from the material
  42480. * @returns an array of textures
  42481. */
  42482. getActiveTextures(): BaseTexture[];
  42483. /**
  42484. * Specifies if the material uses a texture
  42485. * @param texture defines the texture to check against the material
  42486. * @returns a boolean specifying if the material uses the texture
  42487. */
  42488. hasTexture(texture: BaseTexture): boolean;
  42489. /**
  42490. * Disposes the material
  42491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42493. */
  42494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42495. /**
  42496. * Makes a duplicate of the material, and gives it a new name
  42497. * @param name defines the new name for the duplicated material
  42498. * @returns the cloned material
  42499. */
  42500. clone(name: string): StandardMaterial;
  42501. /**
  42502. * Serializes this material in a JSON representation
  42503. * @returns the serialized material object
  42504. */
  42505. serialize(): any;
  42506. /**
  42507. * Creates a standard material from parsed material data
  42508. * @param source defines the JSON representation of the material
  42509. * @param scene defines the hosting scene
  42510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42511. * @returns a new standard material
  42512. */
  42513. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42514. /**
  42515. * Are diffuse textures enabled in the application.
  42516. */
  42517. static DiffuseTextureEnabled: boolean;
  42518. /**
  42519. * Are ambient textures enabled in the application.
  42520. */
  42521. static AmbientTextureEnabled: boolean;
  42522. /**
  42523. * Are opacity textures enabled in the application.
  42524. */
  42525. static OpacityTextureEnabled: boolean;
  42526. /**
  42527. * Are reflection textures enabled in the application.
  42528. */
  42529. static ReflectionTextureEnabled: boolean;
  42530. /**
  42531. * Are emissive textures enabled in the application.
  42532. */
  42533. static EmissiveTextureEnabled: boolean;
  42534. /**
  42535. * Are specular textures enabled in the application.
  42536. */
  42537. static SpecularTextureEnabled: boolean;
  42538. /**
  42539. * Are bump textures enabled in the application.
  42540. */
  42541. static BumpTextureEnabled: boolean;
  42542. /**
  42543. * Are lightmap textures enabled in the application.
  42544. */
  42545. static LightmapTextureEnabled: boolean;
  42546. /**
  42547. * Are refraction textures enabled in the application.
  42548. */
  42549. static RefractionTextureEnabled: boolean;
  42550. /**
  42551. * Are color grading textures enabled in the application.
  42552. */
  42553. static ColorGradingTextureEnabled: boolean;
  42554. /**
  42555. * Are fresnels enabled in the application.
  42556. */
  42557. static FresnelEnabled: boolean;
  42558. }
  42559. }
  42560. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42561. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42563. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42564. /** @hidden */
  42565. export var imageProcessingPixelShader: {
  42566. name: string;
  42567. shader: string;
  42568. };
  42569. }
  42570. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42571. import { Nullable } from "babylonjs/types";
  42572. import { Color4 } from "babylonjs/Maths/math.color";
  42573. import { Camera } from "babylonjs/Cameras/camera";
  42574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42575. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42576. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42578. import { Engine } from "babylonjs/Engines/engine";
  42579. import "babylonjs/Shaders/imageProcessing.fragment";
  42580. import "babylonjs/Shaders/postprocess.vertex";
  42581. /**
  42582. * ImageProcessingPostProcess
  42583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42584. */
  42585. export class ImageProcessingPostProcess extends PostProcess {
  42586. /**
  42587. * Default configuration related to image processing available in the PBR Material.
  42588. */
  42589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42590. /**
  42591. * Gets the image processing configuration used either in this material.
  42592. */
  42593. /**
  42594. * Sets the Default image processing configuration used either in the this material.
  42595. *
  42596. * If sets to null, the scene one is in use.
  42597. */
  42598. imageProcessingConfiguration: ImageProcessingConfiguration;
  42599. /**
  42600. * Keep track of the image processing observer to allow dispose and replace.
  42601. */
  42602. private _imageProcessingObserver;
  42603. /**
  42604. * Attaches a new image processing configuration to the PBR Material.
  42605. * @param configuration
  42606. */
  42607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42608. /**
  42609. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42610. */
  42611. /**
  42612. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42613. */
  42614. colorCurves: Nullable<ColorCurves>;
  42615. /**
  42616. * Gets wether the color curves effect is enabled.
  42617. */
  42618. /**
  42619. * Sets wether the color curves effect is enabled.
  42620. */
  42621. colorCurvesEnabled: boolean;
  42622. /**
  42623. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42624. */
  42625. /**
  42626. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42627. */
  42628. colorGradingTexture: Nullable<BaseTexture>;
  42629. /**
  42630. * Gets wether the color grading effect is enabled.
  42631. */
  42632. /**
  42633. * Gets wether the color grading effect is enabled.
  42634. */
  42635. colorGradingEnabled: boolean;
  42636. /**
  42637. * Gets exposure used in the effect.
  42638. */
  42639. /**
  42640. * Sets exposure used in the effect.
  42641. */
  42642. exposure: number;
  42643. /**
  42644. * Gets wether tonemapping is enabled or not.
  42645. */
  42646. /**
  42647. * Sets wether tonemapping is enabled or not
  42648. */
  42649. toneMappingEnabled: boolean;
  42650. /**
  42651. * Gets the type of tone mapping effect.
  42652. */
  42653. /**
  42654. * Sets the type of tone mapping effect.
  42655. */
  42656. toneMappingType: number;
  42657. /**
  42658. * Gets contrast used in the effect.
  42659. */
  42660. /**
  42661. * Sets contrast used in the effect.
  42662. */
  42663. contrast: number;
  42664. /**
  42665. * Gets Vignette stretch size.
  42666. */
  42667. /**
  42668. * Sets Vignette stretch size.
  42669. */
  42670. vignetteStretch: number;
  42671. /**
  42672. * Gets Vignette centre X Offset.
  42673. */
  42674. /**
  42675. * Sets Vignette centre X Offset.
  42676. */
  42677. vignetteCentreX: number;
  42678. /**
  42679. * Gets Vignette centre Y Offset.
  42680. */
  42681. /**
  42682. * Sets Vignette centre Y Offset.
  42683. */
  42684. vignetteCentreY: number;
  42685. /**
  42686. * Gets Vignette weight or intensity of the vignette effect.
  42687. */
  42688. /**
  42689. * Sets Vignette weight or intensity of the vignette effect.
  42690. */
  42691. vignetteWeight: number;
  42692. /**
  42693. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42694. * if vignetteEnabled is set to true.
  42695. */
  42696. /**
  42697. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42698. * if vignetteEnabled is set to true.
  42699. */
  42700. vignetteColor: Color4;
  42701. /**
  42702. * Gets Camera field of view used by the Vignette effect.
  42703. */
  42704. /**
  42705. * Sets Camera field of view used by the Vignette effect.
  42706. */
  42707. vignetteCameraFov: number;
  42708. /**
  42709. * Gets the vignette blend mode allowing different kind of effect.
  42710. */
  42711. /**
  42712. * Sets the vignette blend mode allowing different kind of effect.
  42713. */
  42714. vignetteBlendMode: number;
  42715. /**
  42716. * Gets wether the vignette effect is enabled.
  42717. */
  42718. /**
  42719. * Sets wether the vignette effect is enabled.
  42720. */
  42721. vignetteEnabled: boolean;
  42722. private _fromLinearSpace;
  42723. /**
  42724. * Gets wether the input of the processing is in Gamma or Linear Space.
  42725. */
  42726. /**
  42727. * Sets wether the input of the processing is in Gamma or Linear Space.
  42728. */
  42729. fromLinearSpace: boolean;
  42730. /**
  42731. * Defines cache preventing GC.
  42732. */
  42733. private _defines;
  42734. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42735. /**
  42736. * "ImageProcessingPostProcess"
  42737. * @returns "ImageProcessingPostProcess"
  42738. */
  42739. getClassName(): string;
  42740. protected _updateParameters(): void;
  42741. dispose(camera?: Camera): void;
  42742. }
  42743. }
  42744. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42745. import { Scene } from "babylonjs/scene";
  42746. import { Color3 } from "babylonjs/Maths/math.color";
  42747. import { Mesh } from "babylonjs/Meshes/mesh";
  42748. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42749. import { Nullable } from "babylonjs/types";
  42750. /**
  42751. * Class containing static functions to help procedurally build meshes
  42752. */
  42753. export class GroundBuilder {
  42754. /**
  42755. * Creates a ground mesh
  42756. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42757. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42759. * @param name defines the name of the mesh
  42760. * @param options defines the options used to create the mesh
  42761. * @param scene defines the hosting scene
  42762. * @returns the ground mesh
  42763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42764. */
  42765. static CreateGround(name: string, options: {
  42766. width?: number;
  42767. height?: number;
  42768. subdivisions?: number;
  42769. subdivisionsX?: number;
  42770. subdivisionsY?: number;
  42771. updatable?: boolean;
  42772. }, scene: any): Mesh;
  42773. /**
  42774. * Creates a tiled ground mesh
  42775. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42776. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42777. * * 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
  42778. * * 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
  42779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42780. * @param name defines the name of the mesh
  42781. * @param options defines the options used to create the mesh
  42782. * @param scene defines the hosting scene
  42783. * @returns the tiled ground mesh
  42784. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42785. */
  42786. static CreateTiledGround(name: string, options: {
  42787. xmin: number;
  42788. zmin: number;
  42789. xmax: number;
  42790. zmax: number;
  42791. subdivisions?: {
  42792. w: number;
  42793. h: number;
  42794. };
  42795. precision?: {
  42796. w: number;
  42797. h: number;
  42798. };
  42799. updatable?: boolean;
  42800. }, scene?: Nullable<Scene>): Mesh;
  42801. /**
  42802. * Creates a ground mesh from a height map
  42803. * * The parameter `url` sets the URL of the height map image resource.
  42804. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42805. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42806. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42807. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42808. * * 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.
  42809. * * 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).
  42810. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42812. * @param name defines the name of the mesh
  42813. * @param url defines the url to the height map
  42814. * @param options defines the options used to create the mesh
  42815. * @param scene defines the hosting scene
  42816. * @returns the ground mesh
  42817. * @see https://doc.babylonjs.com/babylon101/height_map
  42818. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42819. */
  42820. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42821. width?: number;
  42822. height?: number;
  42823. subdivisions?: number;
  42824. minHeight?: number;
  42825. maxHeight?: number;
  42826. colorFilter?: Color3;
  42827. alphaFilter?: number;
  42828. updatable?: boolean;
  42829. onReady?: (mesh: GroundMesh) => void;
  42830. }, scene?: Nullable<Scene>): GroundMesh;
  42831. }
  42832. }
  42833. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42834. import { Vector4 } from "babylonjs/Maths/math.vector";
  42835. import { Mesh } from "babylonjs/Meshes/mesh";
  42836. /**
  42837. * Class containing static functions to help procedurally build meshes
  42838. */
  42839. export class TorusBuilder {
  42840. /**
  42841. * Creates a torus mesh
  42842. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42843. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42844. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42848. * @param name defines the name of the mesh
  42849. * @param options defines the options used to create the mesh
  42850. * @param scene defines the hosting scene
  42851. * @returns the torus mesh
  42852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42853. */
  42854. static CreateTorus(name: string, options: {
  42855. diameter?: number;
  42856. thickness?: number;
  42857. tessellation?: number;
  42858. updatable?: boolean;
  42859. sideOrientation?: number;
  42860. frontUVs?: Vector4;
  42861. backUVs?: Vector4;
  42862. }, scene: any): Mesh;
  42863. }
  42864. }
  42865. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42866. import { Vector4 } from "babylonjs/Maths/math.vector";
  42867. import { Color4 } from "babylonjs/Maths/math.color";
  42868. import { Mesh } from "babylonjs/Meshes/mesh";
  42869. /**
  42870. * Class containing static functions to help procedurally build meshes
  42871. */
  42872. export class CylinderBuilder {
  42873. /**
  42874. * Creates a cylinder or a cone mesh
  42875. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42876. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42877. * * 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.
  42878. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42879. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42880. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42881. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42882. * * 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).
  42883. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42884. * * 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).
  42885. * * 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
  42886. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42887. * * 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
  42888. * * 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.
  42889. * * If `enclose` is false, a ring surface is one element.
  42890. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42891. * * 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
  42892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42895. * @param name defines the name of the mesh
  42896. * @param options defines the options used to create the mesh
  42897. * @param scene defines the hosting scene
  42898. * @returns the cylinder mesh
  42899. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42900. */
  42901. static CreateCylinder(name: string, options: {
  42902. height?: number;
  42903. diameterTop?: number;
  42904. diameterBottom?: number;
  42905. diameter?: number;
  42906. tessellation?: number;
  42907. subdivisions?: number;
  42908. arc?: number;
  42909. faceColors?: Color4[];
  42910. faceUV?: Vector4[];
  42911. updatable?: boolean;
  42912. hasRings?: boolean;
  42913. enclose?: boolean;
  42914. cap?: number;
  42915. sideOrientation?: number;
  42916. frontUVs?: Vector4;
  42917. backUVs?: Vector4;
  42918. }, scene: any): Mesh;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42922. import { Observable } from "babylonjs/Misc/observable";
  42923. import { Nullable } from "babylonjs/types";
  42924. import { Camera } from "babylonjs/Cameras/camera";
  42925. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42926. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42927. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42928. import { Scene } from "babylonjs/scene";
  42929. import { Vector3 } from "babylonjs/Maths/math.vector";
  42930. import { Color3 } from "babylonjs/Maths/math.color";
  42931. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42933. import { Mesh } from "babylonjs/Meshes/mesh";
  42934. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42935. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42936. import "babylonjs/Meshes/Builders/groundBuilder";
  42937. import "babylonjs/Meshes/Builders/torusBuilder";
  42938. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42939. import "babylonjs/Gamepads/gamepadSceneComponent";
  42940. import "babylonjs/Animations/animatable";
  42941. /**
  42942. * Options to modify the vr teleportation behavior.
  42943. */
  42944. export interface VRTeleportationOptions {
  42945. /**
  42946. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42947. */
  42948. floorMeshName?: string;
  42949. /**
  42950. * A list of meshes to be used as the teleportation floor. (default: empty)
  42951. */
  42952. floorMeshes?: Mesh[];
  42953. }
  42954. /**
  42955. * Options to modify the vr experience helper's behavior.
  42956. */
  42957. export interface VRExperienceHelperOptions extends WebVROptions {
  42958. /**
  42959. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42960. */
  42961. createDeviceOrientationCamera?: boolean;
  42962. /**
  42963. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42964. */
  42965. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42966. /**
  42967. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42968. */
  42969. laserToggle?: boolean;
  42970. /**
  42971. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42972. */
  42973. floorMeshes?: Mesh[];
  42974. /**
  42975. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42976. */
  42977. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42978. }
  42979. /**
  42980. * Event containing information after VR has been entered
  42981. */
  42982. export class OnAfterEnteringVRObservableEvent {
  42983. /**
  42984. * If entering vr was successful
  42985. */
  42986. success: boolean;
  42987. }
  42988. /**
  42989. * Helps to quickly add VR support to an existing scene.
  42990. * See http://doc.babylonjs.com/how_to/webvr_helper
  42991. */
  42992. export class VRExperienceHelper {
  42993. /** Options to modify the vr experience helper's behavior. */
  42994. webVROptions: VRExperienceHelperOptions;
  42995. private _scene;
  42996. private _position;
  42997. private _btnVR;
  42998. private _btnVRDisplayed;
  42999. private _webVRsupported;
  43000. private _webVRready;
  43001. private _webVRrequesting;
  43002. private _webVRpresenting;
  43003. private _hasEnteredVR;
  43004. private _fullscreenVRpresenting;
  43005. private _inputElement;
  43006. private _webVRCamera;
  43007. private _vrDeviceOrientationCamera;
  43008. private _deviceOrientationCamera;
  43009. private _existingCamera;
  43010. private _onKeyDown;
  43011. private _onVrDisplayPresentChange;
  43012. private _onVRDisplayChanged;
  43013. private _onVRRequestPresentStart;
  43014. private _onVRRequestPresentComplete;
  43015. /**
  43016. * 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)
  43017. */
  43018. enableGazeEvenWhenNoPointerLock: boolean;
  43019. /**
  43020. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43021. */
  43022. exitVROnDoubleTap: boolean;
  43023. /**
  43024. * Observable raised right before entering VR.
  43025. */
  43026. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43027. /**
  43028. * Observable raised when entering VR has completed.
  43029. */
  43030. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43031. /**
  43032. * Observable raised when exiting VR.
  43033. */
  43034. onExitingVRObservable: Observable<VRExperienceHelper>;
  43035. /**
  43036. * Observable raised when controller mesh is loaded.
  43037. */
  43038. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43039. /** Return this.onEnteringVRObservable
  43040. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43041. */
  43042. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43043. /** Return this.onExitingVRObservable
  43044. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43045. */
  43046. readonly onExitingVR: Observable<VRExperienceHelper>;
  43047. /** Return this.onControllerMeshLoadedObservable
  43048. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43049. */
  43050. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43051. private _rayLength;
  43052. private _useCustomVRButton;
  43053. private _teleportationRequested;
  43054. private _teleportActive;
  43055. private _floorMeshName;
  43056. private _floorMeshesCollection;
  43057. private _rotationAllowed;
  43058. private _teleportBackwardsVector;
  43059. private _teleportationTarget;
  43060. private _isDefaultTeleportationTarget;
  43061. private _postProcessMove;
  43062. private _teleportationFillColor;
  43063. private _teleportationBorderColor;
  43064. private _rotationAngle;
  43065. private _haloCenter;
  43066. private _cameraGazer;
  43067. private _padSensibilityUp;
  43068. private _padSensibilityDown;
  43069. private _leftController;
  43070. private _rightController;
  43071. /**
  43072. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43073. */
  43074. onNewMeshSelected: Observable<AbstractMesh>;
  43075. /**
  43076. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43077. * This observable will provide the mesh and the controller used to select the mesh
  43078. */
  43079. onMeshSelectedWithController: Observable<{
  43080. mesh: AbstractMesh;
  43081. controller: WebVRController;
  43082. }>;
  43083. /**
  43084. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43085. */
  43086. onNewMeshPicked: Observable<PickingInfo>;
  43087. private _circleEase;
  43088. /**
  43089. * Observable raised before camera teleportation
  43090. */
  43091. onBeforeCameraTeleport: Observable<Vector3>;
  43092. /**
  43093. * Observable raised after camera teleportation
  43094. */
  43095. onAfterCameraTeleport: Observable<Vector3>;
  43096. /**
  43097. * Observable raised when current selected mesh gets unselected
  43098. */
  43099. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43100. private _raySelectionPredicate;
  43101. /**
  43102. * To be optionaly changed by user to define custom ray selection
  43103. */
  43104. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43105. /**
  43106. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43107. */
  43108. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43109. /**
  43110. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43111. */
  43112. teleportationEnabled: boolean;
  43113. private _defaultHeight;
  43114. private _teleportationInitialized;
  43115. private _interactionsEnabled;
  43116. private _interactionsRequested;
  43117. private _displayGaze;
  43118. private _displayLaserPointer;
  43119. /**
  43120. * The mesh used to display where the user is going to teleport.
  43121. */
  43122. /**
  43123. * Sets the mesh to be used to display where the user is going to teleport.
  43124. */
  43125. teleportationTarget: Mesh;
  43126. /**
  43127. * 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
  43128. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43129. * See http://doc.babylonjs.com/resources/baking_transformations
  43130. */
  43131. gazeTrackerMesh: Mesh;
  43132. /**
  43133. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43134. */
  43135. updateGazeTrackerScale: boolean;
  43136. /**
  43137. * If the gaze trackers color should be updated when selecting meshes
  43138. */
  43139. updateGazeTrackerColor: boolean;
  43140. /**
  43141. * If the controller laser color should be updated when selecting meshes
  43142. */
  43143. updateControllerLaserColor: boolean;
  43144. /**
  43145. * The gaze tracking mesh corresponding to the left controller
  43146. */
  43147. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43148. /**
  43149. * The gaze tracking mesh corresponding to the right controller
  43150. */
  43151. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43152. /**
  43153. * If the ray of the gaze should be displayed.
  43154. */
  43155. /**
  43156. * Sets if the ray of the gaze should be displayed.
  43157. */
  43158. displayGaze: boolean;
  43159. /**
  43160. * If the ray of the LaserPointer should be displayed.
  43161. */
  43162. /**
  43163. * Sets if the ray of the LaserPointer should be displayed.
  43164. */
  43165. displayLaserPointer: boolean;
  43166. /**
  43167. * The deviceOrientationCamera used as the camera when not in VR.
  43168. */
  43169. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43170. /**
  43171. * Based on the current WebVR support, returns the current VR camera used.
  43172. */
  43173. readonly currentVRCamera: Nullable<Camera>;
  43174. /**
  43175. * The webVRCamera which is used when in VR.
  43176. */
  43177. readonly webVRCamera: WebVRFreeCamera;
  43178. /**
  43179. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43180. */
  43181. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43182. /**
  43183. * The html button that is used to trigger entering into VR.
  43184. */
  43185. readonly vrButton: Nullable<HTMLButtonElement>;
  43186. private readonly _teleportationRequestInitiated;
  43187. /**
  43188. * Defines wether or not Pointer lock should be requested when switching to
  43189. * full screen.
  43190. */
  43191. requestPointerLockOnFullScreen: boolean;
  43192. /**
  43193. * Instantiates a VRExperienceHelper.
  43194. * Helps to quickly add VR support to an existing scene.
  43195. * @param scene The scene the VRExperienceHelper belongs to.
  43196. * @param webVROptions Options to modify the vr experience helper's behavior.
  43197. */
  43198. constructor(scene: Scene,
  43199. /** Options to modify the vr experience helper's behavior. */
  43200. webVROptions?: VRExperienceHelperOptions);
  43201. private _onDefaultMeshLoaded;
  43202. private _onResize;
  43203. private _onFullscreenChange;
  43204. /**
  43205. * Gets a value indicating if we are currently in VR mode.
  43206. */
  43207. readonly isInVRMode: boolean;
  43208. private onVrDisplayPresentChange;
  43209. private onVRDisplayChanged;
  43210. private moveButtonToBottomRight;
  43211. private displayVRButton;
  43212. private updateButtonVisibility;
  43213. private _cachedAngularSensibility;
  43214. /**
  43215. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43216. * Otherwise, will use the fullscreen API.
  43217. */
  43218. enterVR(): void;
  43219. /**
  43220. * Attempt to exit VR, or fullscreen.
  43221. */
  43222. exitVR(): void;
  43223. /**
  43224. * The position of the vr experience helper.
  43225. */
  43226. /**
  43227. * Sets the position of the vr experience helper.
  43228. */
  43229. position: Vector3;
  43230. /**
  43231. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43232. */
  43233. enableInteractions(): void;
  43234. private readonly _noControllerIsActive;
  43235. private beforeRender;
  43236. private _isTeleportationFloor;
  43237. /**
  43238. * Adds a floor mesh to be used for teleportation.
  43239. * @param floorMesh the mesh to be used for teleportation.
  43240. */
  43241. addFloorMesh(floorMesh: Mesh): void;
  43242. /**
  43243. * Removes a floor mesh from being used for teleportation.
  43244. * @param floorMesh the mesh to be removed.
  43245. */
  43246. removeFloorMesh(floorMesh: Mesh): void;
  43247. /**
  43248. * Enables interactions and teleportation using the VR controllers and gaze.
  43249. * @param vrTeleportationOptions options to modify teleportation behavior.
  43250. */
  43251. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43252. private _onNewGamepadConnected;
  43253. private _tryEnableInteractionOnController;
  43254. private _onNewGamepadDisconnected;
  43255. private _enableInteractionOnController;
  43256. private _checkTeleportWithRay;
  43257. private _checkRotate;
  43258. private _checkTeleportBackwards;
  43259. private _enableTeleportationOnController;
  43260. private _createTeleportationCircles;
  43261. private _displayTeleportationTarget;
  43262. private _hideTeleportationTarget;
  43263. private _rotateCamera;
  43264. private _moveTeleportationSelectorTo;
  43265. private _workingVector;
  43266. private _workingQuaternion;
  43267. private _workingMatrix;
  43268. /**
  43269. * Teleports the users feet to the desired location
  43270. * @param location The location where the user's feet should be placed
  43271. */
  43272. teleportCamera(location: Vector3): void;
  43273. private _convertNormalToDirectionOfRay;
  43274. private _castRayAndSelectObject;
  43275. private _notifySelectedMeshUnselected;
  43276. /**
  43277. * Sets the color of the laser ray from the vr controllers.
  43278. * @param color new color for the ray.
  43279. */
  43280. changeLaserColor(color: Color3): void;
  43281. /**
  43282. * Sets the color of the ray from the vr headsets gaze.
  43283. * @param color new color for the ray.
  43284. */
  43285. changeGazeColor(color: Color3): void;
  43286. /**
  43287. * Exits VR and disposes of the vr experience helper
  43288. */
  43289. dispose(): void;
  43290. /**
  43291. * Gets the name of the VRExperienceHelper class
  43292. * @returns "VRExperienceHelper"
  43293. */
  43294. getClassName(): string;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/VR/index" {
  43298. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43299. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43300. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43301. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43302. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43303. export * from "babylonjs/Cameras/VR/webVRCamera";
  43304. }
  43305. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43306. import { Nullable } from "babylonjs/types";
  43307. import { IDisposable } from "babylonjs/scene";
  43308. /**
  43309. * States of the webXR experience
  43310. */
  43311. export enum WebXRState {
  43312. /**
  43313. * Transitioning to being in XR mode
  43314. */
  43315. ENTERING_XR = 0,
  43316. /**
  43317. * Transitioning to non XR mode
  43318. */
  43319. EXITING_XR = 1,
  43320. /**
  43321. * In XR mode and presenting
  43322. */
  43323. IN_XR = 2,
  43324. /**
  43325. * Not entered XR mode
  43326. */
  43327. NOT_IN_XR = 3
  43328. }
  43329. /**
  43330. * Abstraction of the XR render target
  43331. */
  43332. export interface WebXRRenderTarget extends IDisposable {
  43333. /**
  43334. * xrpresent context of the canvas which can be used to display/mirror xr content
  43335. */
  43336. canvasContext: WebGLRenderingContext;
  43337. /**
  43338. * xr layer for the canvas
  43339. */
  43340. xrLayer: Nullable<XRWebGLLayer>;
  43341. /**
  43342. * Initializes the xr layer for the session
  43343. * @param xrSession xr session
  43344. * @returns a promise that will resolve once the XR Layer has been created
  43345. */
  43346. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43347. }
  43348. }
  43349. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43350. import { Nullable } from "babylonjs/types";
  43351. import { Observable } from "babylonjs/Misc/observable";
  43352. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43353. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43354. /**
  43355. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43356. */
  43357. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43358. private _engine;
  43359. private _canvas;
  43360. /**
  43361. * xrpresent context of the canvas which can be used to display/mirror xr content
  43362. */
  43363. canvasContext: WebGLRenderingContext;
  43364. /**
  43365. * xr layer for the canvas
  43366. */
  43367. xrLayer: Nullable<XRWebGLLayer>;
  43368. /**
  43369. * Initializes the xr layer for the session
  43370. * @param xrSession xr session
  43371. * @returns a promise that will resolve once the XR Layer has been created
  43372. */
  43373. initializeXRLayerAsync(xrSession: any): any;
  43374. /**
  43375. * Initializes the canvas to be added/removed upon entering/exiting xr
  43376. * @param engine the Babylon engine
  43377. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43378. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43379. */
  43380. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  43381. /**
  43382. * Disposes of the object
  43383. */
  43384. dispose(): void;
  43385. private _setManagedOutputCanvas;
  43386. private _addCanvas;
  43387. private _removeCanvas;
  43388. }
  43389. }
  43390. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43391. import { Observable } from "babylonjs/Misc/observable";
  43392. import { Nullable } from "babylonjs/types";
  43393. import { IDisposable, Scene } from "babylonjs/scene";
  43394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43395. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43396. /**
  43397. * Manages an XRSession to work with Babylon's engine
  43398. * @see https://doc.babylonjs.com/how_to/webxr
  43399. */
  43400. export class WebXRSessionManager implements IDisposable {
  43401. private scene;
  43402. /**
  43403. * Fires every time a new xrFrame arrives which can be used to update the camera
  43404. */
  43405. onXRFrameObservable: Observable<any>;
  43406. /**
  43407. * Fires when the xr session is ended either by the device or manually done
  43408. */
  43409. onXRSessionEnded: Observable<any>;
  43410. /**
  43411. * Underlying xr session
  43412. */
  43413. session: XRSession;
  43414. /**
  43415. * Type of reference space used when creating the session
  43416. */
  43417. referenceSpace: XRReferenceSpace;
  43418. /**
  43419. * Current XR frame
  43420. */
  43421. currentFrame: Nullable<XRFrame>;
  43422. private _xrNavigator;
  43423. private baseLayer;
  43424. private _rttProvider;
  43425. private _sessionEnded;
  43426. /**
  43427. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43428. * @param scene The scene which the session should be created for
  43429. */
  43430. constructor(scene: Scene);
  43431. /**
  43432. * Initializes the manager
  43433. * After initialization enterXR can be called to start an XR session
  43434. * @returns Promise which resolves after it is initialized
  43435. */
  43436. initializeAsync(): Promise<void>;
  43437. /**
  43438. * Initializes an xr session
  43439. * @param xrSessionMode mode to initialize
  43440. * @param optionalFeatures defines optional values to pass to the session builder
  43441. * @returns a promise which will resolve once the session has been initialized
  43442. */
  43443. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  43444. /**
  43445. * Sets the reference space on the xr session
  43446. * @param referenceSpace space to set
  43447. * @returns a promise that will resolve once the reference space has been set
  43448. */
  43449. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43450. /**
  43451. * Updates the render state of the session
  43452. * @param state state to set
  43453. * @returns a promise that resolves once the render state has been updated
  43454. */
  43455. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43456. /**
  43457. * Starts rendering to the xr layer
  43458. * @returns a promise that will resolve once rendering has started
  43459. */
  43460. startRenderingToXRAsync(): Promise<void>;
  43461. /**
  43462. * Gets the correct render target texture to be rendered this frame for this eye
  43463. * @param eye the eye for which to get the render target
  43464. * @returns the render target for the specified eye
  43465. */
  43466. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43467. /**
  43468. * Stops the xrSession and restores the renderloop
  43469. * @returns Promise which resolves after it exits XR
  43470. */
  43471. exitXRAsync(): Promise<void>;
  43472. /**
  43473. * Checks if a session would be supported for the creation options specified
  43474. * @param sessionMode session mode to check if supported eg. immersive-vr
  43475. * @returns true if supported
  43476. */
  43477. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43478. /**
  43479. * Creates a WebXRRenderTarget object for the XR session
  43480. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43481. * @returns a WebXR render target to which the session can render
  43482. */
  43483. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43484. /**
  43485. * @hidden
  43486. * Converts the render layer of xrSession to a render target
  43487. * @param session session to create render target for
  43488. * @param scene scene the new render target should be created for
  43489. */
  43490. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43491. /**
  43492. * Disposes of the session manager
  43493. */
  43494. dispose(): void;
  43495. }
  43496. }
  43497. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43498. import { Scene } from "babylonjs/scene";
  43499. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43500. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43501. /**
  43502. * WebXR Camera which holds the views for the xrSession
  43503. * @see https://doc.babylonjs.com/how_to/webxr
  43504. */
  43505. export class WebXRCamera extends FreeCamera {
  43506. private static _TmpMatrix;
  43507. /**
  43508. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43509. * @param name the name of the camera
  43510. * @param scene the scene to add the camera to
  43511. */
  43512. constructor(name: string, scene: Scene);
  43513. private _updateNumberOfRigCameras;
  43514. /** @hidden */
  43515. _updateForDualEyeDebugging(): void;
  43516. /**
  43517. * Updates the cameras position from the current pose information of the XR session
  43518. * @param xrSessionManager the session containing pose information
  43519. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43520. */
  43521. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43522. }
  43523. }
  43524. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43525. import { Observable } from "babylonjs/Misc/observable";
  43526. import { IDisposable, Scene } from "babylonjs/scene";
  43527. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43529. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43530. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43531. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43532. /**
  43533. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43534. * @see https://doc.babylonjs.com/how_to/webxr
  43535. */
  43536. export class WebXRExperienceHelper implements IDisposable {
  43537. private scene;
  43538. /**
  43539. * 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
  43540. */
  43541. container: AbstractMesh;
  43542. /**
  43543. * Camera used to render xr content
  43544. */
  43545. camera: WebXRCamera;
  43546. /**
  43547. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43548. */
  43549. state: WebXRState;
  43550. private _setState;
  43551. private static _TmpVector;
  43552. /**
  43553. * Fires when the state of the experience helper has changed
  43554. */
  43555. onStateChangedObservable: Observable<WebXRState>;
  43556. /** Session manager used to keep track of xr session */
  43557. sessionManager: WebXRSessionManager;
  43558. private _nonVRCamera;
  43559. private _originalSceneAutoClear;
  43560. private _supported;
  43561. /**
  43562. * Creates the experience helper
  43563. * @param scene the scene to attach the experience helper to
  43564. * @returns a promise for the experience helper
  43565. */
  43566. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43567. /**
  43568. * Creates a WebXRExperienceHelper
  43569. * @param scene The scene the helper should be created in
  43570. */
  43571. private constructor();
  43572. /**
  43573. * Exits XR mode and returns the scene to its original state
  43574. * @returns promise that resolves after xr mode has exited
  43575. */
  43576. exitXRAsync(): Promise<void>;
  43577. /**
  43578. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43579. * @param sessionMode options for the XR session
  43580. * @param referenceSpaceType frame of reference of the XR session
  43581. * @param renderTarget the output canvas that will be used to enter XR mode
  43582. * @returns promise that resolves after xr mode has entered
  43583. */
  43584. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43585. /**
  43586. * Updates the global position of the camera by moving the camera's container
  43587. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43588. * @param position The desired global position of the camera
  43589. */
  43590. setPositionOfCameraUsingContainer(position: Vector3): void;
  43591. /**
  43592. * Rotates the xr camera by rotating the camera's container around the camera's position
  43593. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43594. * @param rotation the desired quaternion rotation to apply to the camera
  43595. */
  43596. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43597. /**
  43598. * Disposes of the experience helper
  43599. */
  43600. dispose(): void;
  43601. }
  43602. }
  43603. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43604. import { Nullable } from "babylonjs/types";
  43605. import { Observable } from "babylonjs/Misc/observable";
  43606. import { IDisposable, Scene } from "babylonjs/scene";
  43607. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43608. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43609. /**
  43610. * Button which can be used to enter a different mode of XR
  43611. */
  43612. export class WebXREnterExitUIButton {
  43613. /** button element */
  43614. element: HTMLElement;
  43615. /** XR initialization options for the button */
  43616. sessionMode: XRSessionMode;
  43617. /** Reference space type */
  43618. referenceSpaceType: XRReferenceSpaceType;
  43619. /**
  43620. * Creates a WebXREnterExitUIButton
  43621. * @param element button element
  43622. * @param sessionMode XR initialization session mode
  43623. * @param referenceSpaceType the type of reference space to be used
  43624. */
  43625. constructor(
  43626. /** button element */
  43627. element: HTMLElement,
  43628. /** XR initialization options for the button */
  43629. sessionMode: XRSessionMode,
  43630. /** Reference space type */
  43631. referenceSpaceType: XRReferenceSpaceType);
  43632. /**
  43633. * Overwritable function which can be used to update the button's visuals when the state changes
  43634. * @param activeButton the current active button in the UI
  43635. */
  43636. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43637. }
  43638. /**
  43639. * Options to create the webXR UI
  43640. */
  43641. export class WebXREnterExitUIOptions {
  43642. /**
  43643. * Context to enter xr with
  43644. */
  43645. renderTarget?: Nullable<WebXRRenderTarget>;
  43646. /**
  43647. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43648. */
  43649. customButtons?: Array<WebXREnterExitUIButton>;
  43650. }
  43651. /**
  43652. * UI to allow the user to enter/exit XR mode
  43653. */
  43654. export class WebXREnterExitUI implements IDisposable {
  43655. private scene;
  43656. private _overlay;
  43657. private _buttons;
  43658. private _activeButton;
  43659. /**
  43660. * Fired every time the active button is changed.
  43661. *
  43662. * When xr is entered via a button that launches xr that button will be the callback parameter
  43663. *
  43664. * When exiting xr the callback parameter will be null)
  43665. */
  43666. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43667. /**
  43668. * Creates UI to allow the user to enter/exit XR mode
  43669. * @param scene the scene to add the ui to
  43670. * @param helper the xr experience helper to enter/exit xr with
  43671. * @param options options to configure the UI
  43672. * @returns the created ui
  43673. */
  43674. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43675. private constructor();
  43676. private _updateButtons;
  43677. /**
  43678. * Disposes of the object
  43679. */
  43680. dispose(): void;
  43681. }
  43682. }
  43683. declare module "babylonjs/Cameras/XR/webXRController" {
  43684. import { Nullable } from "babylonjs/types";
  43685. import { Observable } from "babylonjs/Misc/observable";
  43686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43687. import { Ray } from "babylonjs/Culling/ray";
  43688. import { Scene } from "babylonjs/scene";
  43689. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43690. /**
  43691. * Represents an XR input
  43692. */
  43693. export class WebXRController {
  43694. private scene;
  43695. /** The underlying input source for the controller */
  43696. inputSource: XRInputSource;
  43697. private parentContainer;
  43698. /**
  43699. * 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
  43700. */
  43701. grip?: AbstractMesh;
  43702. /**
  43703. * Pointer which can be used to select objects or attach a visible laser to
  43704. */
  43705. pointer: AbstractMesh;
  43706. private _gamepadMode;
  43707. /**
  43708. * If available, this is the gamepad object related to this controller.
  43709. * Using this object it is possible to get click events and trackpad changes of the
  43710. * webxr controller that is currently being used.
  43711. */
  43712. gamepadController?: WebVRController;
  43713. /**
  43714. * Event that fires when the controller is removed/disposed
  43715. */
  43716. onDisposeObservable: Observable<{}>;
  43717. private _tmpMatrix;
  43718. private _tmpQuaternion;
  43719. private _tmpVector;
  43720. /**
  43721. * Creates the controller
  43722. * @see https://doc.babylonjs.com/how_to/webxr
  43723. * @param scene the scene which the controller should be associated to
  43724. * @param inputSource the underlying input source for the controller
  43725. * @param parentContainer parent that the controller meshes should be children of
  43726. */
  43727. constructor(scene: Scene,
  43728. /** The underlying input source for the controller */
  43729. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43730. /**
  43731. * Updates the controller pose based on the given XRFrame
  43732. * @param xrFrame xr frame to update the pose with
  43733. * @param referenceSpace reference space to use
  43734. */
  43735. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43736. /**
  43737. * Gets a world space ray coming from the controller
  43738. * @param result the resulting ray
  43739. */
  43740. getWorldPointerRayToRef(result: Ray): void;
  43741. /**
  43742. * Get the scene associated with this controller
  43743. * @returns the scene object
  43744. */
  43745. getScene(): Scene;
  43746. /**
  43747. * Disposes of the object
  43748. */
  43749. dispose(): void;
  43750. }
  43751. }
  43752. declare module "babylonjs/Cameras/XR/webXRInput" {
  43753. import { Observable } from "babylonjs/Misc/observable";
  43754. import { IDisposable } from "babylonjs/scene";
  43755. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43756. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43757. /**
  43758. * XR input used to track XR inputs such as controllers/rays
  43759. */
  43760. export class WebXRInput implements IDisposable {
  43761. /**
  43762. * Base experience the input listens to
  43763. */
  43764. baseExperience: WebXRExperienceHelper;
  43765. /**
  43766. * XR controllers being tracked
  43767. */
  43768. controllers: Array<WebXRController>;
  43769. private _frameObserver;
  43770. private _stateObserver;
  43771. /**
  43772. * Event when a controller has been connected/added
  43773. */
  43774. onControllerAddedObservable: Observable<WebXRController>;
  43775. /**
  43776. * Event when a controller has been removed/disconnected
  43777. */
  43778. onControllerRemovedObservable: Observable<WebXRController>;
  43779. /**
  43780. * Initializes the WebXRInput
  43781. * @param baseExperience experience helper which the input should be created for
  43782. */
  43783. constructor(
  43784. /**
  43785. * Base experience the input listens to
  43786. */
  43787. baseExperience: WebXRExperienceHelper);
  43788. private _onInputSourcesChange;
  43789. private _addAndRemoveControllers;
  43790. /**
  43791. * Disposes of the object
  43792. */
  43793. dispose(): void;
  43794. }
  43795. }
  43796. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43798. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43799. /**
  43800. * Enables teleportation
  43801. */
  43802. export class WebXRControllerTeleportation {
  43803. private _teleportationFillColor;
  43804. private _teleportationBorderColor;
  43805. private _tmpRay;
  43806. private _tmpVector;
  43807. /**
  43808. * Creates a WebXRControllerTeleportation
  43809. * @param input input manager to add teleportation to
  43810. * @param floorMeshes floormeshes which can be teleported to
  43811. */
  43812. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43813. }
  43814. }
  43815. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43816. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43817. /**
  43818. * Handles pointer input automatically for the pointer of XR controllers
  43819. */
  43820. export class WebXRControllerPointerSelection {
  43821. private static _idCounter;
  43822. private _tmpRay;
  43823. /**
  43824. * Creates a WebXRControllerPointerSelection
  43825. * @param input input manager to setup pointer selection
  43826. */
  43827. constructor(input: WebXRInput);
  43828. private _convertNormalToDirectionOfRay;
  43829. private _updatePointerDistance;
  43830. }
  43831. }
  43832. declare module "babylonjs/Loading/sceneLoader" {
  43833. import { Observable } from "babylonjs/Misc/observable";
  43834. import { Nullable } from "babylonjs/types";
  43835. import { Scene } from "babylonjs/scene";
  43836. import { Engine } from "babylonjs/Engines/engine";
  43837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43838. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43839. import { AssetContainer } from "babylonjs/assetContainer";
  43840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43841. import { Skeleton } from "babylonjs/Bones/skeleton";
  43842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43843. import { WebRequest } from "babylonjs/Misc/webRequest";
  43844. /**
  43845. * Class used to represent data loading progression
  43846. */
  43847. export class SceneLoaderProgressEvent {
  43848. /** defines if data length to load can be evaluated */
  43849. readonly lengthComputable: boolean;
  43850. /** defines the loaded data length */
  43851. readonly loaded: number;
  43852. /** defines the data length to load */
  43853. readonly total: number;
  43854. /**
  43855. * Create a new progress event
  43856. * @param lengthComputable defines if data length to load can be evaluated
  43857. * @param loaded defines the loaded data length
  43858. * @param total defines the data length to load
  43859. */
  43860. constructor(
  43861. /** defines if data length to load can be evaluated */
  43862. lengthComputable: boolean,
  43863. /** defines the loaded data length */
  43864. loaded: number,
  43865. /** defines the data length to load */
  43866. total: number);
  43867. /**
  43868. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43869. * @param event defines the source event
  43870. * @returns a new SceneLoaderProgressEvent
  43871. */
  43872. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43873. }
  43874. /**
  43875. * Interface used by SceneLoader plugins to define supported file extensions
  43876. */
  43877. export interface ISceneLoaderPluginExtensions {
  43878. /**
  43879. * Defines the list of supported extensions
  43880. */
  43881. [extension: string]: {
  43882. isBinary: boolean;
  43883. };
  43884. }
  43885. /**
  43886. * Interface used by SceneLoader plugin factory
  43887. */
  43888. export interface ISceneLoaderPluginFactory {
  43889. /**
  43890. * Defines the name of the factory
  43891. */
  43892. name: string;
  43893. /**
  43894. * Function called to create a new plugin
  43895. * @return the new plugin
  43896. */
  43897. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43898. /**
  43899. * The callback that returns true if the data can be directly loaded.
  43900. * @param data string containing the file data
  43901. * @returns if the data can be loaded directly
  43902. */
  43903. canDirectLoad?(data: string): boolean;
  43904. }
  43905. /**
  43906. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43907. */
  43908. export interface ISceneLoaderPluginBase {
  43909. /**
  43910. * The friendly name of this plugin.
  43911. */
  43912. name: string;
  43913. /**
  43914. * The file extensions supported by this plugin.
  43915. */
  43916. extensions: string | ISceneLoaderPluginExtensions;
  43917. /**
  43918. * The callback called when loading from a url.
  43919. * @param scene scene loading this url
  43920. * @param url url to load
  43921. * @param onSuccess callback called when the file successfully loads
  43922. * @param onProgress callback called while file is loading (if the server supports this mode)
  43923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43924. * @param onError callback called when the file fails to load
  43925. * @returns a file request object
  43926. */
  43927. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43928. /**
  43929. * The callback called when loading from a file object.
  43930. * @param scene scene loading this file
  43931. * @param file defines the file to load
  43932. * @param onSuccess defines the callback to call when data is loaded
  43933. * @param onProgress defines the callback to call during loading process
  43934. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43935. * @param onError defines the callback to call when an error occurs
  43936. * @returns a file request object
  43937. */
  43938. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43939. /**
  43940. * The callback that returns true if the data can be directly loaded.
  43941. * @param data string containing the file data
  43942. * @returns if the data can be loaded directly
  43943. */
  43944. canDirectLoad?(data: string): boolean;
  43945. /**
  43946. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43947. * @param scene scene loading this data
  43948. * @param data string containing the data
  43949. * @returns data to pass to the plugin
  43950. */
  43951. directLoad?(scene: Scene, data: string): any;
  43952. /**
  43953. * The callback that allows custom handling of the root url based on the response url.
  43954. * @param rootUrl the original root url
  43955. * @param responseURL the response url if available
  43956. * @returns the new root url
  43957. */
  43958. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43959. }
  43960. /**
  43961. * Interface used to define a SceneLoader plugin
  43962. */
  43963. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43964. /**
  43965. * Import meshes into a scene.
  43966. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43967. * @param scene The scene to import into
  43968. * @param data The data to import
  43969. * @param rootUrl The root url for scene and resources
  43970. * @param meshes The meshes array to import into
  43971. * @param particleSystems The particle systems array to import into
  43972. * @param skeletons The skeletons array to import into
  43973. * @param onError The callback when import fails
  43974. * @returns True if successful or false otherwise
  43975. */
  43976. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43977. /**
  43978. * Load into a scene.
  43979. * @param scene The scene to load into
  43980. * @param data The data to import
  43981. * @param rootUrl The root url for scene and resources
  43982. * @param onError The callback when import fails
  43983. * @returns True if successful or false otherwise
  43984. */
  43985. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43986. /**
  43987. * Load into an asset container.
  43988. * @param scene The scene to load into
  43989. * @param data The data to import
  43990. * @param rootUrl The root url for scene and resources
  43991. * @param onError The callback when import fails
  43992. * @returns The loaded asset container
  43993. */
  43994. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43995. }
  43996. /**
  43997. * Interface used to define an async SceneLoader plugin
  43998. */
  43999. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44000. /**
  44001. * Import meshes into a scene.
  44002. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44003. * @param scene The scene to import into
  44004. * @param data The data to import
  44005. * @param rootUrl The root url for scene and resources
  44006. * @param onProgress The callback when the load progresses
  44007. * @param fileName Defines the name of the file to load
  44008. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44009. */
  44010. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44011. meshes: AbstractMesh[];
  44012. particleSystems: IParticleSystem[];
  44013. skeletons: Skeleton[];
  44014. animationGroups: AnimationGroup[];
  44015. }>;
  44016. /**
  44017. * Load into a scene.
  44018. * @param scene The scene to load into
  44019. * @param data The data to import
  44020. * @param rootUrl The root url for scene and resources
  44021. * @param onProgress The callback when the load progresses
  44022. * @param fileName Defines the name of the file to load
  44023. * @returns Nothing
  44024. */
  44025. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44026. /**
  44027. * Load into an asset container.
  44028. * @param scene The scene to load into
  44029. * @param data The data to import
  44030. * @param rootUrl The root url for scene and resources
  44031. * @param onProgress The callback when the load progresses
  44032. * @param fileName Defines the name of the file to load
  44033. * @returns The loaded asset container
  44034. */
  44035. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44036. }
  44037. /**
  44038. * Class used to load scene from various file formats using registered plugins
  44039. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44040. */
  44041. export class SceneLoader {
  44042. /**
  44043. * No logging while loading
  44044. */
  44045. static readonly NO_LOGGING: number;
  44046. /**
  44047. * Minimal logging while loading
  44048. */
  44049. static readonly MINIMAL_LOGGING: number;
  44050. /**
  44051. * Summary logging while loading
  44052. */
  44053. static readonly SUMMARY_LOGGING: number;
  44054. /**
  44055. * Detailled logging while loading
  44056. */
  44057. static readonly DETAILED_LOGGING: number;
  44058. /**
  44059. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44060. */
  44061. static ForceFullSceneLoadingForIncremental: boolean;
  44062. /**
  44063. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44064. */
  44065. static ShowLoadingScreen: boolean;
  44066. /**
  44067. * Defines the current logging level (while loading the scene)
  44068. * @ignorenaming
  44069. */
  44070. static loggingLevel: number;
  44071. /**
  44072. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44073. */
  44074. static CleanBoneMatrixWeights: boolean;
  44075. /**
  44076. * Event raised when a plugin is used to load a scene
  44077. */
  44078. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44079. private static _registeredPlugins;
  44080. private static _getDefaultPlugin;
  44081. private static _getPluginForExtension;
  44082. private static _getPluginForDirectLoad;
  44083. private static _getPluginForFilename;
  44084. private static _getDirectLoad;
  44085. private static _loadData;
  44086. private static _getFileInfo;
  44087. /**
  44088. * Gets a plugin that can load the given extension
  44089. * @param extension defines the extension to load
  44090. * @returns a plugin or null if none works
  44091. */
  44092. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44093. /**
  44094. * Gets a boolean indicating that the given extension can be loaded
  44095. * @param extension defines the extension to load
  44096. * @returns true if the extension is supported
  44097. */
  44098. static IsPluginForExtensionAvailable(extension: string): boolean;
  44099. /**
  44100. * Adds a new plugin to the list of registered plugins
  44101. * @param plugin defines the plugin to add
  44102. */
  44103. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44104. /**
  44105. * Import meshes into a scene
  44106. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44107. * @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)
  44108. * @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)
  44109. * @param scene the instance of BABYLON.Scene to append to
  44110. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44111. * @param onProgress a callback with a progress event for each file being loaded
  44112. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44113. * @param pluginExtension the extension used to determine the plugin
  44114. * @returns The loaded plugin
  44115. */
  44116. 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>;
  44117. /**
  44118. * Import meshes into a scene
  44119. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44120. * @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)
  44121. * @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)
  44122. * @param scene the instance of BABYLON.Scene to append to
  44123. * @param onProgress a callback with a progress event for each file being loaded
  44124. * @param pluginExtension the extension used to determine the plugin
  44125. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44126. */
  44127. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44128. meshes: AbstractMesh[];
  44129. particleSystems: IParticleSystem[];
  44130. skeletons: Skeleton[];
  44131. animationGroups: AnimationGroup[];
  44132. }>;
  44133. /**
  44134. * Load a scene
  44135. * @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)
  44136. * @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)
  44137. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44138. * @param onSuccess a callback with the scene when import succeeds
  44139. * @param onProgress a callback with a progress event for each file being loaded
  44140. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44141. * @param pluginExtension the extension used to determine the plugin
  44142. * @returns The loaded plugin
  44143. */
  44144. 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>;
  44145. /**
  44146. * Load a scene
  44147. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44148. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44149. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44150. * @param onProgress a callback with a progress event for each file being loaded
  44151. * @param pluginExtension the extension used to determine the plugin
  44152. * @returns The loaded scene
  44153. */
  44154. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44155. /**
  44156. * Append a scene
  44157. * @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)
  44158. * @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)
  44159. * @param scene is the instance of BABYLON.Scene to append to
  44160. * @param onSuccess a callback with the scene when import succeeds
  44161. * @param onProgress a callback with a progress event for each file being loaded
  44162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44163. * @param pluginExtension the extension used to determine the plugin
  44164. * @returns The loaded plugin
  44165. */
  44166. 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>;
  44167. /**
  44168. * Append a scene
  44169. * @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)
  44170. * @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)
  44171. * @param scene is the instance of BABYLON.Scene to append to
  44172. * @param onProgress a callback with a progress event for each file being loaded
  44173. * @param pluginExtension the extension used to determine the plugin
  44174. * @returns The given scene
  44175. */
  44176. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44177. /**
  44178. * Load a scene into an asset container
  44179. * @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)
  44180. * @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)
  44181. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44182. * @param onSuccess a callback with the scene when import succeeds
  44183. * @param onProgress a callback with a progress event for each file being loaded
  44184. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44185. * @param pluginExtension the extension used to determine the plugin
  44186. * @returns The loaded plugin
  44187. */
  44188. 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>;
  44189. /**
  44190. * Load a scene into an asset container
  44191. * @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)
  44192. * @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)
  44193. * @param scene is the instance of Scene to append to
  44194. * @param onProgress a callback with a progress event for each file being loaded
  44195. * @param pluginExtension the extension used to determine the plugin
  44196. * @returns The loaded asset container
  44197. */
  44198. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44199. }
  44200. }
  44201. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44202. import { Scene } from "babylonjs/scene";
  44203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44204. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44205. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44206. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44207. /**
  44208. * Generic Controller
  44209. */
  44210. export class GenericController extends WebVRController {
  44211. /**
  44212. * Base Url for the controller model.
  44213. */
  44214. static readonly MODEL_BASE_URL: string;
  44215. /**
  44216. * File name for the controller model.
  44217. */
  44218. static readonly MODEL_FILENAME: string;
  44219. /**
  44220. * Creates a new GenericController from a gamepad
  44221. * @param vrGamepad the gamepad that the controller should be created from
  44222. */
  44223. constructor(vrGamepad: any);
  44224. /**
  44225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44226. * @param scene scene in which to add meshes
  44227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44228. */
  44229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44230. /**
  44231. * Called once for each button that changed state since the last frame
  44232. * @param buttonIdx Which button index changed
  44233. * @param state New state of the button
  44234. * @param changes Which properties on the state changed since last frame
  44235. */
  44236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44237. }
  44238. }
  44239. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44240. import { Observable } from "babylonjs/Misc/observable";
  44241. import { Scene } from "babylonjs/scene";
  44242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44243. import { Ray } from "babylonjs/Culling/ray";
  44244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44246. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44247. /**
  44248. * Defines the WindowsMotionController object that the state of the windows motion controller
  44249. */
  44250. export class WindowsMotionController extends WebVRController {
  44251. /**
  44252. * The base url used to load the left and right controller models
  44253. */
  44254. static MODEL_BASE_URL: string;
  44255. /**
  44256. * The name of the left controller model file
  44257. */
  44258. static MODEL_LEFT_FILENAME: string;
  44259. /**
  44260. * The name of the right controller model file
  44261. */
  44262. static MODEL_RIGHT_FILENAME: string;
  44263. /**
  44264. * The controller name prefix for this controller type
  44265. */
  44266. static readonly GAMEPAD_ID_PREFIX: string;
  44267. /**
  44268. * The controller id pattern for this controller type
  44269. */
  44270. private static readonly GAMEPAD_ID_PATTERN;
  44271. private _loadedMeshInfo;
  44272. private readonly _mapping;
  44273. /**
  44274. * Fired when the trackpad on this controller is clicked
  44275. */
  44276. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44277. /**
  44278. * Fired when the trackpad on this controller is modified
  44279. */
  44280. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44281. /**
  44282. * The current x and y values of this controller's trackpad
  44283. */
  44284. trackpad: StickValues;
  44285. /**
  44286. * Creates a new WindowsMotionController from a gamepad
  44287. * @param vrGamepad the gamepad that the controller should be created from
  44288. */
  44289. constructor(vrGamepad: any);
  44290. /**
  44291. * Fired when the trigger on this controller is modified
  44292. */
  44293. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44294. /**
  44295. * Fired when the menu button on this controller is modified
  44296. */
  44297. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44298. /**
  44299. * Fired when the grip button on this controller is modified
  44300. */
  44301. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44302. /**
  44303. * Fired when the thumbstick button on this controller is modified
  44304. */
  44305. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44306. /**
  44307. * Fired when the touchpad button on this controller is modified
  44308. */
  44309. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44310. /**
  44311. * Fired when the touchpad values on this controller are modified
  44312. */
  44313. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44314. private _updateTrackpad;
  44315. /**
  44316. * Called once per frame by the engine.
  44317. */
  44318. update(): void;
  44319. /**
  44320. * Called once for each button that changed state since the last frame
  44321. * @param buttonIdx Which button index changed
  44322. * @param state New state of the button
  44323. * @param changes Which properties on the state changed since last frame
  44324. */
  44325. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44326. /**
  44327. * Moves the buttons on the controller mesh based on their current state
  44328. * @param buttonName the name of the button to move
  44329. * @param buttonValue the value of the button which determines the buttons new position
  44330. */
  44331. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44332. /**
  44333. * Moves the axis on the controller mesh based on its current state
  44334. * @param axis the index of the axis
  44335. * @param axisValue the value of the axis which determines the meshes new position
  44336. * @hidden
  44337. */
  44338. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44339. /**
  44340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44341. * @param scene scene in which to add meshes
  44342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44343. */
  44344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44345. /**
  44346. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44347. * can be transformed by button presses and axes values, based on this._mapping.
  44348. *
  44349. * @param scene scene in which the meshes exist
  44350. * @param meshes list of meshes that make up the controller model to process
  44351. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44352. */
  44353. private processModel;
  44354. private createMeshInfo;
  44355. /**
  44356. * Gets the ray of the controller in the direction the controller is pointing
  44357. * @param length the length the resulting ray should be
  44358. * @returns a ray in the direction the controller is pointing
  44359. */
  44360. getForwardRay(length?: number): Ray;
  44361. /**
  44362. * Disposes of the controller
  44363. */
  44364. dispose(): void;
  44365. }
  44366. }
  44367. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44368. import { Observable } from "babylonjs/Misc/observable";
  44369. import { Scene } from "babylonjs/scene";
  44370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44371. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44372. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44373. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44374. /**
  44375. * Oculus Touch Controller
  44376. */
  44377. export class OculusTouchController extends WebVRController {
  44378. /**
  44379. * Base Url for the controller model.
  44380. */
  44381. static MODEL_BASE_URL: string;
  44382. /**
  44383. * File name for the left controller model.
  44384. */
  44385. static MODEL_LEFT_FILENAME: string;
  44386. /**
  44387. * File name for the right controller model.
  44388. */
  44389. static MODEL_RIGHT_FILENAME: string;
  44390. /**
  44391. * Base Url for the Quest controller model.
  44392. */
  44393. static QUEST_MODEL_BASE_URL: string;
  44394. /**
  44395. * @hidden
  44396. * If the controllers are running on a device that needs the updated Quest controller models
  44397. */
  44398. static _IsQuest: boolean;
  44399. /**
  44400. * Fired when the secondary trigger on this controller is modified
  44401. */
  44402. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44403. /**
  44404. * Fired when the thumb rest on this controller is modified
  44405. */
  44406. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44407. /**
  44408. * Creates a new OculusTouchController from a gamepad
  44409. * @param vrGamepad the gamepad that the controller should be created from
  44410. */
  44411. constructor(vrGamepad: any);
  44412. /**
  44413. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44414. * @param scene scene in which to add meshes
  44415. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44416. */
  44417. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44418. /**
  44419. * Fired when the A button on this controller is modified
  44420. */
  44421. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44422. /**
  44423. * Fired when the B button on this controller is modified
  44424. */
  44425. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44426. /**
  44427. * Fired when the X button on this controller is modified
  44428. */
  44429. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44430. /**
  44431. * Fired when the Y button on this controller is modified
  44432. */
  44433. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44434. /**
  44435. * Called once for each button that changed state since the last frame
  44436. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44437. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44438. * 2) secondary trigger (same)
  44439. * 3) A (right) X (left), touch, pressed = value
  44440. * 4) B / Y
  44441. * 5) thumb rest
  44442. * @param buttonIdx Which button index changed
  44443. * @param state New state of the button
  44444. * @param changes Which properties on the state changed since last frame
  44445. */
  44446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44447. }
  44448. }
  44449. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44450. import { Scene } from "babylonjs/scene";
  44451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44452. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44453. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44454. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44455. import { Observable } from "babylonjs/Misc/observable";
  44456. /**
  44457. * Vive Controller
  44458. */
  44459. export class ViveController extends WebVRController {
  44460. /**
  44461. * Base Url for the controller model.
  44462. */
  44463. static MODEL_BASE_URL: string;
  44464. /**
  44465. * File name for the controller model.
  44466. */
  44467. static MODEL_FILENAME: string;
  44468. /**
  44469. * Creates a new ViveController from a gamepad
  44470. * @param vrGamepad the gamepad that the controller should be created from
  44471. */
  44472. constructor(vrGamepad: any);
  44473. /**
  44474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44475. * @param scene scene in which to add meshes
  44476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44477. */
  44478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44479. /**
  44480. * Fired when the left button on this controller is modified
  44481. */
  44482. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44483. /**
  44484. * Fired when the right button on this controller is modified
  44485. */
  44486. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44487. /**
  44488. * Fired when the menu button on this controller is modified
  44489. */
  44490. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44491. /**
  44492. * Called once for each button that changed state since the last frame
  44493. * Vive mapping:
  44494. * 0: touchpad
  44495. * 1: trigger
  44496. * 2: left AND right buttons
  44497. * 3: menu button
  44498. * @param buttonIdx Which button index changed
  44499. * @param state New state of the button
  44500. * @param changes Which properties on the state changed since last frame
  44501. */
  44502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44503. }
  44504. }
  44505. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44506. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44507. /**
  44508. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44509. */
  44510. export class WebXRControllerModelLoader {
  44511. /**
  44512. * Creates the WebXRControllerModelLoader
  44513. * @param input xr input that creates the controllers
  44514. */
  44515. constructor(input: WebXRInput);
  44516. }
  44517. }
  44518. declare module "babylonjs/Cameras/XR/index" {
  44519. export * from "babylonjs/Cameras/XR/webXRCamera";
  44520. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44521. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44522. export * from "babylonjs/Cameras/XR/webXRInput";
  44523. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44524. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44525. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44526. export * from "babylonjs/Cameras/XR/webXRController";
  44527. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44528. export * from "babylonjs/Cameras/XR/webXRTypes";
  44529. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44530. }
  44531. declare module "babylonjs/Cameras/RigModes/index" {
  44532. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44533. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44534. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44535. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44536. }
  44537. declare module "babylonjs/Cameras/index" {
  44538. export * from "babylonjs/Cameras/Inputs/index";
  44539. export * from "babylonjs/Cameras/cameraInputsManager";
  44540. export * from "babylonjs/Cameras/camera";
  44541. export * from "babylonjs/Cameras/targetCamera";
  44542. export * from "babylonjs/Cameras/freeCamera";
  44543. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44544. export * from "babylonjs/Cameras/touchCamera";
  44545. export * from "babylonjs/Cameras/arcRotateCamera";
  44546. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44547. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44548. export * from "babylonjs/Cameras/flyCamera";
  44549. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44550. export * from "babylonjs/Cameras/followCamera";
  44551. export * from "babylonjs/Cameras/followCameraInputsManager";
  44552. export * from "babylonjs/Cameras/gamepadCamera";
  44553. export * from "babylonjs/Cameras/Stereoscopic/index";
  44554. export * from "babylonjs/Cameras/universalCamera";
  44555. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44556. export * from "babylonjs/Cameras/VR/index";
  44557. export * from "babylonjs/Cameras/XR/index";
  44558. export * from "babylonjs/Cameras/RigModes/index";
  44559. }
  44560. declare module "babylonjs/Collisions/index" {
  44561. export * from "babylonjs/Collisions/collider";
  44562. export * from "babylonjs/Collisions/collisionCoordinator";
  44563. export * from "babylonjs/Collisions/pickingInfo";
  44564. export * from "babylonjs/Collisions/intersectionInfo";
  44565. export * from "babylonjs/Collisions/meshCollisionData";
  44566. }
  44567. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44568. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44569. import { Vector3 } from "babylonjs/Maths/math.vector";
  44570. import { Ray } from "babylonjs/Culling/ray";
  44571. import { Plane } from "babylonjs/Maths/math.plane";
  44572. /**
  44573. * Contains an array of blocks representing the octree
  44574. */
  44575. export interface IOctreeContainer<T> {
  44576. /**
  44577. * Blocks within the octree
  44578. */
  44579. blocks: Array<OctreeBlock<T>>;
  44580. }
  44581. /**
  44582. * Class used to store a cell in an octree
  44583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44584. */
  44585. export class OctreeBlock<T> {
  44586. /**
  44587. * Gets the content of the current block
  44588. */
  44589. entries: T[];
  44590. /**
  44591. * Gets the list of block children
  44592. */
  44593. blocks: Array<OctreeBlock<T>>;
  44594. private _depth;
  44595. private _maxDepth;
  44596. private _capacity;
  44597. private _minPoint;
  44598. private _maxPoint;
  44599. private _boundingVectors;
  44600. private _creationFunc;
  44601. /**
  44602. * Creates a new block
  44603. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44604. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44605. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44606. * @param depth defines the current depth of this block in the octree
  44607. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44608. * @param creationFunc defines a callback to call when an element is added to the block
  44609. */
  44610. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44611. /**
  44612. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44613. */
  44614. readonly capacity: number;
  44615. /**
  44616. * Gets the minimum vector (in world space) of the block's bounding box
  44617. */
  44618. readonly minPoint: Vector3;
  44619. /**
  44620. * Gets the maximum vector (in world space) of the block's bounding box
  44621. */
  44622. readonly maxPoint: Vector3;
  44623. /**
  44624. * Add a new element to this block
  44625. * @param entry defines the element to add
  44626. */
  44627. addEntry(entry: T): void;
  44628. /**
  44629. * Remove an element from this block
  44630. * @param entry defines the element to remove
  44631. */
  44632. removeEntry(entry: T): void;
  44633. /**
  44634. * Add an array of elements to this block
  44635. * @param entries defines the array of elements to add
  44636. */
  44637. addEntries(entries: T[]): void;
  44638. /**
  44639. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44640. * @param frustumPlanes defines the frustum planes to test
  44641. * @param selection defines the array to store current content if selection is positive
  44642. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44643. */
  44644. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44645. /**
  44646. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44647. * @param sphereCenter defines the bounding sphere center
  44648. * @param sphereRadius defines the bounding sphere radius
  44649. * @param selection defines the array to store current content if selection is positive
  44650. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44651. */
  44652. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44653. /**
  44654. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44655. * @param ray defines the ray to test with
  44656. * @param selection defines the array to store current content if selection is positive
  44657. */
  44658. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44659. /**
  44660. * Subdivide the content into child blocks (this block will then be empty)
  44661. */
  44662. createInnerBlocks(): void;
  44663. /**
  44664. * @hidden
  44665. */
  44666. 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;
  44667. }
  44668. }
  44669. declare module "babylonjs/Culling/Octrees/octree" {
  44670. import { SmartArray } from "babylonjs/Misc/smartArray";
  44671. import { Vector3 } from "babylonjs/Maths/math.vector";
  44672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44674. import { Ray } from "babylonjs/Culling/ray";
  44675. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44676. import { Plane } from "babylonjs/Maths/math.plane";
  44677. /**
  44678. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44679. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44680. */
  44681. export class Octree<T> {
  44682. /** 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.) */
  44683. maxDepth: number;
  44684. /**
  44685. * Blocks within the octree containing objects
  44686. */
  44687. blocks: Array<OctreeBlock<T>>;
  44688. /**
  44689. * Content stored in the octree
  44690. */
  44691. dynamicContent: T[];
  44692. private _maxBlockCapacity;
  44693. private _selectionContent;
  44694. private _creationFunc;
  44695. /**
  44696. * Creates a octree
  44697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44698. * @param creationFunc function to be used to instatiate the octree
  44699. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44700. * @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.)
  44701. */
  44702. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44703. /** 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.) */
  44704. maxDepth?: number);
  44705. /**
  44706. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44707. * @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);
  44708. * @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);
  44709. * @param entries meshes to be added to the octree blocks
  44710. */
  44711. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44712. /**
  44713. * Adds a mesh to the octree
  44714. * @param entry Mesh to add to the octree
  44715. */
  44716. addMesh(entry: T): void;
  44717. /**
  44718. * Remove an element from the octree
  44719. * @param entry defines the element to remove
  44720. */
  44721. removeMesh(entry: T): void;
  44722. /**
  44723. * Selects an array of meshes within the frustum
  44724. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44725. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44726. * @returns array of meshes within the frustum
  44727. */
  44728. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44729. /**
  44730. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44731. * @param sphereCenter defines the bounding sphere center
  44732. * @param sphereRadius defines the bounding sphere radius
  44733. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44734. * @returns an array of objects that intersect the sphere
  44735. */
  44736. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44737. /**
  44738. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44739. * @param ray defines the ray to test with
  44740. * @returns array of intersected objects
  44741. */
  44742. intersectsRay(ray: Ray): SmartArray<T>;
  44743. /**
  44744. * Adds a mesh into the octree block if it intersects the block
  44745. */
  44746. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44747. /**
  44748. * Adds a submesh into the octree block if it intersects the block
  44749. */
  44750. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44751. }
  44752. }
  44753. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44754. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44755. import { Scene } from "babylonjs/scene";
  44756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44758. import { Ray } from "babylonjs/Culling/ray";
  44759. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44760. import { Collider } from "babylonjs/Collisions/collider";
  44761. module "babylonjs/scene" {
  44762. interface Scene {
  44763. /**
  44764. * @hidden
  44765. * Backing Filed
  44766. */
  44767. _selectionOctree: Octree<AbstractMesh>;
  44768. /**
  44769. * Gets the octree used to boost mesh selection (picking)
  44770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44771. */
  44772. selectionOctree: Octree<AbstractMesh>;
  44773. /**
  44774. * Creates or updates the octree used to boost selection (picking)
  44775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44776. * @param maxCapacity defines the maximum capacity per leaf
  44777. * @param maxDepth defines the maximum depth of the octree
  44778. * @returns an octree of AbstractMesh
  44779. */
  44780. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44781. }
  44782. }
  44783. module "babylonjs/Meshes/abstractMesh" {
  44784. interface AbstractMesh {
  44785. /**
  44786. * @hidden
  44787. * Backing Field
  44788. */
  44789. _submeshesOctree: Octree<SubMesh>;
  44790. /**
  44791. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44792. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44793. * @param maxCapacity defines the maximum size of each block (64 by default)
  44794. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44795. * @returns the new octree
  44796. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44797. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44798. */
  44799. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44800. }
  44801. }
  44802. /**
  44803. * Defines the octree scene component responsible to manage any octrees
  44804. * in a given scene.
  44805. */
  44806. export class OctreeSceneComponent {
  44807. /**
  44808. * The component name help to identify the component in the list of scene components.
  44809. */
  44810. readonly name: string;
  44811. /**
  44812. * The scene the component belongs to.
  44813. */
  44814. scene: Scene;
  44815. /**
  44816. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44817. */
  44818. readonly checksIsEnabled: boolean;
  44819. /**
  44820. * Creates a new instance of the component for the given scene
  44821. * @param scene Defines the scene to register the component in
  44822. */
  44823. constructor(scene: Scene);
  44824. /**
  44825. * Registers the component in a given scene
  44826. */
  44827. register(): void;
  44828. /**
  44829. * Return the list of active meshes
  44830. * @returns the list of active meshes
  44831. */
  44832. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44833. /**
  44834. * Return the list of active sub meshes
  44835. * @param mesh The mesh to get the candidates sub meshes from
  44836. * @returns the list of active sub meshes
  44837. */
  44838. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44839. private _tempRay;
  44840. /**
  44841. * Return the list of sub meshes intersecting with a given local ray
  44842. * @param mesh defines the mesh to find the submesh for
  44843. * @param localRay defines the ray in local space
  44844. * @returns the list of intersecting sub meshes
  44845. */
  44846. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44847. /**
  44848. * Return the list of sub meshes colliding with a collider
  44849. * @param mesh defines the mesh to find the submesh for
  44850. * @param collider defines the collider to evaluate the collision against
  44851. * @returns the list of colliding sub meshes
  44852. */
  44853. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44854. /**
  44855. * Rebuilds the elements related to this component in case of
  44856. * context lost for instance.
  44857. */
  44858. rebuild(): void;
  44859. /**
  44860. * Disposes the component and the associated ressources.
  44861. */
  44862. dispose(): void;
  44863. }
  44864. }
  44865. declare module "babylonjs/Culling/Octrees/index" {
  44866. export * from "babylonjs/Culling/Octrees/octree";
  44867. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44868. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44869. }
  44870. declare module "babylonjs/Culling/index" {
  44871. export * from "babylonjs/Culling/boundingBox";
  44872. export * from "babylonjs/Culling/boundingInfo";
  44873. export * from "babylonjs/Culling/boundingSphere";
  44874. export * from "babylonjs/Culling/Octrees/index";
  44875. export * from "babylonjs/Culling/ray";
  44876. }
  44877. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44878. import { IDisposable, Scene } from "babylonjs/scene";
  44879. import { Nullable } from "babylonjs/types";
  44880. import { Observable } from "babylonjs/Misc/observable";
  44881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44882. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44883. import { Camera } from "babylonjs/Cameras/camera";
  44884. /**
  44885. * Renders a layer on top of an existing scene
  44886. */
  44887. export class UtilityLayerRenderer implements IDisposable {
  44888. /** the original scene that will be rendered on top of */
  44889. originalScene: Scene;
  44890. private _pointerCaptures;
  44891. private _lastPointerEvents;
  44892. private static _DefaultUtilityLayer;
  44893. private static _DefaultKeepDepthUtilityLayer;
  44894. private _sharedGizmoLight;
  44895. private _renderCamera;
  44896. /**
  44897. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44898. * @returns the camera that is used when rendering the utility layer
  44899. */
  44900. getRenderCamera(): Nullable<Camera>;
  44901. /**
  44902. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44903. * @param cam the camera that should be used when rendering the utility layer
  44904. */
  44905. setRenderCamera(cam: Nullable<Camera>): void;
  44906. /**
  44907. * @hidden
  44908. * Light which used by gizmos to get light shading
  44909. */
  44910. _getSharedGizmoLight(): HemisphericLight;
  44911. /**
  44912. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44913. */
  44914. pickUtilitySceneFirst: boolean;
  44915. /**
  44916. * 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)
  44917. */
  44918. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44919. /**
  44920. * 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)
  44921. */
  44922. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44923. /**
  44924. * The scene that is rendered on top of the original scene
  44925. */
  44926. utilityLayerScene: Scene;
  44927. /**
  44928. * If the utility layer should automatically be rendered on top of existing scene
  44929. */
  44930. shouldRender: boolean;
  44931. /**
  44932. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44933. */
  44934. onlyCheckPointerDownEvents: boolean;
  44935. /**
  44936. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44937. */
  44938. processAllEvents: boolean;
  44939. /**
  44940. * Observable raised when the pointer move from the utility layer scene to the main scene
  44941. */
  44942. onPointerOutObservable: Observable<number>;
  44943. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44944. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44945. private _afterRenderObserver;
  44946. private _sceneDisposeObserver;
  44947. private _originalPointerObserver;
  44948. /**
  44949. * Instantiates a UtilityLayerRenderer
  44950. * @param originalScene the original scene that will be rendered on top of
  44951. * @param handleEvents boolean indicating if the utility layer should handle events
  44952. */
  44953. constructor(
  44954. /** the original scene that will be rendered on top of */
  44955. originalScene: Scene, handleEvents?: boolean);
  44956. private _notifyObservers;
  44957. /**
  44958. * Renders the utility layers scene on top of the original scene
  44959. */
  44960. render(): void;
  44961. /**
  44962. * Disposes of the renderer
  44963. */
  44964. dispose(): void;
  44965. private _updateCamera;
  44966. }
  44967. }
  44968. declare module "babylonjs/Gizmos/gizmo" {
  44969. import { Nullable } from "babylonjs/types";
  44970. import { IDisposable } from "babylonjs/scene";
  44971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44972. import { Mesh } from "babylonjs/Meshes/mesh";
  44973. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44974. /**
  44975. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44976. */
  44977. export class Gizmo implements IDisposable {
  44978. /** The utility layer the gizmo will be added to */
  44979. gizmoLayer: UtilityLayerRenderer;
  44980. /**
  44981. * The root mesh of the gizmo
  44982. */
  44983. _rootMesh: Mesh;
  44984. private _attachedMesh;
  44985. /**
  44986. * Ratio for the scale of the gizmo (Default: 1)
  44987. */
  44988. scaleRatio: number;
  44989. /**
  44990. * If a custom mesh has been set (Default: false)
  44991. */
  44992. protected _customMeshSet: boolean;
  44993. /**
  44994. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44995. * * When set, interactions will be enabled
  44996. */
  44997. attachedMesh: Nullable<AbstractMesh>;
  44998. /**
  44999. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45000. * @param mesh The mesh to replace the default mesh of the gizmo
  45001. */
  45002. setCustomMesh(mesh: Mesh): void;
  45003. /**
  45004. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45005. */
  45006. updateGizmoRotationToMatchAttachedMesh: boolean;
  45007. /**
  45008. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45009. */
  45010. updateGizmoPositionToMatchAttachedMesh: boolean;
  45011. /**
  45012. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45013. */
  45014. updateScale: boolean;
  45015. protected _interactionsEnabled: boolean;
  45016. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45017. private _beforeRenderObserver;
  45018. private _tempVector;
  45019. /**
  45020. * Creates a gizmo
  45021. * @param gizmoLayer The utility layer the gizmo will be added to
  45022. */
  45023. constructor(
  45024. /** The utility layer the gizmo will be added to */
  45025. gizmoLayer?: UtilityLayerRenderer);
  45026. /**
  45027. * Updates the gizmo to match the attached mesh's position/rotation
  45028. */
  45029. protected _update(): void;
  45030. /**
  45031. * Disposes of the gizmo
  45032. */
  45033. dispose(): void;
  45034. }
  45035. }
  45036. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45037. import { Observable } from "babylonjs/Misc/observable";
  45038. import { Nullable } from "babylonjs/types";
  45039. import { Vector3 } from "babylonjs/Maths/math.vector";
  45040. import { Color3 } from "babylonjs/Maths/math.color";
  45041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45043. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45044. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45045. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45046. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45047. import { Scene } from "babylonjs/scene";
  45048. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45049. /**
  45050. * Single plane drag gizmo
  45051. */
  45052. export class PlaneDragGizmo extends Gizmo {
  45053. /**
  45054. * Drag behavior responsible for the gizmos dragging interactions
  45055. */
  45056. dragBehavior: PointerDragBehavior;
  45057. private _pointerObserver;
  45058. /**
  45059. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45060. */
  45061. snapDistance: number;
  45062. /**
  45063. * Event that fires each time the gizmo snaps to a new location.
  45064. * * snapDistance is the the change in distance
  45065. */
  45066. onSnapObservable: Observable<{
  45067. snapDistance: number;
  45068. }>;
  45069. private _plane;
  45070. private _coloredMaterial;
  45071. private _hoverMaterial;
  45072. private _isEnabled;
  45073. private _parent;
  45074. /** @hidden */
  45075. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45076. /** @hidden */
  45077. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45078. /**
  45079. * Creates a PlaneDragGizmo
  45080. * @param gizmoLayer The utility layer the gizmo will be added to
  45081. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45082. * @param color The color of the gizmo
  45083. */
  45084. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45085. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45086. /**
  45087. * If the gizmo is enabled
  45088. */
  45089. isEnabled: boolean;
  45090. /**
  45091. * Disposes of the gizmo
  45092. */
  45093. dispose(): void;
  45094. }
  45095. }
  45096. declare module "babylonjs/Gizmos/positionGizmo" {
  45097. import { Observable } from "babylonjs/Misc/observable";
  45098. import { Nullable } from "babylonjs/types";
  45099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45100. import { Mesh } from "babylonjs/Meshes/mesh";
  45101. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45102. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45103. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45104. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45105. /**
  45106. * Gizmo that enables dragging a mesh along 3 axis
  45107. */
  45108. export class PositionGizmo extends Gizmo {
  45109. /**
  45110. * Internal gizmo used for interactions on the x axis
  45111. */
  45112. xGizmo: AxisDragGizmo;
  45113. /**
  45114. * Internal gizmo used for interactions on the y axis
  45115. */
  45116. yGizmo: AxisDragGizmo;
  45117. /**
  45118. * Internal gizmo used for interactions on the z axis
  45119. */
  45120. zGizmo: AxisDragGizmo;
  45121. /**
  45122. * Internal gizmo used for interactions on the yz plane
  45123. */
  45124. xPlaneGizmo: PlaneDragGizmo;
  45125. /**
  45126. * Internal gizmo used for interactions on the xz plane
  45127. */
  45128. yPlaneGizmo: PlaneDragGizmo;
  45129. /**
  45130. * Internal gizmo used for interactions on the xy plane
  45131. */
  45132. zPlaneGizmo: PlaneDragGizmo;
  45133. /**
  45134. * private variables
  45135. */
  45136. private _meshAttached;
  45137. private _updateGizmoRotationToMatchAttachedMesh;
  45138. private _snapDistance;
  45139. private _scaleRatio;
  45140. /** Fires an event when any of it's sub gizmos are dragged */
  45141. onDragStartObservable: Observable<unknown>;
  45142. /** Fires an event when any of it's sub gizmos are released from dragging */
  45143. onDragEndObservable: Observable<unknown>;
  45144. /**
  45145. * If set to true, planar drag is enabled
  45146. */
  45147. private _planarGizmoEnabled;
  45148. attachedMesh: Nullable<AbstractMesh>;
  45149. /**
  45150. * Creates a PositionGizmo
  45151. * @param gizmoLayer The utility layer the gizmo will be added to
  45152. */
  45153. constructor(gizmoLayer?: UtilityLayerRenderer);
  45154. /**
  45155. * If the planar drag gizmo is enabled
  45156. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45157. */
  45158. planarGizmoEnabled: boolean;
  45159. updateGizmoRotationToMatchAttachedMesh: boolean;
  45160. /**
  45161. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45162. */
  45163. snapDistance: number;
  45164. /**
  45165. * Ratio for the scale of the gizmo (Default: 1)
  45166. */
  45167. scaleRatio: number;
  45168. /**
  45169. * Disposes of the gizmo
  45170. */
  45171. dispose(): void;
  45172. /**
  45173. * CustomMeshes are not supported by this gizmo
  45174. * @param mesh The mesh to replace the default mesh of the gizmo
  45175. */
  45176. setCustomMesh(mesh: Mesh): void;
  45177. }
  45178. }
  45179. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45180. import { Observable } from "babylonjs/Misc/observable";
  45181. import { Nullable } from "babylonjs/types";
  45182. import { Vector3 } from "babylonjs/Maths/math.vector";
  45183. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45185. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45186. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45187. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45188. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45189. import { Scene } from "babylonjs/scene";
  45190. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45191. import { Color3 } from "babylonjs/Maths/math.color";
  45192. /**
  45193. * Single axis drag gizmo
  45194. */
  45195. export class AxisDragGizmo extends Gizmo {
  45196. /**
  45197. * Drag behavior responsible for the gizmos dragging interactions
  45198. */
  45199. dragBehavior: PointerDragBehavior;
  45200. private _pointerObserver;
  45201. /**
  45202. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45203. */
  45204. snapDistance: number;
  45205. /**
  45206. * Event that fires each time the gizmo snaps to a new location.
  45207. * * snapDistance is the the change in distance
  45208. */
  45209. onSnapObservable: Observable<{
  45210. snapDistance: number;
  45211. }>;
  45212. private _isEnabled;
  45213. private _parent;
  45214. private _arrow;
  45215. private _coloredMaterial;
  45216. private _hoverMaterial;
  45217. /** @hidden */
  45218. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45219. /** @hidden */
  45220. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45221. /**
  45222. * Creates an AxisDragGizmo
  45223. * @param gizmoLayer The utility layer the gizmo will be added to
  45224. * @param dragAxis The axis which the gizmo will be able to drag on
  45225. * @param color The color of the gizmo
  45226. */
  45227. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45228. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45229. /**
  45230. * If the gizmo is enabled
  45231. */
  45232. isEnabled: boolean;
  45233. /**
  45234. * Disposes of the gizmo
  45235. */
  45236. dispose(): void;
  45237. }
  45238. }
  45239. declare module "babylonjs/Debug/axesViewer" {
  45240. import { Vector3 } from "babylonjs/Maths/math.vector";
  45241. import { Nullable } from "babylonjs/types";
  45242. import { Scene } from "babylonjs/scene";
  45243. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45244. /**
  45245. * The Axes viewer will show 3 axes in a specific point in space
  45246. */
  45247. export class AxesViewer {
  45248. private _xAxis;
  45249. private _yAxis;
  45250. private _zAxis;
  45251. private _scaleLinesFactor;
  45252. private _instanced;
  45253. /**
  45254. * Gets the hosting scene
  45255. */
  45256. scene: Scene;
  45257. /**
  45258. * Gets or sets a number used to scale line length
  45259. */
  45260. scaleLines: number;
  45261. /** Gets the node hierarchy used to render x-axis */
  45262. readonly xAxis: TransformNode;
  45263. /** Gets the node hierarchy used to render y-axis */
  45264. readonly yAxis: TransformNode;
  45265. /** Gets the node hierarchy used to render z-axis */
  45266. readonly zAxis: TransformNode;
  45267. /**
  45268. * Creates a new AxesViewer
  45269. * @param scene defines the hosting scene
  45270. * @param scaleLines defines a number used to scale line length (1 by default)
  45271. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45272. * @param xAxis defines the node hierarchy used to render the x-axis
  45273. * @param yAxis defines the node hierarchy used to render the y-axis
  45274. * @param zAxis defines the node hierarchy used to render the z-axis
  45275. */
  45276. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45277. /**
  45278. * Force the viewer to update
  45279. * @param position defines the position of the viewer
  45280. * @param xaxis defines the x axis of the viewer
  45281. * @param yaxis defines the y axis of the viewer
  45282. * @param zaxis defines the z axis of the viewer
  45283. */
  45284. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45285. /**
  45286. * Creates an instance of this axes viewer.
  45287. * @returns a new axes viewer with instanced meshes
  45288. */
  45289. createInstance(): AxesViewer;
  45290. /** Releases resources */
  45291. dispose(): void;
  45292. private static _SetRenderingGroupId;
  45293. }
  45294. }
  45295. declare module "babylonjs/Debug/boneAxesViewer" {
  45296. import { Nullable } from "babylonjs/types";
  45297. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45298. import { Vector3 } from "babylonjs/Maths/math.vector";
  45299. import { Mesh } from "babylonjs/Meshes/mesh";
  45300. import { Bone } from "babylonjs/Bones/bone";
  45301. import { Scene } from "babylonjs/scene";
  45302. /**
  45303. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45304. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45305. */
  45306. export class BoneAxesViewer extends AxesViewer {
  45307. /**
  45308. * Gets or sets the target mesh where to display the axes viewer
  45309. */
  45310. mesh: Nullable<Mesh>;
  45311. /**
  45312. * Gets or sets the target bone where to display the axes viewer
  45313. */
  45314. bone: Nullable<Bone>;
  45315. /** Gets current position */
  45316. pos: Vector3;
  45317. /** Gets direction of X axis */
  45318. xaxis: Vector3;
  45319. /** Gets direction of Y axis */
  45320. yaxis: Vector3;
  45321. /** Gets direction of Z axis */
  45322. zaxis: Vector3;
  45323. /**
  45324. * Creates a new BoneAxesViewer
  45325. * @param scene defines the hosting scene
  45326. * @param bone defines the target bone
  45327. * @param mesh defines the target mesh
  45328. * @param scaleLines defines a scaling factor for line length (1 by default)
  45329. */
  45330. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45331. /**
  45332. * Force the viewer to update
  45333. */
  45334. update(): void;
  45335. /** Releases resources */
  45336. dispose(): void;
  45337. }
  45338. }
  45339. declare module "babylonjs/Debug/debugLayer" {
  45340. import { Scene } from "babylonjs/scene";
  45341. /**
  45342. * Interface used to define scene explorer extensibility option
  45343. */
  45344. export interface IExplorerExtensibilityOption {
  45345. /**
  45346. * Define the option label
  45347. */
  45348. label: string;
  45349. /**
  45350. * Defines the action to execute on click
  45351. */
  45352. action: (entity: any) => void;
  45353. }
  45354. /**
  45355. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45356. */
  45357. export interface IExplorerExtensibilityGroup {
  45358. /**
  45359. * Defines a predicate to test if a given type mut be extended
  45360. */
  45361. predicate: (entity: any) => boolean;
  45362. /**
  45363. * Gets the list of options added to a type
  45364. */
  45365. entries: IExplorerExtensibilityOption[];
  45366. }
  45367. /**
  45368. * Interface used to define the options to use to create the Inspector
  45369. */
  45370. export interface IInspectorOptions {
  45371. /**
  45372. * Display in overlay mode (default: false)
  45373. */
  45374. overlay?: boolean;
  45375. /**
  45376. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45377. */
  45378. globalRoot?: HTMLElement;
  45379. /**
  45380. * Display the Scene explorer
  45381. */
  45382. showExplorer?: boolean;
  45383. /**
  45384. * Display the property inspector
  45385. */
  45386. showInspector?: boolean;
  45387. /**
  45388. * Display in embed mode (both panes on the right)
  45389. */
  45390. embedMode?: boolean;
  45391. /**
  45392. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45393. */
  45394. handleResize?: boolean;
  45395. /**
  45396. * Allow the panes to popup (default: true)
  45397. */
  45398. enablePopup?: boolean;
  45399. /**
  45400. * Allow the panes to be closed by users (default: true)
  45401. */
  45402. enableClose?: boolean;
  45403. /**
  45404. * Optional list of extensibility entries
  45405. */
  45406. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45407. /**
  45408. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45409. */
  45410. inspectorURL?: string;
  45411. }
  45412. module "babylonjs/scene" {
  45413. interface Scene {
  45414. /**
  45415. * @hidden
  45416. * Backing field
  45417. */
  45418. _debugLayer: DebugLayer;
  45419. /**
  45420. * Gets the debug layer (aka Inspector) associated with the scene
  45421. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45422. */
  45423. debugLayer: DebugLayer;
  45424. }
  45425. }
  45426. /**
  45427. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45428. * what is happening in your scene
  45429. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45430. */
  45431. export class DebugLayer {
  45432. /**
  45433. * Define the url to get the inspector script from.
  45434. * By default it uses the babylonjs CDN.
  45435. * @ignoreNaming
  45436. */
  45437. static InspectorURL: string;
  45438. private _scene;
  45439. private BJSINSPECTOR;
  45440. private _onPropertyChangedObservable?;
  45441. /**
  45442. * Observable triggered when a property is changed through the inspector.
  45443. */
  45444. readonly onPropertyChangedObservable: any;
  45445. /**
  45446. * Instantiates a new debug layer.
  45447. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45448. * what is happening in your scene
  45449. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45450. * @param scene Defines the scene to inspect
  45451. */
  45452. constructor(scene: Scene);
  45453. /** Creates the inspector window. */
  45454. private _createInspector;
  45455. /**
  45456. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45457. * @param entity defines the entity to select
  45458. * @param lineContainerTitle defines the specific block to highlight
  45459. */
  45460. select(entity: any, lineContainerTitle?: string): void;
  45461. /** Get the inspector from bundle or global */
  45462. private _getGlobalInspector;
  45463. /**
  45464. * Get if the inspector is visible or not.
  45465. * @returns true if visible otherwise, false
  45466. */
  45467. isVisible(): boolean;
  45468. /**
  45469. * Hide the inspector and close its window.
  45470. */
  45471. hide(): void;
  45472. /**
  45473. * Launch the debugLayer.
  45474. * @param config Define the configuration of the inspector
  45475. * @return a promise fulfilled when the debug layer is visible
  45476. */
  45477. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45478. }
  45479. }
  45480. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45481. import { Nullable } from "babylonjs/types";
  45482. import { Scene } from "babylonjs/scene";
  45483. import { Vector4 } from "babylonjs/Maths/math.vector";
  45484. import { Color4 } from "babylonjs/Maths/math.color";
  45485. import { Mesh } from "babylonjs/Meshes/mesh";
  45486. /**
  45487. * Class containing static functions to help procedurally build meshes
  45488. */
  45489. export class BoxBuilder {
  45490. /**
  45491. * Creates a box mesh
  45492. * * The parameter `size` sets the size (float) of each box side (default 1)
  45493. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45494. * * 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)
  45495. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45499. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45500. * @param name defines the name of the mesh
  45501. * @param options defines the options used to create the mesh
  45502. * @param scene defines the hosting scene
  45503. * @returns the box mesh
  45504. */
  45505. static CreateBox(name: string, options: {
  45506. size?: number;
  45507. width?: number;
  45508. height?: number;
  45509. depth?: number;
  45510. faceUV?: Vector4[];
  45511. faceColors?: Color4[];
  45512. sideOrientation?: number;
  45513. frontUVs?: Vector4;
  45514. backUVs?: Vector4;
  45515. wrap?: boolean;
  45516. topBaseAt?: number;
  45517. bottomBaseAt?: number;
  45518. updatable?: boolean;
  45519. }, scene?: Nullable<Scene>): Mesh;
  45520. }
  45521. }
  45522. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45523. import { Vector4 } from "babylonjs/Maths/math.vector";
  45524. import { Mesh } from "babylonjs/Meshes/mesh";
  45525. import { Scene } from "babylonjs/scene";
  45526. import { Nullable } from "babylonjs/types";
  45527. /**
  45528. * Class containing static functions to help procedurally build meshes
  45529. */
  45530. export class SphereBuilder {
  45531. /**
  45532. * Creates a sphere mesh
  45533. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45534. * * 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`)
  45535. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45536. * * 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
  45537. * * 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)
  45538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45541. * @param name defines the name of the mesh
  45542. * @param options defines the options used to create the mesh
  45543. * @param scene defines the hosting scene
  45544. * @returns the sphere mesh
  45545. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45546. */
  45547. static CreateSphere(name: string, options: {
  45548. segments?: number;
  45549. diameter?: number;
  45550. diameterX?: number;
  45551. diameterY?: number;
  45552. diameterZ?: number;
  45553. arc?: number;
  45554. slice?: number;
  45555. sideOrientation?: number;
  45556. frontUVs?: Vector4;
  45557. backUVs?: Vector4;
  45558. updatable?: boolean;
  45559. }, scene?: Nullable<Scene>): Mesh;
  45560. }
  45561. }
  45562. declare module "babylonjs/Debug/physicsViewer" {
  45563. import { Nullable } from "babylonjs/types";
  45564. import { Scene } from "babylonjs/scene";
  45565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45566. import { Mesh } from "babylonjs/Meshes/mesh";
  45567. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45568. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45569. /**
  45570. * Used to show the physics impostor around the specific mesh
  45571. */
  45572. export class PhysicsViewer {
  45573. /** @hidden */
  45574. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45575. /** @hidden */
  45576. protected _meshes: Array<Nullable<AbstractMesh>>;
  45577. /** @hidden */
  45578. protected _scene: Nullable<Scene>;
  45579. /** @hidden */
  45580. protected _numMeshes: number;
  45581. /** @hidden */
  45582. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45583. private _renderFunction;
  45584. private _utilityLayer;
  45585. private _debugBoxMesh;
  45586. private _debugSphereMesh;
  45587. private _debugCylinderMesh;
  45588. private _debugMaterial;
  45589. private _debugMeshMeshes;
  45590. /**
  45591. * Creates a new PhysicsViewer
  45592. * @param scene defines the hosting scene
  45593. */
  45594. constructor(scene: Scene);
  45595. /** @hidden */
  45596. protected _updateDebugMeshes(): void;
  45597. /**
  45598. * Renders a specified physic impostor
  45599. * @param impostor defines the impostor to render
  45600. * @param targetMesh defines the mesh represented by the impostor
  45601. * @returns the new debug mesh used to render the impostor
  45602. */
  45603. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45604. /**
  45605. * Hides a specified physic impostor
  45606. * @param impostor defines the impostor to hide
  45607. */
  45608. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45609. private _getDebugMaterial;
  45610. private _getDebugBoxMesh;
  45611. private _getDebugSphereMesh;
  45612. private _getDebugCylinderMesh;
  45613. private _getDebugMeshMesh;
  45614. private _getDebugMesh;
  45615. /** Releases all resources */
  45616. dispose(): void;
  45617. }
  45618. }
  45619. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45620. import { Vector3 } from "babylonjs/Maths/math.vector";
  45621. import { Color4 } from "babylonjs/Maths/math.color";
  45622. import { Nullable } from "babylonjs/types";
  45623. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45624. import { Scene } from "babylonjs/scene";
  45625. /**
  45626. * Class containing static functions to help procedurally build meshes
  45627. */
  45628. export class LinesBuilder {
  45629. /**
  45630. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45631. * * 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
  45632. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45633. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45634. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45635. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45636. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45637. * * 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
  45638. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45641. * @param name defines the name of the new line system
  45642. * @param options defines the options used to create the line system
  45643. * @param scene defines the hosting scene
  45644. * @returns a new line system mesh
  45645. */
  45646. static CreateLineSystem(name: string, options: {
  45647. lines: Vector3[][];
  45648. updatable?: boolean;
  45649. instance?: Nullable<LinesMesh>;
  45650. colors?: Nullable<Color4[][]>;
  45651. useVertexAlpha?: boolean;
  45652. }, scene: Nullable<Scene>): LinesMesh;
  45653. /**
  45654. * Creates a line mesh
  45655. * 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
  45656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45657. * * The parameter `points` is an array successive Vector3
  45658. * * 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
  45659. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45660. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45661. * * When updating an instance, remember that only point positions can change, not the number of points
  45662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45664. * @param name defines the name of the new line system
  45665. * @param options defines the options used to create the line system
  45666. * @param scene defines the hosting scene
  45667. * @returns a new line mesh
  45668. */
  45669. static CreateLines(name: string, options: {
  45670. points: Vector3[];
  45671. updatable?: boolean;
  45672. instance?: Nullable<LinesMesh>;
  45673. colors?: Color4[];
  45674. useVertexAlpha?: boolean;
  45675. }, scene?: Nullable<Scene>): LinesMesh;
  45676. /**
  45677. * Creates a dashed line mesh
  45678. * * 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
  45679. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45680. * * The parameter `points` is an array successive Vector3
  45681. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45682. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45683. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45684. * * 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
  45685. * * When updating an instance, remember that only point positions can change, not the number of points
  45686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45687. * @param name defines the name of the mesh
  45688. * @param options defines the options used to create the mesh
  45689. * @param scene defines the hosting scene
  45690. * @returns the dashed line mesh
  45691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45692. */
  45693. static CreateDashedLines(name: string, options: {
  45694. points: Vector3[];
  45695. dashSize?: number;
  45696. gapSize?: number;
  45697. dashNb?: number;
  45698. updatable?: boolean;
  45699. instance?: LinesMesh;
  45700. }, scene?: Nullable<Scene>): LinesMesh;
  45701. }
  45702. }
  45703. declare module "babylonjs/Debug/rayHelper" {
  45704. import { Nullable } from "babylonjs/types";
  45705. import { Ray } from "babylonjs/Culling/ray";
  45706. import { Vector3 } from "babylonjs/Maths/math.vector";
  45707. import { Color3 } from "babylonjs/Maths/math.color";
  45708. import { Scene } from "babylonjs/scene";
  45709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45710. import "babylonjs/Meshes/Builders/linesBuilder";
  45711. /**
  45712. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45713. * in order to better appreciate the issue one might have.
  45714. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45715. */
  45716. export class RayHelper {
  45717. /**
  45718. * Defines the ray we are currently tryin to visualize.
  45719. */
  45720. ray: Nullable<Ray>;
  45721. private _renderPoints;
  45722. private _renderLine;
  45723. private _renderFunction;
  45724. private _scene;
  45725. private _updateToMeshFunction;
  45726. private _attachedToMesh;
  45727. private _meshSpaceDirection;
  45728. private _meshSpaceOrigin;
  45729. /**
  45730. * Helper function to create a colored helper in a scene in one line.
  45731. * @param ray Defines the ray we are currently tryin to visualize
  45732. * @param scene Defines the scene the ray is used in
  45733. * @param color Defines the color we want to see the ray in
  45734. * @returns The newly created ray helper.
  45735. */
  45736. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45737. /**
  45738. * Instantiate a new ray helper.
  45739. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45740. * in order to better appreciate the issue one might have.
  45741. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45742. * @param ray Defines the ray we are currently tryin to visualize
  45743. */
  45744. constructor(ray: Ray);
  45745. /**
  45746. * Shows the ray we are willing to debug.
  45747. * @param scene Defines the scene the ray needs to be rendered in
  45748. * @param color Defines the color the ray needs to be rendered in
  45749. */
  45750. show(scene: Scene, color?: Color3): void;
  45751. /**
  45752. * Hides the ray we are debugging.
  45753. */
  45754. hide(): void;
  45755. private _render;
  45756. /**
  45757. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45758. * @param mesh Defines the mesh we want the helper attached to
  45759. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45760. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45761. * @param length Defines the length of the ray
  45762. */
  45763. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45764. /**
  45765. * Detach the ray helper from the mesh it has previously been attached to.
  45766. */
  45767. detachFromMesh(): void;
  45768. private _updateToMesh;
  45769. /**
  45770. * Dispose the helper and release its associated resources.
  45771. */
  45772. dispose(): void;
  45773. }
  45774. }
  45775. declare module "babylonjs/Debug/skeletonViewer" {
  45776. import { Color3 } from "babylonjs/Maths/math.color";
  45777. import { Scene } from "babylonjs/scene";
  45778. import { Nullable } from "babylonjs/types";
  45779. import { Skeleton } from "babylonjs/Bones/skeleton";
  45780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45781. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45782. /**
  45783. * Class used to render a debug view of a given skeleton
  45784. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45785. */
  45786. export class SkeletonViewer {
  45787. /** defines the skeleton to render */
  45788. skeleton: Skeleton;
  45789. /** defines the mesh attached to the skeleton */
  45790. mesh: AbstractMesh;
  45791. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45792. autoUpdateBonesMatrices: boolean;
  45793. /** defines the rendering group id to use with the viewer */
  45794. renderingGroupId: number;
  45795. /** Gets or sets the color used to render the skeleton */
  45796. color: Color3;
  45797. private _scene;
  45798. private _debugLines;
  45799. private _debugMesh;
  45800. private _isEnabled;
  45801. private _renderFunction;
  45802. private _utilityLayer;
  45803. /**
  45804. * Returns the mesh used to render the bones
  45805. */
  45806. readonly debugMesh: Nullable<LinesMesh>;
  45807. /**
  45808. * Creates a new SkeletonViewer
  45809. * @param skeleton defines the skeleton to render
  45810. * @param mesh defines the mesh attached to the skeleton
  45811. * @param scene defines the hosting scene
  45812. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45813. * @param renderingGroupId defines the rendering group id to use with the viewer
  45814. */
  45815. constructor(
  45816. /** defines the skeleton to render */
  45817. skeleton: Skeleton,
  45818. /** defines the mesh attached to the skeleton */
  45819. mesh: AbstractMesh, scene: Scene,
  45820. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45821. autoUpdateBonesMatrices?: boolean,
  45822. /** defines the rendering group id to use with the viewer */
  45823. renderingGroupId?: number);
  45824. /** Gets or sets a boolean indicating if the viewer is enabled */
  45825. isEnabled: boolean;
  45826. private _getBonePosition;
  45827. private _getLinesForBonesWithLength;
  45828. private _getLinesForBonesNoLength;
  45829. /** Update the viewer to sync with current skeleton state */
  45830. update(): void;
  45831. /** Release associated resources */
  45832. dispose(): void;
  45833. }
  45834. }
  45835. declare module "babylonjs/Debug/index" {
  45836. export * from "babylonjs/Debug/axesViewer";
  45837. export * from "babylonjs/Debug/boneAxesViewer";
  45838. export * from "babylonjs/Debug/debugLayer";
  45839. export * from "babylonjs/Debug/physicsViewer";
  45840. export * from "babylonjs/Debug/rayHelper";
  45841. export * from "babylonjs/Debug/skeletonViewer";
  45842. }
  45843. declare module "babylonjs/Engines/nullEngine" {
  45844. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45845. import { Scene } from "babylonjs/scene";
  45846. import { Engine } from "babylonjs/Engines/engine";
  45847. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45848. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45850. import { Effect } from "babylonjs/Materials/effect";
  45851. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45852. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45853. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45854. /**
  45855. * Options to create the null engine
  45856. */
  45857. export class NullEngineOptions {
  45858. /**
  45859. * Render width (Default: 512)
  45860. */
  45861. renderWidth: number;
  45862. /**
  45863. * Render height (Default: 256)
  45864. */
  45865. renderHeight: number;
  45866. /**
  45867. * Texture size (Default: 512)
  45868. */
  45869. textureSize: number;
  45870. /**
  45871. * If delta time between frames should be constant
  45872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45873. */
  45874. deterministicLockstep: boolean;
  45875. /**
  45876. * Maximum about of steps between frames (Default: 4)
  45877. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45878. */
  45879. lockstepMaxSteps: number;
  45880. }
  45881. /**
  45882. * The null engine class provides support for headless version of babylon.js.
  45883. * This can be used in server side scenario or for testing purposes
  45884. */
  45885. export class NullEngine extends Engine {
  45886. private _options;
  45887. /**
  45888. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45889. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45890. * @returns true if engine is in deterministic lock step mode
  45891. */
  45892. isDeterministicLockStep(): boolean;
  45893. /**
  45894. * Gets the max steps when engine is running in deterministic lock step
  45895. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45896. * @returns the max steps
  45897. */
  45898. getLockstepMaxSteps(): number;
  45899. /**
  45900. * Gets the current hardware scaling level.
  45901. * By default the hardware scaling level is computed from the window device ratio.
  45902. * 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.
  45903. * @returns a number indicating the current hardware scaling level
  45904. */
  45905. getHardwareScalingLevel(): number;
  45906. constructor(options?: NullEngineOptions);
  45907. /**
  45908. * Creates a vertex buffer
  45909. * @param vertices the data for the vertex buffer
  45910. * @returns the new WebGL static buffer
  45911. */
  45912. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45913. /**
  45914. * Creates a new index buffer
  45915. * @param indices defines the content of the index buffer
  45916. * @param updatable defines if the index buffer must be updatable
  45917. * @returns a new webGL buffer
  45918. */
  45919. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45920. /**
  45921. * Clear the current render buffer or the current render target (if any is set up)
  45922. * @param color defines the color to use
  45923. * @param backBuffer defines if the back buffer must be cleared
  45924. * @param depth defines if the depth buffer must be cleared
  45925. * @param stencil defines if the stencil buffer must be cleared
  45926. */
  45927. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45928. /**
  45929. * Gets the current render width
  45930. * @param useScreen defines if screen size must be used (or the current render target if any)
  45931. * @returns a number defining the current render width
  45932. */
  45933. getRenderWidth(useScreen?: boolean): number;
  45934. /**
  45935. * Gets the current render height
  45936. * @param useScreen defines if screen size must be used (or the current render target if any)
  45937. * @returns a number defining the current render height
  45938. */
  45939. getRenderHeight(useScreen?: boolean): number;
  45940. /**
  45941. * Set the WebGL's viewport
  45942. * @param viewport defines the viewport element to be used
  45943. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45944. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45945. */
  45946. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45947. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45948. /**
  45949. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45950. * @param pipelineContext defines the pipeline context to use
  45951. * @param uniformsNames defines the list of uniform names
  45952. * @returns an array of webGL uniform locations
  45953. */
  45954. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45955. /**
  45956. * Gets the lsit of active attributes for a given webGL program
  45957. * @param pipelineContext defines the pipeline context to use
  45958. * @param attributesNames defines the list of attribute names to get
  45959. * @returns an array of indices indicating the offset of each attribute
  45960. */
  45961. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45962. /**
  45963. * Binds an effect to the webGL context
  45964. * @param effect defines the effect to bind
  45965. */
  45966. bindSamplers(effect: Effect): void;
  45967. /**
  45968. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45969. * @param effect defines the effect to activate
  45970. */
  45971. enableEffect(effect: Effect): void;
  45972. /**
  45973. * Set various states to the webGL context
  45974. * @param culling defines backface culling state
  45975. * @param zOffset defines the value to apply to zOffset (0 by default)
  45976. * @param force defines if states must be applied even if cache is up to date
  45977. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45978. */
  45979. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45980. /**
  45981. * Set the value of an uniform to an array of int32
  45982. * @param uniform defines the webGL uniform location where to store the value
  45983. * @param array defines the array of int32 to store
  45984. */
  45985. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45986. /**
  45987. * Set the value of an uniform to an array of int32 (stored as vec2)
  45988. * @param uniform defines the webGL uniform location where to store the value
  45989. * @param array defines the array of int32 to store
  45990. */
  45991. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45992. /**
  45993. * Set the value of an uniform to an array of int32 (stored as vec3)
  45994. * @param uniform defines the webGL uniform location where to store the value
  45995. * @param array defines the array of int32 to store
  45996. */
  45997. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45998. /**
  45999. * Set the value of an uniform to an array of int32 (stored as vec4)
  46000. * @param uniform defines the webGL uniform location where to store the value
  46001. * @param array defines the array of int32 to store
  46002. */
  46003. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46004. /**
  46005. * Set the value of an uniform to an array of float32
  46006. * @param uniform defines the webGL uniform location where to store the value
  46007. * @param array defines the array of float32 to store
  46008. */
  46009. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46010. /**
  46011. * Set the value of an uniform to an array of float32 (stored as vec2)
  46012. * @param uniform defines the webGL uniform location where to store the value
  46013. * @param array defines the array of float32 to store
  46014. */
  46015. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46016. /**
  46017. * Set the value of an uniform to an array of float32 (stored as vec3)
  46018. * @param uniform defines the webGL uniform location where to store the value
  46019. * @param array defines the array of float32 to store
  46020. */
  46021. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46022. /**
  46023. * Set the value of an uniform to an array of float32 (stored as vec4)
  46024. * @param uniform defines the webGL uniform location where to store the value
  46025. * @param array defines the array of float32 to store
  46026. */
  46027. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46028. /**
  46029. * Set the value of an uniform to an array of number
  46030. * @param uniform defines the webGL uniform location where to store the value
  46031. * @param array defines the array of number to store
  46032. */
  46033. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46034. /**
  46035. * Set the value of an uniform to an array of number (stored as vec2)
  46036. * @param uniform defines the webGL uniform location where to store the value
  46037. * @param array defines the array of number to store
  46038. */
  46039. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46040. /**
  46041. * Set the value of an uniform to an array of number (stored as vec3)
  46042. * @param uniform defines the webGL uniform location where to store the value
  46043. * @param array defines the array of number to store
  46044. */
  46045. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46046. /**
  46047. * Set the value of an uniform to an array of number (stored as vec4)
  46048. * @param uniform defines the webGL uniform location where to store the value
  46049. * @param array defines the array of number to store
  46050. */
  46051. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46052. /**
  46053. * Set the value of an uniform to an array of float32 (stored as matrices)
  46054. * @param uniform defines the webGL uniform location where to store the value
  46055. * @param matrices defines the array of float32 to store
  46056. */
  46057. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46058. /**
  46059. * Set the value of an uniform to a matrix (3x3)
  46060. * @param uniform defines the webGL uniform location where to store the value
  46061. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46062. */
  46063. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46064. /**
  46065. * Set the value of an uniform to a matrix (2x2)
  46066. * @param uniform defines the webGL uniform location where to store the value
  46067. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46068. */
  46069. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46070. /**
  46071. * Set the value of an uniform to a number (float)
  46072. * @param uniform defines the webGL uniform location where to store the value
  46073. * @param value defines the float number to store
  46074. */
  46075. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46076. /**
  46077. * Set the value of an uniform to a vec2
  46078. * @param uniform defines the webGL uniform location where to store the value
  46079. * @param x defines the 1st component of the value
  46080. * @param y defines the 2nd component of the value
  46081. */
  46082. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46083. /**
  46084. * Set the value of an uniform to a vec3
  46085. * @param uniform defines the webGL uniform location where to store the value
  46086. * @param x defines the 1st component of the value
  46087. * @param y defines the 2nd component of the value
  46088. * @param z defines the 3rd component of the value
  46089. */
  46090. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46091. /**
  46092. * Set the value of an uniform to a boolean
  46093. * @param uniform defines the webGL uniform location where to store the value
  46094. * @param bool defines the boolean to store
  46095. */
  46096. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46097. /**
  46098. * Set the value of an uniform to a vec4
  46099. * @param uniform defines the webGL uniform location where to store the value
  46100. * @param x defines the 1st component of the value
  46101. * @param y defines the 2nd component of the value
  46102. * @param z defines the 3rd component of the value
  46103. * @param w defines the 4th component of the value
  46104. */
  46105. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46106. /**
  46107. * Sets the current alpha mode
  46108. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46109. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46111. */
  46112. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46113. /**
  46114. * Bind webGl buffers directly to the webGL context
  46115. * @param vertexBuffers defines the vertex buffer to bind
  46116. * @param indexBuffer defines the index buffer to bind
  46117. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46118. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46119. * @param effect defines the effect associated with the vertex buffer
  46120. */
  46121. bindBuffers(vertexBuffers: {
  46122. [key: string]: VertexBuffer;
  46123. }, indexBuffer: DataBuffer, effect: Effect): void;
  46124. /**
  46125. * Force the entire cache to be cleared
  46126. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46127. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46128. */
  46129. wipeCaches(bruteForce?: boolean): void;
  46130. /**
  46131. * Send a draw order
  46132. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46133. * @param indexStart defines the starting index
  46134. * @param indexCount defines the number of index to draw
  46135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46136. */
  46137. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46138. /**
  46139. * Draw a list of indexed primitives
  46140. * @param fillMode defines the primitive to use
  46141. * @param indexStart defines the starting index
  46142. * @param indexCount defines the number of index to draw
  46143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46144. */
  46145. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46146. /**
  46147. * Draw a list of unindexed primitives
  46148. * @param fillMode defines the primitive to use
  46149. * @param verticesStart defines the index of first vertex to draw
  46150. * @param verticesCount defines the count of vertices to draw
  46151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46152. */
  46153. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46154. /** @hidden */
  46155. _createTexture(): WebGLTexture;
  46156. /** @hidden */
  46157. _releaseTexture(texture: InternalTexture): void;
  46158. /**
  46159. * Usually called from Texture.ts.
  46160. * Passed information to create a WebGLTexture
  46161. * @param urlArg defines a value which contains one of the following:
  46162. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46163. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46164. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46165. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46166. * @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)
  46167. * @param scene needed for loading to the correct scene
  46168. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46169. * @param onLoad optional callback to be called upon successful completion
  46170. * @param onError optional callback to be called upon failure
  46171. * @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
  46172. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46173. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46174. * @param forcedExtension defines the extension to use to pick the right loader
  46175. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46176. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46177. */
  46178. 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;
  46179. /**
  46180. * Creates a new render target texture
  46181. * @param size defines the size of the texture
  46182. * @param options defines the options used to create the texture
  46183. * @returns a new render target texture stored in an InternalTexture
  46184. */
  46185. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46186. /**
  46187. * Update the sampling mode of a given texture
  46188. * @param samplingMode defines the required sampling mode
  46189. * @param texture defines the texture to update
  46190. */
  46191. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46192. /**
  46193. * Binds the frame buffer to the specified texture.
  46194. * @param texture The texture to render to or null for the default canvas
  46195. * @param faceIndex The face of the texture to render to in case of cube texture
  46196. * @param requiredWidth The width of the target to render to
  46197. * @param requiredHeight The height of the target to render to
  46198. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46199. * @param depthStencilTexture The depth stencil texture to use to render
  46200. * @param lodLevel defines le lod level to bind to the frame buffer
  46201. */
  46202. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46203. /**
  46204. * Unbind the current render target texture from the webGL context
  46205. * @param texture defines the render target texture to unbind
  46206. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46207. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46208. */
  46209. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46210. /**
  46211. * Creates a dynamic vertex buffer
  46212. * @param vertices the data for the dynamic vertex buffer
  46213. * @returns the new WebGL dynamic buffer
  46214. */
  46215. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46216. /**
  46217. * Update the content of a dynamic texture
  46218. * @param texture defines the texture to update
  46219. * @param canvas defines the canvas containing the source
  46220. * @param invertY defines if data must be stored with Y axis inverted
  46221. * @param premulAlpha defines if alpha is stored as premultiplied
  46222. * @param format defines the format of the data
  46223. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46224. */
  46225. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46226. /**
  46227. * Gets a boolean indicating if all created effects are ready
  46228. * @returns true if all effects are ready
  46229. */
  46230. areAllEffectsReady(): boolean;
  46231. /**
  46232. * @hidden
  46233. * Get the current error code of the webGL context
  46234. * @returns the error code
  46235. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46236. */
  46237. getError(): number;
  46238. /** @hidden */
  46239. _getUnpackAlignement(): number;
  46240. /** @hidden */
  46241. _unpackFlipY(value: boolean): void;
  46242. /**
  46243. * Update a dynamic index buffer
  46244. * @param indexBuffer defines the target index buffer
  46245. * @param indices defines the data to update
  46246. * @param offset defines the offset in the target index buffer where update should start
  46247. */
  46248. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46249. /**
  46250. * Updates a dynamic vertex buffer.
  46251. * @param vertexBuffer the vertex buffer to update
  46252. * @param vertices the data used to update the vertex buffer
  46253. * @param byteOffset the byte offset of the data (optional)
  46254. * @param byteLength the byte length of the data (optional)
  46255. */
  46256. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46257. /** @hidden */
  46258. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46259. /** @hidden */
  46260. _bindTexture(channel: number, texture: InternalTexture): void;
  46261. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46262. /**
  46263. * 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
  46264. */
  46265. releaseEffects(): void;
  46266. displayLoadingUI(): void;
  46267. hideLoadingUI(): void;
  46268. /** @hidden */
  46269. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46270. /** @hidden */
  46271. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46272. /** @hidden */
  46273. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46274. /** @hidden */
  46275. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46276. }
  46277. }
  46278. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46279. import { Nullable, int } from "babylonjs/types";
  46280. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46281. /** @hidden */
  46282. export class _OcclusionDataStorage {
  46283. /** @hidden */
  46284. occlusionInternalRetryCounter: number;
  46285. /** @hidden */
  46286. isOcclusionQueryInProgress: boolean;
  46287. /** @hidden */
  46288. isOccluded: boolean;
  46289. /** @hidden */
  46290. occlusionRetryCount: number;
  46291. /** @hidden */
  46292. occlusionType: number;
  46293. /** @hidden */
  46294. occlusionQueryAlgorithmType: number;
  46295. }
  46296. module "babylonjs/Engines/engine" {
  46297. interface Engine {
  46298. /**
  46299. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46300. * @return the new query
  46301. */
  46302. createQuery(): WebGLQuery;
  46303. /**
  46304. * Delete and release a webGL query
  46305. * @param query defines the query to delete
  46306. * @return the current engine
  46307. */
  46308. deleteQuery(query: WebGLQuery): Engine;
  46309. /**
  46310. * Check if a given query has resolved and got its value
  46311. * @param query defines the query to check
  46312. * @returns true if the query got its value
  46313. */
  46314. isQueryResultAvailable(query: WebGLQuery): boolean;
  46315. /**
  46316. * Gets the value of a given query
  46317. * @param query defines the query to check
  46318. * @returns the value of the query
  46319. */
  46320. getQueryResult(query: WebGLQuery): number;
  46321. /**
  46322. * Initiates an occlusion query
  46323. * @param algorithmType defines the algorithm to use
  46324. * @param query defines the query to use
  46325. * @returns the current engine
  46326. * @see http://doc.babylonjs.com/features/occlusionquery
  46327. */
  46328. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46329. /**
  46330. * Ends an occlusion query
  46331. * @see http://doc.babylonjs.com/features/occlusionquery
  46332. * @param algorithmType defines the algorithm to use
  46333. * @returns the current engine
  46334. */
  46335. endOcclusionQuery(algorithmType: number): Engine;
  46336. /**
  46337. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46338. * Please note that only one query can be issued at a time
  46339. * @returns a time token used to track the time span
  46340. */
  46341. startTimeQuery(): Nullable<_TimeToken>;
  46342. /**
  46343. * Ends a time query
  46344. * @param token defines the token used to measure the time span
  46345. * @returns the time spent (in ns)
  46346. */
  46347. endTimeQuery(token: _TimeToken): int;
  46348. /** @hidden */
  46349. _currentNonTimestampToken: Nullable<_TimeToken>;
  46350. /** @hidden */
  46351. _createTimeQuery(): WebGLQuery;
  46352. /** @hidden */
  46353. _deleteTimeQuery(query: WebGLQuery): void;
  46354. /** @hidden */
  46355. _getGlAlgorithmType(algorithmType: number): number;
  46356. /** @hidden */
  46357. _getTimeQueryResult(query: WebGLQuery): any;
  46358. /** @hidden */
  46359. _getTimeQueryAvailability(query: WebGLQuery): any;
  46360. }
  46361. }
  46362. module "babylonjs/Meshes/abstractMesh" {
  46363. interface AbstractMesh {
  46364. /**
  46365. * Backing filed
  46366. * @hidden
  46367. */
  46368. __occlusionDataStorage: _OcclusionDataStorage;
  46369. /**
  46370. * Access property
  46371. * @hidden
  46372. */
  46373. _occlusionDataStorage: _OcclusionDataStorage;
  46374. /**
  46375. * 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.
  46376. * The default value is -1 which means don't break the query and wait till the result
  46377. * @see http://doc.babylonjs.com/features/occlusionquery
  46378. */
  46379. occlusionRetryCount: number;
  46380. /**
  46381. * 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:
  46382. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46383. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46384. * * 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.
  46385. * @see http://doc.babylonjs.com/features/occlusionquery
  46386. */
  46387. occlusionType: number;
  46388. /**
  46389. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46390. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46391. * * 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.
  46392. * @see http://doc.babylonjs.com/features/occlusionquery
  46393. */
  46394. occlusionQueryAlgorithmType: number;
  46395. /**
  46396. * 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
  46397. * @see http://doc.babylonjs.com/features/occlusionquery
  46398. */
  46399. isOccluded: boolean;
  46400. /**
  46401. * Flag to check the progress status of the query
  46402. * @see http://doc.babylonjs.com/features/occlusionquery
  46403. */
  46404. isOcclusionQueryInProgress: boolean;
  46405. }
  46406. }
  46407. }
  46408. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46409. import { Nullable } from "babylonjs/types";
  46410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46411. /** @hidden */
  46412. export var _forceTransformFeedbackToBundle: boolean;
  46413. module "babylonjs/Engines/engine" {
  46414. interface Engine {
  46415. /**
  46416. * Creates a webGL transform feedback object
  46417. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46418. * @returns the webGL transform feedback object
  46419. */
  46420. createTransformFeedback(): WebGLTransformFeedback;
  46421. /**
  46422. * Delete a webGL transform feedback object
  46423. * @param value defines the webGL transform feedback object to delete
  46424. */
  46425. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46426. /**
  46427. * Bind a webGL transform feedback object to the webgl context
  46428. * @param value defines the webGL transform feedback object to bind
  46429. */
  46430. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46431. /**
  46432. * Begins a transform feedback operation
  46433. * @param usePoints defines if points or triangles must be used
  46434. */
  46435. beginTransformFeedback(usePoints: boolean): void;
  46436. /**
  46437. * Ends a transform feedback operation
  46438. */
  46439. endTransformFeedback(): void;
  46440. /**
  46441. * Specify the varyings to use with transform feedback
  46442. * @param program defines the associated webGL program
  46443. * @param value defines the list of strings representing the varying names
  46444. */
  46445. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46446. /**
  46447. * Bind a webGL buffer for a transform feedback operation
  46448. * @param value defines the webGL buffer to bind
  46449. */
  46450. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46451. }
  46452. }
  46453. }
  46454. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46455. import { Scene } from "babylonjs/scene";
  46456. import { Engine } from "babylonjs/Engines/engine";
  46457. import { Texture } from "babylonjs/Materials/Textures/texture";
  46458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46459. import "babylonjs/Engines/Extensions/engine.multiRender";
  46460. /**
  46461. * Creation options of the multi render target texture.
  46462. */
  46463. export interface IMultiRenderTargetOptions {
  46464. /**
  46465. * Define if the texture needs to create mip maps after render.
  46466. */
  46467. generateMipMaps?: boolean;
  46468. /**
  46469. * Define the types of all the draw buffers we want to create
  46470. */
  46471. types?: number[];
  46472. /**
  46473. * Define the sampling modes of all the draw buffers we want to create
  46474. */
  46475. samplingModes?: number[];
  46476. /**
  46477. * Define if a depth buffer is required
  46478. */
  46479. generateDepthBuffer?: boolean;
  46480. /**
  46481. * Define if a stencil buffer is required
  46482. */
  46483. generateStencilBuffer?: boolean;
  46484. /**
  46485. * Define if a depth texture is required instead of a depth buffer
  46486. */
  46487. generateDepthTexture?: boolean;
  46488. /**
  46489. * Define the number of desired draw buffers
  46490. */
  46491. textureCount?: number;
  46492. /**
  46493. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46494. */
  46495. doNotChangeAspectRatio?: boolean;
  46496. /**
  46497. * Define the default type of the buffers we are creating
  46498. */
  46499. defaultType?: number;
  46500. }
  46501. /**
  46502. * A multi render target, like a render target provides the ability to render to a texture.
  46503. * Unlike the render target, it can render to several draw buffers in one draw.
  46504. * This is specially interesting in deferred rendering or for any effects requiring more than
  46505. * just one color from a single pass.
  46506. */
  46507. export class MultiRenderTarget extends RenderTargetTexture {
  46508. private _internalTextures;
  46509. private _textures;
  46510. private _multiRenderTargetOptions;
  46511. /**
  46512. * Get if draw buffers are currently supported by the used hardware and browser.
  46513. */
  46514. readonly isSupported: boolean;
  46515. /**
  46516. * Get the list of textures generated by the multi render target.
  46517. */
  46518. readonly textures: Texture[];
  46519. /**
  46520. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46521. */
  46522. readonly depthTexture: Texture;
  46523. /**
  46524. * Set the wrapping mode on U of all the textures we are rendering to.
  46525. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46526. */
  46527. wrapU: number;
  46528. /**
  46529. * Set the wrapping mode on V of all the textures we are rendering to.
  46530. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46531. */
  46532. wrapV: number;
  46533. /**
  46534. * Instantiate a new multi render target texture.
  46535. * A multi render target, like a render target provides the ability to render to a texture.
  46536. * Unlike the render target, it can render to several draw buffers in one draw.
  46537. * This is specially interesting in deferred rendering or for any effects requiring more than
  46538. * just one color from a single pass.
  46539. * @param name Define the name of the texture
  46540. * @param size Define the size of the buffers to render to
  46541. * @param count Define the number of target we are rendering into
  46542. * @param scene Define the scene the texture belongs to
  46543. * @param options Define the options used to create the multi render target
  46544. */
  46545. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46546. /** @hidden */
  46547. _rebuild(): void;
  46548. private _createInternalTextures;
  46549. private _createTextures;
  46550. /**
  46551. * Define the number of samples used if MSAA is enabled.
  46552. */
  46553. samples: number;
  46554. /**
  46555. * Resize all the textures in the multi render target.
  46556. * Be carrefull as it will recreate all the data in the new texture.
  46557. * @param size Define the new size
  46558. */
  46559. resize(size: any): void;
  46560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46561. /**
  46562. * Dispose the render targets and their associated resources
  46563. */
  46564. dispose(): void;
  46565. /**
  46566. * Release all the underlying texture used as draw buffers.
  46567. */
  46568. releaseInternalTextures(): void;
  46569. }
  46570. }
  46571. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46573. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46574. import { Nullable } from "babylonjs/types";
  46575. module "babylonjs/Engines/thinEngine" {
  46576. interface ThinEngine {
  46577. /**
  46578. * Unbind a list of render target textures from the webGL context
  46579. * This is used only when drawBuffer extension or webGL2 are active
  46580. * @param textures defines the render target textures to unbind
  46581. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46582. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46583. */
  46584. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46585. /**
  46586. * Create a multi render target texture
  46587. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46588. * @param size defines the size of the texture
  46589. * @param options defines the creation options
  46590. * @returns the cube texture as an InternalTexture
  46591. */
  46592. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46593. /**
  46594. * Update the sample count for a given multiple render target texture
  46595. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46596. * @param textures defines the textures to update
  46597. * @param samples defines the sample count to set
  46598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46599. */
  46600. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46601. }
  46602. }
  46603. }
  46604. declare module "babylonjs/Engines/Extensions/engine.views" {
  46605. import { Camera } from "babylonjs/Cameras/camera";
  46606. import { Nullable } from "babylonjs/types";
  46607. /**
  46608. * Class used to define an additional view for the engine
  46609. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46610. */
  46611. export class EngineView {
  46612. /** Defines the canvas where to render the view */
  46613. target: HTMLCanvasElement;
  46614. /** Defines an optional camera used to render the view (will use active camera else) */
  46615. camera?: Camera;
  46616. }
  46617. module "babylonjs/Engines/engine" {
  46618. interface Engine {
  46619. /**
  46620. * Gets or sets the HTML element to use for attaching events
  46621. */
  46622. inputElement: Nullable<HTMLElement>;
  46623. /**
  46624. * Gets the current engine view
  46625. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46626. */
  46627. activeView: Nullable<EngineView>;
  46628. /** Gets or sets the list of views */
  46629. views: EngineView[];
  46630. /**
  46631. * Register a new child canvas
  46632. * @param canvas defines the canvas to register
  46633. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46634. * @returns the associated view
  46635. */
  46636. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46637. /**
  46638. * Remove a registered child canvas
  46639. * @param canvas defines the canvas to remove
  46640. * @returns the current engine
  46641. */
  46642. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46643. }
  46644. }
  46645. }
  46646. declare module "babylonjs/Engines/Extensions/index" {
  46647. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46648. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46649. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46650. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46651. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46652. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46653. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46654. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46655. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46656. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46657. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46658. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46659. export * from "babylonjs/Engines/Extensions/engine.views";
  46660. }
  46661. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46662. import { Nullable } from "babylonjs/types";
  46663. /**
  46664. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46665. */
  46666. export interface CubeMapInfo {
  46667. /**
  46668. * The pixel array for the front face.
  46669. * This is stored in format, left to right, up to down format.
  46670. */
  46671. front: Nullable<ArrayBufferView>;
  46672. /**
  46673. * The pixel array for the back face.
  46674. * This is stored in format, left to right, up to down format.
  46675. */
  46676. back: Nullable<ArrayBufferView>;
  46677. /**
  46678. * The pixel array for the left face.
  46679. * This is stored in format, left to right, up to down format.
  46680. */
  46681. left: Nullable<ArrayBufferView>;
  46682. /**
  46683. * The pixel array for the right face.
  46684. * This is stored in format, left to right, up to down format.
  46685. */
  46686. right: Nullable<ArrayBufferView>;
  46687. /**
  46688. * The pixel array for the up face.
  46689. * This is stored in format, left to right, up to down format.
  46690. */
  46691. up: Nullable<ArrayBufferView>;
  46692. /**
  46693. * The pixel array for the down face.
  46694. * This is stored in format, left to right, up to down format.
  46695. */
  46696. down: Nullable<ArrayBufferView>;
  46697. /**
  46698. * The size of the cubemap stored.
  46699. *
  46700. * Each faces will be size * size pixels.
  46701. */
  46702. size: number;
  46703. /**
  46704. * The format of the texture.
  46705. *
  46706. * RGBA, RGB.
  46707. */
  46708. format: number;
  46709. /**
  46710. * The type of the texture data.
  46711. *
  46712. * UNSIGNED_INT, FLOAT.
  46713. */
  46714. type: number;
  46715. /**
  46716. * Specifies whether the texture is in gamma space.
  46717. */
  46718. gammaSpace: boolean;
  46719. }
  46720. /**
  46721. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46722. */
  46723. export class PanoramaToCubeMapTools {
  46724. private static FACE_FRONT;
  46725. private static FACE_BACK;
  46726. private static FACE_RIGHT;
  46727. private static FACE_LEFT;
  46728. private static FACE_DOWN;
  46729. private static FACE_UP;
  46730. /**
  46731. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46732. *
  46733. * @param float32Array The source data.
  46734. * @param inputWidth The width of the input panorama.
  46735. * @param inputHeight The height of the input panorama.
  46736. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46737. * @return The cubemap data
  46738. */
  46739. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46740. private static CreateCubemapTexture;
  46741. private static CalcProjectionSpherical;
  46742. }
  46743. }
  46744. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46745. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46747. import { Nullable } from "babylonjs/types";
  46748. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46749. /**
  46750. * Helper class dealing with the extraction of spherical polynomial dataArray
  46751. * from a cube map.
  46752. */
  46753. export class CubeMapToSphericalPolynomialTools {
  46754. private static FileFaces;
  46755. /**
  46756. * Converts a texture to the according Spherical Polynomial data.
  46757. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46758. *
  46759. * @param texture The texture to extract the information from.
  46760. * @return The Spherical Polynomial data.
  46761. */
  46762. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46763. /**
  46764. * Converts a cubemap to the according Spherical Polynomial data.
  46765. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46766. *
  46767. * @param cubeInfo The Cube map to extract the information from.
  46768. * @return The Spherical Polynomial data.
  46769. */
  46770. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46771. }
  46772. }
  46773. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46774. import { Nullable } from "babylonjs/types";
  46775. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46776. module "babylonjs/Materials/Textures/baseTexture" {
  46777. interface BaseTexture {
  46778. /**
  46779. * Get the polynomial representation of the texture data.
  46780. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46781. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46782. */
  46783. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46784. }
  46785. }
  46786. }
  46787. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46788. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46789. /** @hidden */
  46790. export var rgbdEncodePixelShader: {
  46791. name: string;
  46792. shader: string;
  46793. };
  46794. }
  46795. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46797. /** @hidden */
  46798. export var rgbdDecodePixelShader: {
  46799. name: string;
  46800. shader: string;
  46801. };
  46802. }
  46803. declare module "babylonjs/Misc/environmentTextureTools" {
  46804. import { Nullable } from "babylonjs/types";
  46805. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46807. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46808. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46809. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46810. import "babylonjs/Shaders/rgbdEncode.fragment";
  46811. import "babylonjs/Shaders/rgbdDecode.fragment";
  46812. /**
  46813. * Raw texture data and descriptor sufficient for WebGL texture upload
  46814. */
  46815. export interface EnvironmentTextureInfo {
  46816. /**
  46817. * Version of the environment map
  46818. */
  46819. version: number;
  46820. /**
  46821. * Width of image
  46822. */
  46823. width: number;
  46824. /**
  46825. * Irradiance information stored in the file.
  46826. */
  46827. irradiance: any;
  46828. /**
  46829. * Specular information stored in the file.
  46830. */
  46831. specular: any;
  46832. }
  46833. /**
  46834. * Defines One Image in the file. It requires only the position in the file
  46835. * as well as the length.
  46836. */
  46837. interface BufferImageData {
  46838. /**
  46839. * Length of the image data.
  46840. */
  46841. length: number;
  46842. /**
  46843. * Position of the data from the null terminator delimiting the end of the JSON.
  46844. */
  46845. position: number;
  46846. }
  46847. /**
  46848. * Defines the specular data enclosed in the file.
  46849. * This corresponds to the version 1 of the data.
  46850. */
  46851. export interface EnvironmentTextureSpecularInfoV1 {
  46852. /**
  46853. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46854. */
  46855. specularDataPosition?: number;
  46856. /**
  46857. * This contains all the images data needed to reconstruct the cubemap.
  46858. */
  46859. mipmaps: Array<BufferImageData>;
  46860. /**
  46861. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46862. */
  46863. lodGenerationScale: number;
  46864. }
  46865. /**
  46866. * Sets of helpers addressing the serialization and deserialization of environment texture
  46867. * stored in a BabylonJS env file.
  46868. * Those files are usually stored as .env files.
  46869. */
  46870. export class EnvironmentTextureTools {
  46871. /**
  46872. * Magic number identifying the env file.
  46873. */
  46874. private static _MagicBytes;
  46875. /**
  46876. * Gets the environment info from an env file.
  46877. * @param data The array buffer containing the .env bytes.
  46878. * @returns the environment file info (the json header) if successfully parsed.
  46879. */
  46880. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46881. /**
  46882. * Creates an environment texture from a loaded cube texture.
  46883. * @param texture defines the cube texture to convert in env file
  46884. * @return a promise containing the environment data if succesfull.
  46885. */
  46886. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46887. /**
  46888. * Creates a JSON representation of the spherical data.
  46889. * @param texture defines the texture containing the polynomials
  46890. * @return the JSON representation of the spherical info
  46891. */
  46892. private static _CreateEnvTextureIrradiance;
  46893. /**
  46894. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46895. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46896. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46897. * @return the views described by info providing access to the underlying buffer
  46898. */
  46899. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46900. /**
  46901. * Uploads the texture info contained in the env file to the GPU.
  46902. * @param texture defines the internal texture to upload to
  46903. * @param arrayBuffer defines the buffer cotaining the data to load
  46904. * @param info defines the texture info retrieved through the GetEnvInfo method
  46905. * @returns a promise
  46906. */
  46907. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46908. private static _OnImageReadyAsync;
  46909. /**
  46910. * Uploads the levels of image data to the GPU.
  46911. * @param texture defines the internal texture to upload to
  46912. * @param imageData defines the array buffer views of image data [mipmap][face]
  46913. * @returns a promise
  46914. */
  46915. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46916. /**
  46917. * Uploads spherical polynomials information to the texture.
  46918. * @param texture defines the texture we are trying to upload the information to
  46919. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46920. */
  46921. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46922. /** @hidden */
  46923. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46924. }
  46925. }
  46926. declare module "babylonjs/Maths/math.vertexFormat" {
  46927. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46928. /**
  46929. * Contains position and normal vectors for a vertex
  46930. */
  46931. export class PositionNormalVertex {
  46932. /** the position of the vertex (defaut: 0,0,0) */
  46933. position: Vector3;
  46934. /** the normal of the vertex (defaut: 0,1,0) */
  46935. normal: Vector3;
  46936. /**
  46937. * Creates a PositionNormalVertex
  46938. * @param position the position of the vertex (defaut: 0,0,0)
  46939. * @param normal the normal of the vertex (defaut: 0,1,0)
  46940. */
  46941. constructor(
  46942. /** the position of the vertex (defaut: 0,0,0) */
  46943. position?: Vector3,
  46944. /** the normal of the vertex (defaut: 0,1,0) */
  46945. normal?: Vector3);
  46946. /**
  46947. * Clones the PositionNormalVertex
  46948. * @returns the cloned PositionNormalVertex
  46949. */
  46950. clone(): PositionNormalVertex;
  46951. }
  46952. /**
  46953. * Contains position, normal and uv vectors for a vertex
  46954. */
  46955. export class PositionNormalTextureVertex {
  46956. /** the position of the vertex (defaut: 0,0,0) */
  46957. position: Vector3;
  46958. /** the normal of the vertex (defaut: 0,1,0) */
  46959. normal: Vector3;
  46960. /** the uv of the vertex (default: 0,0) */
  46961. uv: Vector2;
  46962. /**
  46963. * Creates a PositionNormalTextureVertex
  46964. * @param position the position of the vertex (defaut: 0,0,0)
  46965. * @param normal the normal of the vertex (defaut: 0,1,0)
  46966. * @param uv the uv of the vertex (default: 0,0)
  46967. */
  46968. constructor(
  46969. /** the position of the vertex (defaut: 0,0,0) */
  46970. position?: Vector3,
  46971. /** the normal of the vertex (defaut: 0,1,0) */
  46972. normal?: Vector3,
  46973. /** the uv of the vertex (default: 0,0) */
  46974. uv?: Vector2);
  46975. /**
  46976. * Clones the PositionNormalTextureVertex
  46977. * @returns the cloned PositionNormalTextureVertex
  46978. */
  46979. clone(): PositionNormalTextureVertex;
  46980. }
  46981. }
  46982. declare module "babylonjs/Maths/math" {
  46983. export * from "babylonjs/Maths/math.axis";
  46984. export * from "babylonjs/Maths/math.color";
  46985. export * from "babylonjs/Maths/math.constants";
  46986. export * from "babylonjs/Maths/math.frustum";
  46987. export * from "babylonjs/Maths/math.path";
  46988. export * from "babylonjs/Maths/math.plane";
  46989. export * from "babylonjs/Maths/math.size";
  46990. export * from "babylonjs/Maths/math.vector";
  46991. export * from "babylonjs/Maths/math.vertexFormat";
  46992. export * from "babylonjs/Maths/math.viewport";
  46993. }
  46994. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46995. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46996. /** @hidden */
  46997. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46998. private _genericAttributeLocation;
  46999. private _varyingLocationCount;
  47000. private _varyingLocationMap;
  47001. private _replacements;
  47002. private _textureCount;
  47003. private _uniforms;
  47004. lineProcessor(line: string): string;
  47005. attributeProcessor(attribute: string): string;
  47006. varyingProcessor(varying: string, isFragment: boolean): string;
  47007. uniformProcessor(uniform: string): string;
  47008. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47009. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47010. }
  47011. }
  47012. declare module "babylonjs/Engines/nativeEngine" {
  47013. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47014. import { Engine } from "babylonjs/Engines/engine";
  47015. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47018. import { Effect } from "babylonjs/Materials/effect";
  47019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47020. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47021. import { IColor4Like } from "babylonjs/Maths/math.like";
  47022. import { Scene } from "babylonjs/scene";
  47023. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47025. /**
  47026. * Container for accessors for natively-stored mesh data buffers.
  47027. */
  47028. class NativeDataBuffer extends DataBuffer {
  47029. /**
  47030. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47031. */
  47032. nativeIndexBuffer?: any;
  47033. /**
  47034. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47035. */
  47036. nativeVertexBuffer?: any;
  47037. }
  47038. /** @hidden */
  47039. class NativeTexture extends InternalTexture {
  47040. getInternalTexture(): InternalTexture;
  47041. getViewCount(): number;
  47042. }
  47043. /** @hidden */
  47044. export class NativeEngine extends Engine {
  47045. private readonly _native;
  47046. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47047. private readonly INVALID_HANDLE;
  47048. getHardwareScalingLevel(): number;
  47049. constructor();
  47050. /**
  47051. * Can be used to override the current requestAnimationFrame requester.
  47052. * @hidden
  47053. */
  47054. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47055. /**
  47056. * Override default engine behavior.
  47057. * @param color
  47058. * @param backBuffer
  47059. * @param depth
  47060. * @param stencil
  47061. */
  47062. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47063. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47064. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47065. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47066. recordVertexArrayObject(vertexBuffers: {
  47067. [key: string]: VertexBuffer;
  47068. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47069. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47070. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47071. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47072. /**
  47073. * Draw a list of indexed primitives
  47074. * @param fillMode defines the primitive to use
  47075. * @param indexStart defines the starting index
  47076. * @param indexCount defines the number of index to draw
  47077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47078. */
  47079. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47080. /**
  47081. * Draw a list of unindexed primitives
  47082. * @param fillMode defines the primitive to use
  47083. * @param verticesStart defines the index of first vertex to draw
  47084. * @param verticesCount defines the count of vertices to draw
  47085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47086. */
  47087. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47088. createPipelineContext(): IPipelineContext;
  47089. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47090. /** @hidden */
  47091. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47092. /** @hidden */
  47093. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47094. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47096. protected _setProgram(program: WebGLProgram): void;
  47097. _releaseEffect(effect: Effect): void;
  47098. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47099. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47100. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47101. bindSamplers(effect: Effect): void;
  47102. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47103. getRenderWidth(useScreen?: boolean): number;
  47104. getRenderHeight(useScreen?: boolean): number;
  47105. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47106. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47107. /**
  47108. * Set the z offset to apply to current rendering
  47109. * @param value defines the offset to apply
  47110. */
  47111. setZOffset(value: number): void;
  47112. /**
  47113. * Gets the current value of the zOffset
  47114. * @returns the current zOffset state
  47115. */
  47116. getZOffset(): number;
  47117. /**
  47118. * Enable or disable depth buffering
  47119. * @param enable defines the state to set
  47120. */
  47121. setDepthBuffer(enable: boolean): void;
  47122. /**
  47123. * Gets a boolean indicating if depth writing is enabled
  47124. * @returns the current depth writing state
  47125. */
  47126. getDepthWrite(): boolean;
  47127. /**
  47128. * Enable or disable depth writing
  47129. * @param enable defines the state to set
  47130. */
  47131. setDepthWrite(enable: boolean): void;
  47132. /**
  47133. * Enable or disable color writing
  47134. * @param enable defines the state to set
  47135. */
  47136. setColorWrite(enable: boolean): void;
  47137. /**
  47138. * Gets a boolean indicating if color writing is enabled
  47139. * @returns the current color writing state
  47140. */
  47141. getColorWrite(): boolean;
  47142. /**
  47143. * Sets alpha constants used by some alpha blending modes
  47144. * @param r defines the red component
  47145. * @param g defines the green component
  47146. * @param b defines the blue component
  47147. * @param a defines the alpha component
  47148. */
  47149. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47150. /**
  47151. * Sets the current alpha mode
  47152. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47153. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47154. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47155. */
  47156. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47157. /**
  47158. * Gets the current alpha mode
  47159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47160. * @returns the current alpha mode
  47161. */
  47162. getAlphaMode(): number;
  47163. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47164. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47165. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47166. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47167. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47168. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47169. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47170. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47171. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47172. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47173. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47174. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47175. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47176. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47177. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47178. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47179. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47180. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47181. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47182. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47183. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47184. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47185. wipeCaches(bruteForce?: boolean): void;
  47186. _createTexture(): WebGLTexture;
  47187. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47188. /**
  47189. * Usually called from BABYLON.Texture.ts.
  47190. * Passed information to create a WebGLTexture
  47191. * @param urlArg defines a value which contains one of the following:
  47192. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47193. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47194. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47195. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47196. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47197. * @param scene needed for loading to the correct scene
  47198. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47199. * @param onLoad optional callback to be called upon successful completion
  47200. * @param onError optional callback to be called upon failure
  47201. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47202. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47203. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47204. * @param forcedExtension defines the extension to use to pick the right loader
  47205. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47206. */
  47207. 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;
  47208. /**
  47209. * Creates a cube texture
  47210. * @param rootUrl defines the url where the files to load is located
  47211. * @param scene defines the current scene
  47212. * @param files defines the list of files to load (1 per face)
  47213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47214. * @param onLoad defines an optional callback raised when the texture is loaded
  47215. * @param onError defines an optional callback raised if there is an issue to load the texture
  47216. * @param format defines the format of the data
  47217. * @param forcedExtension defines the extension to use to pick the right loader
  47218. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47219. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47220. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47221. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47222. * @returns the cube texture as an InternalTexture
  47223. */
  47224. 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;
  47225. private _getSamplingFilter;
  47226. private static _GetNativeTextureFormat;
  47227. createRenderTargetTexture(size: number | {
  47228. width: number;
  47229. height: number;
  47230. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47231. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47232. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47233. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47234. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47235. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47236. /**
  47237. * Updates a dynamic vertex buffer.
  47238. * @param vertexBuffer the vertex buffer to update
  47239. * @param data the data used to update the vertex buffer
  47240. * @param byteOffset the byte offset of the data (optional)
  47241. * @param byteLength the byte length of the data (optional)
  47242. */
  47243. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47244. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47245. private _updateAnisotropicLevel;
  47246. private _getAddressMode;
  47247. /** @hidden */
  47248. _bindTexture(channel: number, texture: InternalTexture): void;
  47249. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47250. releaseEffects(): void;
  47251. /** @hidden */
  47252. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47253. /** @hidden */
  47254. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47255. /** @hidden */
  47256. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47257. /** @hidden */
  47258. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47259. }
  47260. }
  47261. declare module "babylonjs/Engines/index" {
  47262. export * from "babylonjs/Engines/constants";
  47263. export * from "babylonjs/Engines/engineCapabilities";
  47264. export * from "babylonjs/Engines/instancingAttributeInfo";
  47265. export * from "babylonjs/Engines/thinEngine";
  47266. export * from "babylonjs/Engines/engine";
  47267. export * from "babylonjs/Engines/engineStore";
  47268. export * from "babylonjs/Engines/nullEngine";
  47269. export * from "babylonjs/Engines/Extensions/index";
  47270. export * from "babylonjs/Engines/IPipelineContext";
  47271. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47272. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47273. export * from "babylonjs/Engines/nativeEngine";
  47274. }
  47275. declare module "babylonjs/Events/clipboardEvents" {
  47276. /**
  47277. * Gather the list of clipboard event types as constants.
  47278. */
  47279. export class ClipboardEventTypes {
  47280. /**
  47281. * The clipboard event is fired when a copy command is active (pressed).
  47282. */
  47283. static readonly COPY: number;
  47284. /**
  47285. * The clipboard event is fired when a cut command is active (pressed).
  47286. */
  47287. static readonly CUT: number;
  47288. /**
  47289. * The clipboard event is fired when a paste command is active (pressed).
  47290. */
  47291. static readonly PASTE: number;
  47292. }
  47293. /**
  47294. * This class is used to store clipboard related info for the onClipboardObservable event.
  47295. */
  47296. export class ClipboardInfo {
  47297. /**
  47298. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47299. */
  47300. type: number;
  47301. /**
  47302. * Defines the related dom event
  47303. */
  47304. event: ClipboardEvent;
  47305. /**
  47306. *Creates an instance of ClipboardInfo.
  47307. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47308. * @param event Defines the related dom event
  47309. */
  47310. constructor(
  47311. /**
  47312. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47313. */
  47314. type: number,
  47315. /**
  47316. * Defines the related dom event
  47317. */
  47318. event: ClipboardEvent);
  47319. /**
  47320. * Get the clipboard event's type from the keycode.
  47321. * @param keyCode Defines the keyCode for the current keyboard event.
  47322. * @return {number}
  47323. */
  47324. static GetTypeFromCharacter(keyCode: number): number;
  47325. }
  47326. }
  47327. declare module "babylonjs/Events/index" {
  47328. export * from "babylonjs/Events/keyboardEvents";
  47329. export * from "babylonjs/Events/pointerEvents";
  47330. export * from "babylonjs/Events/clipboardEvents";
  47331. }
  47332. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47333. import { Scene } from "babylonjs/scene";
  47334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47335. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47336. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47337. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47338. /**
  47339. * Google Daydream controller
  47340. */
  47341. export class DaydreamController extends WebVRController {
  47342. /**
  47343. * Base Url for the controller model.
  47344. */
  47345. static MODEL_BASE_URL: string;
  47346. /**
  47347. * File name for the controller model.
  47348. */
  47349. static MODEL_FILENAME: string;
  47350. /**
  47351. * Gamepad Id prefix used to identify Daydream Controller.
  47352. */
  47353. static readonly GAMEPAD_ID_PREFIX: string;
  47354. /**
  47355. * Creates a new DaydreamController from a gamepad
  47356. * @param vrGamepad the gamepad that the controller should be created from
  47357. */
  47358. constructor(vrGamepad: any);
  47359. /**
  47360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47361. * @param scene scene in which to add meshes
  47362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47363. */
  47364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47365. /**
  47366. * Called once for each button that changed state since the last frame
  47367. * @param buttonIdx Which button index changed
  47368. * @param state New state of the button
  47369. * @param changes Which properties on the state changed since last frame
  47370. */
  47371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47372. }
  47373. }
  47374. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47375. import { Scene } from "babylonjs/scene";
  47376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47377. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47378. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47379. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47380. /**
  47381. * Gear VR Controller
  47382. */
  47383. export class GearVRController extends WebVRController {
  47384. /**
  47385. * Base Url for the controller model.
  47386. */
  47387. static MODEL_BASE_URL: string;
  47388. /**
  47389. * File name for the controller model.
  47390. */
  47391. static MODEL_FILENAME: string;
  47392. /**
  47393. * Gamepad Id prefix used to identify this controller.
  47394. */
  47395. static readonly GAMEPAD_ID_PREFIX: string;
  47396. private readonly _buttonIndexToObservableNameMap;
  47397. /**
  47398. * Creates a new GearVRController from a gamepad
  47399. * @param vrGamepad the gamepad that the controller should be created from
  47400. */
  47401. constructor(vrGamepad: any);
  47402. /**
  47403. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47404. * @param scene scene in which to add meshes
  47405. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47406. */
  47407. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47408. /**
  47409. * Called once for each button that changed state since the last frame
  47410. * @param buttonIdx Which button index changed
  47411. * @param state New state of the button
  47412. * @param changes Which properties on the state changed since last frame
  47413. */
  47414. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47415. }
  47416. }
  47417. declare module "babylonjs/Gamepads/Controllers/index" {
  47418. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47419. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47420. export * from "babylonjs/Gamepads/Controllers/genericController";
  47421. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47422. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47423. export * from "babylonjs/Gamepads/Controllers/viveController";
  47424. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47425. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47426. }
  47427. declare module "babylonjs/Gamepads/index" {
  47428. export * from "babylonjs/Gamepads/Controllers/index";
  47429. export * from "babylonjs/Gamepads/gamepad";
  47430. export * from "babylonjs/Gamepads/gamepadManager";
  47431. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47432. export * from "babylonjs/Gamepads/xboxGamepad";
  47433. export * from "babylonjs/Gamepads/dualShockGamepad";
  47434. }
  47435. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47436. import { Scene } from "babylonjs/scene";
  47437. import { Vector4 } from "babylonjs/Maths/math.vector";
  47438. import { Color4 } from "babylonjs/Maths/math.color";
  47439. import { Mesh } from "babylonjs/Meshes/mesh";
  47440. import { Nullable } from "babylonjs/types";
  47441. /**
  47442. * Class containing static functions to help procedurally build meshes
  47443. */
  47444. export class PolyhedronBuilder {
  47445. /**
  47446. * Creates a polyhedron mesh
  47447. * * 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
  47448. * * The parameter `size` (positive float, default 1) sets the polygon size
  47449. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47450. * * 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`
  47451. * * 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
  47452. * * 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)`)
  47453. * * 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
  47454. * * 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
  47455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47458. * @param name defines the name of the mesh
  47459. * @param options defines the options used to create the mesh
  47460. * @param scene defines the hosting scene
  47461. * @returns the polyhedron mesh
  47462. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47463. */
  47464. static CreatePolyhedron(name: string, options: {
  47465. type?: number;
  47466. size?: number;
  47467. sizeX?: number;
  47468. sizeY?: number;
  47469. sizeZ?: number;
  47470. custom?: any;
  47471. faceUV?: Vector4[];
  47472. faceColors?: Color4[];
  47473. flat?: boolean;
  47474. updatable?: boolean;
  47475. sideOrientation?: number;
  47476. frontUVs?: Vector4;
  47477. backUVs?: Vector4;
  47478. }, scene?: Nullable<Scene>): Mesh;
  47479. }
  47480. }
  47481. declare module "babylonjs/Gizmos/scaleGizmo" {
  47482. import { Observable } from "babylonjs/Misc/observable";
  47483. import { Nullable } from "babylonjs/types";
  47484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47485. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47486. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47487. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47488. /**
  47489. * Gizmo that enables scaling a mesh along 3 axis
  47490. */
  47491. export class ScaleGizmo extends Gizmo {
  47492. /**
  47493. * Internal gizmo used for interactions on the x axis
  47494. */
  47495. xGizmo: AxisScaleGizmo;
  47496. /**
  47497. * Internal gizmo used for interactions on the y axis
  47498. */
  47499. yGizmo: AxisScaleGizmo;
  47500. /**
  47501. * Internal gizmo used for interactions on the z axis
  47502. */
  47503. zGizmo: AxisScaleGizmo;
  47504. /**
  47505. * Internal gizmo used to scale all axis equally
  47506. */
  47507. uniformScaleGizmo: AxisScaleGizmo;
  47508. private _meshAttached;
  47509. private _updateGizmoRotationToMatchAttachedMesh;
  47510. private _snapDistance;
  47511. private _scaleRatio;
  47512. private _uniformScalingMesh;
  47513. private _octahedron;
  47514. /** Fires an event when any of it's sub gizmos are dragged */
  47515. onDragStartObservable: Observable<unknown>;
  47516. /** Fires an event when any of it's sub gizmos are released from dragging */
  47517. onDragEndObservable: Observable<unknown>;
  47518. attachedMesh: Nullable<AbstractMesh>;
  47519. /**
  47520. * Creates a ScaleGizmo
  47521. * @param gizmoLayer The utility layer the gizmo will be added to
  47522. */
  47523. constructor(gizmoLayer?: UtilityLayerRenderer);
  47524. updateGizmoRotationToMatchAttachedMesh: boolean;
  47525. /**
  47526. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47527. */
  47528. snapDistance: number;
  47529. /**
  47530. * Ratio for the scale of the gizmo (Default: 1)
  47531. */
  47532. scaleRatio: number;
  47533. /**
  47534. * Disposes of the gizmo
  47535. */
  47536. dispose(): void;
  47537. }
  47538. }
  47539. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47540. import { Observable } from "babylonjs/Misc/observable";
  47541. import { Nullable } from "babylonjs/types";
  47542. import { Vector3 } from "babylonjs/Maths/math.vector";
  47543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47544. import { Mesh } from "babylonjs/Meshes/mesh";
  47545. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47547. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47548. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47549. import { Color3 } from "babylonjs/Maths/math.color";
  47550. /**
  47551. * Single axis scale gizmo
  47552. */
  47553. export class AxisScaleGizmo extends Gizmo {
  47554. /**
  47555. * Drag behavior responsible for the gizmos dragging interactions
  47556. */
  47557. dragBehavior: PointerDragBehavior;
  47558. private _pointerObserver;
  47559. /**
  47560. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47561. */
  47562. snapDistance: number;
  47563. /**
  47564. * Event that fires each time the gizmo snaps to a new location.
  47565. * * snapDistance is the the change in distance
  47566. */
  47567. onSnapObservable: Observable<{
  47568. snapDistance: number;
  47569. }>;
  47570. /**
  47571. * If the scaling operation should be done on all axis (default: false)
  47572. */
  47573. uniformScaling: boolean;
  47574. private _isEnabled;
  47575. private _parent;
  47576. private _arrow;
  47577. private _coloredMaterial;
  47578. private _hoverMaterial;
  47579. /**
  47580. * Creates an AxisScaleGizmo
  47581. * @param gizmoLayer The utility layer the gizmo will be added to
  47582. * @param dragAxis The axis which the gizmo will be able to scale on
  47583. * @param color The color of the gizmo
  47584. */
  47585. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47586. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47587. /**
  47588. * If the gizmo is enabled
  47589. */
  47590. isEnabled: boolean;
  47591. /**
  47592. * Disposes of the gizmo
  47593. */
  47594. dispose(): void;
  47595. /**
  47596. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47597. * @param mesh The mesh to replace the default mesh of the gizmo
  47598. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47599. */
  47600. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47601. }
  47602. }
  47603. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47604. import { Observable } from "babylonjs/Misc/observable";
  47605. import { Nullable } from "babylonjs/types";
  47606. import { Vector3 } from "babylonjs/Maths/math.vector";
  47607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47608. import { Mesh } from "babylonjs/Meshes/mesh";
  47609. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47610. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47611. import { Color3 } from "babylonjs/Maths/math.color";
  47612. import "babylonjs/Meshes/Builders/boxBuilder";
  47613. /**
  47614. * Bounding box gizmo
  47615. */
  47616. export class BoundingBoxGizmo extends Gizmo {
  47617. private _lineBoundingBox;
  47618. private _rotateSpheresParent;
  47619. private _scaleBoxesParent;
  47620. private _boundingDimensions;
  47621. private _renderObserver;
  47622. private _pointerObserver;
  47623. private _scaleDragSpeed;
  47624. private _tmpQuaternion;
  47625. private _tmpVector;
  47626. private _tmpRotationMatrix;
  47627. /**
  47628. * 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)
  47629. */
  47630. ignoreChildren: boolean;
  47631. /**
  47632. * 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)
  47633. */
  47634. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47635. /**
  47636. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47637. */
  47638. rotationSphereSize: number;
  47639. /**
  47640. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47641. */
  47642. scaleBoxSize: number;
  47643. /**
  47644. * 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)
  47645. */
  47646. fixedDragMeshScreenSize: boolean;
  47647. /**
  47648. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47649. */
  47650. fixedDragMeshScreenSizeDistanceFactor: number;
  47651. /**
  47652. * Fired when a rotation sphere or scale box is dragged
  47653. */
  47654. onDragStartObservable: Observable<{}>;
  47655. /**
  47656. * Fired when a scale box is dragged
  47657. */
  47658. onScaleBoxDragObservable: Observable<{}>;
  47659. /**
  47660. * Fired when a scale box drag is ended
  47661. */
  47662. onScaleBoxDragEndObservable: Observable<{}>;
  47663. /**
  47664. * Fired when a rotation sphere is dragged
  47665. */
  47666. onRotationSphereDragObservable: Observable<{}>;
  47667. /**
  47668. * Fired when a rotation sphere drag is ended
  47669. */
  47670. onRotationSphereDragEndObservable: Observable<{}>;
  47671. /**
  47672. * 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)
  47673. */
  47674. scalePivot: Nullable<Vector3>;
  47675. /**
  47676. * Mesh used as a pivot to rotate the attached mesh
  47677. */
  47678. private _anchorMesh;
  47679. private _existingMeshScale;
  47680. private _dragMesh;
  47681. private pointerDragBehavior;
  47682. private coloredMaterial;
  47683. private hoverColoredMaterial;
  47684. /**
  47685. * Sets the color of the bounding box gizmo
  47686. * @param color the color to set
  47687. */
  47688. setColor(color: Color3): void;
  47689. /**
  47690. * Creates an BoundingBoxGizmo
  47691. * @param gizmoLayer The utility layer the gizmo will be added to
  47692. * @param color The color of the gizmo
  47693. */
  47694. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47696. private _selectNode;
  47697. /**
  47698. * Updates the bounding box information for the Gizmo
  47699. */
  47700. updateBoundingBox(): void;
  47701. private _updateRotationSpheres;
  47702. private _updateScaleBoxes;
  47703. /**
  47704. * Enables rotation on the specified axis and disables rotation on the others
  47705. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47706. */
  47707. setEnabledRotationAxis(axis: string): void;
  47708. /**
  47709. * Enables/disables scaling
  47710. * @param enable if scaling should be enabled
  47711. */
  47712. setEnabledScaling(enable: boolean): void;
  47713. private _updateDummy;
  47714. /**
  47715. * Enables a pointer drag behavior on the bounding box of the gizmo
  47716. */
  47717. enableDragBehavior(): void;
  47718. /**
  47719. * Disposes of the gizmo
  47720. */
  47721. dispose(): void;
  47722. /**
  47723. * 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)
  47724. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47725. * @returns the bounding box mesh with the passed in mesh as a child
  47726. */
  47727. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47728. /**
  47729. * CustomMeshes are not supported by this gizmo
  47730. * @param mesh The mesh to replace the default mesh of the gizmo
  47731. */
  47732. setCustomMesh(mesh: Mesh): void;
  47733. }
  47734. }
  47735. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47736. import { Observable } from "babylonjs/Misc/observable";
  47737. import { Nullable } from "babylonjs/types";
  47738. import { Vector3 } from "babylonjs/Maths/math.vector";
  47739. import { Color3 } from "babylonjs/Maths/math.color";
  47740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47741. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47742. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47744. import "babylonjs/Meshes/Builders/linesBuilder";
  47745. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47746. /**
  47747. * Single plane rotation gizmo
  47748. */
  47749. export class PlaneRotationGizmo extends Gizmo {
  47750. /**
  47751. * Drag behavior responsible for the gizmos dragging interactions
  47752. */
  47753. dragBehavior: PointerDragBehavior;
  47754. private _pointerObserver;
  47755. /**
  47756. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47757. */
  47758. snapDistance: number;
  47759. /**
  47760. * Event that fires each time the gizmo snaps to a new location.
  47761. * * snapDistance is the the change in distance
  47762. */
  47763. onSnapObservable: Observable<{
  47764. snapDistance: number;
  47765. }>;
  47766. private _isEnabled;
  47767. private _parent;
  47768. /**
  47769. * Creates a PlaneRotationGizmo
  47770. * @param gizmoLayer The utility layer the gizmo will be added to
  47771. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47772. * @param color The color of the gizmo
  47773. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47774. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47775. */
  47776. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47777. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47778. /**
  47779. * If the gizmo is enabled
  47780. */
  47781. isEnabled: boolean;
  47782. /**
  47783. * Disposes of the gizmo
  47784. */
  47785. dispose(): void;
  47786. }
  47787. }
  47788. declare module "babylonjs/Gizmos/rotationGizmo" {
  47789. import { Observable } from "babylonjs/Misc/observable";
  47790. import { Nullable } from "babylonjs/types";
  47791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47792. import { Mesh } from "babylonjs/Meshes/mesh";
  47793. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47794. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47795. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47796. /**
  47797. * Gizmo that enables rotating a mesh along 3 axis
  47798. */
  47799. export class RotationGizmo extends Gizmo {
  47800. /**
  47801. * Internal gizmo used for interactions on the x axis
  47802. */
  47803. xGizmo: PlaneRotationGizmo;
  47804. /**
  47805. * Internal gizmo used for interactions on the y axis
  47806. */
  47807. yGizmo: PlaneRotationGizmo;
  47808. /**
  47809. * Internal gizmo used for interactions on the z axis
  47810. */
  47811. zGizmo: PlaneRotationGizmo;
  47812. /** Fires an event when any of it's sub gizmos are dragged */
  47813. onDragStartObservable: Observable<unknown>;
  47814. /** Fires an event when any of it's sub gizmos are released from dragging */
  47815. onDragEndObservable: Observable<unknown>;
  47816. private _meshAttached;
  47817. attachedMesh: Nullable<AbstractMesh>;
  47818. /**
  47819. * Creates a RotationGizmo
  47820. * @param gizmoLayer The utility layer the gizmo will be added to
  47821. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47822. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47823. */
  47824. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47825. updateGizmoRotationToMatchAttachedMesh: boolean;
  47826. /**
  47827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47828. */
  47829. snapDistance: number;
  47830. /**
  47831. * Ratio for the scale of the gizmo (Default: 1)
  47832. */
  47833. scaleRatio: number;
  47834. /**
  47835. * Disposes of the gizmo
  47836. */
  47837. dispose(): void;
  47838. /**
  47839. * CustomMeshes are not supported by this gizmo
  47840. * @param mesh The mesh to replace the default mesh of the gizmo
  47841. */
  47842. setCustomMesh(mesh: Mesh): void;
  47843. }
  47844. }
  47845. declare module "babylonjs/Gizmos/gizmoManager" {
  47846. import { Observable } from "babylonjs/Misc/observable";
  47847. import { Nullable } from "babylonjs/types";
  47848. import { Scene, IDisposable } from "babylonjs/scene";
  47849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47850. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47851. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47852. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47853. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47854. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47855. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47856. /**
  47857. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47858. */
  47859. export class GizmoManager implements IDisposable {
  47860. private scene;
  47861. /**
  47862. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47863. */
  47864. gizmos: {
  47865. positionGizmo: Nullable<PositionGizmo>;
  47866. rotationGizmo: Nullable<RotationGizmo>;
  47867. scaleGizmo: Nullable<ScaleGizmo>;
  47868. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47869. };
  47870. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47871. clearGizmoOnEmptyPointerEvent: boolean;
  47872. /** Fires an event when the manager is attached to a mesh */
  47873. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47874. private _gizmosEnabled;
  47875. private _pointerObserver;
  47876. private _attachedMesh;
  47877. private _boundingBoxColor;
  47878. private _defaultUtilityLayer;
  47879. private _defaultKeepDepthUtilityLayer;
  47880. /**
  47881. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47882. */
  47883. boundingBoxDragBehavior: SixDofDragBehavior;
  47884. /**
  47885. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47886. */
  47887. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47888. /**
  47889. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47890. */
  47891. usePointerToAttachGizmos: boolean;
  47892. /**
  47893. * Utility layer that the bounding box gizmo belongs to
  47894. */
  47895. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47896. /**
  47897. * Utility layer that all gizmos besides bounding box belong to
  47898. */
  47899. readonly utilityLayer: UtilityLayerRenderer;
  47900. /**
  47901. * Instatiates a gizmo manager
  47902. * @param scene the scene to overlay the gizmos on top of
  47903. */
  47904. constructor(scene: Scene);
  47905. /**
  47906. * Attaches a set of gizmos to the specified mesh
  47907. * @param mesh The mesh the gizmo's should be attached to
  47908. */
  47909. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47910. /**
  47911. * If the position gizmo is enabled
  47912. */
  47913. positionGizmoEnabled: boolean;
  47914. /**
  47915. * If the rotation gizmo is enabled
  47916. */
  47917. rotationGizmoEnabled: boolean;
  47918. /**
  47919. * If the scale gizmo is enabled
  47920. */
  47921. scaleGizmoEnabled: boolean;
  47922. /**
  47923. * If the boundingBox gizmo is enabled
  47924. */
  47925. boundingBoxGizmoEnabled: boolean;
  47926. /**
  47927. * Disposes of the gizmo manager
  47928. */
  47929. dispose(): void;
  47930. }
  47931. }
  47932. declare module "babylonjs/Lights/directionalLight" {
  47933. import { Camera } from "babylonjs/Cameras/camera";
  47934. import { Scene } from "babylonjs/scene";
  47935. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47937. import { Light } from "babylonjs/Lights/light";
  47938. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47939. import { Effect } from "babylonjs/Materials/effect";
  47940. /**
  47941. * A directional light is defined by a direction (what a surprise!).
  47942. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47943. * 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.
  47944. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47945. */
  47946. export class DirectionalLight extends ShadowLight {
  47947. private _shadowFrustumSize;
  47948. /**
  47949. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47950. */
  47951. /**
  47952. * Specifies a fix frustum size for the shadow generation.
  47953. */
  47954. shadowFrustumSize: number;
  47955. private _shadowOrthoScale;
  47956. /**
  47957. * Gets the shadow projection scale against the optimal computed one.
  47958. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47959. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47960. */
  47961. /**
  47962. * Sets the shadow projection scale against the optimal computed one.
  47963. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47964. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47965. */
  47966. shadowOrthoScale: number;
  47967. /**
  47968. * Automatically compute the projection matrix to best fit (including all the casters)
  47969. * on each frame.
  47970. */
  47971. autoUpdateExtends: boolean;
  47972. private _orthoLeft;
  47973. private _orthoRight;
  47974. private _orthoTop;
  47975. private _orthoBottom;
  47976. /**
  47977. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47978. * The directional light is emitted from everywhere in the given direction.
  47979. * It can cast shadows.
  47980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47981. * @param name The friendly name of the light
  47982. * @param direction The direction of the light
  47983. * @param scene The scene the light belongs to
  47984. */
  47985. constructor(name: string, direction: Vector3, scene: Scene);
  47986. /**
  47987. * Returns the string "DirectionalLight".
  47988. * @return The class name
  47989. */
  47990. getClassName(): string;
  47991. /**
  47992. * Returns the integer 1.
  47993. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47994. */
  47995. getTypeID(): number;
  47996. /**
  47997. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47998. * Returns the DirectionalLight Shadow projection matrix.
  47999. */
  48000. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48001. /**
  48002. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48003. * Returns the DirectionalLight Shadow projection matrix.
  48004. */
  48005. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48006. /**
  48007. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48008. * Returns the DirectionalLight Shadow projection matrix.
  48009. */
  48010. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48011. protected _buildUniformLayout(): void;
  48012. /**
  48013. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48014. * @param effect The effect to update
  48015. * @param lightIndex The index of the light in the effect to update
  48016. * @returns The directional light
  48017. */
  48018. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48019. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48020. /**
  48021. * Gets the minZ used for shadow according to both the scene and the light.
  48022. *
  48023. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48024. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48025. * @param activeCamera The camera we are returning the min for
  48026. * @returns the depth min z
  48027. */
  48028. getDepthMinZ(activeCamera: Camera): number;
  48029. /**
  48030. * Gets the maxZ used for shadow according to both the scene and the light.
  48031. *
  48032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48034. * @param activeCamera The camera we are returning the max for
  48035. * @returns the depth max z
  48036. */
  48037. getDepthMaxZ(activeCamera: Camera): number;
  48038. /**
  48039. * Prepares the list of defines specific to the light type.
  48040. * @param defines the list of defines
  48041. * @param lightIndex defines the index of the light for the effect
  48042. */
  48043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48044. }
  48045. }
  48046. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48047. import { Mesh } from "babylonjs/Meshes/mesh";
  48048. /**
  48049. * Class containing static functions to help procedurally build meshes
  48050. */
  48051. export class HemisphereBuilder {
  48052. /**
  48053. * Creates a hemisphere mesh
  48054. * @param name defines the name of the mesh
  48055. * @param options defines the options used to create the mesh
  48056. * @param scene defines the hosting scene
  48057. * @returns the hemisphere mesh
  48058. */
  48059. static CreateHemisphere(name: string, options: {
  48060. segments?: number;
  48061. diameter?: number;
  48062. sideOrientation?: number;
  48063. }, scene: any): Mesh;
  48064. }
  48065. }
  48066. declare module "babylonjs/Lights/spotLight" {
  48067. import { Nullable } from "babylonjs/types";
  48068. import { Scene } from "babylonjs/scene";
  48069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48071. import { Effect } from "babylonjs/Materials/effect";
  48072. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48073. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48074. /**
  48075. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48076. * These values define a cone of light starting from the position, emitting toward the direction.
  48077. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48078. * and the exponent defines the speed of the decay of the light with distance (reach).
  48079. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48080. */
  48081. export class SpotLight extends ShadowLight {
  48082. private _angle;
  48083. private _innerAngle;
  48084. private _cosHalfAngle;
  48085. private _lightAngleScale;
  48086. private _lightAngleOffset;
  48087. /**
  48088. * Gets the cone angle of the spot light in Radians.
  48089. */
  48090. /**
  48091. * Sets the cone angle of the spot light in Radians.
  48092. */
  48093. angle: number;
  48094. /**
  48095. * Only used in gltf falloff mode, this defines the angle where
  48096. * the directional falloff will start before cutting at angle which could be seen
  48097. * as outer angle.
  48098. */
  48099. /**
  48100. * Only used in gltf falloff mode, this defines the angle where
  48101. * the directional falloff will start before cutting at angle which could be seen
  48102. * as outer angle.
  48103. */
  48104. innerAngle: number;
  48105. private _shadowAngleScale;
  48106. /**
  48107. * Allows scaling the angle of the light for shadow generation only.
  48108. */
  48109. /**
  48110. * Allows scaling the angle of the light for shadow generation only.
  48111. */
  48112. shadowAngleScale: number;
  48113. /**
  48114. * The light decay speed with the distance from the emission spot.
  48115. */
  48116. exponent: number;
  48117. private _projectionTextureMatrix;
  48118. /**
  48119. * Allows reading the projecton texture
  48120. */
  48121. readonly projectionTextureMatrix: Matrix;
  48122. protected _projectionTextureLightNear: number;
  48123. /**
  48124. * Gets the near clip of the Spotlight for texture projection.
  48125. */
  48126. /**
  48127. * Sets the near clip of the Spotlight for texture projection.
  48128. */
  48129. projectionTextureLightNear: number;
  48130. protected _projectionTextureLightFar: number;
  48131. /**
  48132. * Gets the far clip of the Spotlight for texture projection.
  48133. */
  48134. /**
  48135. * Sets the far clip of the Spotlight for texture projection.
  48136. */
  48137. projectionTextureLightFar: number;
  48138. protected _projectionTextureUpDirection: Vector3;
  48139. /**
  48140. * Gets the Up vector of the Spotlight for texture projection.
  48141. */
  48142. /**
  48143. * Sets the Up vector of the Spotlight for texture projection.
  48144. */
  48145. projectionTextureUpDirection: Vector3;
  48146. private _projectionTexture;
  48147. /**
  48148. * Gets the projection texture of the light.
  48149. */
  48150. /**
  48151. * Sets the projection texture of the light.
  48152. */
  48153. projectionTexture: Nullable<BaseTexture>;
  48154. private _projectionTextureViewLightDirty;
  48155. private _projectionTextureProjectionLightDirty;
  48156. private _projectionTextureDirty;
  48157. private _projectionTextureViewTargetVector;
  48158. private _projectionTextureViewLightMatrix;
  48159. private _projectionTextureProjectionLightMatrix;
  48160. private _projectionTextureScalingMatrix;
  48161. /**
  48162. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48163. * It can cast shadows.
  48164. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48165. * @param name The light friendly name
  48166. * @param position The position of the spot light in the scene
  48167. * @param direction The direction of the light in the scene
  48168. * @param angle The cone angle of the light in Radians
  48169. * @param exponent The light decay speed with the distance from the emission spot
  48170. * @param scene The scene the lights belongs to
  48171. */
  48172. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48173. /**
  48174. * Returns the string "SpotLight".
  48175. * @returns the class name
  48176. */
  48177. getClassName(): string;
  48178. /**
  48179. * Returns the integer 2.
  48180. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48181. */
  48182. getTypeID(): number;
  48183. /**
  48184. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48185. */
  48186. protected _setDirection(value: Vector3): void;
  48187. /**
  48188. * Overrides the position setter to recompute the projection texture view light Matrix.
  48189. */
  48190. protected _setPosition(value: Vector3): void;
  48191. /**
  48192. * 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.
  48193. * Returns the SpotLight.
  48194. */
  48195. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48196. protected _computeProjectionTextureViewLightMatrix(): void;
  48197. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48198. /**
  48199. * Main function for light texture projection matrix computing.
  48200. */
  48201. protected _computeProjectionTextureMatrix(): void;
  48202. protected _buildUniformLayout(): void;
  48203. private _computeAngleValues;
  48204. /**
  48205. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48206. * @param effect The effect to update
  48207. * @param lightIndex The index of the light in the effect to update
  48208. * @returns The spot light
  48209. */
  48210. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48211. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48212. /**
  48213. * Disposes the light and the associated resources.
  48214. */
  48215. dispose(): void;
  48216. /**
  48217. * Prepares the list of defines specific to the light type.
  48218. * @param defines the list of defines
  48219. * @param lightIndex defines the index of the light for the effect
  48220. */
  48221. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48222. }
  48223. }
  48224. declare module "babylonjs/Gizmos/lightGizmo" {
  48225. import { Nullable } from "babylonjs/types";
  48226. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48227. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48228. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48229. import { Light } from "babylonjs/Lights/light";
  48230. /**
  48231. * Gizmo that enables viewing a light
  48232. */
  48233. export class LightGizmo extends Gizmo {
  48234. private _lightMesh;
  48235. private _material;
  48236. private cachedPosition;
  48237. private cachedForward;
  48238. /**
  48239. * Creates a LightGizmo
  48240. * @param gizmoLayer The utility layer the gizmo will be added to
  48241. */
  48242. constructor(gizmoLayer?: UtilityLayerRenderer);
  48243. private _light;
  48244. /**
  48245. * The light that the gizmo is attached to
  48246. */
  48247. light: Nullable<Light>;
  48248. /**
  48249. * Gets the material used to render the light gizmo
  48250. */
  48251. readonly material: StandardMaterial;
  48252. /**
  48253. * @hidden
  48254. * Updates the gizmo to match the attached mesh's position/rotation
  48255. */
  48256. protected _update(): void;
  48257. private static _Scale;
  48258. /**
  48259. * Creates the lines for a light mesh
  48260. */
  48261. private static _createLightLines;
  48262. /**
  48263. * Disposes of the light gizmo
  48264. */
  48265. dispose(): void;
  48266. private static _CreateHemisphericLightMesh;
  48267. private static _CreatePointLightMesh;
  48268. private static _CreateSpotLightMesh;
  48269. private static _CreateDirectionalLightMesh;
  48270. }
  48271. }
  48272. declare module "babylonjs/Gizmos/index" {
  48273. export * from "babylonjs/Gizmos/axisDragGizmo";
  48274. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48275. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48276. export * from "babylonjs/Gizmos/gizmo";
  48277. export * from "babylonjs/Gizmos/gizmoManager";
  48278. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48279. export * from "babylonjs/Gizmos/positionGizmo";
  48280. export * from "babylonjs/Gizmos/rotationGizmo";
  48281. export * from "babylonjs/Gizmos/scaleGizmo";
  48282. export * from "babylonjs/Gizmos/lightGizmo";
  48283. export * from "babylonjs/Gizmos/planeDragGizmo";
  48284. }
  48285. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48286. /** @hidden */
  48287. export var backgroundFragmentDeclaration: {
  48288. name: string;
  48289. shader: string;
  48290. };
  48291. }
  48292. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48293. /** @hidden */
  48294. export var backgroundUboDeclaration: {
  48295. name: string;
  48296. shader: string;
  48297. };
  48298. }
  48299. declare module "babylonjs/Shaders/background.fragment" {
  48300. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48301. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48302. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48303. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48304. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48305. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48307. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48308. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48309. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48310. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48311. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48312. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48313. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48314. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48315. /** @hidden */
  48316. export var backgroundPixelShader: {
  48317. name: string;
  48318. shader: string;
  48319. };
  48320. }
  48321. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48322. /** @hidden */
  48323. export var backgroundVertexDeclaration: {
  48324. name: string;
  48325. shader: string;
  48326. };
  48327. }
  48328. declare module "babylonjs/Shaders/background.vertex" {
  48329. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48330. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48332. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48333. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48334. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48335. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48336. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48337. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48338. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48339. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48340. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48341. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48342. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48343. /** @hidden */
  48344. export var backgroundVertexShader: {
  48345. name: string;
  48346. shader: string;
  48347. };
  48348. }
  48349. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48350. import { Nullable, int, float } from "babylonjs/types";
  48351. import { Scene } from "babylonjs/scene";
  48352. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48355. import { Mesh } from "babylonjs/Meshes/mesh";
  48356. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48357. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48358. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48360. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48361. import { Color3 } from "babylonjs/Maths/math.color";
  48362. import "babylonjs/Shaders/background.fragment";
  48363. import "babylonjs/Shaders/background.vertex";
  48364. /**
  48365. * Background material used to create an efficient environement around your scene.
  48366. */
  48367. export class BackgroundMaterial extends PushMaterial {
  48368. /**
  48369. * Standard reflectance value at parallel view angle.
  48370. */
  48371. static StandardReflectance0: number;
  48372. /**
  48373. * Standard reflectance value at grazing angle.
  48374. */
  48375. static StandardReflectance90: number;
  48376. protected _primaryColor: Color3;
  48377. /**
  48378. * Key light Color (multiply against the environement texture)
  48379. */
  48380. primaryColor: Color3;
  48381. protected __perceptualColor: Nullable<Color3>;
  48382. /**
  48383. * Experimental Internal Use Only.
  48384. *
  48385. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48386. * This acts as a helper to set the primary color to a more "human friendly" value.
  48387. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48388. * output color as close as possible from the chosen value.
  48389. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48390. * part of lighting setup.)
  48391. */
  48392. _perceptualColor: Nullable<Color3>;
  48393. protected _primaryColorShadowLevel: float;
  48394. /**
  48395. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48396. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48397. */
  48398. primaryColorShadowLevel: float;
  48399. protected _primaryColorHighlightLevel: float;
  48400. /**
  48401. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48402. * The primary color is used at the level chosen to define what the white area would look.
  48403. */
  48404. primaryColorHighlightLevel: float;
  48405. protected _reflectionTexture: Nullable<BaseTexture>;
  48406. /**
  48407. * Reflection Texture used in the material.
  48408. * Should be author in a specific way for the best result (refer to the documentation).
  48409. */
  48410. reflectionTexture: Nullable<BaseTexture>;
  48411. protected _reflectionBlur: float;
  48412. /**
  48413. * Reflection Texture level of blur.
  48414. *
  48415. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48416. * texture twice.
  48417. */
  48418. reflectionBlur: float;
  48419. protected _diffuseTexture: Nullable<BaseTexture>;
  48420. /**
  48421. * Diffuse Texture used in the material.
  48422. * Should be author in a specific way for the best result (refer to the documentation).
  48423. */
  48424. diffuseTexture: Nullable<BaseTexture>;
  48425. protected _shadowLights: Nullable<IShadowLight[]>;
  48426. /**
  48427. * Specify the list of lights casting shadow on the material.
  48428. * All scene shadow lights will be included if null.
  48429. */
  48430. shadowLights: Nullable<IShadowLight[]>;
  48431. protected _shadowLevel: float;
  48432. /**
  48433. * Helps adjusting the shadow to a softer level if required.
  48434. * 0 means black shadows and 1 means no shadows.
  48435. */
  48436. shadowLevel: float;
  48437. protected _sceneCenter: Vector3;
  48438. /**
  48439. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48440. * It is usually zero but might be interesting to modify according to your setup.
  48441. */
  48442. sceneCenter: Vector3;
  48443. protected _opacityFresnel: boolean;
  48444. /**
  48445. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48446. * This helps ensuring a nice transition when the camera goes under the ground.
  48447. */
  48448. opacityFresnel: boolean;
  48449. protected _reflectionFresnel: boolean;
  48450. /**
  48451. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48452. * This helps adding a mirror texture on the ground.
  48453. */
  48454. reflectionFresnel: boolean;
  48455. protected _reflectionFalloffDistance: number;
  48456. /**
  48457. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48458. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48459. */
  48460. reflectionFalloffDistance: number;
  48461. protected _reflectionAmount: number;
  48462. /**
  48463. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48464. */
  48465. reflectionAmount: number;
  48466. protected _reflectionReflectance0: number;
  48467. /**
  48468. * This specifies the weight of the reflection at grazing angle.
  48469. */
  48470. reflectionReflectance0: number;
  48471. protected _reflectionReflectance90: number;
  48472. /**
  48473. * This specifies the weight of the reflection at a perpendicular point of view.
  48474. */
  48475. reflectionReflectance90: number;
  48476. /**
  48477. * Sets the reflection reflectance fresnel values according to the default standard
  48478. * empirically know to work well :-)
  48479. */
  48480. reflectionStandardFresnelWeight: number;
  48481. protected _useRGBColor: boolean;
  48482. /**
  48483. * Helps to directly use the maps channels instead of their level.
  48484. */
  48485. useRGBColor: boolean;
  48486. protected _enableNoise: boolean;
  48487. /**
  48488. * This helps reducing the banding effect that could occur on the background.
  48489. */
  48490. enableNoise: boolean;
  48491. /**
  48492. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48493. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48494. * Recommended to be keep at 1.0 except for special cases.
  48495. */
  48496. fovMultiplier: number;
  48497. private _fovMultiplier;
  48498. /**
  48499. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48500. */
  48501. useEquirectangularFOV: boolean;
  48502. private _maxSimultaneousLights;
  48503. /**
  48504. * Number of Simultaneous lights allowed on the material.
  48505. */
  48506. maxSimultaneousLights: int;
  48507. /**
  48508. * Default configuration related to image processing available in the Background Material.
  48509. */
  48510. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48511. /**
  48512. * Keep track of the image processing observer to allow dispose and replace.
  48513. */
  48514. private _imageProcessingObserver;
  48515. /**
  48516. * Attaches a new image processing configuration to the PBR Material.
  48517. * @param configuration (if null the scene configuration will be use)
  48518. */
  48519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48520. /**
  48521. * Gets the image processing configuration used either in this material.
  48522. */
  48523. /**
  48524. * Sets the Default image processing configuration used either in the this material.
  48525. *
  48526. * If sets to null, the scene one is in use.
  48527. */
  48528. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48529. /**
  48530. * Gets wether the color curves effect is enabled.
  48531. */
  48532. /**
  48533. * Sets wether the color curves effect is enabled.
  48534. */
  48535. cameraColorCurvesEnabled: boolean;
  48536. /**
  48537. * Gets wether the color grading effect is enabled.
  48538. */
  48539. /**
  48540. * Gets wether the color grading effect is enabled.
  48541. */
  48542. cameraColorGradingEnabled: boolean;
  48543. /**
  48544. * Gets wether tonemapping is enabled or not.
  48545. */
  48546. /**
  48547. * Sets wether tonemapping is enabled or not
  48548. */
  48549. cameraToneMappingEnabled: boolean;
  48550. /**
  48551. * The camera exposure used on this material.
  48552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48553. * This corresponds to a photographic exposure.
  48554. */
  48555. /**
  48556. * The camera exposure used on this material.
  48557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48558. * This corresponds to a photographic exposure.
  48559. */
  48560. cameraExposure: float;
  48561. /**
  48562. * Gets The camera contrast used on this material.
  48563. */
  48564. /**
  48565. * Sets The camera contrast used on this material.
  48566. */
  48567. cameraContrast: float;
  48568. /**
  48569. * Gets the Color Grading 2D Lookup Texture.
  48570. */
  48571. /**
  48572. * Sets the Color Grading 2D Lookup Texture.
  48573. */
  48574. cameraColorGradingTexture: Nullable<BaseTexture>;
  48575. /**
  48576. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48577. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48578. * 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;
  48579. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48580. */
  48581. /**
  48582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48584. * 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;
  48585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48586. */
  48587. cameraColorCurves: Nullable<ColorCurves>;
  48588. /**
  48589. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48590. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48591. */
  48592. switchToBGR: boolean;
  48593. private _renderTargets;
  48594. private _reflectionControls;
  48595. private _white;
  48596. private _primaryShadowColor;
  48597. private _primaryHighlightColor;
  48598. /**
  48599. * Instantiates a Background Material in the given scene
  48600. * @param name The friendly name of the material
  48601. * @param scene The scene to add the material to
  48602. */
  48603. constructor(name: string, scene: Scene);
  48604. /**
  48605. * Gets a boolean indicating that current material needs to register RTT
  48606. */
  48607. readonly hasRenderTargetTextures: boolean;
  48608. /**
  48609. * The entire material has been created in order to prevent overdraw.
  48610. * @returns false
  48611. */
  48612. needAlphaTesting(): boolean;
  48613. /**
  48614. * The entire material has been created in order to prevent overdraw.
  48615. * @returns true if blending is enable
  48616. */
  48617. needAlphaBlending(): boolean;
  48618. /**
  48619. * Checks wether the material is ready to be rendered for a given mesh.
  48620. * @param mesh The mesh to render
  48621. * @param subMesh The submesh to check against
  48622. * @param useInstances Specify wether or not the material is used with instances
  48623. * @returns true if all the dependencies are ready (Textures, Effects...)
  48624. */
  48625. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48626. /**
  48627. * Compute the primary color according to the chosen perceptual color.
  48628. */
  48629. private _computePrimaryColorFromPerceptualColor;
  48630. /**
  48631. * Compute the highlights and shadow colors according to their chosen levels.
  48632. */
  48633. private _computePrimaryColors;
  48634. /**
  48635. * Build the uniform buffer used in the material.
  48636. */
  48637. buildUniformLayout(): void;
  48638. /**
  48639. * Unbind the material.
  48640. */
  48641. unbind(): void;
  48642. /**
  48643. * Bind only the world matrix to the material.
  48644. * @param world The world matrix to bind.
  48645. */
  48646. bindOnlyWorldMatrix(world: Matrix): void;
  48647. /**
  48648. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48649. * @param world The world matrix to bind.
  48650. * @param subMesh The submesh to bind for.
  48651. */
  48652. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48653. /**
  48654. * Checks to see if a texture is used in the material.
  48655. * @param texture - Base texture to use.
  48656. * @returns - Boolean specifying if a texture is used in the material.
  48657. */
  48658. hasTexture(texture: BaseTexture): boolean;
  48659. /**
  48660. * Dispose the material.
  48661. * @param forceDisposeEffect Force disposal of the associated effect.
  48662. * @param forceDisposeTextures Force disposal of the associated textures.
  48663. */
  48664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48665. /**
  48666. * Clones the material.
  48667. * @param name The cloned name.
  48668. * @returns The cloned material.
  48669. */
  48670. clone(name: string): BackgroundMaterial;
  48671. /**
  48672. * Serializes the current material to its JSON representation.
  48673. * @returns The JSON representation.
  48674. */
  48675. serialize(): any;
  48676. /**
  48677. * Gets the class name of the material
  48678. * @returns "BackgroundMaterial"
  48679. */
  48680. getClassName(): string;
  48681. /**
  48682. * Parse a JSON input to create back a background material.
  48683. * @param source The JSON data to parse
  48684. * @param scene The scene to create the parsed material in
  48685. * @param rootUrl The root url of the assets the material depends upon
  48686. * @returns the instantiated BackgroundMaterial.
  48687. */
  48688. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48689. }
  48690. }
  48691. declare module "babylonjs/Helpers/environmentHelper" {
  48692. import { Observable } from "babylonjs/Misc/observable";
  48693. import { Nullable } from "babylonjs/types";
  48694. import { Scene } from "babylonjs/scene";
  48695. import { Vector3 } from "babylonjs/Maths/math.vector";
  48696. import { Color3 } from "babylonjs/Maths/math.color";
  48697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48698. import { Mesh } from "babylonjs/Meshes/mesh";
  48699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48700. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48701. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48702. import "babylonjs/Meshes/Builders/planeBuilder";
  48703. import "babylonjs/Meshes/Builders/boxBuilder";
  48704. /**
  48705. * Represents the different options available during the creation of
  48706. * a Environment helper.
  48707. *
  48708. * This can control the default ground, skybox and image processing setup of your scene.
  48709. */
  48710. export interface IEnvironmentHelperOptions {
  48711. /**
  48712. * Specifies wether or not to create a ground.
  48713. * True by default.
  48714. */
  48715. createGround: boolean;
  48716. /**
  48717. * Specifies the ground size.
  48718. * 15 by default.
  48719. */
  48720. groundSize: number;
  48721. /**
  48722. * The texture used on the ground for the main color.
  48723. * Comes from the BabylonJS CDN by default.
  48724. *
  48725. * Remarks: Can be either a texture or a url.
  48726. */
  48727. groundTexture: string | BaseTexture;
  48728. /**
  48729. * The color mixed in the ground texture by default.
  48730. * BabylonJS clearColor by default.
  48731. */
  48732. groundColor: Color3;
  48733. /**
  48734. * Specifies the ground opacity.
  48735. * 1 by default.
  48736. */
  48737. groundOpacity: number;
  48738. /**
  48739. * Enables the ground to receive shadows.
  48740. * True by default.
  48741. */
  48742. enableGroundShadow: boolean;
  48743. /**
  48744. * Helps preventing the shadow to be fully black on the ground.
  48745. * 0.5 by default.
  48746. */
  48747. groundShadowLevel: number;
  48748. /**
  48749. * Creates a mirror texture attach to the ground.
  48750. * false by default.
  48751. */
  48752. enableGroundMirror: boolean;
  48753. /**
  48754. * Specifies the ground mirror size ratio.
  48755. * 0.3 by default as the default kernel is 64.
  48756. */
  48757. groundMirrorSizeRatio: number;
  48758. /**
  48759. * Specifies the ground mirror blur kernel size.
  48760. * 64 by default.
  48761. */
  48762. groundMirrorBlurKernel: number;
  48763. /**
  48764. * Specifies the ground mirror visibility amount.
  48765. * 1 by default
  48766. */
  48767. groundMirrorAmount: number;
  48768. /**
  48769. * Specifies the ground mirror reflectance weight.
  48770. * This uses the standard weight of the background material to setup the fresnel effect
  48771. * of the mirror.
  48772. * 1 by default.
  48773. */
  48774. groundMirrorFresnelWeight: number;
  48775. /**
  48776. * Specifies the ground mirror Falloff distance.
  48777. * This can helps reducing the size of the reflection.
  48778. * 0 by Default.
  48779. */
  48780. groundMirrorFallOffDistance: number;
  48781. /**
  48782. * Specifies the ground mirror texture type.
  48783. * Unsigned Int by Default.
  48784. */
  48785. groundMirrorTextureType: number;
  48786. /**
  48787. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48788. * the shown objects.
  48789. */
  48790. groundYBias: number;
  48791. /**
  48792. * Specifies wether or not to create a skybox.
  48793. * True by default.
  48794. */
  48795. createSkybox: boolean;
  48796. /**
  48797. * Specifies the skybox size.
  48798. * 20 by default.
  48799. */
  48800. skyboxSize: number;
  48801. /**
  48802. * The texture used on the skybox for the main color.
  48803. * Comes from the BabylonJS CDN by default.
  48804. *
  48805. * Remarks: Can be either a texture or a url.
  48806. */
  48807. skyboxTexture: string | BaseTexture;
  48808. /**
  48809. * The color mixed in the skybox texture by default.
  48810. * BabylonJS clearColor by default.
  48811. */
  48812. skyboxColor: Color3;
  48813. /**
  48814. * The background rotation around the Y axis of the scene.
  48815. * This helps aligning the key lights of your scene with the background.
  48816. * 0 by default.
  48817. */
  48818. backgroundYRotation: number;
  48819. /**
  48820. * Compute automatically the size of the elements to best fit with the scene.
  48821. */
  48822. sizeAuto: boolean;
  48823. /**
  48824. * Default position of the rootMesh if autoSize is not true.
  48825. */
  48826. rootPosition: Vector3;
  48827. /**
  48828. * Sets up the image processing in the scene.
  48829. * true by default.
  48830. */
  48831. setupImageProcessing: boolean;
  48832. /**
  48833. * The texture used as your environment texture in the scene.
  48834. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48835. *
  48836. * Remarks: Can be either a texture or a url.
  48837. */
  48838. environmentTexture: string | BaseTexture;
  48839. /**
  48840. * The value of the exposure to apply to the scene.
  48841. * 0.6 by default if setupImageProcessing is true.
  48842. */
  48843. cameraExposure: number;
  48844. /**
  48845. * The value of the contrast to apply to the scene.
  48846. * 1.6 by default if setupImageProcessing is true.
  48847. */
  48848. cameraContrast: number;
  48849. /**
  48850. * Specifies wether or not tonemapping should be enabled in the scene.
  48851. * true by default if setupImageProcessing is true.
  48852. */
  48853. toneMappingEnabled: boolean;
  48854. }
  48855. /**
  48856. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48857. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48858. * It also helps with the default setup of your imageProcessing configuration.
  48859. */
  48860. export class EnvironmentHelper {
  48861. /**
  48862. * Default ground texture URL.
  48863. */
  48864. private static _groundTextureCDNUrl;
  48865. /**
  48866. * Default skybox texture URL.
  48867. */
  48868. private static _skyboxTextureCDNUrl;
  48869. /**
  48870. * Default environment texture URL.
  48871. */
  48872. private static _environmentTextureCDNUrl;
  48873. /**
  48874. * Creates the default options for the helper.
  48875. */
  48876. private static _getDefaultOptions;
  48877. private _rootMesh;
  48878. /**
  48879. * Gets the root mesh created by the helper.
  48880. */
  48881. readonly rootMesh: Mesh;
  48882. private _skybox;
  48883. /**
  48884. * Gets the skybox created by the helper.
  48885. */
  48886. readonly skybox: Nullable<Mesh>;
  48887. private _skyboxTexture;
  48888. /**
  48889. * Gets the skybox texture created by the helper.
  48890. */
  48891. readonly skyboxTexture: Nullable<BaseTexture>;
  48892. private _skyboxMaterial;
  48893. /**
  48894. * Gets the skybox material created by the helper.
  48895. */
  48896. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48897. private _ground;
  48898. /**
  48899. * Gets the ground mesh created by the helper.
  48900. */
  48901. readonly ground: Nullable<Mesh>;
  48902. private _groundTexture;
  48903. /**
  48904. * Gets the ground texture created by the helper.
  48905. */
  48906. readonly groundTexture: Nullable<BaseTexture>;
  48907. private _groundMirror;
  48908. /**
  48909. * Gets the ground mirror created by the helper.
  48910. */
  48911. readonly groundMirror: Nullable<MirrorTexture>;
  48912. /**
  48913. * Gets the ground mirror render list to helps pushing the meshes
  48914. * you wish in the ground reflection.
  48915. */
  48916. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48917. private _groundMaterial;
  48918. /**
  48919. * Gets the ground material created by the helper.
  48920. */
  48921. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48922. /**
  48923. * Stores the creation options.
  48924. */
  48925. private readonly _scene;
  48926. private _options;
  48927. /**
  48928. * This observable will be notified with any error during the creation of the environment,
  48929. * mainly texture creation errors.
  48930. */
  48931. onErrorObservable: Observable<{
  48932. message?: string;
  48933. exception?: any;
  48934. }>;
  48935. /**
  48936. * constructor
  48937. * @param options Defines the options we want to customize the helper
  48938. * @param scene The scene to add the material to
  48939. */
  48940. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48941. /**
  48942. * Updates the background according to the new options
  48943. * @param options
  48944. */
  48945. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48946. /**
  48947. * Sets the primary color of all the available elements.
  48948. * @param color the main color to affect to the ground and the background
  48949. */
  48950. setMainColor(color: Color3): void;
  48951. /**
  48952. * Setup the image processing according to the specified options.
  48953. */
  48954. private _setupImageProcessing;
  48955. /**
  48956. * Setup the environment texture according to the specified options.
  48957. */
  48958. private _setupEnvironmentTexture;
  48959. /**
  48960. * Setup the background according to the specified options.
  48961. */
  48962. private _setupBackground;
  48963. /**
  48964. * Get the scene sizes according to the setup.
  48965. */
  48966. private _getSceneSize;
  48967. /**
  48968. * Setup the ground according to the specified options.
  48969. */
  48970. private _setupGround;
  48971. /**
  48972. * Setup the ground material according to the specified options.
  48973. */
  48974. private _setupGroundMaterial;
  48975. /**
  48976. * Setup the ground diffuse texture according to the specified options.
  48977. */
  48978. private _setupGroundDiffuseTexture;
  48979. /**
  48980. * Setup the ground mirror texture according to the specified options.
  48981. */
  48982. private _setupGroundMirrorTexture;
  48983. /**
  48984. * Setup the ground to receive the mirror texture.
  48985. */
  48986. private _setupMirrorInGroundMaterial;
  48987. /**
  48988. * Setup the skybox according to the specified options.
  48989. */
  48990. private _setupSkybox;
  48991. /**
  48992. * Setup the skybox material according to the specified options.
  48993. */
  48994. private _setupSkyboxMaterial;
  48995. /**
  48996. * Setup the skybox reflection texture according to the specified options.
  48997. */
  48998. private _setupSkyboxReflectionTexture;
  48999. private _errorHandler;
  49000. /**
  49001. * Dispose all the elements created by the Helper.
  49002. */
  49003. dispose(): void;
  49004. }
  49005. }
  49006. declare module "babylonjs/Helpers/photoDome" {
  49007. import { Observable } from "babylonjs/Misc/observable";
  49008. import { Nullable } from "babylonjs/types";
  49009. import { Scene } from "babylonjs/scene";
  49010. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49011. import { Mesh } from "babylonjs/Meshes/mesh";
  49012. import { Texture } from "babylonjs/Materials/Textures/texture";
  49013. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49014. import "babylonjs/Meshes/Builders/sphereBuilder";
  49015. /**
  49016. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49017. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49018. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49019. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49020. */
  49021. export class PhotoDome extends TransformNode {
  49022. /**
  49023. * Define the image as a Monoscopic panoramic 360 image.
  49024. */
  49025. static readonly MODE_MONOSCOPIC: number;
  49026. /**
  49027. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49028. */
  49029. static readonly MODE_TOPBOTTOM: number;
  49030. /**
  49031. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49032. */
  49033. static readonly MODE_SIDEBYSIDE: number;
  49034. private _useDirectMapping;
  49035. /**
  49036. * The texture being displayed on the sphere
  49037. */
  49038. protected _photoTexture: Texture;
  49039. /**
  49040. * Gets or sets the texture being displayed on the sphere
  49041. */
  49042. photoTexture: Texture;
  49043. /**
  49044. * Observable raised when an error occured while loading the 360 image
  49045. */
  49046. onLoadErrorObservable: Observable<string>;
  49047. /**
  49048. * The skybox material
  49049. */
  49050. protected _material: BackgroundMaterial;
  49051. /**
  49052. * The surface used for the skybox
  49053. */
  49054. protected _mesh: Mesh;
  49055. /**
  49056. * Gets the mesh used for the skybox.
  49057. */
  49058. readonly mesh: Mesh;
  49059. /**
  49060. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49061. * Also see the options.resolution property.
  49062. */
  49063. fovMultiplier: number;
  49064. private _imageMode;
  49065. /**
  49066. * Gets or set the current video mode for the video. It can be:
  49067. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49068. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49069. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49070. */
  49071. imageMode: number;
  49072. /**
  49073. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49074. * @param name Element's name, child elements will append suffixes for their own names.
  49075. * @param urlsOfPhoto defines the url of the photo to display
  49076. * @param options defines an object containing optional or exposed sub element properties
  49077. * @param onError defines a callback called when an error occured while loading the texture
  49078. */
  49079. constructor(name: string, urlOfPhoto: string, options: {
  49080. resolution?: number;
  49081. size?: number;
  49082. useDirectMapping?: boolean;
  49083. faceForward?: boolean;
  49084. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49085. private _onBeforeCameraRenderObserver;
  49086. private _changeImageMode;
  49087. /**
  49088. * Releases resources associated with this node.
  49089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49091. */
  49092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49093. }
  49094. }
  49095. declare module "babylonjs/Misc/rgbdTextureTools" {
  49096. import "babylonjs/Shaders/rgbdDecode.fragment";
  49097. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49098. import { Texture } from "babylonjs/Materials/Textures/texture";
  49099. /**
  49100. * Class used to host RGBD texture specific utilities
  49101. */
  49102. export class RGBDTextureTools {
  49103. /**
  49104. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49105. * @param texture the texture to expand.
  49106. */
  49107. static ExpandRGBDTexture(texture: Texture): void;
  49108. }
  49109. }
  49110. declare module "babylonjs/Misc/brdfTextureTools" {
  49111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49112. import { Scene } from "babylonjs/scene";
  49113. /**
  49114. * Class used to host texture specific utilities
  49115. */
  49116. export class BRDFTextureTools {
  49117. /**
  49118. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49119. * @param scene defines the hosting scene
  49120. * @returns the environment BRDF texture
  49121. */
  49122. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49123. private static _environmentBRDFBase64Texture;
  49124. }
  49125. }
  49126. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49127. import { Nullable } from "babylonjs/types";
  49128. import { Color3 } from "babylonjs/Maths/math.color";
  49129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49130. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49131. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49132. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49133. import { Engine } from "babylonjs/Engines/engine";
  49134. import { Scene } from "babylonjs/scene";
  49135. /**
  49136. * @hidden
  49137. */
  49138. export interface IMaterialClearCoatDefines {
  49139. CLEARCOAT: boolean;
  49140. CLEARCOAT_DEFAULTIOR: boolean;
  49141. CLEARCOAT_TEXTURE: boolean;
  49142. CLEARCOAT_TEXTUREDIRECTUV: number;
  49143. CLEARCOAT_BUMP: boolean;
  49144. CLEARCOAT_BUMPDIRECTUV: number;
  49145. CLEARCOAT_TINT: boolean;
  49146. CLEARCOAT_TINT_TEXTURE: boolean;
  49147. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49148. /** @hidden */
  49149. _areTexturesDirty: boolean;
  49150. }
  49151. /**
  49152. * Define the code related to the clear coat parameters of the pbr material.
  49153. */
  49154. export class PBRClearCoatConfiguration {
  49155. /**
  49156. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49157. * The default fits with a polyurethane material.
  49158. */
  49159. private static readonly _DefaultIndexOfRefraction;
  49160. private _isEnabled;
  49161. /**
  49162. * Defines if the clear coat is enabled in the material.
  49163. */
  49164. isEnabled: boolean;
  49165. /**
  49166. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49167. */
  49168. intensity: number;
  49169. /**
  49170. * Defines the clear coat layer roughness.
  49171. */
  49172. roughness: number;
  49173. private _indexOfRefraction;
  49174. /**
  49175. * Defines the index of refraction of the clear coat.
  49176. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49177. * The default fits with a polyurethane material.
  49178. * Changing the default value is more performance intensive.
  49179. */
  49180. indexOfRefraction: number;
  49181. private _texture;
  49182. /**
  49183. * Stores the clear coat values in a texture.
  49184. */
  49185. texture: Nullable<BaseTexture>;
  49186. private _bumpTexture;
  49187. /**
  49188. * Define the clear coat specific bump texture.
  49189. */
  49190. bumpTexture: Nullable<BaseTexture>;
  49191. private _isTintEnabled;
  49192. /**
  49193. * Defines if the clear coat tint is enabled in the material.
  49194. */
  49195. isTintEnabled: boolean;
  49196. /**
  49197. * Defines the clear coat tint of the material.
  49198. * This is only use if tint is enabled
  49199. */
  49200. tintColor: Color3;
  49201. /**
  49202. * Defines the distance at which the tint color should be found in the
  49203. * clear coat media.
  49204. * This is only use if tint is enabled
  49205. */
  49206. tintColorAtDistance: number;
  49207. /**
  49208. * Defines the clear coat layer thickness.
  49209. * This is only use if tint is enabled
  49210. */
  49211. tintThickness: number;
  49212. private _tintTexture;
  49213. /**
  49214. * Stores the clear tint values in a texture.
  49215. * rgb is tint
  49216. * a is a thickness factor
  49217. */
  49218. tintTexture: Nullable<BaseTexture>;
  49219. /** @hidden */
  49220. private _internalMarkAllSubMeshesAsTexturesDirty;
  49221. /** @hidden */
  49222. _markAllSubMeshesAsTexturesDirty(): void;
  49223. /**
  49224. * Instantiate a new istance of clear coat configuration.
  49225. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49226. */
  49227. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49228. /**
  49229. * Gets wehter the submesh is ready to be used or not.
  49230. * @param defines the list of "defines" to update.
  49231. * @param scene defines the scene the material belongs to.
  49232. * @param engine defines the engine the material belongs to.
  49233. * @param disableBumpMap defines wether the material disables bump or not.
  49234. * @returns - boolean indicating that the submesh is ready or not.
  49235. */
  49236. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49237. /**
  49238. * Checks to see if a texture is used in the material.
  49239. * @param defines the list of "defines" to update.
  49240. * @param scene defines the scene to the material belongs to.
  49241. */
  49242. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49243. /**
  49244. * Binds the material data.
  49245. * @param uniformBuffer defines the Uniform buffer to fill in.
  49246. * @param scene defines the scene the material belongs to.
  49247. * @param engine defines the engine the material belongs to.
  49248. * @param disableBumpMap defines wether the material disables bump or not.
  49249. * @param isFrozen defines wether the material is frozen or not.
  49250. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49251. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49252. */
  49253. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49254. /**
  49255. * Checks to see if a texture is used in the material.
  49256. * @param texture - Base texture to use.
  49257. * @returns - Boolean specifying if a texture is used in the material.
  49258. */
  49259. hasTexture(texture: BaseTexture): boolean;
  49260. /**
  49261. * Returns an array of the actively used textures.
  49262. * @param activeTextures Array of BaseTextures
  49263. */
  49264. getActiveTextures(activeTextures: BaseTexture[]): void;
  49265. /**
  49266. * Returns the animatable textures.
  49267. * @param animatables Array of animatable textures.
  49268. */
  49269. getAnimatables(animatables: IAnimatable[]): void;
  49270. /**
  49271. * Disposes the resources of the material.
  49272. * @param forceDisposeTextures - Forces the disposal of all textures.
  49273. */
  49274. dispose(forceDisposeTextures?: boolean): void;
  49275. /**
  49276. * Get the current class name of the texture useful for serialization or dynamic coding.
  49277. * @returns "PBRClearCoatConfiguration"
  49278. */
  49279. getClassName(): string;
  49280. /**
  49281. * Add fallbacks to the effect fallbacks list.
  49282. * @param defines defines the Base texture to use.
  49283. * @param fallbacks defines the current fallback list.
  49284. * @param currentRank defines the current fallback rank.
  49285. * @returns the new fallback rank.
  49286. */
  49287. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49288. /**
  49289. * Add the required uniforms to the current list.
  49290. * @param uniforms defines the current uniform list.
  49291. */
  49292. static AddUniforms(uniforms: string[]): void;
  49293. /**
  49294. * Add the required samplers to the current list.
  49295. * @param samplers defines the current sampler list.
  49296. */
  49297. static AddSamplers(samplers: string[]): void;
  49298. /**
  49299. * Add the required uniforms to the current buffer.
  49300. * @param uniformBuffer defines the current uniform buffer.
  49301. */
  49302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49303. /**
  49304. * Makes a duplicate of the current configuration into another one.
  49305. * @param clearCoatConfiguration define the config where to copy the info
  49306. */
  49307. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49308. /**
  49309. * Serializes this clear coat configuration.
  49310. * @returns - An object with the serialized config.
  49311. */
  49312. serialize(): any;
  49313. /**
  49314. * Parses a anisotropy Configuration from a serialized object.
  49315. * @param source - Serialized object.
  49316. * @param scene Defines the scene we are parsing for
  49317. * @param rootUrl Defines the rootUrl to load from
  49318. */
  49319. parse(source: any, scene: Scene, rootUrl: string): void;
  49320. }
  49321. }
  49322. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49323. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49325. import { Vector2 } from "babylonjs/Maths/math.vector";
  49326. import { Scene } from "babylonjs/scene";
  49327. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49328. import { Nullable } from "babylonjs/types";
  49329. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49330. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49331. /**
  49332. * @hidden
  49333. */
  49334. export interface IMaterialAnisotropicDefines {
  49335. ANISOTROPIC: boolean;
  49336. ANISOTROPIC_TEXTURE: boolean;
  49337. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49338. MAINUV1: boolean;
  49339. _areTexturesDirty: boolean;
  49340. _needUVs: boolean;
  49341. }
  49342. /**
  49343. * Define the code related to the anisotropic parameters of the pbr material.
  49344. */
  49345. export class PBRAnisotropicConfiguration {
  49346. private _isEnabled;
  49347. /**
  49348. * Defines if the anisotropy is enabled in the material.
  49349. */
  49350. isEnabled: boolean;
  49351. /**
  49352. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49353. */
  49354. intensity: number;
  49355. /**
  49356. * Defines if the effect is along the tangents, bitangents or in between.
  49357. * By default, the effect is "strectching" the highlights along the tangents.
  49358. */
  49359. direction: Vector2;
  49360. private _texture;
  49361. /**
  49362. * Stores the anisotropy values in a texture.
  49363. * rg is direction (like normal from -1 to 1)
  49364. * b is a intensity
  49365. */
  49366. texture: Nullable<BaseTexture>;
  49367. /** @hidden */
  49368. private _internalMarkAllSubMeshesAsTexturesDirty;
  49369. /** @hidden */
  49370. _markAllSubMeshesAsTexturesDirty(): void;
  49371. /**
  49372. * Instantiate a new istance of anisotropy configuration.
  49373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49374. */
  49375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49376. /**
  49377. * Specifies that the submesh is ready to be used.
  49378. * @param defines the list of "defines" to update.
  49379. * @param scene defines the scene the material belongs to.
  49380. * @returns - boolean indicating that the submesh is ready or not.
  49381. */
  49382. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49383. /**
  49384. * Checks to see if a texture is used in the material.
  49385. * @param defines the list of "defines" to update.
  49386. * @param mesh the mesh we are preparing the defines for.
  49387. * @param scene defines the scene the material belongs to.
  49388. */
  49389. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49390. /**
  49391. * Binds the material data.
  49392. * @param uniformBuffer defines the Uniform buffer to fill in.
  49393. * @param scene defines the scene the material belongs to.
  49394. * @param isFrozen defines wether the material is frozen or not.
  49395. */
  49396. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49397. /**
  49398. * Checks to see if a texture is used in the material.
  49399. * @param texture - Base texture to use.
  49400. * @returns - Boolean specifying if a texture is used in the material.
  49401. */
  49402. hasTexture(texture: BaseTexture): boolean;
  49403. /**
  49404. * Returns an array of the actively used textures.
  49405. * @param activeTextures Array of BaseTextures
  49406. */
  49407. getActiveTextures(activeTextures: BaseTexture[]): void;
  49408. /**
  49409. * Returns the animatable textures.
  49410. * @param animatables Array of animatable textures.
  49411. */
  49412. getAnimatables(animatables: IAnimatable[]): void;
  49413. /**
  49414. * Disposes the resources of the material.
  49415. * @param forceDisposeTextures - Forces the disposal of all textures.
  49416. */
  49417. dispose(forceDisposeTextures?: boolean): void;
  49418. /**
  49419. * Get the current class name of the texture useful for serialization or dynamic coding.
  49420. * @returns "PBRAnisotropicConfiguration"
  49421. */
  49422. getClassName(): string;
  49423. /**
  49424. * Add fallbacks to the effect fallbacks list.
  49425. * @param defines defines the Base texture to use.
  49426. * @param fallbacks defines the current fallback list.
  49427. * @param currentRank defines the current fallback rank.
  49428. * @returns the new fallback rank.
  49429. */
  49430. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49431. /**
  49432. * Add the required uniforms to the current list.
  49433. * @param uniforms defines the current uniform list.
  49434. */
  49435. static AddUniforms(uniforms: string[]): void;
  49436. /**
  49437. * Add the required uniforms to the current buffer.
  49438. * @param uniformBuffer defines the current uniform buffer.
  49439. */
  49440. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49441. /**
  49442. * Add the required samplers to the current list.
  49443. * @param samplers defines the current sampler list.
  49444. */
  49445. static AddSamplers(samplers: string[]): void;
  49446. /**
  49447. * Makes a duplicate of the current configuration into another one.
  49448. * @param anisotropicConfiguration define the config where to copy the info
  49449. */
  49450. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49451. /**
  49452. * Serializes this anisotropy configuration.
  49453. * @returns - An object with the serialized config.
  49454. */
  49455. serialize(): any;
  49456. /**
  49457. * Parses a anisotropy Configuration from a serialized object.
  49458. * @param source - Serialized object.
  49459. * @param scene Defines the scene we are parsing for
  49460. * @param rootUrl Defines the rootUrl to load from
  49461. */
  49462. parse(source: any, scene: Scene, rootUrl: string): void;
  49463. }
  49464. }
  49465. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49466. import { Scene } from "babylonjs/scene";
  49467. /**
  49468. * @hidden
  49469. */
  49470. export interface IMaterialBRDFDefines {
  49471. BRDF_V_HEIGHT_CORRELATED: boolean;
  49472. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49473. SPHERICAL_HARMONICS: boolean;
  49474. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49475. /** @hidden */
  49476. _areMiscDirty: boolean;
  49477. }
  49478. /**
  49479. * Define the code related to the BRDF parameters of the pbr material.
  49480. */
  49481. export class PBRBRDFConfiguration {
  49482. /**
  49483. * Default value used for the energy conservation.
  49484. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49485. */
  49486. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49487. /**
  49488. * Default value used for the Smith Visibility Height Correlated mode.
  49489. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49490. */
  49491. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49492. /**
  49493. * Default value used for the IBL diffuse part.
  49494. * This can help switching back to the polynomials mode globally which is a tiny bit
  49495. * less GPU intensive at the drawback of a lower quality.
  49496. */
  49497. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49498. /**
  49499. * Default value used for activating energy conservation for the specular workflow.
  49500. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49501. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49502. */
  49503. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49504. private _useEnergyConservation;
  49505. /**
  49506. * Defines if the material uses energy conservation.
  49507. */
  49508. useEnergyConservation: boolean;
  49509. private _useSmithVisibilityHeightCorrelated;
  49510. /**
  49511. * LEGACY Mode set to false
  49512. * Defines if the material uses height smith correlated visibility term.
  49513. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49514. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49515. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49516. * Not relying on height correlated will also disable energy conservation.
  49517. */
  49518. useSmithVisibilityHeightCorrelated: boolean;
  49519. private _useSphericalHarmonics;
  49520. /**
  49521. * LEGACY Mode set to false
  49522. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49523. * diffuse part of the IBL.
  49524. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49525. * to the ground truth.
  49526. */
  49527. useSphericalHarmonics: boolean;
  49528. private _useSpecularGlossinessInputEnergyConservation;
  49529. /**
  49530. * Defines if the material uses energy conservation, when the specular workflow is active.
  49531. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49532. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49533. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49534. */
  49535. useSpecularGlossinessInputEnergyConservation: boolean;
  49536. /** @hidden */
  49537. private _internalMarkAllSubMeshesAsMiscDirty;
  49538. /** @hidden */
  49539. _markAllSubMeshesAsMiscDirty(): void;
  49540. /**
  49541. * Instantiate a new istance of clear coat configuration.
  49542. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49543. */
  49544. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49545. /**
  49546. * Checks to see if a texture is used in the material.
  49547. * @param defines the list of "defines" to update.
  49548. */
  49549. prepareDefines(defines: IMaterialBRDFDefines): void;
  49550. /**
  49551. * Get the current class name of the texture useful for serialization or dynamic coding.
  49552. * @returns "PBRClearCoatConfiguration"
  49553. */
  49554. getClassName(): string;
  49555. /**
  49556. * Makes a duplicate of the current configuration into another one.
  49557. * @param brdfConfiguration define the config where to copy the info
  49558. */
  49559. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49560. /**
  49561. * Serializes this BRDF configuration.
  49562. * @returns - An object with the serialized config.
  49563. */
  49564. serialize(): any;
  49565. /**
  49566. * Parses a anisotropy Configuration from a serialized object.
  49567. * @param source - Serialized object.
  49568. * @param scene Defines the scene we are parsing for
  49569. * @param rootUrl Defines the rootUrl to load from
  49570. */
  49571. parse(source: any, scene: Scene, rootUrl: string): void;
  49572. }
  49573. }
  49574. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49575. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49576. import { Color3 } from "babylonjs/Maths/math.color";
  49577. import { Scene } from "babylonjs/scene";
  49578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49579. import { Nullable } from "babylonjs/types";
  49580. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49581. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49582. /**
  49583. * @hidden
  49584. */
  49585. export interface IMaterialSheenDefines {
  49586. SHEEN: boolean;
  49587. SHEEN_TEXTURE: boolean;
  49588. SHEEN_TEXTUREDIRECTUV: number;
  49589. SHEEN_LINKWITHALBEDO: boolean;
  49590. /** @hidden */
  49591. _areTexturesDirty: boolean;
  49592. }
  49593. /**
  49594. * Define the code related to the Sheen parameters of the pbr material.
  49595. */
  49596. export class PBRSheenConfiguration {
  49597. private _isEnabled;
  49598. /**
  49599. * Defines if the material uses sheen.
  49600. */
  49601. isEnabled: boolean;
  49602. private _linkSheenWithAlbedo;
  49603. /**
  49604. * Defines if the sheen is linked to the sheen color.
  49605. */
  49606. linkSheenWithAlbedo: boolean;
  49607. /**
  49608. * Defines the sheen intensity.
  49609. */
  49610. intensity: number;
  49611. /**
  49612. * Defines the sheen color.
  49613. */
  49614. color: Color3;
  49615. private _texture;
  49616. /**
  49617. * Stores the sheen tint values in a texture.
  49618. * rgb is tint
  49619. * a is a intensity
  49620. */
  49621. texture: Nullable<BaseTexture>;
  49622. /** @hidden */
  49623. private _internalMarkAllSubMeshesAsTexturesDirty;
  49624. /** @hidden */
  49625. _markAllSubMeshesAsTexturesDirty(): void;
  49626. /**
  49627. * Instantiate a new istance of clear coat configuration.
  49628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49629. */
  49630. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49631. /**
  49632. * Specifies that the submesh is ready to be used.
  49633. * @param defines the list of "defines" to update.
  49634. * @param scene defines the scene the material belongs to.
  49635. * @returns - boolean indicating that the submesh is ready or not.
  49636. */
  49637. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49638. /**
  49639. * Checks to see if a texture is used in the material.
  49640. * @param defines the list of "defines" to update.
  49641. * @param scene defines the scene the material belongs to.
  49642. */
  49643. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49644. /**
  49645. * Binds the material data.
  49646. * @param uniformBuffer defines the Uniform buffer to fill in.
  49647. * @param scene defines the scene the material belongs to.
  49648. * @param isFrozen defines wether the material is frozen or not.
  49649. */
  49650. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49651. /**
  49652. * Checks to see if a texture is used in the material.
  49653. * @param texture - Base texture to use.
  49654. * @returns - Boolean specifying if a texture is used in the material.
  49655. */
  49656. hasTexture(texture: BaseTexture): boolean;
  49657. /**
  49658. * Returns an array of the actively used textures.
  49659. * @param activeTextures Array of BaseTextures
  49660. */
  49661. getActiveTextures(activeTextures: BaseTexture[]): void;
  49662. /**
  49663. * Returns the animatable textures.
  49664. * @param animatables Array of animatable textures.
  49665. */
  49666. getAnimatables(animatables: IAnimatable[]): void;
  49667. /**
  49668. * Disposes the resources of the material.
  49669. * @param forceDisposeTextures - Forces the disposal of all textures.
  49670. */
  49671. dispose(forceDisposeTextures?: boolean): void;
  49672. /**
  49673. * Get the current class name of the texture useful for serialization or dynamic coding.
  49674. * @returns "PBRSheenConfiguration"
  49675. */
  49676. getClassName(): string;
  49677. /**
  49678. * Add fallbacks to the effect fallbacks list.
  49679. * @param defines defines the Base texture to use.
  49680. * @param fallbacks defines the current fallback list.
  49681. * @param currentRank defines the current fallback rank.
  49682. * @returns the new fallback rank.
  49683. */
  49684. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49685. /**
  49686. * Add the required uniforms to the current list.
  49687. * @param uniforms defines the current uniform list.
  49688. */
  49689. static AddUniforms(uniforms: string[]): void;
  49690. /**
  49691. * Add the required uniforms to the current buffer.
  49692. * @param uniformBuffer defines the current uniform buffer.
  49693. */
  49694. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49695. /**
  49696. * Add the required samplers to the current list.
  49697. * @param samplers defines the current sampler list.
  49698. */
  49699. static AddSamplers(samplers: string[]): void;
  49700. /**
  49701. * Makes a duplicate of the current configuration into another one.
  49702. * @param sheenConfiguration define the config where to copy the info
  49703. */
  49704. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49705. /**
  49706. * Serializes this BRDF configuration.
  49707. * @returns - An object with the serialized config.
  49708. */
  49709. serialize(): any;
  49710. /**
  49711. * Parses a anisotropy Configuration from a serialized object.
  49712. * @param source - Serialized object.
  49713. * @param scene Defines the scene we are parsing for
  49714. * @param rootUrl Defines the rootUrl to load from
  49715. */
  49716. parse(source: any, scene: Scene, rootUrl: string): void;
  49717. }
  49718. }
  49719. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49720. import { Nullable } from "babylonjs/types";
  49721. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49722. import { Color3 } from "babylonjs/Maths/math.color";
  49723. import { SmartArray } from "babylonjs/Misc/smartArray";
  49724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49725. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49726. import { Effect } from "babylonjs/Materials/effect";
  49727. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49728. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49729. import { Engine } from "babylonjs/Engines/engine";
  49730. import { Scene } from "babylonjs/scene";
  49731. /**
  49732. * @hidden
  49733. */
  49734. export interface IMaterialSubSurfaceDefines {
  49735. SUBSURFACE: boolean;
  49736. SS_REFRACTION: boolean;
  49737. SS_TRANSLUCENCY: boolean;
  49738. SS_SCATERRING: boolean;
  49739. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49740. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49741. SS_REFRACTIONMAP_3D: boolean;
  49742. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49743. SS_LODINREFRACTIONALPHA: boolean;
  49744. SS_GAMMAREFRACTION: boolean;
  49745. SS_RGBDREFRACTION: boolean;
  49746. SS_LINEARSPECULARREFRACTION: boolean;
  49747. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49748. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49749. /** @hidden */
  49750. _areTexturesDirty: boolean;
  49751. }
  49752. /**
  49753. * Define the code related to the sub surface parameters of the pbr material.
  49754. */
  49755. export class PBRSubSurfaceConfiguration {
  49756. private _isRefractionEnabled;
  49757. /**
  49758. * Defines if the refraction is enabled in the material.
  49759. */
  49760. isRefractionEnabled: boolean;
  49761. private _isTranslucencyEnabled;
  49762. /**
  49763. * Defines if the translucency is enabled in the material.
  49764. */
  49765. isTranslucencyEnabled: boolean;
  49766. private _isScatteringEnabled;
  49767. /**
  49768. * Defines the refraction intensity of the material.
  49769. * The refraction when enabled replaces the Diffuse part of the material.
  49770. * The intensity helps transitionning between diffuse and refraction.
  49771. */
  49772. refractionIntensity: number;
  49773. /**
  49774. * Defines the translucency intensity of the material.
  49775. * When translucency has been enabled, this defines how much of the "translucency"
  49776. * is addded to the diffuse part of the material.
  49777. */
  49778. translucencyIntensity: number;
  49779. /**
  49780. * Defines the scattering intensity of the material.
  49781. * When scattering has been enabled, this defines how much of the "scattered light"
  49782. * is addded to the diffuse part of the material.
  49783. */
  49784. scatteringIntensity: number;
  49785. private _thicknessTexture;
  49786. /**
  49787. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49788. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49789. * 0 would mean minimumThickness
  49790. * 1 would mean maximumThickness
  49791. * The other channels might be use as a mask to vary the different effects intensity.
  49792. */
  49793. thicknessTexture: Nullable<BaseTexture>;
  49794. private _refractionTexture;
  49795. /**
  49796. * Defines the texture to use for refraction.
  49797. */
  49798. refractionTexture: Nullable<BaseTexture>;
  49799. private _indexOfRefraction;
  49800. /**
  49801. * Defines the index of refraction used in the material.
  49802. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49803. */
  49804. indexOfRefraction: number;
  49805. private _invertRefractionY;
  49806. /**
  49807. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49808. */
  49809. invertRefractionY: boolean;
  49810. private _linkRefractionWithTransparency;
  49811. /**
  49812. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49813. * Materials half opaque for instance using refraction could benefit from this control.
  49814. */
  49815. linkRefractionWithTransparency: boolean;
  49816. /**
  49817. * Defines the minimum thickness stored in the thickness map.
  49818. * If no thickness map is defined, this value will be used to simulate thickness.
  49819. */
  49820. minimumThickness: number;
  49821. /**
  49822. * Defines the maximum thickness stored in the thickness map.
  49823. */
  49824. maximumThickness: number;
  49825. /**
  49826. * Defines the volume tint of the material.
  49827. * This is used for both translucency and scattering.
  49828. */
  49829. tintColor: Color3;
  49830. /**
  49831. * Defines the distance at which the tint color should be found in the media.
  49832. * This is used for refraction only.
  49833. */
  49834. tintColorAtDistance: number;
  49835. /**
  49836. * Defines how far each channel transmit through the media.
  49837. * It is defined as a color to simplify it selection.
  49838. */
  49839. diffusionDistance: Color3;
  49840. private _useMaskFromThicknessTexture;
  49841. /**
  49842. * Stores the intensity of the different subsurface effects in the thickness texture.
  49843. * * the green channel is the translucency intensity.
  49844. * * the blue channel is the scattering intensity.
  49845. * * the alpha channel is the refraction intensity.
  49846. */
  49847. useMaskFromThicknessTexture: boolean;
  49848. /** @hidden */
  49849. private _internalMarkAllSubMeshesAsTexturesDirty;
  49850. /** @hidden */
  49851. _markAllSubMeshesAsTexturesDirty(): void;
  49852. /**
  49853. * Instantiate a new istance of sub surface configuration.
  49854. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49855. */
  49856. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49857. /**
  49858. * Gets wehter the submesh is ready to be used or not.
  49859. * @param defines the list of "defines" to update.
  49860. * @param scene defines the scene the material belongs to.
  49861. * @returns - boolean indicating that the submesh is ready or not.
  49862. */
  49863. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49864. /**
  49865. * Checks to see if a texture is used in the material.
  49866. * @param defines the list of "defines" to update.
  49867. * @param scene defines the scene to the material belongs to.
  49868. */
  49869. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49870. /**
  49871. * Binds the material data.
  49872. * @param uniformBuffer defines the Uniform buffer to fill in.
  49873. * @param scene defines the scene the material belongs to.
  49874. * @param engine defines the engine the material belongs to.
  49875. * @param isFrozen defines wether the material is frozen or not.
  49876. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49877. */
  49878. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49879. /**
  49880. * Unbinds the material from the mesh.
  49881. * @param activeEffect defines the effect that should be unbound from.
  49882. * @returns true if unbound, otherwise false
  49883. */
  49884. unbind(activeEffect: Effect): boolean;
  49885. /**
  49886. * Returns the texture used for refraction or null if none is used.
  49887. * @param scene defines the scene the material belongs to.
  49888. * @returns - Refraction texture if present. If no refraction texture and refraction
  49889. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49890. */
  49891. private _getRefractionTexture;
  49892. /**
  49893. * Returns true if alpha blending should be disabled.
  49894. */
  49895. readonly disableAlphaBlending: boolean;
  49896. /**
  49897. * Fills the list of render target textures.
  49898. * @param renderTargets the list of render targets to update
  49899. */
  49900. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49901. /**
  49902. * Checks to see if a texture is used in the material.
  49903. * @param texture - Base texture to use.
  49904. * @returns - Boolean specifying if a texture is used in the material.
  49905. */
  49906. hasTexture(texture: BaseTexture): boolean;
  49907. /**
  49908. * Gets a boolean indicating that current material needs to register RTT
  49909. * @returns true if this uses a render target otherwise false.
  49910. */
  49911. hasRenderTargetTextures(): boolean;
  49912. /**
  49913. * Returns an array of the actively used textures.
  49914. * @param activeTextures Array of BaseTextures
  49915. */
  49916. getActiveTextures(activeTextures: BaseTexture[]): void;
  49917. /**
  49918. * Returns the animatable textures.
  49919. * @param animatables Array of animatable textures.
  49920. */
  49921. getAnimatables(animatables: IAnimatable[]): void;
  49922. /**
  49923. * Disposes the resources of the material.
  49924. * @param forceDisposeTextures - Forces the disposal of all textures.
  49925. */
  49926. dispose(forceDisposeTextures?: boolean): void;
  49927. /**
  49928. * Get the current class name of the texture useful for serialization or dynamic coding.
  49929. * @returns "PBRSubSurfaceConfiguration"
  49930. */
  49931. getClassName(): string;
  49932. /**
  49933. * Add fallbacks to the effect fallbacks list.
  49934. * @param defines defines the Base texture to use.
  49935. * @param fallbacks defines the current fallback list.
  49936. * @param currentRank defines the current fallback rank.
  49937. * @returns the new fallback rank.
  49938. */
  49939. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49940. /**
  49941. * Add the required uniforms to the current list.
  49942. * @param uniforms defines the current uniform list.
  49943. */
  49944. static AddUniforms(uniforms: string[]): void;
  49945. /**
  49946. * Add the required samplers to the current list.
  49947. * @param samplers defines the current sampler list.
  49948. */
  49949. static AddSamplers(samplers: string[]): void;
  49950. /**
  49951. * Add the required uniforms to the current buffer.
  49952. * @param uniformBuffer defines the current uniform buffer.
  49953. */
  49954. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49955. /**
  49956. * Makes a duplicate of the current configuration into another one.
  49957. * @param configuration define the config where to copy the info
  49958. */
  49959. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49960. /**
  49961. * Serializes this Sub Surface configuration.
  49962. * @returns - An object with the serialized config.
  49963. */
  49964. serialize(): any;
  49965. /**
  49966. * Parses a anisotropy Configuration from a serialized object.
  49967. * @param source - Serialized object.
  49968. * @param scene Defines the scene we are parsing for
  49969. * @param rootUrl Defines the rootUrl to load from
  49970. */
  49971. parse(source: any, scene: Scene, rootUrl: string): void;
  49972. }
  49973. }
  49974. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49975. /** @hidden */
  49976. export var pbrFragmentDeclaration: {
  49977. name: string;
  49978. shader: string;
  49979. };
  49980. }
  49981. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49982. /** @hidden */
  49983. export var pbrUboDeclaration: {
  49984. name: string;
  49985. shader: string;
  49986. };
  49987. }
  49988. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49989. /** @hidden */
  49990. export var pbrFragmentExtraDeclaration: {
  49991. name: string;
  49992. shader: string;
  49993. };
  49994. }
  49995. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49996. /** @hidden */
  49997. export var pbrFragmentSamplersDeclaration: {
  49998. name: string;
  49999. shader: string;
  50000. };
  50001. }
  50002. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50003. /** @hidden */
  50004. export var pbrHelperFunctions: {
  50005. name: string;
  50006. shader: string;
  50007. };
  50008. }
  50009. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50010. /** @hidden */
  50011. export var harmonicsFunctions: {
  50012. name: string;
  50013. shader: string;
  50014. };
  50015. }
  50016. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50017. /** @hidden */
  50018. export var pbrDirectLightingSetupFunctions: {
  50019. name: string;
  50020. shader: string;
  50021. };
  50022. }
  50023. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50024. /** @hidden */
  50025. export var pbrDirectLightingFalloffFunctions: {
  50026. name: string;
  50027. shader: string;
  50028. };
  50029. }
  50030. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50031. /** @hidden */
  50032. export var pbrBRDFFunctions: {
  50033. name: string;
  50034. shader: string;
  50035. };
  50036. }
  50037. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50038. /** @hidden */
  50039. export var pbrDirectLightingFunctions: {
  50040. name: string;
  50041. shader: string;
  50042. };
  50043. }
  50044. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50045. /** @hidden */
  50046. export var pbrIBLFunctions: {
  50047. name: string;
  50048. shader: string;
  50049. };
  50050. }
  50051. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50052. /** @hidden */
  50053. export var pbrDebug: {
  50054. name: string;
  50055. shader: string;
  50056. };
  50057. }
  50058. declare module "babylonjs/Shaders/pbr.fragment" {
  50059. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50060. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50061. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50062. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50063. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50064. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50066. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50067. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50068. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50070. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50071. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50072. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50073. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50074. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50075. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50076. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50077. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50078. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50079. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50080. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50082. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50083. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50084. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50085. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50086. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50087. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50088. /** @hidden */
  50089. export var pbrPixelShader: {
  50090. name: string;
  50091. shader: string;
  50092. };
  50093. }
  50094. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50095. /** @hidden */
  50096. export var pbrVertexDeclaration: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module "babylonjs/Shaders/pbr.vertex" {
  50102. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50103. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50105. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50106. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50107. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50108. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50109. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50110. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50111. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50112. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50113. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50114. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50115. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50117. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50118. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50119. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50121. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50122. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50123. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50124. /** @hidden */
  50125. export var pbrVertexShader: {
  50126. name: string;
  50127. shader: string;
  50128. };
  50129. }
  50130. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50131. import { Nullable } from "babylonjs/types";
  50132. import { Scene } from "babylonjs/scene";
  50133. import { Matrix } from "babylonjs/Maths/math.vector";
  50134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50136. import { Mesh } from "babylonjs/Meshes/mesh";
  50137. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50138. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50139. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50140. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50141. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50142. import { Color3 } from "babylonjs/Maths/math.color";
  50143. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50144. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50145. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50146. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50148. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50149. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50150. import "babylonjs/Shaders/pbr.fragment";
  50151. import "babylonjs/Shaders/pbr.vertex";
  50152. /**
  50153. * Manages the defines for the PBR Material.
  50154. * @hidden
  50155. */
  50156. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50157. PBR: boolean;
  50158. MAINUV1: boolean;
  50159. MAINUV2: boolean;
  50160. UV1: boolean;
  50161. UV2: boolean;
  50162. ALBEDO: boolean;
  50163. ALBEDODIRECTUV: number;
  50164. VERTEXCOLOR: boolean;
  50165. AMBIENT: boolean;
  50166. AMBIENTDIRECTUV: number;
  50167. AMBIENTINGRAYSCALE: boolean;
  50168. OPACITY: boolean;
  50169. VERTEXALPHA: boolean;
  50170. OPACITYDIRECTUV: number;
  50171. OPACITYRGB: boolean;
  50172. ALPHATEST: boolean;
  50173. DEPTHPREPASS: boolean;
  50174. ALPHABLEND: boolean;
  50175. ALPHAFROMALBEDO: boolean;
  50176. ALPHATESTVALUE: string;
  50177. SPECULAROVERALPHA: boolean;
  50178. RADIANCEOVERALPHA: boolean;
  50179. ALPHAFRESNEL: boolean;
  50180. LINEARALPHAFRESNEL: boolean;
  50181. PREMULTIPLYALPHA: boolean;
  50182. EMISSIVE: boolean;
  50183. EMISSIVEDIRECTUV: number;
  50184. REFLECTIVITY: boolean;
  50185. REFLECTIVITYDIRECTUV: number;
  50186. SPECULARTERM: boolean;
  50187. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50188. MICROSURFACEAUTOMATIC: boolean;
  50189. LODBASEDMICROSFURACE: boolean;
  50190. MICROSURFACEMAP: boolean;
  50191. MICROSURFACEMAPDIRECTUV: number;
  50192. METALLICWORKFLOW: boolean;
  50193. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50194. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50195. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50196. AOSTOREINMETALMAPRED: boolean;
  50197. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50198. ENVIRONMENTBRDF: boolean;
  50199. ENVIRONMENTBRDF_RGBD: boolean;
  50200. NORMAL: boolean;
  50201. TANGENT: boolean;
  50202. BUMP: boolean;
  50203. BUMPDIRECTUV: number;
  50204. OBJECTSPACE_NORMALMAP: boolean;
  50205. PARALLAX: boolean;
  50206. PARALLAXOCCLUSION: boolean;
  50207. NORMALXYSCALE: boolean;
  50208. LIGHTMAP: boolean;
  50209. LIGHTMAPDIRECTUV: number;
  50210. USELIGHTMAPASSHADOWMAP: boolean;
  50211. GAMMALIGHTMAP: boolean;
  50212. RGBDLIGHTMAP: boolean;
  50213. REFLECTION: boolean;
  50214. REFLECTIONMAP_3D: boolean;
  50215. REFLECTIONMAP_SPHERICAL: boolean;
  50216. REFLECTIONMAP_PLANAR: boolean;
  50217. REFLECTIONMAP_CUBIC: boolean;
  50218. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50219. REFLECTIONMAP_PROJECTION: boolean;
  50220. REFLECTIONMAP_SKYBOX: boolean;
  50221. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50222. REFLECTIONMAP_EXPLICIT: boolean;
  50223. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50224. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50225. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50226. INVERTCUBICMAP: boolean;
  50227. USESPHERICALFROMREFLECTIONMAP: boolean;
  50228. USEIRRADIANCEMAP: boolean;
  50229. SPHERICAL_HARMONICS: boolean;
  50230. USESPHERICALINVERTEX: boolean;
  50231. REFLECTIONMAP_OPPOSITEZ: boolean;
  50232. LODINREFLECTIONALPHA: boolean;
  50233. GAMMAREFLECTION: boolean;
  50234. RGBDREFLECTION: boolean;
  50235. LINEARSPECULARREFLECTION: boolean;
  50236. RADIANCEOCCLUSION: boolean;
  50237. HORIZONOCCLUSION: boolean;
  50238. INSTANCES: boolean;
  50239. NUM_BONE_INFLUENCERS: number;
  50240. BonesPerMesh: number;
  50241. BONETEXTURE: boolean;
  50242. NONUNIFORMSCALING: boolean;
  50243. MORPHTARGETS: boolean;
  50244. MORPHTARGETS_NORMAL: boolean;
  50245. MORPHTARGETS_TANGENT: boolean;
  50246. MORPHTARGETS_UV: boolean;
  50247. NUM_MORPH_INFLUENCERS: number;
  50248. IMAGEPROCESSING: boolean;
  50249. VIGNETTE: boolean;
  50250. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50251. VIGNETTEBLENDMODEOPAQUE: boolean;
  50252. TONEMAPPING: boolean;
  50253. TONEMAPPING_ACES: boolean;
  50254. CONTRAST: boolean;
  50255. COLORCURVES: boolean;
  50256. COLORGRADING: boolean;
  50257. COLORGRADING3D: boolean;
  50258. SAMPLER3DGREENDEPTH: boolean;
  50259. SAMPLER3DBGRMAP: boolean;
  50260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50261. EXPOSURE: boolean;
  50262. MULTIVIEW: boolean;
  50263. USEPHYSICALLIGHTFALLOFF: boolean;
  50264. USEGLTFLIGHTFALLOFF: boolean;
  50265. TWOSIDEDLIGHTING: boolean;
  50266. SHADOWFLOAT: boolean;
  50267. CLIPPLANE: boolean;
  50268. CLIPPLANE2: boolean;
  50269. CLIPPLANE3: boolean;
  50270. CLIPPLANE4: boolean;
  50271. POINTSIZE: boolean;
  50272. FOG: boolean;
  50273. LOGARITHMICDEPTH: boolean;
  50274. FORCENORMALFORWARD: boolean;
  50275. SPECULARAA: boolean;
  50276. CLEARCOAT: boolean;
  50277. CLEARCOAT_DEFAULTIOR: boolean;
  50278. CLEARCOAT_TEXTURE: boolean;
  50279. CLEARCOAT_TEXTUREDIRECTUV: number;
  50280. CLEARCOAT_BUMP: boolean;
  50281. CLEARCOAT_BUMPDIRECTUV: number;
  50282. CLEARCOAT_TINT: boolean;
  50283. CLEARCOAT_TINT_TEXTURE: boolean;
  50284. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50285. ANISOTROPIC: boolean;
  50286. ANISOTROPIC_TEXTURE: boolean;
  50287. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50288. BRDF_V_HEIGHT_CORRELATED: boolean;
  50289. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50290. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50291. SHEEN: boolean;
  50292. SHEEN_TEXTURE: boolean;
  50293. SHEEN_TEXTUREDIRECTUV: number;
  50294. SHEEN_LINKWITHALBEDO: boolean;
  50295. SUBSURFACE: boolean;
  50296. SS_REFRACTION: boolean;
  50297. SS_TRANSLUCENCY: boolean;
  50298. SS_SCATERRING: boolean;
  50299. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50300. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50301. SS_REFRACTIONMAP_3D: boolean;
  50302. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50303. SS_LODINREFRACTIONALPHA: boolean;
  50304. SS_GAMMAREFRACTION: boolean;
  50305. SS_RGBDREFRACTION: boolean;
  50306. SS_LINEARSPECULARREFRACTION: boolean;
  50307. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50308. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50309. UNLIT: boolean;
  50310. DEBUGMODE: number;
  50311. /**
  50312. * Initializes the PBR Material defines.
  50313. */
  50314. constructor();
  50315. /**
  50316. * Resets the PBR Material defines.
  50317. */
  50318. reset(): void;
  50319. }
  50320. /**
  50321. * The Physically based material base class of BJS.
  50322. *
  50323. * This offers the main features of a standard PBR material.
  50324. * For more information, please refer to the documentation :
  50325. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50326. */
  50327. export abstract class PBRBaseMaterial extends PushMaterial {
  50328. /**
  50329. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50330. */
  50331. static readonly PBRMATERIAL_OPAQUE: number;
  50332. /**
  50333. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50334. */
  50335. static readonly PBRMATERIAL_ALPHATEST: number;
  50336. /**
  50337. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50338. */
  50339. static readonly PBRMATERIAL_ALPHABLEND: number;
  50340. /**
  50341. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50342. * They are also discarded below the alpha cutoff threshold to improve performances.
  50343. */
  50344. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50345. /**
  50346. * Defines the default value of how much AO map is occluding the analytical lights
  50347. * (point spot...).
  50348. */
  50349. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50350. /**
  50351. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50352. */
  50353. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50354. /**
  50355. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50356. * to enhance interoperability with other engines.
  50357. */
  50358. static readonly LIGHTFALLOFF_GLTF: number;
  50359. /**
  50360. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50361. * to enhance interoperability with other materials.
  50362. */
  50363. static readonly LIGHTFALLOFF_STANDARD: number;
  50364. /**
  50365. * Intensity of the direct lights e.g. the four lights available in your scene.
  50366. * This impacts both the direct diffuse and specular highlights.
  50367. */
  50368. protected _directIntensity: number;
  50369. /**
  50370. * Intensity of the emissive part of the material.
  50371. * This helps controlling the emissive effect without modifying the emissive color.
  50372. */
  50373. protected _emissiveIntensity: number;
  50374. /**
  50375. * Intensity of the environment e.g. how much the environment will light the object
  50376. * either through harmonics for rough material or through the refelction for shiny ones.
  50377. */
  50378. protected _environmentIntensity: number;
  50379. /**
  50380. * This is a special control allowing the reduction of the specular highlights coming from the
  50381. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50382. */
  50383. protected _specularIntensity: number;
  50384. /**
  50385. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50386. */
  50387. private _lightingInfos;
  50388. /**
  50389. * Debug Control allowing disabling the bump map on this material.
  50390. */
  50391. protected _disableBumpMap: boolean;
  50392. /**
  50393. * AKA Diffuse Texture in standard nomenclature.
  50394. */
  50395. protected _albedoTexture: Nullable<BaseTexture>;
  50396. /**
  50397. * AKA Occlusion Texture in other nomenclature.
  50398. */
  50399. protected _ambientTexture: Nullable<BaseTexture>;
  50400. /**
  50401. * AKA Occlusion Texture Intensity in other nomenclature.
  50402. */
  50403. protected _ambientTextureStrength: number;
  50404. /**
  50405. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50406. * 1 means it completely occludes it
  50407. * 0 mean it has no impact
  50408. */
  50409. protected _ambientTextureImpactOnAnalyticalLights: number;
  50410. /**
  50411. * Stores the alpha values in a texture.
  50412. */
  50413. protected _opacityTexture: Nullable<BaseTexture>;
  50414. /**
  50415. * Stores the reflection values in a texture.
  50416. */
  50417. protected _reflectionTexture: Nullable<BaseTexture>;
  50418. /**
  50419. * Stores the emissive values in a texture.
  50420. */
  50421. protected _emissiveTexture: Nullable<BaseTexture>;
  50422. /**
  50423. * AKA Specular texture in other nomenclature.
  50424. */
  50425. protected _reflectivityTexture: Nullable<BaseTexture>;
  50426. /**
  50427. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50428. */
  50429. protected _metallicTexture: Nullable<BaseTexture>;
  50430. /**
  50431. * Specifies the metallic scalar of the metallic/roughness workflow.
  50432. * Can also be used to scale the metalness values of the metallic texture.
  50433. */
  50434. protected _metallic: Nullable<number>;
  50435. /**
  50436. * Specifies the roughness scalar of the metallic/roughness workflow.
  50437. * Can also be used to scale the roughness values of the metallic texture.
  50438. */
  50439. protected _roughness: Nullable<number>;
  50440. /**
  50441. * Specifies the an F0 factor to help configuring the material F0.
  50442. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50443. * to 0.5 the previously hard coded value stays the same.
  50444. * Can also be used to scale the F0 values of the metallic texture.
  50445. */
  50446. protected _metallicF0Factor: number;
  50447. /**
  50448. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50449. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50450. * your expectation as it multiplies with the texture data.
  50451. */
  50452. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50453. /**
  50454. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50455. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50456. */
  50457. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50458. /**
  50459. * Stores surface normal data used to displace a mesh in a texture.
  50460. */
  50461. protected _bumpTexture: Nullable<BaseTexture>;
  50462. /**
  50463. * Stores the pre-calculated light information of a mesh in a texture.
  50464. */
  50465. protected _lightmapTexture: Nullable<BaseTexture>;
  50466. /**
  50467. * The color of a material in ambient lighting.
  50468. */
  50469. protected _ambientColor: Color3;
  50470. /**
  50471. * AKA Diffuse Color in other nomenclature.
  50472. */
  50473. protected _albedoColor: Color3;
  50474. /**
  50475. * AKA Specular Color in other nomenclature.
  50476. */
  50477. protected _reflectivityColor: Color3;
  50478. /**
  50479. * The color applied when light is reflected from a material.
  50480. */
  50481. protected _reflectionColor: Color3;
  50482. /**
  50483. * The color applied when light is emitted from a material.
  50484. */
  50485. protected _emissiveColor: Color3;
  50486. /**
  50487. * AKA Glossiness in other nomenclature.
  50488. */
  50489. protected _microSurface: number;
  50490. /**
  50491. * Specifies that the material will use the light map as a show map.
  50492. */
  50493. protected _useLightmapAsShadowmap: boolean;
  50494. /**
  50495. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50496. * makes the reflect vector face the model (under horizon).
  50497. */
  50498. protected _useHorizonOcclusion: boolean;
  50499. /**
  50500. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50501. * too much the area relying on ambient texture to define their ambient occlusion.
  50502. */
  50503. protected _useRadianceOcclusion: boolean;
  50504. /**
  50505. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50506. */
  50507. protected _useAlphaFromAlbedoTexture: boolean;
  50508. /**
  50509. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50510. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50511. */
  50512. protected _useSpecularOverAlpha: boolean;
  50513. /**
  50514. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50515. */
  50516. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50517. /**
  50518. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50519. */
  50520. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50521. /**
  50522. * Specifies if the metallic texture contains the roughness information in its green channel.
  50523. */
  50524. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50525. /**
  50526. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50527. */
  50528. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50529. /**
  50530. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50531. */
  50532. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50533. /**
  50534. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50535. */
  50536. protected _useAmbientInGrayScale: boolean;
  50537. /**
  50538. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50539. * The material will try to infer what glossiness each pixel should be.
  50540. */
  50541. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50542. /**
  50543. * Defines the falloff type used in this material.
  50544. * It by default is Physical.
  50545. */
  50546. protected _lightFalloff: number;
  50547. /**
  50548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50550. */
  50551. protected _useRadianceOverAlpha: boolean;
  50552. /**
  50553. * Allows using an object space normal map (instead of tangent space).
  50554. */
  50555. protected _useObjectSpaceNormalMap: boolean;
  50556. /**
  50557. * Allows using the bump map in parallax mode.
  50558. */
  50559. protected _useParallax: boolean;
  50560. /**
  50561. * Allows using the bump map in parallax occlusion mode.
  50562. */
  50563. protected _useParallaxOcclusion: boolean;
  50564. /**
  50565. * Controls the scale bias of the parallax mode.
  50566. */
  50567. protected _parallaxScaleBias: number;
  50568. /**
  50569. * If sets to true, disables all the lights affecting the material.
  50570. */
  50571. protected _disableLighting: boolean;
  50572. /**
  50573. * Number of Simultaneous lights allowed on the material.
  50574. */
  50575. protected _maxSimultaneousLights: number;
  50576. /**
  50577. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50578. */
  50579. protected _invertNormalMapX: boolean;
  50580. /**
  50581. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50582. */
  50583. protected _invertNormalMapY: boolean;
  50584. /**
  50585. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50586. */
  50587. protected _twoSidedLighting: boolean;
  50588. /**
  50589. * Defines the alpha limits in alpha test mode.
  50590. */
  50591. protected _alphaCutOff: number;
  50592. /**
  50593. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50594. */
  50595. protected _forceAlphaTest: boolean;
  50596. /**
  50597. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50598. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50599. */
  50600. protected _useAlphaFresnel: boolean;
  50601. /**
  50602. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50603. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50604. */
  50605. protected _useLinearAlphaFresnel: boolean;
  50606. /**
  50607. * The transparency mode of the material.
  50608. */
  50609. protected _transparencyMode: Nullable<number>;
  50610. /**
  50611. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50612. * from cos thetav and roughness:
  50613. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50614. */
  50615. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50616. /**
  50617. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50618. */
  50619. protected _forceIrradianceInFragment: boolean;
  50620. /**
  50621. * Force normal to face away from face.
  50622. */
  50623. protected _forceNormalForward: boolean;
  50624. /**
  50625. * Enables specular anti aliasing in the PBR shader.
  50626. * It will both interacts on the Geometry for analytical and IBL lighting.
  50627. * It also prefilter the roughness map based on the bump values.
  50628. */
  50629. protected _enableSpecularAntiAliasing: boolean;
  50630. /**
  50631. * Default configuration related to image processing available in the PBR Material.
  50632. */
  50633. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50634. /**
  50635. * Keep track of the image processing observer to allow dispose and replace.
  50636. */
  50637. private _imageProcessingObserver;
  50638. /**
  50639. * Attaches a new image processing configuration to the PBR Material.
  50640. * @param configuration
  50641. */
  50642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50643. /**
  50644. * Stores the available render targets.
  50645. */
  50646. private _renderTargets;
  50647. /**
  50648. * Sets the global ambient color for the material used in lighting calculations.
  50649. */
  50650. private _globalAmbientColor;
  50651. /**
  50652. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50653. */
  50654. private _useLogarithmicDepth;
  50655. /**
  50656. * If set to true, no lighting calculations will be applied.
  50657. */
  50658. private _unlit;
  50659. private _debugMode;
  50660. /**
  50661. * @hidden
  50662. * This is reserved for the inspector.
  50663. * Defines the material debug mode.
  50664. * It helps seeing only some components of the material while troubleshooting.
  50665. */
  50666. debugMode: number;
  50667. /**
  50668. * @hidden
  50669. * This is reserved for the inspector.
  50670. * Specify from where on screen the debug mode should start.
  50671. * The value goes from -1 (full screen) to 1 (not visible)
  50672. * It helps with side by side comparison against the final render
  50673. * This defaults to -1
  50674. */
  50675. private debugLimit;
  50676. /**
  50677. * @hidden
  50678. * This is reserved for the inspector.
  50679. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50680. * You can use the factor to better multiply the final value.
  50681. */
  50682. private debugFactor;
  50683. /**
  50684. * Defines the clear coat layer parameters for the material.
  50685. */
  50686. readonly clearCoat: PBRClearCoatConfiguration;
  50687. /**
  50688. * Defines the anisotropic parameters for the material.
  50689. */
  50690. readonly anisotropy: PBRAnisotropicConfiguration;
  50691. /**
  50692. * Defines the BRDF parameters for the material.
  50693. */
  50694. readonly brdf: PBRBRDFConfiguration;
  50695. /**
  50696. * Defines the Sheen parameters for the material.
  50697. */
  50698. readonly sheen: PBRSheenConfiguration;
  50699. /**
  50700. * Defines the SubSurface parameters for the material.
  50701. */
  50702. readonly subSurface: PBRSubSurfaceConfiguration;
  50703. /**
  50704. * Custom callback helping to override the default shader used in the material.
  50705. */
  50706. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50707. protected _rebuildInParallel: boolean;
  50708. /**
  50709. * Instantiates a new PBRMaterial instance.
  50710. *
  50711. * @param name The material name
  50712. * @param scene The scene the material will be use in.
  50713. */
  50714. constructor(name: string, scene: Scene);
  50715. /**
  50716. * Gets a boolean indicating that current material needs to register RTT
  50717. */
  50718. readonly hasRenderTargetTextures: boolean;
  50719. /**
  50720. * Gets the name of the material class.
  50721. */
  50722. getClassName(): string;
  50723. /**
  50724. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50725. */
  50726. /**
  50727. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50728. */
  50729. useLogarithmicDepth: boolean;
  50730. /**
  50731. * Gets the current transparency mode.
  50732. */
  50733. /**
  50734. * Sets the transparency mode of the material.
  50735. *
  50736. * | Value | Type | Description |
  50737. * | ----- | ----------------------------------- | ----------- |
  50738. * | 0 | OPAQUE | |
  50739. * | 1 | ALPHATEST | |
  50740. * | 2 | ALPHABLEND | |
  50741. * | 3 | ALPHATESTANDBLEND | |
  50742. *
  50743. */
  50744. transparencyMode: Nullable<number>;
  50745. /**
  50746. * Returns true if alpha blending should be disabled.
  50747. */
  50748. private readonly _disableAlphaBlending;
  50749. /**
  50750. * Specifies whether or not this material should be rendered in alpha blend mode.
  50751. */
  50752. needAlphaBlending(): boolean;
  50753. /**
  50754. * Specifies if the mesh will require alpha blending.
  50755. * @param mesh - BJS mesh.
  50756. */
  50757. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50758. /**
  50759. * Specifies whether or not this material should be rendered in alpha test mode.
  50760. */
  50761. needAlphaTesting(): boolean;
  50762. /**
  50763. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50764. */
  50765. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50766. /**
  50767. * Gets the texture used for the alpha test.
  50768. */
  50769. getAlphaTestTexture(): Nullable<BaseTexture>;
  50770. /**
  50771. * Specifies that the submesh is ready to be used.
  50772. * @param mesh - BJS mesh.
  50773. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50774. * @param useInstances - Specifies that instances should be used.
  50775. * @returns - boolean indicating that the submesh is ready or not.
  50776. */
  50777. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50778. /**
  50779. * Specifies if the material uses metallic roughness workflow.
  50780. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50781. */
  50782. isMetallicWorkflow(): boolean;
  50783. private _prepareEffect;
  50784. private _prepareDefines;
  50785. /**
  50786. * Force shader compilation
  50787. */
  50788. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50789. /**
  50790. * Initializes the uniform buffer layout for the shader.
  50791. */
  50792. buildUniformLayout(): void;
  50793. /**
  50794. * Unbinds the material from the mesh
  50795. */
  50796. unbind(): void;
  50797. /**
  50798. * Binds the submesh data.
  50799. * @param world - The world matrix.
  50800. * @param mesh - The BJS mesh.
  50801. * @param subMesh - A submesh of the BJS mesh.
  50802. */
  50803. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50804. /**
  50805. * Returns the animatable textures.
  50806. * @returns - Array of animatable textures.
  50807. */
  50808. getAnimatables(): IAnimatable[];
  50809. /**
  50810. * Returns the texture used for reflections.
  50811. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50812. */
  50813. private _getReflectionTexture;
  50814. /**
  50815. * Returns an array of the actively used textures.
  50816. * @returns - Array of BaseTextures
  50817. */
  50818. getActiveTextures(): BaseTexture[];
  50819. /**
  50820. * Checks to see if a texture is used in the material.
  50821. * @param texture - Base texture to use.
  50822. * @returns - Boolean specifying if a texture is used in the material.
  50823. */
  50824. hasTexture(texture: BaseTexture): boolean;
  50825. /**
  50826. * Disposes the resources of the material.
  50827. * @param forceDisposeEffect - Forces the disposal of effects.
  50828. * @param forceDisposeTextures - Forces the disposal of all textures.
  50829. */
  50830. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50831. }
  50832. }
  50833. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50834. import { Nullable } from "babylonjs/types";
  50835. import { Scene } from "babylonjs/scene";
  50836. import { Color3 } from "babylonjs/Maths/math.color";
  50837. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50838. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50840. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50841. /**
  50842. * The Physically based material of BJS.
  50843. *
  50844. * This offers the main features of a standard PBR material.
  50845. * For more information, please refer to the documentation :
  50846. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50847. */
  50848. export class PBRMaterial extends PBRBaseMaterial {
  50849. /**
  50850. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50851. */
  50852. static readonly PBRMATERIAL_OPAQUE: number;
  50853. /**
  50854. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50855. */
  50856. static readonly PBRMATERIAL_ALPHATEST: number;
  50857. /**
  50858. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50859. */
  50860. static readonly PBRMATERIAL_ALPHABLEND: number;
  50861. /**
  50862. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50863. * They are also discarded below the alpha cutoff threshold to improve performances.
  50864. */
  50865. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50866. /**
  50867. * Defines the default value of how much AO map is occluding the analytical lights
  50868. * (point spot...).
  50869. */
  50870. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50871. /**
  50872. * Intensity of the direct lights e.g. the four lights available in your scene.
  50873. * This impacts both the direct diffuse and specular highlights.
  50874. */
  50875. directIntensity: number;
  50876. /**
  50877. * Intensity of the emissive part of the material.
  50878. * This helps controlling the emissive effect without modifying the emissive color.
  50879. */
  50880. emissiveIntensity: number;
  50881. /**
  50882. * Intensity of the environment e.g. how much the environment will light the object
  50883. * either through harmonics for rough material or through the refelction for shiny ones.
  50884. */
  50885. environmentIntensity: number;
  50886. /**
  50887. * This is a special control allowing the reduction of the specular highlights coming from the
  50888. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50889. */
  50890. specularIntensity: number;
  50891. /**
  50892. * Debug Control allowing disabling the bump map on this material.
  50893. */
  50894. disableBumpMap: boolean;
  50895. /**
  50896. * AKA Diffuse Texture in standard nomenclature.
  50897. */
  50898. albedoTexture: BaseTexture;
  50899. /**
  50900. * AKA Occlusion Texture in other nomenclature.
  50901. */
  50902. ambientTexture: BaseTexture;
  50903. /**
  50904. * AKA Occlusion Texture Intensity in other nomenclature.
  50905. */
  50906. ambientTextureStrength: number;
  50907. /**
  50908. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50909. * 1 means it completely occludes it
  50910. * 0 mean it has no impact
  50911. */
  50912. ambientTextureImpactOnAnalyticalLights: number;
  50913. /**
  50914. * Stores the alpha values in a texture.
  50915. */
  50916. opacityTexture: BaseTexture;
  50917. /**
  50918. * Stores the reflection values in a texture.
  50919. */
  50920. reflectionTexture: Nullable<BaseTexture>;
  50921. /**
  50922. * Stores the emissive values in a texture.
  50923. */
  50924. emissiveTexture: BaseTexture;
  50925. /**
  50926. * AKA Specular texture in other nomenclature.
  50927. */
  50928. reflectivityTexture: BaseTexture;
  50929. /**
  50930. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50931. */
  50932. metallicTexture: BaseTexture;
  50933. /**
  50934. * Specifies the metallic scalar of the metallic/roughness workflow.
  50935. * Can also be used to scale the metalness values of the metallic texture.
  50936. */
  50937. metallic: Nullable<number>;
  50938. /**
  50939. * Specifies the roughness scalar of the metallic/roughness workflow.
  50940. * Can also be used to scale the roughness values of the metallic texture.
  50941. */
  50942. roughness: Nullable<number>;
  50943. /**
  50944. * Specifies the an F0 factor to help configuring the material F0.
  50945. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50946. * to 0.5 the previously hard coded value stays the same.
  50947. * Can also be used to scale the F0 values of the metallic texture.
  50948. */
  50949. metallicF0Factor: number;
  50950. /**
  50951. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50952. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50953. * your expectation as it multiplies with the texture data.
  50954. */
  50955. useMetallicF0FactorFromMetallicTexture: boolean;
  50956. /**
  50957. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50958. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50959. */
  50960. microSurfaceTexture: BaseTexture;
  50961. /**
  50962. * Stores surface normal data used to displace a mesh in a texture.
  50963. */
  50964. bumpTexture: BaseTexture;
  50965. /**
  50966. * Stores the pre-calculated light information of a mesh in a texture.
  50967. */
  50968. lightmapTexture: BaseTexture;
  50969. /**
  50970. * Stores the refracted light information in a texture.
  50971. */
  50972. refractionTexture: Nullable<BaseTexture>;
  50973. /**
  50974. * The color of a material in ambient lighting.
  50975. */
  50976. ambientColor: Color3;
  50977. /**
  50978. * AKA Diffuse Color in other nomenclature.
  50979. */
  50980. albedoColor: Color3;
  50981. /**
  50982. * AKA Specular Color in other nomenclature.
  50983. */
  50984. reflectivityColor: Color3;
  50985. /**
  50986. * The color reflected from the material.
  50987. */
  50988. reflectionColor: Color3;
  50989. /**
  50990. * The color emitted from the material.
  50991. */
  50992. emissiveColor: Color3;
  50993. /**
  50994. * AKA Glossiness in other nomenclature.
  50995. */
  50996. microSurface: number;
  50997. /**
  50998. * source material index of refraction (IOR)' / 'destination material IOR.
  50999. */
  51000. indexOfRefraction: number;
  51001. /**
  51002. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51003. */
  51004. invertRefractionY: boolean;
  51005. /**
  51006. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51007. * Materials half opaque for instance using refraction could benefit from this control.
  51008. */
  51009. linkRefractionWithTransparency: boolean;
  51010. /**
  51011. * If true, the light map contains occlusion information instead of lighting info.
  51012. */
  51013. useLightmapAsShadowmap: boolean;
  51014. /**
  51015. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51016. */
  51017. useAlphaFromAlbedoTexture: boolean;
  51018. /**
  51019. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51020. */
  51021. forceAlphaTest: boolean;
  51022. /**
  51023. * Defines the alpha limits in alpha test mode.
  51024. */
  51025. alphaCutOff: number;
  51026. /**
  51027. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51029. */
  51030. useSpecularOverAlpha: boolean;
  51031. /**
  51032. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51033. */
  51034. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51035. /**
  51036. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51037. */
  51038. useRoughnessFromMetallicTextureAlpha: boolean;
  51039. /**
  51040. * Specifies if the metallic texture contains the roughness information in its green channel.
  51041. */
  51042. useRoughnessFromMetallicTextureGreen: boolean;
  51043. /**
  51044. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51045. */
  51046. useMetallnessFromMetallicTextureBlue: boolean;
  51047. /**
  51048. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51049. */
  51050. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51051. /**
  51052. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51053. */
  51054. useAmbientInGrayScale: boolean;
  51055. /**
  51056. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51057. * The material will try to infer what glossiness each pixel should be.
  51058. */
  51059. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51060. /**
  51061. * BJS is using an harcoded light falloff based on a manually sets up range.
  51062. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51063. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51064. */
  51065. /**
  51066. * BJS is using an harcoded light falloff based on a manually sets up range.
  51067. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51068. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51069. */
  51070. usePhysicalLightFalloff: boolean;
  51071. /**
  51072. * In order to support the falloff compatibility with gltf, a special mode has been added
  51073. * to reproduce the gltf light falloff.
  51074. */
  51075. /**
  51076. * In order to support the falloff compatibility with gltf, a special mode has been added
  51077. * to reproduce the gltf light falloff.
  51078. */
  51079. useGLTFLightFalloff: boolean;
  51080. /**
  51081. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51082. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51083. */
  51084. useRadianceOverAlpha: boolean;
  51085. /**
  51086. * Allows using an object space normal map (instead of tangent space).
  51087. */
  51088. useObjectSpaceNormalMap: boolean;
  51089. /**
  51090. * Allows using the bump map in parallax mode.
  51091. */
  51092. useParallax: boolean;
  51093. /**
  51094. * Allows using the bump map in parallax occlusion mode.
  51095. */
  51096. useParallaxOcclusion: boolean;
  51097. /**
  51098. * Controls the scale bias of the parallax mode.
  51099. */
  51100. parallaxScaleBias: number;
  51101. /**
  51102. * If sets to true, disables all the lights affecting the material.
  51103. */
  51104. disableLighting: boolean;
  51105. /**
  51106. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51107. */
  51108. forceIrradianceInFragment: boolean;
  51109. /**
  51110. * Number of Simultaneous lights allowed on the material.
  51111. */
  51112. maxSimultaneousLights: number;
  51113. /**
  51114. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51115. */
  51116. invertNormalMapX: boolean;
  51117. /**
  51118. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51119. */
  51120. invertNormalMapY: boolean;
  51121. /**
  51122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51123. */
  51124. twoSidedLighting: boolean;
  51125. /**
  51126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51127. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51128. */
  51129. useAlphaFresnel: boolean;
  51130. /**
  51131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51132. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51133. */
  51134. useLinearAlphaFresnel: boolean;
  51135. /**
  51136. * Let user defines the brdf lookup texture used for IBL.
  51137. * A default 8bit version is embedded but you could point at :
  51138. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51139. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51140. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51141. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51142. */
  51143. environmentBRDFTexture: Nullable<BaseTexture>;
  51144. /**
  51145. * Force normal to face away from face.
  51146. */
  51147. forceNormalForward: boolean;
  51148. /**
  51149. * Enables specular anti aliasing in the PBR shader.
  51150. * It will both interacts on the Geometry for analytical and IBL lighting.
  51151. * It also prefilter the roughness map based on the bump values.
  51152. */
  51153. enableSpecularAntiAliasing: boolean;
  51154. /**
  51155. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51156. * makes the reflect vector face the model (under horizon).
  51157. */
  51158. useHorizonOcclusion: boolean;
  51159. /**
  51160. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51161. * too much the area relying on ambient texture to define their ambient occlusion.
  51162. */
  51163. useRadianceOcclusion: boolean;
  51164. /**
  51165. * If set to true, no lighting calculations will be applied.
  51166. */
  51167. unlit: boolean;
  51168. /**
  51169. * Gets the image processing configuration used either in this material.
  51170. */
  51171. /**
  51172. * Sets the Default image processing configuration used either in the this material.
  51173. *
  51174. * If sets to null, the scene one is in use.
  51175. */
  51176. imageProcessingConfiguration: ImageProcessingConfiguration;
  51177. /**
  51178. * Gets wether the color curves effect is enabled.
  51179. */
  51180. /**
  51181. * Sets wether the color curves effect is enabled.
  51182. */
  51183. cameraColorCurvesEnabled: boolean;
  51184. /**
  51185. * Gets wether the color grading effect is enabled.
  51186. */
  51187. /**
  51188. * Gets wether the color grading effect is enabled.
  51189. */
  51190. cameraColorGradingEnabled: boolean;
  51191. /**
  51192. * Gets wether tonemapping is enabled or not.
  51193. */
  51194. /**
  51195. * Sets wether tonemapping is enabled or not
  51196. */
  51197. cameraToneMappingEnabled: boolean;
  51198. /**
  51199. * The camera exposure used on this material.
  51200. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51201. * This corresponds to a photographic exposure.
  51202. */
  51203. /**
  51204. * The camera exposure used on this material.
  51205. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51206. * This corresponds to a photographic exposure.
  51207. */
  51208. cameraExposure: number;
  51209. /**
  51210. * Gets The camera contrast used on this material.
  51211. */
  51212. /**
  51213. * Sets The camera contrast used on this material.
  51214. */
  51215. cameraContrast: number;
  51216. /**
  51217. * Gets the Color Grading 2D Lookup Texture.
  51218. */
  51219. /**
  51220. * Sets the Color Grading 2D Lookup Texture.
  51221. */
  51222. cameraColorGradingTexture: Nullable<BaseTexture>;
  51223. /**
  51224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51226. * 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;
  51227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51228. */
  51229. /**
  51230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51232. * 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;
  51233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51234. */
  51235. cameraColorCurves: Nullable<ColorCurves>;
  51236. /**
  51237. * Instantiates a new PBRMaterial instance.
  51238. *
  51239. * @param name The material name
  51240. * @param scene The scene the material will be use in.
  51241. */
  51242. constructor(name: string, scene: Scene);
  51243. /**
  51244. * Returns the name of this material class.
  51245. */
  51246. getClassName(): string;
  51247. /**
  51248. * Makes a duplicate of the current material.
  51249. * @param name - name to use for the new material.
  51250. */
  51251. clone(name: string): PBRMaterial;
  51252. /**
  51253. * Serializes this PBR Material.
  51254. * @returns - An object with the serialized material.
  51255. */
  51256. serialize(): any;
  51257. /**
  51258. * Parses a PBR Material from a serialized object.
  51259. * @param source - Serialized object.
  51260. * @param scene - BJS scene instance.
  51261. * @param rootUrl - url for the scene object
  51262. * @returns - PBRMaterial
  51263. */
  51264. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51265. }
  51266. }
  51267. declare module "babylonjs/Misc/dds" {
  51268. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51270. import { Nullable } from "babylonjs/types";
  51271. import { Scene } from "babylonjs/scene";
  51272. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51273. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51274. /**
  51275. * Direct draw surface info
  51276. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51277. */
  51278. export interface DDSInfo {
  51279. /**
  51280. * Width of the texture
  51281. */
  51282. width: number;
  51283. /**
  51284. * Width of the texture
  51285. */
  51286. height: number;
  51287. /**
  51288. * Number of Mipmaps for the texture
  51289. * @see https://en.wikipedia.org/wiki/Mipmap
  51290. */
  51291. mipmapCount: number;
  51292. /**
  51293. * If the textures format is a known fourCC format
  51294. * @see https://www.fourcc.org/
  51295. */
  51296. isFourCC: boolean;
  51297. /**
  51298. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51299. */
  51300. isRGB: boolean;
  51301. /**
  51302. * If the texture is a lumincance format
  51303. */
  51304. isLuminance: boolean;
  51305. /**
  51306. * If this is a cube texture
  51307. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51308. */
  51309. isCube: boolean;
  51310. /**
  51311. * If the texture is a compressed format eg. FOURCC_DXT1
  51312. */
  51313. isCompressed: boolean;
  51314. /**
  51315. * The dxgiFormat of the texture
  51316. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51317. */
  51318. dxgiFormat: number;
  51319. /**
  51320. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51321. */
  51322. textureType: number;
  51323. /**
  51324. * Sphericle polynomial created for the dds texture
  51325. */
  51326. sphericalPolynomial?: SphericalPolynomial;
  51327. }
  51328. /**
  51329. * Class used to provide DDS decompression tools
  51330. */
  51331. export class DDSTools {
  51332. /**
  51333. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51334. */
  51335. static StoreLODInAlphaChannel: boolean;
  51336. /**
  51337. * Gets DDS information from an array buffer
  51338. * @param arrayBuffer defines the array buffer to read data from
  51339. * @returns the DDS information
  51340. */
  51341. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51342. private static _FloatView;
  51343. private static _Int32View;
  51344. private static _ToHalfFloat;
  51345. private static _FromHalfFloat;
  51346. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51347. private static _GetHalfFloatRGBAArrayBuffer;
  51348. private static _GetFloatRGBAArrayBuffer;
  51349. private static _GetFloatAsUIntRGBAArrayBuffer;
  51350. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51351. private static _GetRGBAArrayBuffer;
  51352. private static _ExtractLongWordOrder;
  51353. private static _GetRGBArrayBuffer;
  51354. private static _GetLuminanceArrayBuffer;
  51355. /**
  51356. * Uploads DDS Levels to a Babylon Texture
  51357. * @hidden
  51358. */
  51359. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51360. }
  51361. module "babylonjs/Engines/thinEngine" {
  51362. interface ThinEngine {
  51363. /**
  51364. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51365. * @param rootUrl defines the url where the file to load is located
  51366. * @param scene defines the current scene
  51367. * @param lodScale defines scale to apply to the mip map selection
  51368. * @param lodOffset defines offset to apply to the mip map selection
  51369. * @param onLoad defines an optional callback raised when the texture is loaded
  51370. * @param onError defines an optional callback raised if there is an issue to load the texture
  51371. * @param format defines the format of the data
  51372. * @param forcedExtension defines the extension to use to pick the right loader
  51373. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51374. * @returns the cube texture as an InternalTexture
  51375. */
  51376. 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;
  51377. }
  51378. }
  51379. }
  51380. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51381. import { Nullable } from "babylonjs/types";
  51382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51383. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51384. /**
  51385. * Implementation of the DDS Texture Loader.
  51386. * @hidden
  51387. */
  51388. export class _DDSTextureLoader implements IInternalTextureLoader {
  51389. /**
  51390. * Defines wether the loader supports cascade loading the different faces.
  51391. */
  51392. readonly supportCascades: boolean;
  51393. /**
  51394. * This returns if the loader support the current file information.
  51395. * @param extension defines the file extension of the file being loaded
  51396. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51397. * @param fallback defines the fallback internal texture if any
  51398. * @param isBase64 defines whether the texture is encoded as a base64
  51399. * @param isBuffer defines whether the texture data are stored as a buffer
  51400. * @returns true if the loader can load the specified file
  51401. */
  51402. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51403. /**
  51404. * Transform the url before loading if required.
  51405. * @param rootUrl the url of the texture
  51406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51407. * @returns the transformed texture
  51408. */
  51409. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51410. /**
  51411. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51412. * @param rootUrl the url of the texture
  51413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51414. * @returns the fallback texture
  51415. */
  51416. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51417. /**
  51418. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51419. * @param data contains the texture data
  51420. * @param texture defines the BabylonJS internal texture
  51421. * @param createPolynomials will be true if polynomials have been requested
  51422. * @param onLoad defines the callback to trigger once the texture is ready
  51423. * @param onError defines the callback to trigger in case of error
  51424. */
  51425. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51426. /**
  51427. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51428. * @param data contains the texture data
  51429. * @param texture defines the BabylonJS internal texture
  51430. * @param callback defines the method to call once ready to upload
  51431. */
  51432. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51433. }
  51434. }
  51435. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51436. import { Nullable } from "babylonjs/types";
  51437. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51438. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51439. /**
  51440. * Implementation of the ENV Texture Loader.
  51441. * @hidden
  51442. */
  51443. export class _ENVTextureLoader implements IInternalTextureLoader {
  51444. /**
  51445. * Defines wether the loader supports cascade loading the different faces.
  51446. */
  51447. readonly supportCascades: boolean;
  51448. /**
  51449. * This returns if the loader support the current file information.
  51450. * @param extension defines the file extension of the file being loaded
  51451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51452. * @param fallback defines the fallback internal texture if any
  51453. * @param isBase64 defines whether the texture is encoded as a base64
  51454. * @param isBuffer defines whether the texture data are stored as a buffer
  51455. * @returns true if the loader can load the specified file
  51456. */
  51457. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51458. /**
  51459. * Transform the url before loading if required.
  51460. * @param rootUrl the url of the texture
  51461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51462. * @returns the transformed texture
  51463. */
  51464. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51465. /**
  51466. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51467. * @param rootUrl the url of the texture
  51468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51469. * @returns the fallback texture
  51470. */
  51471. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51472. /**
  51473. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51474. * @param data contains the texture data
  51475. * @param texture defines the BabylonJS internal texture
  51476. * @param createPolynomials will be true if polynomials have been requested
  51477. * @param onLoad defines the callback to trigger once the texture is ready
  51478. * @param onError defines the callback to trigger in case of error
  51479. */
  51480. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51481. /**
  51482. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51483. * @param data contains the texture data
  51484. * @param texture defines the BabylonJS internal texture
  51485. * @param callback defines the method to call once ready to upload
  51486. */
  51487. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51488. }
  51489. }
  51490. declare module "babylonjs/Misc/khronosTextureContainer" {
  51491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51492. /**
  51493. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51494. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51495. */
  51496. export class KhronosTextureContainer {
  51497. /** contents of the KTX container file */
  51498. arrayBuffer: any;
  51499. private static HEADER_LEN;
  51500. private static COMPRESSED_2D;
  51501. private static COMPRESSED_3D;
  51502. private static TEX_2D;
  51503. private static TEX_3D;
  51504. /**
  51505. * Gets the openGL type
  51506. */
  51507. glType: number;
  51508. /**
  51509. * Gets the openGL type size
  51510. */
  51511. glTypeSize: number;
  51512. /**
  51513. * Gets the openGL format
  51514. */
  51515. glFormat: number;
  51516. /**
  51517. * Gets the openGL internal format
  51518. */
  51519. glInternalFormat: number;
  51520. /**
  51521. * Gets the base internal format
  51522. */
  51523. glBaseInternalFormat: number;
  51524. /**
  51525. * Gets image width in pixel
  51526. */
  51527. pixelWidth: number;
  51528. /**
  51529. * Gets image height in pixel
  51530. */
  51531. pixelHeight: number;
  51532. /**
  51533. * Gets image depth in pixels
  51534. */
  51535. pixelDepth: number;
  51536. /**
  51537. * Gets the number of array elements
  51538. */
  51539. numberOfArrayElements: number;
  51540. /**
  51541. * Gets the number of faces
  51542. */
  51543. numberOfFaces: number;
  51544. /**
  51545. * Gets the number of mipmap levels
  51546. */
  51547. numberOfMipmapLevels: number;
  51548. /**
  51549. * Gets the bytes of key value data
  51550. */
  51551. bytesOfKeyValueData: number;
  51552. /**
  51553. * Gets the load type
  51554. */
  51555. loadType: number;
  51556. /**
  51557. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51558. */
  51559. isInvalid: boolean;
  51560. /**
  51561. * Creates a new KhronosTextureContainer
  51562. * @param arrayBuffer contents of the KTX container file
  51563. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51564. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51565. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51566. */
  51567. constructor(
  51568. /** contents of the KTX container file */
  51569. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51570. /**
  51571. * Uploads KTX content to a Babylon Texture.
  51572. * It is assumed that the texture has already been created & is currently bound
  51573. * @hidden
  51574. */
  51575. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51576. private _upload2DCompressedLevels;
  51577. }
  51578. }
  51579. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51580. import { Nullable } from "babylonjs/types";
  51581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51582. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51583. /**
  51584. * Implementation of the KTX Texture Loader.
  51585. * @hidden
  51586. */
  51587. export class _KTXTextureLoader implements IInternalTextureLoader {
  51588. /**
  51589. * Defines wether the loader supports cascade loading the different faces.
  51590. */
  51591. readonly supportCascades: boolean;
  51592. /**
  51593. * This returns if the loader support the current file information.
  51594. * @param extension defines the file extension of the file being loaded
  51595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51596. * @param fallback defines the fallback internal texture if any
  51597. * @param isBase64 defines whether the texture is encoded as a base64
  51598. * @param isBuffer defines whether the texture data are stored as a buffer
  51599. * @returns true if the loader can load the specified file
  51600. */
  51601. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51602. /**
  51603. * Transform the url before loading if required.
  51604. * @param rootUrl the url of the texture
  51605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51606. * @returns the transformed texture
  51607. */
  51608. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51609. /**
  51610. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51611. * @param rootUrl the url of the texture
  51612. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51613. * @returns the fallback texture
  51614. */
  51615. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51616. /**
  51617. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51618. * @param data contains the texture data
  51619. * @param texture defines the BabylonJS internal texture
  51620. * @param createPolynomials will be true if polynomials have been requested
  51621. * @param onLoad defines the callback to trigger once the texture is ready
  51622. * @param onError defines the callback to trigger in case of error
  51623. */
  51624. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51625. /**
  51626. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51627. * @param data contains the texture data
  51628. * @param texture defines the BabylonJS internal texture
  51629. * @param callback defines the method to call once ready to upload
  51630. */
  51631. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51632. }
  51633. }
  51634. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51635. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51636. import { Scene } from "babylonjs/scene";
  51637. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51638. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51639. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51640. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51641. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51642. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51644. /**
  51645. * Options for the default xr helper
  51646. */
  51647. export class WebXRDefaultExperienceOptions {
  51648. /**
  51649. * Floor meshes that should be used for teleporting
  51650. */
  51651. floorMeshes: Array<AbstractMesh>;
  51652. /**
  51653. * Enable or disable default UI to enter XR
  51654. */
  51655. disableDefaultUI: boolean;
  51656. }
  51657. /**
  51658. * Default experience which provides a similar setup to the previous webVRExperience
  51659. */
  51660. export class WebXRDefaultExperience {
  51661. /**
  51662. * Base experience
  51663. */
  51664. baseExperience: WebXRExperienceHelper;
  51665. /**
  51666. * Input experience extension
  51667. */
  51668. input: WebXRInput;
  51669. /**
  51670. * Loads the controller models
  51671. */
  51672. controllerModelLoader: WebXRControllerModelLoader;
  51673. /**
  51674. * Enables laser pointer and selection
  51675. */
  51676. pointerSelection: WebXRControllerPointerSelection;
  51677. /**
  51678. * Enables teleportation
  51679. */
  51680. teleportation: WebXRControllerTeleportation;
  51681. /**
  51682. * Enables ui for enetering/exiting xr
  51683. */
  51684. enterExitUI: WebXREnterExitUI;
  51685. /**
  51686. * Default target xr should render to
  51687. */
  51688. renderTarget: WebXRRenderTarget;
  51689. /**
  51690. * Creates the default xr experience
  51691. * @param scene scene
  51692. * @param options options for basic configuration
  51693. * @returns resulting WebXRDefaultExperience
  51694. */
  51695. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51696. private constructor();
  51697. /**
  51698. * DIsposes of the experience helper
  51699. */
  51700. dispose(): void;
  51701. }
  51702. }
  51703. declare module "babylonjs/Helpers/sceneHelpers" {
  51704. import { Nullable } from "babylonjs/types";
  51705. import { Mesh } from "babylonjs/Meshes/mesh";
  51706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51707. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51708. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51709. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51710. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51711. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51712. import "babylonjs/Meshes/Builders/boxBuilder";
  51713. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51714. /** @hidden */
  51715. export var _forceSceneHelpersToBundle: boolean;
  51716. module "babylonjs/scene" {
  51717. interface Scene {
  51718. /**
  51719. * Creates a default light for the scene.
  51720. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51721. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51722. */
  51723. createDefaultLight(replace?: boolean): void;
  51724. /**
  51725. * Creates a default camera for the scene.
  51726. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51727. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51728. * @param replace has default false, when true replaces the active camera in the scene
  51729. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51730. */
  51731. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51732. /**
  51733. * Creates a default camera and a default light.
  51734. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51735. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51736. * @param replace has the default false, when true replaces the active camera/light in the scene
  51737. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51738. */
  51739. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51740. /**
  51741. * Creates a new sky box
  51742. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51743. * @param environmentTexture defines the texture to use as environment texture
  51744. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51745. * @param scale defines the overall scale of the skybox
  51746. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51747. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51748. * @returns a new mesh holding the sky box
  51749. */
  51750. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51751. /**
  51752. * Creates a new environment
  51753. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51754. * @param options defines the options you can use to configure the environment
  51755. * @returns the new EnvironmentHelper
  51756. */
  51757. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51758. /**
  51759. * Creates a new VREXperienceHelper
  51760. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51761. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51762. * @returns a new VREXperienceHelper
  51763. */
  51764. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51765. /**
  51766. * Creates a new WebXRDefaultExperience
  51767. * @see http://doc.babylonjs.com/how_to/webxr
  51768. * @param options experience options
  51769. * @returns a promise for a new WebXRDefaultExperience
  51770. */
  51771. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51772. }
  51773. }
  51774. }
  51775. declare module "babylonjs/Helpers/videoDome" {
  51776. import { Scene } from "babylonjs/scene";
  51777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51778. import { Mesh } from "babylonjs/Meshes/mesh";
  51779. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51780. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51781. import "babylonjs/Meshes/Builders/sphereBuilder";
  51782. /**
  51783. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51784. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51785. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51786. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51787. */
  51788. export class VideoDome extends TransformNode {
  51789. /**
  51790. * Define the video source as a Monoscopic panoramic 360 video.
  51791. */
  51792. static readonly MODE_MONOSCOPIC: number;
  51793. /**
  51794. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51795. */
  51796. static readonly MODE_TOPBOTTOM: number;
  51797. /**
  51798. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51799. */
  51800. static readonly MODE_SIDEBYSIDE: number;
  51801. private _halfDome;
  51802. private _useDirectMapping;
  51803. /**
  51804. * The video texture being displayed on the sphere
  51805. */
  51806. protected _videoTexture: VideoTexture;
  51807. /**
  51808. * Gets the video texture being displayed on the sphere
  51809. */
  51810. readonly videoTexture: VideoTexture;
  51811. /**
  51812. * The skybox material
  51813. */
  51814. protected _material: BackgroundMaterial;
  51815. /**
  51816. * The surface used for the skybox
  51817. */
  51818. protected _mesh: Mesh;
  51819. /**
  51820. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51821. */
  51822. private _halfDomeMask;
  51823. /**
  51824. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51825. * Also see the options.resolution property.
  51826. */
  51827. fovMultiplier: number;
  51828. private _videoMode;
  51829. /**
  51830. * Gets or set the current video mode for the video. It can be:
  51831. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51832. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51833. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51834. */
  51835. videoMode: number;
  51836. /**
  51837. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51838. *
  51839. */
  51840. /**
  51841. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51842. */
  51843. halfDome: boolean;
  51844. /**
  51845. * Oberserver used in Stereoscopic VR Mode.
  51846. */
  51847. private _onBeforeCameraRenderObserver;
  51848. /**
  51849. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51850. * @param name Element's name, child elements will append suffixes for their own names.
  51851. * @param urlsOrVideo defines the url(s) or the video element to use
  51852. * @param options An object containing optional or exposed sub element properties
  51853. */
  51854. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51855. resolution?: number;
  51856. clickToPlay?: boolean;
  51857. autoPlay?: boolean;
  51858. loop?: boolean;
  51859. size?: number;
  51860. poster?: string;
  51861. faceForward?: boolean;
  51862. useDirectMapping?: boolean;
  51863. halfDomeMode?: boolean;
  51864. }, scene: Scene);
  51865. private _changeVideoMode;
  51866. /**
  51867. * Releases resources associated with this node.
  51868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51870. */
  51871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51872. }
  51873. }
  51874. declare module "babylonjs/Helpers/index" {
  51875. export * from "babylonjs/Helpers/environmentHelper";
  51876. export * from "babylonjs/Helpers/photoDome";
  51877. export * from "babylonjs/Helpers/sceneHelpers";
  51878. export * from "babylonjs/Helpers/videoDome";
  51879. }
  51880. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51881. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51882. import { IDisposable } from "babylonjs/scene";
  51883. import { Engine } from "babylonjs/Engines/engine";
  51884. /**
  51885. * This class can be used to get instrumentation data from a Babylon engine
  51886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51887. */
  51888. export class EngineInstrumentation implements IDisposable {
  51889. /**
  51890. * Define the instrumented engine.
  51891. */
  51892. engine: Engine;
  51893. private _captureGPUFrameTime;
  51894. private _gpuFrameTimeToken;
  51895. private _gpuFrameTime;
  51896. private _captureShaderCompilationTime;
  51897. private _shaderCompilationTime;
  51898. private _onBeginFrameObserver;
  51899. private _onEndFrameObserver;
  51900. private _onBeforeShaderCompilationObserver;
  51901. private _onAfterShaderCompilationObserver;
  51902. /**
  51903. * Gets the perf counter used for GPU frame time
  51904. */
  51905. readonly gpuFrameTimeCounter: PerfCounter;
  51906. /**
  51907. * Gets the GPU frame time capture status
  51908. */
  51909. /**
  51910. * Enable or disable the GPU frame time capture
  51911. */
  51912. captureGPUFrameTime: boolean;
  51913. /**
  51914. * Gets the perf counter used for shader compilation time
  51915. */
  51916. readonly shaderCompilationTimeCounter: PerfCounter;
  51917. /**
  51918. * Gets the shader compilation time capture status
  51919. */
  51920. /**
  51921. * Enable or disable the shader compilation time capture
  51922. */
  51923. captureShaderCompilationTime: boolean;
  51924. /**
  51925. * Instantiates a new engine instrumentation.
  51926. * This class can be used to get instrumentation data from a Babylon engine
  51927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51928. * @param engine Defines the engine to instrument
  51929. */
  51930. constructor(
  51931. /**
  51932. * Define the instrumented engine.
  51933. */
  51934. engine: Engine);
  51935. /**
  51936. * Dispose and release associated resources.
  51937. */
  51938. dispose(): void;
  51939. }
  51940. }
  51941. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51942. import { Scene, IDisposable } from "babylonjs/scene";
  51943. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51944. /**
  51945. * This class can be used to get instrumentation data from a Babylon engine
  51946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51947. */
  51948. export class SceneInstrumentation implements IDisposable {
  51949. /**
  51950. * Defines the scene to instrument
  51951. */
  51952. scene: Scene;
  51953. private _captureActiveMeshesEvaluationTime;
  51954. private _activeMeshesEvaluationTime;
  51955. private _captureRenderTargetsRenderTime;
  51956. private _renderTargetsRenderTime;
  51957. private _captureFrameTime;
  51958. private _frameTime;
  51959. private _captureRenderTime;
  51960. private _renderTime;
  51961. private _captureInterFrameTime;
  51962. private _interFrameTime;
  51963. private _captureParticlesRenderTime;
  51964. private _particlesRenderTime;
  51965. private _captureSpritesRenderTime;
  51966. private _spritesRenderTime;
  51967. private _capturePhysicsTime;
  51968. private _physicsTime;
  51969. private _captureAnimationsTime;
  51970. private _animationsTime;
  51971. private _captureCameraRenderTime;
  51972. private _cameraRenderTime;
  51973. private _onBeforeActiveMeshesEvaluationObserver;
  51974. private _onAfterActiveMeshesEvaluationObserver;
  51975. private _onBeforeRenderTargetsRenderObserver;
  51976. private _onAfterRenderTargetsRenderObserver;
  51977. private _onAfterRenderObserver;
  51978. private _onBeforeDrawPhaseObserver;
  51979. private _onAfterDrawPhaseObserver;
  51980. private _onBeforeAnimationsObserver;
  51981. private _onBeforeParticlesRenderingObserver;
  51982. private _onAfterParticlesRenderingObserver;
  51983. private _onBeforeSpritesRenderingObserver;
  51984. private _onAfterSpritesRenderingObserver;
  51985. private _onBeforePhysicsObserver;
  51986. private _onAfterPhysicsObserver;
  51987. private _onAfterAnimationsObserver;
  51988. private _onBeforeCameraRenderObserver;
  51989. private _onAfterCameraRenderObserver;
  51990. /**
  51991. * Gets the perf counter used for active meshes evaluation time
  51992. */
  51993. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51994. /**
  51995. * Gets the active meshes evaluation time capture status
  51996. */
  51997. /**
  51998. * Enable or disable the active meshes evaluation time capture
  51999. */
  52000. captureActiveMeshesEvaluationTime: boolean;
  52001. /**
  52002. * Gets the perf counter used for render targets render time
  52003. */
  52004. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52005. /**
  52006. * Gets the render targets render time capture status
  52007. */
  52008. /**
  52009. * Enable or disable the render targets render time capture
  52010. */
  52011. captureRenderTargetsRenderTime: boolean;
  52012. /**
  52013. * Gets the perf counter used for particles render time
  52014. */
  52015. readonly particlesRenderTimeCounter: PerfCounter;
  52016. /**
  52017. * Gets the particles render time capture status
  52018. */
  52019. /**
  52020. * Enable or disable the particles render time capture
  52021. */
  52022. captureParticlesRenderTime: boolean;
  52023. /**
  52024. * Gets the perf counter used for sprites render time
  52025. */
  52026. readonly spritesRenderTimeCounter: PerfCounter;
  52027. /**
  52028. * Gets the sprites render time capture status
  52029. */
  52030. /**
  52031. * Enable or disable the sprites render time capture
  52032. */
  52033. captureSpritesRenderTime: boolean;
  52034. /**
  52035. * Gets the perf counter used for physics time
  52036. */
  52037. readonly physicsTimeCounter: PerfCounter;
  52038. /**
  52039. * Gets the physics time capture status
  52040. */
  52041. /**
  52042. * Enable or disable the physics time capture
  52043. */
  52044. capturePhysicsTime: boolean;
  52045. /**
  52046. * Gets the perf counter used for animations time
  52047. */
  52048. readonly animationsTimeCounter: PerfCounter;
  52049. /**
  52050. * Gets the animations time capture status
  52051. */
  52052. /**
  52053. * Enable or disable the animations time capture
  52054. */
  52055. captureAnimationsTime: boolean;
  52056. /**
  52057. * Gets the perf counter used for frame time capture
  52058. */
  52059. readonly frameTimeCounter: PerfCounter;
  52060. /**
  52061. * Gets the frame time capture status
  52062. */
  52063. /**
  52064. * Enable or disable the frame time capture
  52065. */
  52066. captureFrameTime: boolean;
  52067. /**
  52068. * Gets the perf counter used for inter-frames time capture
  52069. */
  52070. readonly interFrameTimeCounter: PerfCounter;
  52071. /**
  52072. * Gets the inter-frames time capture status
  52073. */
  52074. /**
  52075. * Enable or disable the inter-frames time capture
  52076. */
  52077. captureInterFrameTime: boolean;
  52078. /**
  52079. * Gets the perf counter used for render time capture
  52080. */
  52081. readonly renderTimeCounter: PerfCounter;
  52082. /**
  52083. * Gets the render time capture status
  52084. */
  52085. /**
  52086. * Enable or disable the render time capture
  52087. */
  52088. captureRenderTime: boolean;
  52089. /**
  52090. * Gets the perf counter used for camera render time capture
  52091. */
  52092. readonly cameraRenderTimeCounter: PerfCounter;
  52093. /**
  52094. * Gets the camera render time capture status
  52095. */
  52096. /**
  52097. * Enable or disable the camera render time capture
  52098. */
  52099. captureCameraRenderTime: boolean;
  52100. /**
  52101. * Gets the perf counter used for draw calls
  52102. */
  52103. readonly drawCallsCounter: PerfCounter;
  52104. /**
  52105. * Instantiates a new scene instrumentation.
  52106. * This class can be used to get instrumentation data from a Babylon engine
  52107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52108. * @param scene Defines the scene to instrument
  52109. */
  52110. constructor(
  52111. /**
  52112. * Defines the scene to instrument
  52113. */
  52114. scene: Scene);
  52115. /**
  52116. * Dispose and release associated resources.
  52117. */
  52118. dispose(): void;
  52119. }
  52120. }
  52121. declare module "babylonjs/Instrumentation/index" {
  52122. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52123. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52124. export * from "babylonjs/Instrumentation/timeToken";
  52125. }
  52126. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52127. /** @hidden */
  52128. export var glowMapGenerationPixelShader: {
  52129. name: string;
  52130. shader: string;
  52131. };
  52132. }
  52133. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52134. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52135. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52136. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52137. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52139. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52140. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52141. /** @hidden */
  52142. export var glowMapGenerationVertexShader: {
  52143. name: string;
  52144. shader: string;
  52145. };
  52146. }
  52147. declare module "babylonjs/Layers/effectLayer" {
  52148. import { Observable } from "babylonjs/Misc/observable";
  52149. import { Nullable } from "babylonjs/types";
  52150. import { Camera } from "babylonjs/Cameras/camera";
  52151. import { Scene } from "babylonjs/scene";
  52152. import { ISize } from "babylonjs/Maths/math.size";
  52153. import { Color4 } from "babylonjs/Maths/math.color";
  52154. import { Engine } from "babylonjs/Engines/engine";
  52155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52157. import { Mesh } from "babylonjs/Meshes/mesh";
  52158. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52161. import { Effect } from "babylonjs/Materials/effect";
  52162. import { Material } from "babylonjs/Materials/material";
  52163. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52164. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52165. /**
  52166. * Effect layer options. This helps customizing the behaviour
  52167. * of the effect layer.
  52168. */
  52169. export interface IEffectLayerOptions {
  52170. /**
  52171. * Multiplication factor apply to the canvas size to compute the render target size
  52172. * used to generated the objects (the smaller the faster).
  52173. */
  52174. mainTextureRatio: number;
  52175. /**
  52176. * Enforces a fixed size texture to ensure effect stability across devices.
  52177. */
  52178. mainTextureFixedSize?: number;
  52179. /**
  52180. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52181. */
  52182. alphaBlendingMode: number;
  52183. /**
  52184. * The camera attached to the layer.
  52185. */
  52186. camera: Nullable<Camera>;
  52187. /**
  52188. * The rendering group to draw the layer in.
  52189. */
  52190. renderingGroupId: number;
  52191. }
  52192. /**
  52193. * The effect layer Helps adding post process effect blended with the main pass.
  52194. *
  52195. * This can be for instance use to generate glow or higlight effects on the scene.
  52196. *
  52197. * The effect layer class can not be used directly and is intented to inherited from to be
  52198. * customized per effects.
  52199. */
  52200. export abstract class EffectLayer {
  52201. private _vertexBuffers;
  52202. private _indexBuffer;
  52203. private _cachedDefines;
  52204. private _effectLayerMapGenerationEffect;
  52205. private _effectLayerOptions;
  52206. private _mergeEffect;
  52207. protected _scene: Scene;
  52208. protected _engine: Engine;
  52209. protected _maxSize: number;
  52210. protected _mainTextureDesiredSize: ISize;
  52211. protected _mainTexture: RenderTargetTexture;
  52212. protected _shouldRender: boolean;
  52213. protected _postProcesses: PostProcess[];
  52214. protected _textures: BaseTexture[];
  52215. protected _emissiveTextureAndColor: {
  52216. texture: Nullable<BaseTexture>;
  52217. color: Color4;
  52218. };
  52219. /**
  52220. * The name of the layer
  52221. */
  52222. name: string;
  52223. /**
  52224. * The clear color of the texture used to generate the glow map.
  52225. */
  52226. neutralColor: Color4;
  52227. /**
  52228. * Specifies wether the highlight layer is enabled or not.
  52229. */
  52230. isEnabled: boolean;
  52231. /**
  52232. * Gets the camera attached to the layer.
  52233. */
  52234. readonly camera: Nullable<Camera>;
  52235. /**
  52236. * Gets the rendering group id the layer should render in.
  52237. */
  52238. renderingGroupId: number;
  52239. /**
  52240. * An event triggered when the effect layer has been disposed.
  52241. */
  52242. onDisposeObservable: Observable<EffectLayer>;
  52243. /**
  52244. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52245. */
  52246. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52247. /**
  52248. * An event triggered when the generated texture is being merged in the scene.
  52249. */
  52250. onBeforeComposeObservable: Observable<EffectLayer>;
  52251. /**
  52252. * An event triggered when the mesh is rendered into the effect render target.
  52253. */
  52254. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52255. /**
  52256. * An event triggered after the mesh has been rendered into the effect render target.
  52257. */
  52258. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52259. /**
  52260. * An event triggered when the generated texture has been merged in the scene.
  52261. */
  52262. onAfterComposeObservable: Observable<EffectLayer>;
  52263. /**
  52264. * An event triggered when the efffect layer changes its size.
  52265. */
  52266. onSizeChangedObservable: Observable<EffectLayer>;
  52267. /** @hidden */
  52268. static _SceneComponentInitialization: (scene: Scene) => void;
  52269. /**
  52270. * Instantiates a new effect Layer and references it in the scene.
  52271. * @param name The name of the layer
  52272. * @param scene The scene to use the layer in
  52273. */
  52274. constructor(
  52275. /** The Friendly of the effect in the scene */
  52276. name: string, scene: Scene);
  52277. /**
  52278. * Get the effect name of the layer.
  52279. * @return The effect name
  52280. */
  52281. abstract getEffectName(): string;
  52282. /**
  52283. * Checks for the readiness of the element composing the layer.
  52284. * @param subMesh the mesh to check for
  52285. * @param useInstances specify wether or not to use instances to render the mesh
  52286. * @return true if ready otherwise, false
  52287. */
  52288. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52289. /**
  52290. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52291. * @returns true if the effect requires stencil during the main canvas render pass.
  52292. */
  52293. abstract needStencil(): boolean;
  52294. /**
  52295. * Create the merge effect. This is the shader use to blit the information back
  52296. * to the main canvas at the end of the scene rendering.
  52297. * @returns The effect containing the shader used to merge the effect on the main canvas
  52298. */
  52299. protected abstract _createMergeEffect(): Effect;
  52300. /**
  52301. * Creates the render target textures and post processes used in the effect layer.
  52302. */
  52303. protected abstract _createTextureAndPostProcesses(): void;
  52304. /**
  52305. * Implementation specific of rendering the generating effect on the main canvas.
  52306. * @param effect The effect used to render through
  52307. */
  52308. protected abstract _internalRender(effect: Effect): void;
  52309. /**
  52310. * Sets the required values for both the emissive texture and and the main color.
  52311. */
  52312. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52313. /**
  52314. * Free any resources and references associated to a mesh.
  52315. * Internal use
  52316. * @param mesh The mesh to free.
  52317. */
  52318. abstract _disposeMesh(mesh: Mesh): void;
  52319. /**
  52320. * Serializes this layer (Glow or Highlight for example)
  52321. * @returns a serialized layer object
  52322. */
  52323. abstract serialize?(): any;
  52324. /**
  52325. * Initializes the effect layer with the required options.
  52326. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52327. */
  52328. protected _init(options: Partial<IEffectLayerOptions>): void;
  52329. /**
  52330. * Generates the index buffer of the full screen quad blending to the main canvas.
  52331. */
  52332. private _generateIndexBuffer;
  52333. /**
  52334. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52335. */
  52336. private _generateVertexBuffer;
  52337. /**
  52338. * Sets the main texture desired size which is the closest power of two
  52339. * of the engine canvas size.
  52340. */
  52341. private _setMainTextureSize;
  52342. /**
  52343. * Creates the main texture for the effect layer.
  52344. */
  52345. protected _createMainTexture(): void;
  52346. /**
  52347. * Adds specific effects defines.
  52348. * @param defines The defines to add specifics to.
  52349. */
  52350. protected _addCustomEffectDefines(defines: string[]): void;
  52351. /**
  52352. * Checks for the readiness of the element composing the layer.
  52353. * @param subMesh the mesh to check for
  52354. * @param useInstances specify wether or not to use instances to render the mesh
  52355. * @param emissiveTexture the associated emissive texture used to generate the glow
  52356. * @return true if ready otherwise, false
  52357. */
  52358. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52359. /**
  52360. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52361. */
  52362. render(): void;
  52363. /**
  52364. * Determine if a given mesh will be used in the current effect.
  52365. * @param mesh mesh to test
  52366. * @returns true if the mesh will be used
  52367. */
  52368. hasMesh(mesh: AbstractMesh): boolean;
  52369. /**
  52370. * Returns true if the layer contains information to display, otherwise false.
  52371. * @returns true if the glow layer should be rendered
  52372. */
  52373. shouldRender(): boolean;
  52374. /**
  52375. * Returns true if the mesh should render, otherwise false.
  52376. * @param mesh The mesh to render
  52377. * @returns true if it should render otherwise false
  52378. */
  52379. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52380. /**
  52381. * Returns true if the mesh can be rendered, otherwise false.
  52382. * @param mesh The mesh to render
  52383. * @param material The material used on the mesh
  52384. * @returns true if it can be rendered otherwise false
  52385. */
  52386. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52387. /**
  52388. * Returns true if the mesh should render, otherwise false.
  52389. * @param mesh The mesh to render
  52390. * @returns true if it should render otherwise false
  52391. */
  52392. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52393. /**
  52394. * Renders the submesh passed in parameter to the generation map.
  52395. */
  52396. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52397. /**
  52398. * Defines wether the current material of the mesh should be use to render the effect.
  52399. * @param mesh defines the current mesh to render
  52400. */
  52401. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52402. /**
  52403. * Rebuild the required buffers.
  52404. * @hidden Internal use only.
  52405. */
  52406. _rebuild(): void;
  52407. /**
  52408. * Dispose only the render target textures and post process.
  52409. */
  52410. private _disposeTextureAndPostProcesses;
  52411. /**
  52412. * Dispose the highlight layer and free resources.
  52413. */
  52414. dispose(): void;
  52415. /**
  52416. * Gets the class name of the effect layer
  52417. * @returns the string with the class name of the effect layer
  52418. */
  52419. getClassName(): string;
  52420. /**
  52421. * Creates an effect layer from parsed effect layer data
  52422. * @param parsedEffectLayer defines effect layer data
  52423. * @param scene defines the current scene
  52424. * @param rootUrl defines the root URL containing the effect layer information
  52425. * @returns a parsed effect Layer
  52426. */
  52427. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52428. }
  52429. }
  52430. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52431. import { Scene } from "babylonjs/scene";
  52432. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52433. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52434. import { AbstractScene } from "babylonjs/abstractScene";
  52435. module "babylonjs/abstractScene" {
  52436. interface AbstractScene {
  52437. /**
  52438. * The list of effect layers (highlights/glow) added to the scene
  52439. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52440. * @see http://doc.babylonjs.com/how_to/glow_layer
  52441. */
  52442. effectLayers: Array<EffectLayer>;
  52443. /**
  52444. * Removes the given effect layer from this scene.
  52445. * @param toRemove defines the effect layer to remove
  52446. * @returns the index of the removed effect layer
  52447. */
  52448. removeEffectLayer(toRemove: EffectLayer): number;
  52449. /**
  52450. * Adds the given effect layer to this scene
  52451. * @param newEffectLayer defines the effect layer to add
  52452. */
  52453. addEffectLayer(newEffectLayer: EffectLayer): void;
  52454. }
  52455. }
  52456. /**
  52457. * Defines the layer scene component responsible to manage any effect layers
  52458. * in a given scene.
  52459. */
  52460. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52461. /**
  52462. * The component name helpfull to identify the component in the list of scene components.
  52463. */
  52464. readonly name: string;
  52465. /**
  52466. * The scene the component belongs to.
  52467. */
  52468. scene: Scene;
  52469. private _engine;
  52470. private _renderEffects;
  52471. private _needStencil;
  52472. private _previousStencilState;
  52473. /**
  52474. * Creates a new instance of the component for the given scene
  52475. * @param scene Defines the scene to register the component in
  52476. */
  52477. constructor(scene: Scene);
  52478. /**
  52479. * Registers the component in a given scene
  52480. */
  52481. register(): void;
  52482. /**
  52483. * Rebuilds the elements related to this component in case of
  52484. * context lost for instance.
  52485. */
  52486. rebuild(): void;
  52487. /**
  52488. * Serializes the component data to the specified json object
  52489. * @param serializationObject The object to serialize to
  52490. */
  52491. serialize(serializationObject: any): void;
  52492. /**
  52493. * Adds all the elements from the container to the scene
  52494. * @param container the container holding the elements
  52495. */
  52496. addFromContainer(container: AbstractScene): void;
  52497. /**
  52498. * Removes all the elements in the container from the scene
  52499. * @param container contains the elements to remove
  52500. * @param dispose if the removed element should be disposed (default: false)
  52501. */
  52502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52503. /**
  52504. * Disposes the component and the associated ressources.
  52505. */
  52506. dispose(): void;
  52507. private _isReadyForMesh;
  52508. private _renderMainTexture;
  52509. private _setStencil;
  52510. private _setStencilBack;
  52511. private _draw;
  52512. private _drawCamera;
  52513. private _drawRenderingGroup;
  52514. }
  52515. }
  52516. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52517. /** @hidden */
  52518. export var glowMapMergePixelShader: {
  52519. name: string;
  52520. shader: string;
  52521. };
  52522. }
  52523. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52524. /** @hidden */
  52525. export var glowMapMergeVertexShader: {
  52526. name: string;
  52527. shader: string;
  52528. };
  52529. }
  52530. declare module "babylonjs/Layers/glowLayer" {
  52531. import { Nullable } from "babylonjs/types";
  52532. import { Camera } from "babylonjs/Cameras/camera";
  52533. import { Scene } from "babylonjs/scene";
  52534. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52536. import { Mesh } from "babylonjs/Meshes/mesh";
  52537. import { Texture } from "babylonjs/Materials/Textures/texture";
  52538. import { Effect } from "babylonjs/Materials/effect";
  52539. import { Material } from "babylonjs/Materials/material";
  52540. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52541. import { Color4 } from "babylonjs/Maths/math.color";
  52542. import "babylonjs/Shaders/glowMapMerge.fragment";
  52543. import "babylonjs/Shaders/glowMapMerge.vertex";
  52544. import "babylonjs/Layers/effectLayerSceneComponent";
  52545. module "babylonjs/abstractScene" {
  52546. interface AbstractScene {
  52547. /**
  52548. * Return a the first highlight layer of the scene with a given name.
  52549. * @param name The name of the highlight layer to look for.
  52550. * @return The highlight layer if found otherwise null.
  52551. */
  52552. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52553. }
  52554. }
  52555. /**
  52556. * Glow layer options. This helps customizing the behaviour
  52557. * of the glow layer.
  52558. */
  52559. export interface IGlowLayerOptions {
  52560. /**
  52561. * Multiplication factor apply to the canvas size to compute the render target size
  52562. * used to generated the glowing objects (the smaller the faster).
  52563. */
  52564. mainTextureRatio: number;
  52565. /**
  52566. * Enforces a fixed size texture to ensure resize independant blur.
  52567. */
  52568. mainTextureFixedSize?: number;
  52569. /**
  52570. * How big is the kernel of the blur texture.
  52571. */
  52572. blurKernelSize: number;
  52573. /**
  52574. * The camera attached to the layer.
  52575. */
  52576. camera: Nullable<Camera>;
  52577. /**
  52578. * Enable MSAA by chosing the number of samples.
  52579. */
  52580. mainTextureSamples?: number;
  52581. /**
  52582. * The rendering group to draw the layer in.
  52583. */
  52584. renderingGroupId: number;
  52585. }
  52586. /**
  52587. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52588. *
  52589. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52590. *
  52591. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52592. */
  52593. export class GlowLayer extends EffectLayer {
  52594. /**
  52595. * Effect Name of the layer.
  52596. */
  52597. static readonly EffectName: string;
  52598. /**
  52599. * The default blur kernel size used for the glow.
  52600. */
  52601. static DefaultBlurKernelSize: number;
  52602. /**
  52603. * The default texture size ratio used for the glow.
  52604. */
  52605. static DefaultTextureRatio: number;
  52606. /**
  52607. * Sets the kernel size of the blur.
  52608. */
  52609. /**
  52610. * Gets the kernel size of the blur.
  52611. */
  52612. blurKernelSize: number;
  52613. /**
  52614. * Sets the glow intensity.
  52615. */
  52616. /**
  52617. * Gets the glow intensity.
  52618. */
  52619. intensity: number;
  52620. private _options;
  52621. private _intensity;
  52622. private _horizontalBlurPostprocess1;
  52623. private _verticalBlurPostprocess1;
  52624. private _horizontalBlurPostprocess2;
  52625. private _verticalBlurPostprocess2;
  52626. private _blurTexture1;
  52627. private _blurTexture2;
  52628. private _postProcesses1;
  52629. private _postProcesses2;
  52630. private _includedOnlyMeshes;
  52631. private _excludedMeshes;
  52632. private _meshesUsingTheirOwnMaterials;
  52633. /**
  52634. * Callback used to let the user override the color selection on a per mesh basis
  52635. */
  52636. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52637. /**
  52638. * Callback used to let the user override the texture selection on a per mesh basis
  52639. */
  52640. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52641. /**
  52642. * Instantiates a new glow Layer and references it to the scene.
  52643. * @param name The name of the layer
  52644. * @param scene The scene to use the layer in
  52645. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52646. */
  52647. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52648. /**
  52649. * Get the effect name of the layer.
  52650. * @return The effect name
  52651. */
  52652. getEffectName(): string;
  52653. /**
  52654. * Create the merge effect. This is the shader use to blit the information back
  52655. * to the main canvas at the end of the scene rendering.
  52656. */
  52657. protected _createMergeEffect(): Effect;
  52658. /**
  52659. * Creates the render target textures and post processes used in the glow layer.
  52660. */
  52661. protected _createTextureAndPostProcesses(): void;
  52662. /**
  52663. * Checks for the readiness of the element composing the layer.
  52664. * @param subMesh the mesh to check for
  52665. * @param useInstances specify wether or not to use instances to render the mesh
  52666. * @param emissiveTexture the associated emissive texture used to generate the glow
  52667. * @return true if ready otherwise, false
  52668. */
  52669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52670. /**
  52671. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52672. */
  52673. needStencil(): boolean;
  52674. /**
  52675. * Returns true if the mesh can be rendered, otherwise false.
  52676. * @param mesh The mesh to render
  52677. * @param material The material used on the mesh
  52678. * @returns true if it can be rendered otherwise false
  52679. */
  52680. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52681. /**
  52682. * Implementation specific of rendering the generating effect on the main canvas.
  52683. * @param effect The effect used to render through
  52684. */
  52685. protected _internalRender(effect: Effect): void;
  52686. /**
  52687. * Sets the required values for both the emissive texture and and the main color.
  52688. */
  52689. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52690. /**
  52691. * Returns true if the mesh should render, otherwise false.
  52692. * @param mesh The mesh to render
  52693. * @returns true if it should render otherwise false
  52694. */
  52695. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52696. /**
  52697. * Adds specific effects defines.
  52698. * @param defines The defines to add specifics to.
  52699. */
  52700. protected _addCustomEffectDefines(defines: string[]): void;
  52701. /**
  52702. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52703. * @param mesh The mesh to exclude from the glow layer
  52704. */
  52705. addExcludedMesh(mesh: Mesh): void;
  52706. /**
  52707. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52708. * @param mesh The mesh to remove
  52709. */
  52710. removeExcludedMesh(mesh: Mesh): void;
  52711. /**
  52712. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52713. * @param mesh The mesh to include in the glow layer
  52714. */
  52715. addIncludedOnlyMesh(mesh: Mesh): void;
  52716. /**
  52717. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52718. * @param mesh The mesh to remove
  52719. */
  52720. removeIncludedOnlyMesh(mesh: Mesh): void;
  52721. /**
  52722. * Determine if a given mesh will be used in the glow layer
  52723. * @param mesh The mesh to test
  52724. * @returns true if the mesh will be highlighted by the current glow layer
  52725. */
  52726. hasMesh(mesh: AbstractMesh): boolean;
  52727. /**
  52728. * Defines wether the current material of the mesh should be use to render the effect.
  52729. * @param mesh defines the current mesh to render
  52730. */
  52731. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52732. /**
  52733. * Add a mesh to be rendered through its own material and not with emissive only.
  52734. * @param mesh The mesh for which we need to use its material
  52735. */
  52736. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52737. /**
  52738. * Remove a mesh from being rendered through its own material and not with emissive only.
  52739. * @param mesh The mesh for which we need to not use its material
  52740. */
  52741. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52742. /**
  52743. * Free any resources and references associated to a mesh.
  52744. * Internal use
  52745. * @param mesh The mesh to free.
  52746. * @hidden
  52747. */
  52748. _disposeMesh(mesh: Mesh): void;
  52749. /**
  52750. * Gets the class name of the effect layer
  52751. * @returns the string with the class name of the effect layer
  52752. */
  52753. getClassName(): string;
  52754. /**
  52755. * Serializes this glow layer
  52756. * @returns a serialized glow layer object
  52757. */
  52758. serialize(): any;
  52759. /**
  52760. * Creates a Glow Layer from parsed glow layer data
  52761. * @param parsedGlowLayer defines glow layer data
  52762. * @param scene defines the current scene
  52763. * @param rootUrl defines the root URL containing the glow layer information
  52764. * @returns a parsed Glow Layer
  52765. */
  52766. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52767. }
  52768. }
  52769. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52770. /** @hidden */
  52771. export var glowBlurPostProcessPixelShader: {
  52772. name: string;
  52773. shader: string;
  52774. };
  52775. }
  52776. declare module "babylonjs/Layers/highlightLayer" {
  52777. import { Observable } from "babylonjs/Misc/observable";
  52778. import { Nullable } from "babylonjs/types";
  52779. import { Camera } from "babylonjs/Cameras/camera";
  52780. import { Scene } from "babylonjs/scene";
  52781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52783. import { Mesh } from "babylonjs/Meshes/mesh";
  52784. import { Effect } from "babylonjs/Materials/effect";
  52785. import { Material } from "babylonjs/Materials/material";
  52786. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52787. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52788. import "babylonjs/Shaders/glowMapMerge.fragment";
  52789. import "babylonjs/Shaders/glowMapMerge.vertex";
  52790. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52791. module "babylonjs/abstractScene" {
  52792. interface AbstractScene {
  52793. /**
  52794. * Return a the first highlight layer of the scene with a given name.
  52795. * @param name The name of the highlight layer to look for.
  52796. * @return The highlight layer if found otherwise null.
  52797. */
  52798. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52799. }
  52800. }
  52801. /**
  52802. * Highlight layer options. This helps customizing the behaviour
  52803. * of the highlight layer.
  52804. */
  52805. export interface IHighlightLayerOptions {
  52806. /**
  52807. * Multiplication factor apply to the canvas size to compute the render target size
  52808. * used to generated the glowing objects (the smaller the faster).
  52809. */
  52810. mainTextureRatio: number;
  52811. /**
  52812. * Enforces a fixed size texture to ensure resize independant blur.
  52813. */
  52814. mainTextureFixedSize?: number;
  52815. /**
  52816. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52817. * of the picture to blur (the smaller the faster).
  52818. */
  52819. blurTextureSizeRatio: number;
  52820. /**
  52821. * How big in texel of the blur texture is the vertical blur.
  52822. */
  52823. blurVerticalSize: number;
  52824. /**
  52825. * How big in texel of the blur texture is the horizontal blur.
  52826. */
  52827. blurHorizontalSize: number;
  52828. /**
  52829. * Alpha blending mode used to apply the blur. Default is combine.
  52830. */
  52831. alphaBlendingMode: number;
  52832. /**
  52833. * The camera attached to the layer.
  52834. */
  52835. camera: Nullable<Camera>;
  52836. /**
  52837. * Should we display highlight as a solid stroke?
  52838. */
  52839. isStroke?: boolean;
  52840. /**
  52841. * The rendering group to draw the layer in.
  52842. */
  52843. renderingGroupId: number;
  52844. }
  52845. /**
  52846. * The highlight layer Helps adding a glow effect around a mesh.
  52847. *
  52848. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52849. * glowy meshes to your scene.
  52850. *
  52851. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52852. */
  52853. export class HighlightLayer extends EffectLayer {
  52854. name: string;
  52855. /**
  52856. * Effect Name of the highlight layer.
  52857. */
  52858. static readonly EffectName: string;
  52859. /**
  52860. * The neutral color used during the preparation of the glow effect.
  52861. * This is black by default as the blend operation is a blend operation.
  52862. */
  52863. static NeutralColor: Color4;
  52864. /**
  52865. * Stencil value used for glowing meshes.
  52866. */
  52867. static GlowingMeshStencilReference: number;
  52868. /**
  52869. * Stencil value used for the other meshes in the scene.
  52870. */
  52871. static NormalMeshStencilReference: number;
  52872. /**
  52873. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52874. */
  52875. innerGlow: boolean;
  52876. /**
  52877. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52878. */
  52879. outerGlow: boolean;
  52880. /**
  52881. * Specifies the horizontal size of the blur.
  52882. */
  52883. /**
  52884. * Gets the horizontal size of the blur.
  52885. */
  52886. blurHorizontalSize: number;
  52887. /**
  52888. * Specifies the vertical size of the blur.
  52889. */
  52890. /**
  52891. * Gets the vertical size of the blur.
  52892. */
  52893. blurVerticalSize: number;
  52894. /**
  52895. * An event triggered when the highlight layer is being blurred.
  52896. */
  52897. onBeforeBlurObservable: Observable<HighlightLayer>;
  52898. /**
  52899. * An event triggered when the highlight layer has been blurred.
  52900. */
  52901. onAfterBlurObservable: Observable<HighlightLayer>;
  52902. private _instanceGlowingMeshStencilReference;
  52903. private _options;
  52904. private _downSamplePostprocess;
  52905. private _horizontalBlurPostprocess;
  52906. private _verticalBlurPostprocess;
  52907. private _blurTexture;
  52908. private _meshes;
  52909. private _excludedMeshes;
  52910. /**
  52911. * Instantiates a new highlight Layer and references it to the scene..
  52912. * @param name The name of the layer
  52913. * @param scene The scene to use the layer in
  52914. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52915. */
  52916. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52917. /**
  52918. * Get the effect name of the layer.
  52919. * @return The effect name
  52920. */
  52921. getEffectName(): string;
  52922. /**
  52923. * Create the merge effect. This is the shader use to blit the information back
  52924. * to the main canvas at the end of the scene rendering.
  52925. */
  52926. protected _createMergeEffect(): Effect;
  52927. /**
  52928. * Creates the render target textures and post processes used in the highlight layer.
  52929. */
  52930. protected _createTextureAndPostProcesses(): void;
  52931. /**
  52932. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52933. */
  52934. needStencil(): boolean;
  52935. /**
  52936. * Checks for the readiness of the element composing the layer.
  52937. * @param subMesh the mesh to check for
  52938. * @param useInstances specify wether or not to use instances to render the mesh
  52939. * @param emissiveTexture the associated emissive texture used to generate the glow
  52940. * @return true if ready otherwise, false
  52941. */
  52942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52943. /**
  52944. * Implementation specific of rendering the generating effect on the main canvas.
  52945. * @param effect The effect used to render through
  52946. */
  52947. protected _internalRender(effect: Effect): void;
  52948. /**
  52949. * Returns true if the layer contains information to display, otherwise false.
  52950. */
  52951. shouldRender(): boolean;
  52952. /**
  52953. * Returns true if the mesh should render, otherwise false.
  52954. * @param mesh The mesh to render
  52955. * @returns true if it should render otherwise false
  52956. */
  52957. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52958. /**
  52959. * Sets the required values for both the emissive texture and and the main color.
  52960. */
  52961. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52962. /**
  52963. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52964. * @param mesh The mesh to exclude from the highlight layer
  52965. */
  52966. addExcludedMesh(mesh: Mesh): void;
  52967. /**
  52968. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52969. * @param mesh The mesh to highlight
  52970. */
  52971. removeExcludedMesh(mesh: Mesh): void;
  52972. /**
  52973. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52974. * @param mesh mesh to test
  52975. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52976. */
  52977. hasMesh(mesh: AbstractMesh): boolean;
  52978. /**
  52979. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52980. * @param mesh The mesh to highlight
  52981. * @param color The color of the highlight
  52982. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52983. */
  52984. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52985. /**
  52986. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52987. * @param mesh The mesh to highlight
  52988. */
  52989. removeMesh(mesh: Mesh): void;
  52990. /**
  52991. * Force the stencil to the normal expected value for none glowing parts
  52992. */
  52993. private _defaultStencilReference;
  52994. /**
  52995. * Free any resources and references associated to a mesh.
  52996. * Internal use
  52997. * @param mesh The mesh to free.
  52998. * @hidden
  52999. */
  53000. _disposeMesh(mesh: Mesh): void;
  53001. /**
  53002. * Dispose the highlight layer and free resources.
  53003. */
  53004. dispose(): void;
  53005. /**
  53006. * Gets the class name of the effect layer
  53007. * @returns the string with the class name of the effect layer
  53008. */
  53009. getClassName(): string;
  53010. /**
  53011. * Serializes this Highlight layer
  53012. * @returns a serialized Highlight layer object
  53013. */
  53014. serialize(): any;
  53015. /**
  53016. * Creates a Highlight layer from parsed Highlight layer data
  53017. * @param parsedHightlightLayer defines the Highlight layer data
  53018. * @param scene defines the current scene
  53019. * @param rootUrl defines the root URL containing the Highlight layer information
  53020. * @returns a parsed Highlight layer
  53021. */
  53022. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53023. }
  53024. }
  53025. declare module "babylonjs/Layers/layerSceneComponent" {
  53026. import { Scene } from "babylonjs/scene";
  53027. import { ISceneComponent } from "babylonjs/sceneComponent";
  53028. import { Layer } from "babylonjs/Layers/layer";
  53029. import { AbstractScene } from "babylonjs/abstractScene";
  53030. module "babylonjs/abstractScene" {
  53031. interface AbstractScene {
  53032. /**
  53033. * The list of layers (background and foreground) of the scene
  53034. */
  53035. layers: Array<Layer>;
  53036. }
  53037. }
  53038. /**
  53039. * Defines the layer scene component responsible to manage any layers
  53040. * in a given scene.
  53041. */
  53042. export class LayerSceneComponent implements ISceneComponent {
  53043. /**
  53044. * The component name helpfull to identify the component in the list of scene components.
  53045. */
  53046. readonly name: string;
  53047. /**
  53048. * The scene the component belongs to.
  53049. */
  53050. scene: Scene;
  53051. private _engine;
  53052. /**
  53053. * Creates a new instance of the component for the given scene
  53054. * @param scene Defines the scene to register the component in
  53055. */
  53056. constructor(scene: Scene);
  53057. /**
  53058. * Registers the component in a given scene
  53059. */
  53060. register(): void;
  53061. /**
  53062. * Rebuilds the elements related to this component in case of
  53063. * context lost for instance.
  53064. */
  53065. rebuild(): void;
  53066. /**
  53067. * Disposes the component and the associated ressources.
  53068. */
  53069. dispose(): void;
  53070. private _draw;
  53071. private _drawCameraPredicate;
  53072. private _drawCameraBackground;
  53073. private _drawCameraForeground;
  53074. private _drawRenderTargetPredicate;
  53075. private _drawRenderTargetBackground;
  53076. private _drawRenderTargetForeground;
  53077. /**
  53078. * Adds all the elements from the container to the scene
  53079. * @param container the container holding the elements
  53080. */
  53081. addFromContainer(container: AbstractScene): void;
  53082. /**
  53083. * Removes all the elements in the container from the scene
  53084. * @param container contains the elements to remove
  53085. * @param dispose if the removed element should be disposed (default: false)
  53086. */
  53087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53088. }
  53089. }
  53090. declare module "babylonjs/Shaders/layer.fragment" {
  53091. /** @hidden */
  53092. export var layerPixelShader: {
  53093. name: string;
  53094. shader: string;
  53095. };
  53096. }
  53097. declare module "babylonjs/Shaders/layer.vertex" {
  53098. /** @hidden */
  53099. export var layerVertexShader: {
  53100. name: string;
  53101. shader: string;
  53102. };
  53103. }
  53104. declare module "babylonjs/Layers/layer" {
  53105. import { Observable } from "babylonjs/Misc/observable";
  53106. import { Nullable } from "babylonjs/types";
  53107. import { Scene } from "babylonjs/scene";
  53108. import { Vector2 } from "babylonjs/Maths/math.vector";
  53109. import { Color4 } from "babylonjs/Maths/math.color";
  53110. import { Texture } from "babylonjs/Materials/Textures/texture";
  53111. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53112. import "babylonjs/Shaders/layer.fragment";
  53113. import "babylonjs/Shaders/layer.vertex";
  53114. /**
  53115. * This represents a full screen 2d layer.
  53116. * This can be useful to display a picture in the background of your scene for instance.
  53117. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53118. */
  53119. export class Layer {
  53120. /**
  53121. * Define the name of the layer.
  53122. */
  53123. name: string;
  53124. /**
  53125. * Define the texture the layer should display.
  53126. */
  53127. texture: Nullable<Texture>;
  53128. /**
  53129. * Is the layer in background or foreground.
  53130. */
  53131. isBackground: boolean;
  53132. /**
  53133. * Define the color of the layer (instead of texture).
  53134. */
  53135. color: Color4;
  53136. /**
  53137. * Define the scale of the layer in order to zoom in out of the texture.
  53138. */
  53139. scale: Vector2;
  53140. /**
  53141. * Define an offset for the layer in order to shift the texture.
  53142. */
  53143. offset: Vector2;
  53144. /**
  53145. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53146. */
  53147. alphaBlendingMode: number;
  53148. /**
  53149. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53150. * Alpha test will not mix with the background color in case of transparency.
  53151. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53152. */
  53153. alphaTest: boolean;
  53154. /**
  53155. * Define a mask to restrict the layer to only some of the scene cameras.
  53156. */
  53157. layerMask: number;
  53158. /**
  53159. * Define the list of render target the layer is visible into.
  53160. */
  53161. renderTargetTextures: RenderTargetTexture[];
  53162. /**
  53163. * Define if the layer is only used in renderTarget or if it also
  53164. * renders in the main frame buffer of the canvas.
  53165. */
  53166. renderOnlyInRenderTargetTextures: boolean;
  53167. private _scene;
  53168. private _vertexBuffers;
  53169. private _indexBuffer;
  53170. private _effect;
  53171. private _alphaTestEffect;
  53172. /**
  53173. * An event triggered when the layer is disposed.
  53174. */
  53175. onDisposeObservable: Observable<Layer>;
  53176. private _onDisposeObserver;
  53177. /**
  53178. * Back compatibility with callback before the onDisposeObservable existed.
  53179. * The set callback will be triggered when the layer has been disposed.
  53180. */
  53181. onDispose: () => void;
  53182. /**
  53183. * An event triggered before rendering the scene
  53184. */
  53185. onBeforeRenderObservable: Observable<Layer>;
  53186. private _onBeforeRenderObserver;
  53187. /**
  53188. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53189. * The set callback will be triggered just before rendering the layer.
  53190. */
  53191. onBeforeRender: () => void;
  53192. /**
  53193. * An event triggered after rendering the scene
  53194. */
  53195. onAfterRenderObservable: Observable<Layer>;
  53196. private _onAfterRenderObserver;
  53197. /**
  53198. * Back compatibility with callback before the onAfterRenderObservable existed.
  53199. * The set callback will be triggered just after rendering the layer.
  53200. */
  53201. onAfterRender: () => void;
  53202. /**
  53203. * Instantiates a new layer.
  53204. * This represents a full screen 2d layer.
  53205. * This can be useful to display a picture in the background of your scene for instance.
  53206. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53207. * @param name Define the name of the layer in the scene
  53208. * @param imgUrl Define the url of the texture to display in the layer
  53209. * @param scene Define the scene the layer belongs to
  53210. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53211. * @param color Defines a color for the layer
  53212. */
  53213. constructor(
  53214. /**
  53215. * Define the name of the layer.
  53216. */
  53217. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53218. private _createIndexBuffer;
  53219. /** @hidden */
  53220. _rebuild(): void;
  53221. /**
  53222. * Renders the layer in the scene.
  53223. */
  53224. render(): void;
  53225. /**
  53226. * Disposes and releases the associated ressources.
  53227. */
  53228. dispose(): void;
  53229. }
  53230. }
  53231. declare module "babylonjs/Layers/index" {
  53232. export * from "babylonjs/Layers/effectLayer";
  53233. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53234. export * from "babylonjs/Layers/glowLayer";
  53235. export * from "babylonjs/Layers/highlightLayer";
  53236. export * from "babylonjs/Layers/layer";
  53237. export * from "babylonjs/Layers/layerSceneComponent";
  53238. }
  53239. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53240. /** @hidden */
  53241. export var lensFlarePixelShader: {
  53242. name: string;
  53243. shader: string;
  53244. };
  53245. }
  53246. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53247. /** @hidden */
  53248. export var lensFlareVertexShader: {
  53249. name: string;
  53250. shader: string;
  53251. };
  53252. }
  53253. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53254. import { Scene } from "babylonjs/scene";
  53255. import { Vector3 } from "babylonjs/Maths/math.vector";
  53256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53257. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53258. import "babylonjs/Shaders/lensFlare.fragment";
  53259. import "babylonjs/Shaders/lensFlare.vertex";
  53260. import { Viewport } from "babylonjs/Maths/math.viewport";
  53261. /**
  53262. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53263. * It is usually composed of several `lensFlare`.
  53264. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53265. */
  53266. export class LensFlareSystem {
  53267. /**
  53268. * Define the name of the lens flare system
  53269. */
  53270. name: string;
  53271. /**
  53272. * List of lens flares used in this system.
  53273. */
  53274. lensFlares: LensFlare[];
  53275. /**
  53276. * Define a limit from the border the lens flare can be visible.
  53277. */
  53278. borderLimit: number;
  53279. /**
  53280. * Define a viewport border we do not want to see the lens flare in.
  53281. */
  53282. viewportBorder: number;
  53283. /**
  53284. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53285. */
  53286. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53287. /**
  53288. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53289. */
  53290. layerMask: number;
  53291. /**
  53292. * Define the id of the lens flare system in the scene.
  53293. * (equal to name by default)
  53294. */
  53295. id: string;
  53296. private _scene;
  53297. private _emitter;
  53298. private _vertexBuffers;
  53299. private _indexBuffer;
  53300. private _effect;
  53301. private _positionX;
  53302. private _positionY;
  53303. private _isEnabled;
  53304. /** @hidden */
  53305. static _SceneComponentInitialization: (scene: Scene) => void;
  53306. /**
  53307. * Instantiates a lens flare system.
  53308. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53309. * It is usually composed of several `lensFlare`.
  53310. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53311. * @param name Define the name of the lens flare system in the scene
  53312. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53313. * @param scene Define the scene the lens flare system belongs to
  53314. */
  53315. constructor(
  53316. /**
  53317. * Define the name of the lens flare system
  53318. */
  53319. name: string, emitter: any, scene: Scene);
  53320. /**
  53321. * Define if the lens flare system is enabled.
  53322. */
  53323. isEnabled: boolean;
  53324. /**
  53325. * Get the scene the effects belongs to.
  53326. * @returns the scene holding the lens flare system
  53327. */
  53328. getScene(): Scene;
  53329. /**
  53330. * Get the emitter of the lens flare system.
  53331. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53332. * @returns the emitter of the lens flare system
  53333. */
  53334. getEmitter(): any;
  53335. /**
  53336. * Set the emitter of the lens flare system.
  53337. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53338. * @param newEmitter Define the new emitter of the system
  53339. */
  53340. setEmitter(newEmitter: any): void;
  53341. /**
  53342. * Get the lens flare system emitter position.
  53343. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53344. * @returns the position
  53345. */
  53346. getEmitterPosition(): Vector3;
  53347. /**
  53348. * @hidden
  53349. */
  53350. computeEffectivePosition(globalViewport: Viewport): boolean;
  53351. /** @hidden */
  53352. _isVisible(): boolean;
  53353. /**
  53354. * @hidden
  53355. */
  53356. render(): boolean;
  53357. /**
  53358. * Dispose and release the lens flare with its associated resources.
  53359. */
  53360. dispose(): void;
  53361. /**
  53362. * Parse a lens flare system from a JSON repressentation
  53363. * @param parsedLensFlareSystem Define the JSON to parse
  53364. * @param scene Define the scene the parsed system should be instantiated in
  53365. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53366. * @returns the parsed system
  53367. */
  53368. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53369. /**
  53370. * Serialize the current Lens Flare System into a JSON representation.
  53371. * @returns the serialized JSON
  53372. */
  53373. serialize(): any;
  53374. }
  53375. }
  53376. declare module "babylonjs/LensFlares/lensFlare" {
  53377. import { Nullable } from "babylonjs/types";
  53378. import { Color3 } from "babylonjs/Maths/math.color";
  53379. import { Texture } from "babylonjs/Materials/Textures/texture";
  53380. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53381. /**
  53382. * This represents one of the lens effect in a `lensFlareSystem`.
  53383. * It controls one of the indiviual texture used in the effect.
  53384. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53385. */
  53386. export class LensFlare {
  53387. /**
  53388. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53389. */
  53390. size: number;
  53391. /**
  53392. * 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.
  53393. */
  53394. position: number;
  53395. /**
  53396. * Define the lens color.
  53397. */
  53398. color: Color3;
  53399. /**
  53400. * Define the lens texture.
  53401. */
  53402. texture: Nullable<Texture>;
  53403. /**
  53404. * Define the alpha mode to render this particular lens.
  53405. */
  53406. alphaMode: number;
  53407. private _system;
  53408. /**
  53409. * Creates a new Lens Flare.
  53410. * This represents one of the lens effect in a `lensFlareSystem`.
  53411. * It controls one of the indiviual texture used in the effect.
  53412. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53413. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53414. * @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.
  53415. * @param color Define the lens color
  53416. * @param imgUrl Define the lens texture url
  53417. * @param system Define the `lensFlareSystem` this flare is part of
  53418. * @returns The newly created Lens Flare
  53419. */
  53420. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53421. /**
  53422. * Instantiates a new Lens Flare.
  53423. * This represents one of the lens effect in a `lensFlareSystem`.
  53424. * It controls one of the indiviual texture used in the effect.
  53425. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53426. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53427. * @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.
  53428. * @param color Define the lens color
  53429. * @param imgUrl Define the lens texture url
  53430. * @param system Define the `lensFlareSystem` this flare is part of
  53431. */
  53432. constructor(
  53433. /**
  53434. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53435. */
  53436. size: number,
  53437. /**
  53438. * 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.
  53439. */
  53440. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53441. /**
  53442. * Dispose and release the lens flare with its associated resources.
  53443. */
  53444. dispose(): void;
  53445. }
  53446. }
  53447. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53448. import { Nullable } from "babylonjs/types";
  53449. import { Scene } from "babylonjs/scene";
  53450. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53451. import { AbstractScene } from "babylonjs/abstractScene";
  53452. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53453. module "babylonjs/abstractScene" {
  53454. interface AbstractScene {
  53455. /**
  53456. * The list of lens flare system added to the scene
  53457. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53458. */
  53459. lensFlareSystems: Array<LensFlareSystem>;
  53460. /**
  53461. * Removes the given lens flare system from this scene.
  53462. * @param toRemove The lens flare system to remove
  53463. * @returns The index of the removed lens flare system
  53464. */
  53465. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53466. /**
  53467. * Adds the given lens flare system to this scene
  53468. * @param newLensFlareSystem The lens flare system to add
  53469. */
  53470. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53471. /**
  53472. * Gets a lens flare system using its name
  53473. * @param name defines the name to look for
  53474. * @returns the lens flare system or null if not found
  53475. */
  53476. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53477. /**
  53478. * Gets a lens flare system using its id
  53479. * @param id defines the id to look for
  53480. * @returns the lens flare system or null if not found
  53481. */
  53482. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53483. }
  53484. }
  53485. /**
  53486. * Defines the lens flare scene component responsible to manage any lens flares
  53487. * in a given scene.
  53488. */
  53489. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53490. /**
  53491. * The component name helpfull to identify the component in the list of scene components.
  53492. */
  53493. readonly name: string;
  53494. /**
  53495. * The scene the component belongs to.
  53496. */
  53497. scene: Scene;
  53498. /**
  53499. * Creates a new instance of the component for the given scene
  53500. * @param scene Defines the scene to register the component in
  53501. */
  53502. constructor(scene: Scene);
  53503. /**
  53504. * Registers the component in a given scene
  53505. */
  53506. register(): void;
  53507. /**
  53508. * Rebuilds the elements related to this component in case of
  53509. * context lost for instance.
  53510. */
  53511. rebuild(): void;
  53512. /**
  53513. * Adds all the elements from the container to the scene
  53514. * @param container the container holding the elements
  53515. */
  53516. addFromContainer(container: AbstractScene): void;
  53517. /**
  53518. * Removes all the elements in the container from the scene
  53519. * @param container contains the elements to remove
  53520. * @param dispose if the removed element should be disposed (default: false)
  53521. */
  53522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53523. /**
  53524. * Serializes the component data to the specified json object
  53525. * @param serializationObject The object to serialize to
  53526. */
  53527. serialize(serializationObject: any): void;
  53528. /**
  53529. * Disposes the component and the associated ressources.
  53530. */
  53531. dispose(): void;
  53532. private _draw;
  53533. }
  53534. }
  53535. declare module "babylonjs/LensFlares/index" {
  53536. export * from "babylonjs/LensFlares/lensFlare";
  53537. export * from "babylonjs/LensFlares/lensFlareSystem";
  53538. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53539. }
  53540. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53541. import { Scene } from "babylonjs/scene";
  53542. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53543. import { AbstractScene } from "babylonjs/abstractScene";
  53544. /**
  53545. * Defines the shadow generator component responsible to manage any shadow generators
  53546. * in a given scene.
  53547. */
  53548. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53549. /**
  53550. * The component name helpfull to identify the component in the list of scene components.
  53551. */
  53552. readonly name: string;
  53553. /**
  53554. * The scene the component belongs to.
  53555. */
  53556. scene: Scene;
  53557. /**
  53558. * Creates a new instance of the component for the given scene
  53559. * @param scene Defines the scene to register the component in
  53560. */
  53561. constructor(scene: Scene);
  53562. /**
  53563. * Registers the component in a given scene
  53564. */
  53565. register(): void;
  53566. /**
  53567. * Rebuilds the elements related to this component in case of
  53568. * context lost for instance.
  53569. */
  53570. rebuild(): void;
  53571. /**
  53572. * Serializes the component data to the specified json object
  53573. * @param serializationObject The object to serialize to
  53574. */
  53575. serialize(serializationObject: any): void;
  53576. /**
  53577. * Adds all the elements from the container to the scene
  53578. * @param container the container holding the elements
  53579. */
  53580. addFromContainer(container: AbstractScene): void;
  53581. /**
  53582. * Removes all the elements in the container from the scene
  53583. * @param container contains the elements to remove
  53584. * @param dispose if the removed element should be disposed (default: false)
  53585. */
  53586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53587. /**
  53588. * Rebuilds the elements related to this component in case of
  53589. * context lost for instance.
  53590. */
  53591. dispose(): void;
  53592. private _gatherRenderTargets;
  53593. }
  53594. }
  53595. declare module "babylonjs/Lights/Shadows/index" {
  53596. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53597. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53598. }
  53599. declare module "babylonjs/Lights/pointLight" {
  53600. import { Scene } from "babylonjs/scene";
  53601. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53603. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53604. import { Effect } from "babylonjs/Materials/effect";
  53605. /**
  53606. * A point light is a light defined by an unique point in world space.
  53607. * The light is emitted in every direction from this point.
  53608. * A good example of a point light is a standard light bulb.
  53609. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53610. */
  53611. export class PointLight extends ShadowLight {
  53612. private _shadowAngle;
  53613. /**
  53614. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53615. * This specifies what angle the shadow will use to be created.
  53616. *
  53617. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53618. */
  53619. /**
  53620. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53621. * This specifies what angle the shadow will use to be created.
  53622. *
  53623. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53624. */
  53625. shadowAngle: number;
  53626. /**
  53627. * Gets the direction if it has been set.
  53628. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53629. */
  53630. /**
  53631. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53632. */
  53633. direction: Vector3;
  53634. /**
  53635. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53636. * A PointLight emits the light in every direction.
  53637. * It can cast shadows.
  53638. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53639. * ```javascript
  53640. * var pointLight = new PointLight("pl", camera.position, scene);
  53641. * ```
  53642. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53643. * @param name The light friendly name
  53644. * @param position The position of the point light in the scene
  53645. * @param scene The scene the lights belongs to
  53646. */
  53647. constructor(name: string, position: Vector3, scene: Scene);
  53648. /**
  53649. * Returns the string "PointLight"
  53650. * @returns the class name
  53651. */
  53652. getClassName(): string;
  53653. /**
  53654. * Returns the integer 0.
  53655. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53656. */
  53657. getTypeID(): number;
  53658. /**
  53659. * Specifies wether or not the shadowmap should be a cube texture.
  53660. * @returns true if the shadowmap needs to be a cube texture.
  53661. */
  53662. needCube(): boolean;
  53663. /**
  53664. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53665. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53666. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53667. */
  53668. getShadowDirection(faceIndex?: number): Vector3;
  53669. /**
  53670. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53671. * - fov = PI / 2
  53672. * - aspect ratio : 1.0
  53673. * - z-near and far equal to the active camera minZ and maxZ.
  53674. * Returns the PointLight.
  53675. */
  53676. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53677. protected _buildUniformLayout(): void;
  53678. /**
  53679. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53680. * @param effect The effect to update
  53681. * @param lightIndex The index of the light in the effect to update
  53682. * @returns The point light
  53683. */
  53684. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53685. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53686. /**
  53687. * Prepares the list of defines specific to the light type.
  53688. * @param defines the list of defines
  53689. * @param lightIndex defines the index of the light for the effect
  53690. */
  53691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53692. }
  53693. }
  53694. declare module "babylonjs/Lights/index" {
  53695. export * from "babylonjs/Lights/light";
  53696. export * from "babylonjs/Lights/shadowLight";
  53697. export * from "babylonjs/Lights/Shadows/index";
  53698. export * from "babylonjs/Lights/directionalLight";
  53699. export * from "babylonjs/Lights/hemisphericLight";
  53700. export * from "babylonjs/Lights/pointLight";
  53701. export * from "babylonjs/Lights/spotLight";
  53702. }
  53703. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53704. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53705. /**
  53706. * Header information of HDR texture files.
  53707. */
  53708. export interface HDRInfo {
  53709. /**
  53710. * The height of the texture in pixels.
  53711. */
  53712. height: number;
  53713. /**
  53714. * The width of the texture in pixels.
  53715. */
  53716. width: number;
  53717. /**
  53718. * The index of the beginning of the data in the binary file.
  53719. */
  53720. dataPosition: number;
  53721. }
  53722. /**
  53723. * This groups tools to convert HDR texture to native colors array.
  53724. */
  53725. export class HDRTools {
  53726. private static Ldexp;
  53727. private static Rgbe2float;
  53728. private static readStringLine;
  53729. /**
  53730. * Reads header information from an RGBE texture stored in a native array.
  53731. * More information on this format are available here:
  53732. * https://en.wikipedia.org/wiki/RGBE_image_format
  53733. *
  53734. * @param uint8array The binary file stored in native array.
  53735. * @return The header information.
  53736. */
  53737. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53738. /**
  53739. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53740. * This RGBE texture needs to store the information as a panorama.
  53741. *
  53742. * More information on this format are available here:
  53743. * https://en.wikipedia.org/wiki/RGBE_image_format
  53744. *
  53745. * @param buffer The binary file stored in an array buffer.
  53746. * @param size The expected size of the extracted cubemap.
  53747. * @return The Cube Map information.
  53748. */
  53749. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53750. /**
  53751. * Returns the pixels data extracted from an RGBE texture.
  53752. * This pixels will be stored left to right up to down in the R G B order in one array.
  53753. *
  53754. * More information on this format are available here:
  53755. * https://en.wikipedia.org/wiki/RGBE_image_format
  53756. *
  53757. * @param uint8array The binary file stored in an array buffer.
  53758. * @param hdrInfo The header information of the file.
  53759. * @return The pixels data in RGB right to left up to down order.
  53760. */
  53761. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53762. private static RGBE_ReadPixels_RLE;
  53763. }
  53764. }
  53765. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53766. import { Nullable } from "babylonjs/types";
  53767. import { Scene } from "babylonjs/scene";
  53768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53771. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53772. /**
  53773. * This represents a texture coming from an HDR input.
  53774. *
  53775. * The only supported format is currently panorama picture stored in RGBE format.
  53776. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53777. */
  53778. export class HDRCubeTexture extends BaseTexture {
  53779. private static _facesMapping;
  53780. private _generateHarmonics;
  53781. private _noMipmap;
  53782. private _textureMatrix;
  53783. private _size;
  53784. private _onLoad;
  53785. private _onError;
  53786. /**
  53787. * The texture URL.
  53788. */
  53789. url: string;
  53790. /**
  53791. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53792. */
  53793. coordinatesMode: number;
  53794. protected _isBlocking: boolean;
  53795. /**
  53796. * Sets wether or not the texture is blocking during loading.
  53797. */
  53798. /**
  53799. * Gets wether or not the texture is blocking during loading.
  53800. */
  53801. isBlocking: boolean;
  53802. protected _rotationY: number;
  53803. /**
  53804. * Sets texture matrix rotation angle around Y axis in radians.
  53805. */
  53806. /**
  53807. * Gets texture matrix rotation angle around Y axis radians.
  53808. */
  53809. rotationY: number;
  53810. /**
  53811. * Gets or sets the center of the bounding box associated with the cube texture
  53812. * It must define where the camera used to render the texture was set
  53813. */
  53814. boundingBoxPosition: Vector3;
  53815. private _boundingBoxSize;
  53816. /**
  53817. * Gets or sets the size of the bounding box associated with the cube texture
  53818. * When defined, the cubemap will switch to local mode
  53819. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53820. * @example https://www.babylonjs-playground.com/#RNASML
  53821. */
  53822. boundingBoxSize: Vector3;
  53823. /**
  53824. * Instantiates an HDRTexture from the following parameters.
  53825. *
  53826. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53827. * @param scene The scene the texture will be used in
  53828. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53829. * @param noMipmap Forces to not generate the mipmap if true
  53830. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53831. * @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)
  53832. * @param reserved Reserved flag for internal use.
  53833. */
  53834. 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>);
  53835. /**
  53836. * Get the current class name of the texture useful for serialization or dynamic coding.
  53837. * @returns "HDRCubeTexture"
  53838. */
  53839. getClassName(): string;
  53840. /**
  53841. * Occurs when the file is raw .hdr file.
  53842. */
  53843. private loadTexture;
  53844. clone(): HDRCubeTexture;
  53845. delayLoad(): void;
  53846. /**
  53847. * Get the texture reflection matrix used to rotate/transform the reflection.
  53848. * @returns the reflection matrix
  53849. */
  53850. getReflectionTextureMatrix(): Matrix;
  53851. /**
  53852. * Set the texture reflection matrix used to rotate/transform the reflection.
  53853. * @param value Define the reflection matrix to set
  53854. */
  53855. setReflectionTextureMatrix(value: Matrix): void;
  53856. /**
  53857. * Parses a JSON representation of an HDR Texture in order to create the texture
  53858. * @param parsedTexture Define the JSON representation
  53859. * @param scene Define the scene the texture should be created in
  53860. * @param rootUrl Define the root url in case we need to load relative dependencies
  53861. * @returns the newly created texture after parsing
  53862. */
  53863. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53864. serialize(): any;
  53865. }
  53866. }
  53867. declare module "babylonjs/Physics/physicsEngine" {
  53868. import { Nullable } from "babylonjs/types";
  53869. import { Vector3 } from "babylonjs/Maths/math.vector";
  53870. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53871. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53872. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53873. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53874. /**
  53875. * Class used to control physics engine
  53876. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53877. */
  53878. export class PhysicsEngine implements IPhysicsEngine {
  53879. private _physicsPlugin;
  53880. /**
  53881. * Global value used to control the smallest number supported by the simulation
  53882. */
  53883. static Epsilon: number;
  53884. private _impostors;
  53885. private _joints;
  53886. /**
  53887. * Gets the gravity vector used by the simulation
  53888. */
  53889. gravity: Vector3;
  53890. /**
  53891. * Factory used to create the default physics plugin.
  53892. * @returns The default physics plugin
  53893. */
  53894. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53895. /**
  53896. * Creates a new Physics Engine
  53897. * @param gravity defines the gravity vector used by the simulation
  53898. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53899. */
  53900. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53901. /**
  53902. * Sets the gravity vector used by the simulation
  53903. * @param gravity defines the gravity vector to use
  53904. */
  53905. setGravity(gravity: Vector3): void;
  53906. /**
  53907. * Set the time step of the physics engine.
  53908. * Default is 1/60.
  53909. * To slow it down, enter 1/600 for example.
  53910. * To speed it up, 1/30
  53911. * @param newTimeStep defines the new timestep to apply to this world.
  53912. */
  53913. setTimeStep(newTimeStep?: number): void;
  53914. /**
  53915. * Get the time step of the physics engine.
  53916. * @returns the current time step
  53917. */
  53918. getTimeStep(): number;
  53919. /**
  53920. * Release all resources
  53921. */
  53922. dispose(): void;
  53923. /**
  53924. * Gets the name of the current physics plugin
  53925. * @returns the name of the plugin
  53926. */
  53927. getPhysicsPluginName(): string;
  53928. /**
  53929. * Adding a new impostor for the impostor tracking.
  53930. * This will be done by the impostor itself.
  53931. * @param impostor the impostor to add
  53932. */
  53933. addImpostor(impostor: PhysicsImpostor): void;
  53934. /**
  53935. * Remove an impostor from the engine.
  53936. * This impostor and its mesh will not longer be updated by the physics engine.
  53937. * @param impostor the impostor to remove
  53938. */
  53939. removeImpostor(impostor: PhysicsImpostor): void;
  53940. /**
  53941. * Add a joint to the physics engine
  53942. * @param mainImpostor defines the main impostor to which the joint is added.
  53943. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53944. * @param joint defines the joint that will connect both impostors.
  53945. */
  53946. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53947. /**
  53948. * Removes a joint from the simulation
  53949. * @param mainImpostor defines the impostor used with the joint
  53950. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53951. * @param joint defines the joint to remove
  53952. */
  53953. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53954. /**
  53955. * Called by the scene. No need to call it.
  53956. * @param delta defines the timespam between frames
  53957. */
  53958. _step(delta: number): void;
  53959. /**
  53960. * Gets the current plugin used to run the simulation
  53961. * @returns current plugin
  53962. */
  53963. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53964. /**
  53965. * Gets the list of physic impostors
  53966. * @returns an array of PhysicsImpostor
  53967. */
  53968. getImpostors(): Array<PhysicsImpostor>;
  53969. /**
  53970. * Gets the impostor for a physics enabled object
  53971. * @param object defines the object impersonated by the impostor
  53972. * @returns the PhysicsImpostor or null if not found
  53973. */
  53974. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53975. /**
  53976. * Gets the impostor for a physics body object
  53977. * @param body defines physics body used by the impostor
  53978. * @returns the PhysicsImpostor or null if not found
  53979. */
  53980. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53981. /**
  53982. * Does a raycast in the physics world
  53983. * @param from when should the ray start?
  53984. * @param to when should the ray end?
  53985. * @returns PhysicsRaycastResult
  53986. */
  53987. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53988. }
  53989. }
  53990. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53991. import { Nullable } from "babylonjs/types";
  53992. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53994. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53995. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53996. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53997. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53998. /** @hidden */
  53999. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54000. private _useDeltaForWorldStep;
  54001. world: any;
  54002. name: string;
  54003. private _physicsMaterials;
  54004. private _fixedTimeStep;
  54005. private _cannonRaycastResult;
  54006. private _raycastResult;
  54007. private _physicsBodysToRemoveAfterStep;
  54008. BJSCANNON: any;
  54009. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54010. setGravity(gravity: Vector3): void;
  54011. setTimeStep(timeStep: number): void;
  54012. getTimeStep(): number;
  54013. executeStep(delta: number): void;
  54014. private _removeMarkedPhysicsBodiesFromWorld;
  54015. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54016. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54017. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54018. private _processChildMeshes;
  54019. removePhysicsBody(impostor: PhysicsImpostor): void;
  54020. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54021. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54022. private _addMaterial;
  54023. private _checkWithEpsilon;
  54024. private _createShape;
  54025. private _createHeightmap;
  54026. private _minus90X;
  54027. private _plus90X;
  54028. private _tmpPosition;
  54029. private _tmpDeltaPosition;
  54030. private _tmpUnityRotation;
  54031. private _updatePhysicsBodyTransformation;
  54032. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54033. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54034. isSupported(): boolean;
  54035. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54036. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54037. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54038. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54039. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54040. getBodyMass(impostor: PhysicsImpostor): number;
  54041. getBodyFriction(impostor: PhysicsImpostor): number;
  54042. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54043. getBodyRestitution(impostor: PhysicsImpostor): number;
  54044. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54045. sleepBody(impostor: PhysicsImpostor): void;
  54046. wakeUpBody(impostor: PhysicsImpostor): void;
  54047. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54048. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54049. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54050. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54051. getRadius(impostor: PhysicsImpostor): number;
  54052. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54053. dispose(): void;
  54054. private _extendNamespace;
  54055. /**
  54056. * Does a raycast in the physics world
  54057. * @param from when should the ray start?
  54058. * @param to when should the ray end?
  54059. * @returns PhysicsRaycastResult
  54060. */
  54061. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54062. }
  54063. }
  54064. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54065. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54066. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54067. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54069. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54070. import { Nullable } from "babylonjs/types";
  54071. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54072. /** @hidden */
  54073. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54074. world: any;
  54075. name: string;
  54076. BJSOIMO: any;
  54077. private _raycastResult;
  54078. constructor(iterations?: number, oimoInjection?: any);
  54079. setGravity(gravity: Vector3): void;
  54080. setTimeStep(timeStep: number): void;
  54081. getTimeStep(): number;
  54082. private _tmpImpostorsArray;
  54083. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54084. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54085. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54086. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54087. private _tmpPositionVector;
  54088. removePhysicsBody(impostor: PhysicsImpostor): void;
  54089. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54091. isSupported(): boolean;
  54092. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54093. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54094. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54095. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54096. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54097. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54098. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54099. getBodyMass(impostor: PhysicsImpostor): number;
  54100. getBodyFriction(impostor: PhysicsImpostor): number;
  54101. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54102. getBodyRestitution(impostor: PhysicsImpostor): number;
  54103. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54104. sleepBody(impostor: PhysicsImpostor): void;
  54105. wakeUpBody(impostor: PhysicsImpostor): void;
  54106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54107. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54108. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54109. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54110. getRadius(impostor: PhysicsImpostor): number;
  54111. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54112. dispose(): void;
  54113. /**
  54114. * Does a raycast in the physics world
  54115. * @param from when should the ray start?
  54116. * @param to when should the ray end?
  54117. * @returns PhysicsRaycastResult
  54118. */
  54119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54120. }
  54121. }
  54122. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54126. import { Color4 } from "babylonjs/Maths/math.color";
  54127. import { Mesh } from "babylonjs/Meshes/mesh";
  54128. /**
  54129. * Class containing static functions to help procedurally build meshes
  54130. */
  54131. export class RibbonBuilder {
  54132. /**
  54133. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54134. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54135. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54136. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54137. * * 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
  54138. * * 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
  54139. * * 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
  54140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54143. * * 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
  54144. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54145. * * 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
  54146. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54148. * @param name defines the name of the mesh
  54149. * @param options defines the options used to create the mesh
  54150. * @param scene defines the hosting scene
  54151. * @returns the ribbon mesh
  54152. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54154. */
  54155. static CreateRibbon(name: string, options: {
  54156. pathArray: Vector3[][];
  54157. closeArray?: boolean;
  54158. closePath?: boolean;
  54159. offset?: number;
  54160. updatable?: boolean;
  54161. sideOrientation?: number;
  54162. frontUVs?: Vector4;
  54163. backUVs?: Vector4;
  54164. instance?: Mesh;
  54165. invertUV?: boolean;
  54166. uvs?: Vector2[];
  54167. colors?: Color4[];
  54168. }, scene?: Nullable<Scene>): Mesh;
  54169. }
  54170. }
  54171. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54172. import { Nullable } from "babylonjs/types";
  54173. import { Scene } from "babylonjs/scene";
  54174. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54175. import { Mesh } from "babylonjs/Meshes/mesh";
  54176. /**
  54177. * Class containing static functions to help procedurally build meshes
  54178. */
  54179. export class ShapeBuilder {
  54180. /**
  54181. * 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.
  54182. * * 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.
  54183. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54184. * * 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.
  54185. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54186. * * 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
  54187. * * 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
  54188. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54193. * @param name defines the name of the mesh
  54194. * @param options defines the options used to create the mesh
  54195. * @param scene defines the hosting scene
  54196. * @returns the extruded shape mesh
  54197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54199. */
  54200. static ExtrudeShape(name: string, options: {
  54201. shape: Vector3[];
  54202. path: Vector3[];
  54203. scale?: number;
  54204. rotation?: number;
  54205. cap?: number;
  54206. updatable?: boolean;
  54207. sideOrientation?: number;
  54208. frontUVs?: Vector4;
  54209. backUVs?: Vector4;
  54210. instance?: Mesh;
  54211. invertUV?: boolean;
  54212. }, scene?: Nullable<Scene>): Mesh;
  54213. /**
  54214. * Creates an custom extruded shape mesh.
  54215. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54216. * * 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.
  54217. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54218. * * 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
  54219. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54220. * * 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
  54221. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54222. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54223. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54224. * * 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
  54225. * * 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
  54226. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54229. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54231. * @param name defines the name of the mesh
  54232. * @param options defines the options used to create the mesh
  54233. * @param scene defines the hosting scene
  54234. * @returns the custom extruded shape mesh
  54235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54236. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54238. */
  54239. static ExtrudeShapeCustom(name: string, options: {
  54240. shape: Vector3[];
  54241. path: Vector3[];
  54242. scaleFunction?: any;
  54243. rotationFunction?: any;
  54244. ribbonCloseArray?: boolean;
  54245. ribbonClosePath?: boolean;
  54246. cap?: number;
  54247. updatable?: boolean;
  54248. sideOrientation?: number;
  54249. frontUVs?: Vector4;
  54250. backUVs?: Vector4;
  54251. instance?: Mesh;
  54252. invertUV?: boolean;
  54253. }, scene?: Nullable<Scene>): Mesh;
  54254. private static _ExtrudeShapeGeneric;
  54255. }
  54256. }
  54257. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54258. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54259. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54260. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54261. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54262. import { Nullable } from "babylonjs/types";
  54263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54264. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54265. /**
  54266. * AmmoJS Physics plugin
  54267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54268. * @see https://github.com/kripken/ammo.js/
  54269. */
  54270. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54271. private _useDeltaForWorldStep;
  54272. /**
  54273. * Reference to the Ammo library
  54274. */
  54275. bjsAMMO: any;
  54276. /**
  54277. * Created ammoJS world which physics bodies are added to
  54278. */
  54279. world: any;
  54280. /**
  54281. * Name of the plugin
  54282. */
  54283. name: string;
  54284. private _timeStep;
  54285. private _fixedTimeStep;
  54286. private _maxSteps;
  54287. private _tmpQuaternion;
  54288. private _tmpAmmoTransform;
  54289. private _tmpAmmoQuaternion;
  54290. private _tmpAmmoConcreteContactResultCallback;
  54291. private _collisionConfiguration;
  54292. private _dispatcher;
  54293. private _overlappingPairCache;
  54294. private _solver;
  54295. private _softBodySolver;
  54296. private _tmpAmmoVectorA;
  54297. private _tmpAmmoVectorB;
  54298. private _tmpAmmoVectorC;
  54299. private _tmpAmmoVectorD;
  54300. private _tmpContactCallbackResult;
  54301. private _tmpAmmoVectorRCA;
  54302. private _tmpAmmoVectorRCB;
  54303. private _raycastResult;
  54304. private static readonly DISABLE_COLLISION_FLAG;
  54305. private static readonly KINEMATIC_FLAG;
  54306. private static readonly DISABLE_DEACTIVATION_FLAG;
  54307. /**
  54308. * Initializes the ammoJS plugin
  54309. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54310. * @param ammoInjection can be used to inject your own ammo reference
  54311. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54312. */
  54313. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54314. /**
  54315. * Sets the gravity of the physics world (m/(s^2))
  54316. * @param gravity Gravity to set
  54317. */
  54318. setGravity(gravity: Vector3): void;
  54319. /**
  54320. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54321. * @param timeStep timestep to use in seconds
  54322. */
  54323. setTimeStep(timeStep: number): void;
  54324. /**
  54325. * 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)
  54326. * @param fixedTimeStep fixedTimeStep to use in seconds
  54327. */
  54328. setFixedTimeStep(fixedTimeStep: number): void;
  54329. /**
  54330. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54331. * @param maxSteps the maximum number of steps by the physics engine per frame
  54332. */
  54333. setMaxSteps(maxSteps: number): void;
  54334. /**
  54335. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54336. * @returns the current timestep in seconds
  54337. */
  54338. getTimeStep(): number;
  54339. private _isImpostorInContact;
  54340. private _isImpostorPairInContact;
  54341. private _stepSimulation;
  54342. /**
  54343. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54344. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54345. * After the step the babylon meshes are set to the position of the physics imposters
  54346. * @param delta amount of time to step forward
  54347. * @param impostors array of imposters to update before/after the step
  54348. */
  54349. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54350. /**
  54351. * Update babylon mesh to match physics world object
  54352. * @param impostor imposter to match
  54353. */
  54354. private _afterSoftStep;
  54355. /**
  54356. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54357. * @param impostor imposter to match
  54358. */
  54359. private _ropeStep;
  54360. /**
  54361. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54362. * @param impostor imposter to match
  54363. */
  54364. private _softbodyOrClothStep;
  54365. private _tmpVector;
  54366. private _tmpMatrix;
  54367. /**
  54368. * Applies an impulse on the imposter
  54369. * @param impostor imposter to apply impulse to
  54370. * @param force amount of force to be applied to the imposter
  54371. * @param contactPoint the location to apply the impulse on the imposter
  54372. */
  54373. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54374. /**
  54375. * Applies a force on the imposter
  54376. * @param impostor imposter to apply force
  54377. * @param force amount of force to be applied to the imposter
  54378. * @param contactPoint the location to apply the force on the imposter
  54379. */
  54380. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54381. /**
  54382. * Creates a physics body using the plugin
  54383. * @param impostor the imposter to create the physics body on
  54384. */
  54385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54386. /**
  54387. * Removes the physics body from the imposter and disposes of the body's memory
  54388. * @param impostor imposter to remove the physics body from
  54389. */
  54390. removePhysicsBody(impostor: PhysicsImpostor): void;
  54391. /**
  54392. * Generates a joint
  54393. * @param impostorJoint the imposter joint to create the joint with
  54394. */
  54395. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54396. /**
  54397. * Removes a joint
  54398. * @param impostorJoint the imposter joint to remove the joint from
  54399. */
  54400. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54401. private _addMeshVerts;
  54402. /**
  54403. * Initialise the soft body vertices to match its object's (mesh) vertices
  54404. * Softbody vertices (nodes) are in world space and to match this
  54405. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54406. * @param impostor to create the softbody for
  54407. */
  54408. private _softVertexData;
  54409. /**
  54410. * Create an impostor's soft body
  54411. * @param impostor to create the softbody for
  54412. */
  54413. private _createSoftbody;
  54414. /**
  54415. * Create cloth for an impostor
  54416. * @param impostor to create the softbody for
  54417. */
  54418. private _createCloth;
  54419. /**
  54420. * Create rope for an impostor
  54421. * @param impostor to create the softbody for
  54422. */
  54423. private _createRope;
  54424. private _addHullVerts;
  54425. private _createShape;
  54426. /**
  54427. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54428. * @param impostor imposter containing the physics body and babylon object
  54429. */
  54430. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54431. /**
  54432. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54433. * @param impostor imposter containing the physics body and babylon object
  54434. * @param newPosition new position
  54435. * @param newRotation new rotation
  54436. */
  54437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54438. /**
  54439. * If this plugin is supported
  54440. * @returns true if its supported
  54441. */
  54442. isSupported(): boolean;
  54443. /**
  54444. * Sets the linear velocity of the physics body
  54445. * @param impostor imposter to set the velocity on
  54446. * @param velocity velocity to set
  54447. */
  54448. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54449. /**
  54450. * Sets the angular velocity of the physics body
  54451. * @param impostor imposter to set the velocity on
  54452. * @param velocity velocity to set
  54453. */
  54454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54455. /**
  54456. * gets the linear velocity
  54457. * @param impostor imposter to get linear velocity from
  54458. * @returns linear velocity
  54459. */
  54460. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54461. /**
  54462. * gets the angular velocity
  54463. * @param impostor imposter to get angular velocity from
  54464. * @returns angular velocity
  54465. */
  54466. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54467. /**
  54468. * Sets the mass of physics body
  54469. * @param impostor imposter to set the mass on
  54470. * @param mass mass to set
  54471. */
  54472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54473. /**
  54474. * Gets the mass of the physics body
  54475. * @param impostor imposter to get the mass from
  54476. * @returns mass
  54477. */
  54478. getBodyMass(impostor: PhysicsImpostor): number;
  54479. /**
  54480. * Gets friction of the impostor
  54481. * @param impostor impostor to get friction from
  54482. * @returns friction value
  54483. */
  54484. getBodyFriction(impostor: PhysicsImpostor): number;
  54485. /**
  54486. * Sets friction of the impostor
  54487. * @param impostor impostor to set friction on
  54488. * @param friction friction value
  54489. */
  54490. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54491. /**
  54492. * Gets restitution of the impostor
  54493. * @param impostor impostor to get restitution from
  54494. * @returns restitution value
  54495. */
  54496. getBodyRestitution(impostor: PhysicsImpostor): number;
  54497. /**
  54498. * Sets resitution of the impostor
  54499. * @param impostor impostor to set resitution on
  54500. * @param restitution resitution value
  54501. */
  54502. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54503. /**
  54504. * Gets pressure inside the impostor
  54505. * @param impostor impostor to get pressure from
  54506. * @returns pressure value
  54507. */
  54508. getBodyPressure(impostor: PhysicsImpostor): number;
  54509. /**
  54510. * Sets pressure inside a soft body impostor
  54511. * Cloth and rope must remain 0 pressure
  54512. * @param impostor impostor to set pressure on
  54513. * @param pressure pressure value
  54514. */
  54515. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54516. /**
  54517. * Gets stiffness of the impostor
  54518. * @param impostor impostor to get stiffness from
  54519. * @returns pressure value
  54520. */
  54521. getBodyStiffness(impostor: PhysicsImpostor): number;
  54522. /**
  54523. * Sets stiffness of the impostor
  54524. * @param impostor impostor to set stiffness on
  54525. * @param stiffness stiffness value from 0 to 1
  54526. */
  54527. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54528. /**
  54529. * Gets velocityIterations of the impostor
  54530. * @param impostor impostor to get velocity iterations from
  54531. * @returns velocityIterations value
  54532. */
  54533. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54534. /**
  54535. * Sets velocityIterations of the impostor
  54536. * @param impostor impostor to set velocity iterations on
  54537. * @param velocityIterations velocityIterations value
  54538. */
  54539. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54540. /**
  54541. * Gets positionIterations of the impostor
  54542. * @param impostor impostor to get position iterations from
  54543. * @returns positionIterations value
  54544. */
  54545. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54546. /**
  54547. * Sets positionIterations of the impostor
  54548. * @param impostor impostor to set position on
  54549. * @param positionIterations positionIterations value
  54550. */
  54551. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54552. /**
  54553. * Append an anchor to a cloth object
  54554. * @param impostor is the cloth impostor to add anchor to
  54555. * @param otherImpostor is the rigid impostor to anchor to
  54556. * @param width ratio across width from 0 to 1
  54557. * @param height ratio up height from 0 to 1
  54558. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54559. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54560. */
  54561. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54562. /**
  54563. * Append an hook to a rope object
  54564. * @param impostor is the rope impostor to add hook to
  54565. * @param otherImpostor is the rigid impostor to hook to
  54566. * @param length ratio along the rope from 0 to 1
  54567. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54568. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54569. */
  54570. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54571. /**
  54572. * Sleeps the physics body and stops it from being active
  54573. * @param impostor impostor to sleep
  54574. */
  54575. sleepBody(impostor: PhysicsImpostor): void;
  54576. /**
  54577. * Activates the physics body
  54578. * @param impostor impostor to activate
  54579. */
  54580. wakeUpBody(impostor: PhysicsImpostor): void;
  54581. /**
  54582. * Updates the distance parameters of the joint
  54583. * @param joint joint to update
  54584. * @param maxDistance maximum distance of the joint
  54585. * @param minDistance minimum distance of the joint
  54586. */
  54587. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54588. /**
  54589. * Sets a motor on the joint
  54590. * @param joint joint to set motor on
  54591. * @param speed speed of the motor
  54592. * @param maxForce maximum force of the motor
  54593. * @param motorIndex index of the motor
  54594. */
  54595. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54596. /**
  54597. * Sets the motors limit
  54598. * @param joint joint to set limit on
  54599. * @param upperLimit upper limit
  54600. * @param lowerLimit lower limit
  54601. */
  54602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54603. /**
  54604. * Syncs the position and rotation of a mesh with the impostor
  54605. * @param mesh mesh to sync
  54606. * @param impostor impostor to update the mesh with
  54607. */
  54608. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54609. /**
  54610. * Gets the radius of the impostor
  54611. * @param impostor impostor to get radius from
  54612. * @returns the radius
  54613. */
  54614. getRadius(impostor: PhysicsImpostor): number;
  54615. /**
  54616. * Gets the box size of the impostor
  54617. * @param impostor impostor to get box size from
  54618. * @param result the resulting box size
  54619. */
  54620. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54621. /**
  54622. * Disposes of the impostor
  54623. */
  54624. dispose(): void;
  54625. /**
  54626. * Does a raycast in the physics world
  54627. * @param from when should the ray start?
  54628. * @param to when should the ray end?
  54629. * @returns PhysicsRaycastResult
  54630. */
  54631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54632. }
  54633. }
  54634. declare module "babylonjs/Probes/reflectionProbe" {
  54635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54636. import { Vector3 } from "babylonjs/Maths/math.vector";
  54637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54638. import { Nullable } from "babylonjs/types";
  54639. import { Scene } from "babylonjs/scene";
  54640. module "babylonjs/abstractScene" {
  54641. interface AbstractScene {
  54642. /**
  54643. * The list of reflection probes added to the scene
  54644. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54645. */
  54646. reflectionProbes: Array<ReflectionProbe>;
  54647. /**
  54648. * Removes the given reflection probe from this scene.
  54649. * @param toRemove The reflection probe to remove
  54650. * @returns The index of the removed reflection probe
  54651. */
  54652. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54653. /**
  54654. * Adds the given reflection probe to this scene.
  54655. * @param newReflectionProbe The reflection probe to add
  54656. */
  54657. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54658. }
  54659. }
  54660. /**
  54661. * Class used to generate realtime reflection / refraction cube textures
  54662. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54663. */
  54664. export class ReflectionProbe {
  54665. /** defines the name of the probe */
  54666. name: string;
  54667. private _scene;
  54668. private _renderTargetTexture;
  54669. private _projectionMatrix;
  54670. private _viewMatrix;
  54671. private _target;
  54672. private _add;
  54673. private _attachedMesh;
  54674. private _invertYAxis;
  54675. /** Gets or sets probe position (center of the cube map) */
  54676. position: Vector3;
  54677. /**
  54678. * Creates a new reflection probe
  54679. * @param name defines the name of the probe
  54680. * @param size defines the texture resolution (for each face)
  54681. * @param scene defines the hosting scene
  54682. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54683. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54684. */
  54685. constructor(
  54686. /** defines the name of the probe */
  54687. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54688. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54689. samples: number;
  54690. /** Gets or sets the refresh rate to use (on every frame by default) */
  54691. refreshRate: number;
  54692. /**
  54693. * Gets the hosting scene
  54694. * @returns a Scene
  54695. */
  54696. getScene(): Scene;
  54697. /** Gets the internal CubeTexture used to render to */
  54698. readonly cubeTexture: RenderTargetTexture;
  54699. /** Gets the list of meshes to render */
  54700. readonly renderList: Nullable<AbstractMesh[]>;
  54701. /**
  54702. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54703. * @param mesh defines the mesh to attach to
  54704. */
  54705. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54706. /**
  54707. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54708. * @param renderingGroupId The rendering group id corresponding to its index
  54709. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54710. */
  54711. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54712. /**
  54713. * Clean all associated resources
  54714. */
  54715. dispose(): void;
  54716. /**
  54717. * Converts the reflection probe information to a readable string for debug purpose.
  54718. * @param fullDetails Supports for multiple levels of logging within scene loading
  54719. * @returns the human readable reflection probe info
  54720. */
  54721. toString(fullDetails?: boolean): string;
  54722. /**
  54723. * Get the class name of the relfection probe.
  54724. * @returns "ReflectionProbe"
  54725. */
  54726. getClassName(): string;
  54727. /**
  54728. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54729. * @returns The JSON representation of the texture
  54730. */
  54731. serialize(): any;
  54732. /**
  54733. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54734. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54735. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54736. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54737. * @returns The parsed reflection probe if successful
  54738. */
  54739. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54740. }
  54741. }
  54742. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54743. /** @hidden */
  54744. export var _BabylonLoaderRegistered: boolean;
  54745. /**
  54746. * Helps setting up some configuration for the babylon file loader.
  54747. */
  54748. export class BabylonFileLoaderConfiguration {
  54749. /**
  54750. * The loader does not allow injecting custom physix engine into the plugins.
  54751. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54752. * So you could set this variable to your engine import to make it work.
  54753. */
  54754. static LoaderInjectedPhysicsEngine: any;
  54755. }
  54756. }
  54757. declare module "babylonjs/Loading/Plugins/index" {
  54758. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54759. }
  54760. declare module "babylonjs/Loading/index" {
  54761. export * from "babylonjs/Loading/loadingScreen";
  54762. export * from "babylonjs/Loading/Plugins/index";
  54763. export * from "babylonjs/Loading/sceneLoader";
  54764. export * from "babylonjs/Loading/sceneLoaderFlags";
  54765. }
  54766. declare module "babylonjs/Materials/Background/index" {
  54767. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54768. }
  54769. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54770. import { Scene } from "babylonjs/scene";
  54771. import { Color3 } from "babylonjs/Maths/math.color";
  54772. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54774. /**
  54775. * The Physically based simple base material of BJS.
  54776. *
  54777. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54778. * It is used as the base class for both the specGloss and metalRough conventions.
  54779. */
  54780. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54781. /**
  54782. * Number of Simultaneous lights allowed on the material.
  54783. */
  54784. maxSimultaneousLights: number;
  54785. /**
  54786. * If sets to true, disables all the lights affecting the material.
  54787. */
  54788. disableLighting: boolean;
  54789. /**
  54790. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54791. */
  54792. environmentTexture: BaseTexture;
  54793. /**
  54794. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54795. */
  54796. invertNormalMapX: boolean;
  54797. /**
  54798. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54799. */
  54800. invertNormalMapY: boolean;
  54801. /**
  54802. * Normal map used in the model.
  54803. */
  54804. normalTexture: BaseTexture;
  54805. /**
  54806. * Emissivie color used to self-illuminate the model.
  54807. */
  54808. emissiveColor: Color3;
  54809. /**
  54810. * Emissivie texture used to self-illuminate the model.
  54811. */
  54812. emissiveTexture: BaseTexture;
  54813. /**
  54814. * Occlusion Channel Strenght.
  54815. */
  54816. occlusionStrength: number;
  54817. /**
  54818. * Occlusion Texture of the material (adding extra occlusion effects).
  54819. */
  54820. occlusionTexture: BaseTexture;
  54821. /**
  54822. * Defines the alpha limits in alpha test mode.
  54823. */
  54824. alphaCutOff: number;
  54825. /**
  54826. * Gets the current double sided mode.
  54827. */
  54828. /**
  54829. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54830. */
  54831. doubleSided: boolean;
  54832. /**
  54833. * Stores the pre-calculated light information of a mesh in a texture.
  54834. */
  54835. lightmapTexture: BaseTexture;
  54836. /**
  54837. * If true, the light map contains occlusion information instead of lighting info.
  54838. */
  54839. useLightmapAsShadowmap: boolean;
  54840. /**
  54841. * Instantiates a new PBRMaterial instance.
  54842. *
  54843. * @param name The material name
  54844. * @param scene The scene the material will be use in.
  54845. */
  54846. constructor(name: string, scene: Scene);
  54847. getClassName(): string;
  54848. }
  54849. }
  54850. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54851. import { Scene } from "babylonjs/scene";
  54852. import { Color3 } from "babylonjs/Maths/math.color";
  54853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54854. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54855. /**
  54856. * The PBR material of BJS following the metal roughness convention.
  54857. *
  54858. * This fits to the PBR convention in the GLTF definition:
  54859. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54860. */
  54861. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54862. /**
  54863. * The base color has two different interpretations depending on the value of metalness.
  54864. * When the material is a metal, the base color is the specific measured reflectance value
  54865. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54866. * of the material.
  54867. */
  54868. baseColor: Color3;
  54869. /**
  54870. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54871. * well as opacity information in the alpha channel.
  54872. */
  54873. baseTexture: BaseTexture;
  54874. /**
  54875. * Specifies the metallic scalar value of the material.
  54876. * Can also be used to scale the metalness values of the metallic texture.
  54877. */
  54878. metallic: number;
  54879. /**
  54880. * Specifies the roughness scalar value of the material.
  54881. * Can also be used to scale the roughness values of the metallic texture.
  54882. */
  54883. roughness: number;
  54884. /**
  54885. * Texture containing both the metallic value in the B channel and the
  54886. * roughness value in the G channel to keep better precision.
  54887. */
  54888. metallicRoughnessTexture: BaseTexture;
  54889. /**
  54890. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54891. *
  54892. * @param name The material name
  54893. * @param scene The scene the material will be use in.
  54894. */
  54895. constructor(name: string, scene: Scene);
  54896. /**
  54897. * Return the currrent class name of the material.
  54898. */
  54899. getClassName(): string;
  54900. /**
  54901. * Makes a duplicate of the current material.
  54902. * @param name - name to use for the new material.
  54903. */
  54904. clone(name: string): PBRMetallicRoughnessMaterial;
  54905. /**
  54906. * Serialize the material to a parsable JSON object.
  54907. */
  54908. serialize(): any;
  54909. /**
  54910. * Parses a JSON object correponding to the serialize function.
  54911. */
  54912. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54913. }
  54914. }
  54915. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54916. import { Scene } from "babylonjs/scene";
  54917. import { Color3 } from "babylonjs/Maths/math.color";
  54918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54919. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54920. /**
  54921. * The PBR material of BJS following the specular glossiness convention.
  54922. *
  54923. * This fits to the PBR convention in the GLTF definition:
  54924. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54925. */
  54926. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54927. /**
  54928. * Specifies the diffuse color of the material.
  54929. */
  54930. diffuseColor: Color3;
  54931. /**
  54932. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54933. * channel.
  54934. */
  54935. diffuseTexture: BaseTexture;
  54936. /**
  54937. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54938. */
  54939. specularColor: Color3;
  54940. /**
  54941. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54942. */
  54943. glossiness: number;
  54944. /**
  54945. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54946. */
  54947. specularGlossinessTexture: BaseTexture;
  54948. /**
  54949. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54950. *
  54951. * @param name The material name
  54952. * @param scene The scene the material will be use in.
  54953. */
  54954. constructor(name: string, scene: Scene);
  54955. /**
  54956. * Return the currrent class name of the material.
  54957. */
  54958. getClassName(): string;
  54959. /**
  54960. * Makes a duplicate of the current material.
  54961. * @param name - name to use for the new material.
  54962. */
  54963. clone(name: string): PBRSpecularGlossinessMaterial;
  54964. /**
  54965. * Serialize the material to a parsable JSON object.
  54966. */
  54967. serialize(): any;
  54968. /**
  54969. * Parses a JSON object correponding to the serialize function.
  54970. */
  54971. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54972. }
  54973. }
  54974. declare module "babylonjs/Materials/PBR/index" {
  54975. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54976. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54977. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54978. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54979. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54980. }
  54981. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54982. import { Nullable } from "babylonjs/types";
  54983. import { Scene } from "babylonjs/scene";
  54984. import { Matrix } from "babylonjs/Maths/math.vector";
  54985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54986. /**
  54987. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54988. * It can help converting any input color in a desired output one. This can then be used to create effects
  54989. * from sepia, black and white to sixties or futuristic rendering...
  54990. *
  54991. * The only supported format is currently 3dl.
  54992. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54993. */
  54994. export class ColorGradingTexture extends BaseTexture {
  54995. /**
  54996. * The current texture matrix. (will always be identity in color grading texture)
  54997. */
  54998. private _textureMatrix;
  54999. /**
  55000. * The texture URL.
  55001. */
  55002. url: string;
  55003. /**
  55004. * Empty line regex stored for GC.
  55005. */
  55006. private static _noneEmptyLineRegex;
  55007. private _engine;
  55008. /**
  55009. * Instantiates a ColorGradingTexture from the following parameters.
  55010. *
  55011. * @param url The location of the color gradind data (currently only supporting 3dl)
  55012. * @param scene The scene the texture will be used in
  55013. */
  55014. constructor(url: string, scene: Scene);
  55015. /**
  55016. * Returns the texture matrix used in most of the material.
  55017. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55018. */
  55019. getTextureMatrix(): Matrix;
  55020. /**
  55021. * Occurs when the file being loaded is a .3dl LUT file.
  55022. */
  55023. private load3dlTexture;
  55024. /**
  55025. * Starts the loading process of the texture.
  55026. */
  55027. private loadTexture;
  55028. /**
  55029. * Clones the color gradind texture.
  55030. */
  55031. clone(): ColorGradingTexture;
  55032. /**
  55033. * Called during delayed load for textures.
  55034. */
  55035. delayLoad(): void;
  55036. /**
  55037. * Parses a color grading texture serialized by Babylon.
  55038. * @param parsedTexture The texture information being parsedTexture
  55039. * @param scene The scene to load the texture in
  55040. * @param rootUrl The root url of the data assets to load
  55041. * @return A color gradind texture
  55042. */
  55043. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55044. /**
  55045. * Serializes the LUT texture to json format.
  55046. */
  55047. serialize(): any;
  55048. }
  55049. }
  55050. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55051. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55052. import { Scene } from "babylonjs/scene";
  55053. import { Nullable } from "babylonjs/types";
  55054. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55055. /**
  55056. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55057. */
  55058. export class EquiRectangularCubeTexture extends BaseTexture {
  55059. /** The six faces of the cube. */
  55060. private static _FacesMapping;
  55061. private _noMipmap;
  55062. private _onLoad;
  55063. private _onError;
  55064. /** The size of the cubemap. */
  55065. private _size;
  55066. /** The buffer of the image. */
  55067. private _buffer;
  55068. /** The width of the input image. */
  55069. private _width;
  55070. /** The height of the input image. */
  55071. private _height;
  55072. /** The URL to the image. */
  55073. url: string;
  55074. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55075. coordinatesMode: number;
  55076. /**
  55077. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55078. * @param url The location of the image
  55079. * @param scene The scene the texture will be used in
  55080. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55081. * @param noMipmap Forces to not generate the mipmap if true
  55082. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55083. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55084. * @param onLoad — defines a callback called when texture is loaded
  55085. * @param onError — defines a callback called if there is an error
  55086. */
  55087. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55088. /**
  55089. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55090. */
  55091. private loadImage;
  55092. /**
  55093. * Convert the image buffer into a cubemap and create a CubeTexture.
  55094. */
  55095. private loadTexture;
  55096. /**
  55097. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55098. * @param buffer The ArrayBuffer that should be converted.
  55099. * @returns The buffer as Float32Array.
  55100. */
  55101. private getFloat32ArrayFromArrayBuffer;
  55102. /**
  55103. * Get the current class name of the texture useful for serialization or dynamic coding.
  55104. * @returns "EquiRectangularCubeTexture"
  55105. */
  55106. getClassName(): string;
  55107. /**
  55108. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55109. * @returns A clone of the current EquiRectangularCubeTexture.
  55110. */
  55111. clone(): EquiRectangularCubeTexture;
  55112. }
  55113. }
  55114. declare module "babylonjs/Misc/tga" {
  55115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55116. /**
  55117. * Based on jsTGALoader - Javascript loader for TGA file
  55118. * By Vincent Thibault
  55119. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55120. */
  55121. export class TGATools {
  55122. private static _TYPE_INDEXED;
  55123. private static _TYPE_RGB;
  55124. private static _TYPE_GREY;
  55125. private static _TYPE_RLE_INDEXED;
  55126. private static _TYPE_RLE_RGB;
  55127. private static _TYPE_RLE_GREY;
  55128. private static _ORIGIN_MASK;
  55129. private static _ORIGIN_SHIFT;
  55130. private static _ORIGIN_BL;
  55131. private static _ORIGIN_BR;
  55132. private static _ORIGIN_UL;
  55133. private static _ORIGIN_UR;
  55134. /**
  55135. * Gets the header of a TGA file
  55136. * @param data defines the TGA data
  55137. * @returns the header
  55138. */
  55139. static GetTGAHeader(data: Uint8Array): any;
  55140. /**
  55141. * Uploads TGA content to a Babylon Texture
  55142. * @hidden
  55143. */
  55144. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55145. /** @hidden */
  55146. 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;
  55147. /** @hidden */
  55148. 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;
  55149. /** @hidden */
  55150. 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;
  55151. /** @hidden */
  55152. 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;
  55153. /** @hidden */
  55154. 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;
  55155. /** @hidden */
  55156. 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;
  55157. }
  55158. }
  55159. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55160. import { Nullable } from "babylonjs/types";
  55161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55162. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55163. /**
  55164. * Implementation of the TGA Texture Loader.
  55165. * @hidden
  55166. */
  55167. export class _TGATextureLoader implements IInternalTextureLoader {
  55168. /**
  55169. * Defines wether the loader supports cascade loading the different faces.
  55170. */
  55171. readonly supportCascades: boolean;
  55172. /**
  55173. * This returns if the loader support the current file information.
  55174. * @param extension defines the file extension of the file being loaded
  55175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55176. * @param fallback defines the fallback internal texture if any
  55177. * @param isBase64 defines whether the texture is encoded as a base64
  55178. * @param isBuffer defines whether the texture data are stored as a buffer
  55179. * @returns true if the loader can load the specified file
  55180. */
  55181. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55182. /**
  55183. * Transform the url before loading if required.
  55184. * @param rootUrl the url of the texture
  55185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55186. * @returns the transformed texture
  55187. */
  55188. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55189. /**
  55190. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55191. * @param rootUrl the url of the texture
  55192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55193. * @returns the fallback texture
  55194. */
  55195. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55196. /**
  55197. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55198. * @param data contains the texture data
  55199. * @param texture defines the BabylonJS internal texture
  55200. * @param createPolynomials will be true if polynomials have been requested
  55201. * @param onLoad defines the callback to trigger once the texture is ready
  55202. * @param onError defines the callback to trigger in case of error
  55203. */
  55204. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55205. /**
  55206. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55207. * @param data contains the texture data
  55208. * @param texture defines the BabylonJS internal texture
  55209. * @param callback defines the method to call once ready to upload
  55210. */
  55211. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55212. }
  55213. }
  55214. declare module "babylonjs/Misc/basis" {
  55215. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55216. /**
  55217. * Info about the .basis files
  55218. */
  55219. class BasisFileInfo {
  55220. /**
  55221. * If the file has alpha
  55222. */
  55223. hasAlpha: boolean;
  55224. /**
  55225. * Info about each image of the basis file
  55226. */
  55227. images: Array<{
  55228. levels: Array<{
  55229. width: number;
  55230. height: number;
  55231. transcodedPixels: ArrayBufferView;
  55232. }>;
  55233. }>;
  55234. }
  55235. /**
  55236. * Result of transcoding a basis file
  55237. */
  55238. class TranscodeResult {
  55239. /**
  55240. * Info about the .basis file
  55241. */
  55242. fileInfo: BasisFileInfo;
  55243. /**
  55244. * Format to use when loading the file
  55245. */
  55246. format: number;
  55247. }
  55248. /**
  55249. * Configuration options for the Basis transcoder
  55250. */
  55251. export class BasisTranscodeConfiguration {
  55252. /**
  55253. * Supported compression formats used to determine the supported output format of the transcoder
  55254. */
  55255. supportedCompressionFormats?: {
  55256. /**
  55257. * etc1 compression format
  55258. */
  55259. etc1?: boolean;
  55260. /**
  55261. * s3tc compression format
  55262. */
  55263. s3tc?: boolean;
  55264. /**
  55265. * pvrtc compression format
  55266. */
  55267. pvrtc?: boolean;
  55268. /**
  55269. * etc2 compression format
  55270. */
  55271. etc2?: boolean;
  55272. };
  55273. /**
  55274. * If mipmap levels should be loaded for transcoded images (Default: true)
  55275. */
  55276. loadMipmapLevels?: boolean;
  55277. /**
  55278. * Index of a single image to load (Default: all images)
  55279. */
  55280. loadSingleImage?: number;
  55281. }
  55282. /**
  55283. * Used to load .Basis files
  55284. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55285. */
  55286. export class BasisTools {
  55287. private static _IgnoreSupportedFormats;
  55288. /**
  55289. * URL to use when loading the basis transcoder
  55290. */
  55291. static JSModuleURL: string;
  55292. /**
  55293. * URL to use when loading the wasm module for the transcoder
  55294. */
  55295. static WasmModuleURL: string;
  55296. /**
  55297. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55298. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55299. * @returns internal format corresponding to the Basis format
  55300. */
  55301. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55302. private static _WorkerPromise;
  55303. private static _Worker;
  55304. private static _actionId;
  55305. private static _CreateWorkerAsync;
  55306. /**
  55307. * Transcodes a loaded image file to compressed pixel data
  55308. * @param imageData image data to transcode
  55309. * @param config configuration options for the transcoding
  55310. * @returns a promise resulting in the transcoded image
  55311. */
  55312. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55313. /**
  55314. * Loads a texture from the transcode result
  55315. * @param texture texture load to
  55316. * @param transcodeResult the result of transcoding the basis file to load from
  55317. */
  55318. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55319. }
  55320. }
  55321. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55322. import { Nullable } from "babylonjs/types";
  55323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55324. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55325. /**
  55326. * Loader for .basis file format
  55327. */
  55328. export class _BasisTextureLoader implements IInternalTextureLoader {
  55329. /**
  55330. * Defines whether the loader supports cascade loading the different faces.
  55331. */
  55332. readonly supportCascades: boolean;
  55333. /**
  55334. * This returns if the loader support the current file information.
  55335. * @param extension defines the file extension of the file being loaded
  55336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55337. * @param fallback defines the fallback internal texture if any
  55338. * @param isBase64 defines whether the texture is encoded as a base64
  55339. * @param isBuffer defines whether the texture data are stored as a buffer
  55340. * @returns true if the loader can load the specified file
  55341. */
  55342. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55343. /**
  55344. * Transform the url before loading if required.
  55345. * @param rootUrl the url of the texture
  55346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55347. * @returns the transformed texture
  55348. */
  55349. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55350. /**
  55351. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55352. * @param rootUrl the url of the texture
  55353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55354. * @returns the fallback texture
  55355. */
  55356. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55357. /**
  55358. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55359. * @param data contains the texture data
  55360. * @param texture defines the BabylonJS internal texture
  55361. * @param createPolynomials will be true if polynomials have been requested
  55362. * @param onLoad defines the callback to trigger once the texture is ready
  55363. * @param onError defines the callback to trigger in case of error
  55364. */
  55365. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55366. /**
  55367. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55368. * @param data contains the texture data
  55369. * @param texture defines the BabylonJS internal texture
  55370. * @param callback defines the method to call once ready to upload
  55371. */
  55372. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55373. }
  55374. }
  55375. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55376. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55377. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55378. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55379. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55380. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55381. }
  55382. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55383. import { Scene } from "babylonjs/scene";
  55384. import { Texture } from "babylonjs/Materials/Textures/texture";
  55385. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55386. /**
  55387. * 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.
  55388. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55390. */
  55391. export class CustomProceduralTexture extends ProceduralTexture {
  55392. private _animate;
  55393. private _time;
  55394. private _config;
  55395. private _texturePath;
  55396. /**
  55397. * Instantiates a new Custom Procedural Texture.
  55398. * 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.
  55399. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55401. * @param name Define the name of the texture
  55402. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55403. * @param size Define the size of the texture to create
  55404. * @param scene Define the scene the texture belongs to
  55405. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55406. * @param generateMipMaps Define if the texture should creates mip maps or not
  55407. */
  55408. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55409. private _loadJson;
  55410. /**
  55411. * Is the texture ready to be used ? (rendered at least once)
  55412. * @returns true if ready, otherwise, false.
  55413. */
  55414. isReady(): boolean;
  55415. /**
  55416. * Render the texture to its associated render target.
  55417. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55418. */
  55419. render(useCameraPostProcess?: boolean): void;
  55420. /**
  55421. * Update the list of dependant textures samplers in the shader.
  55422. */
  55423. updateTextures(): void;
  55424. /**
  55425. * Update the uniform values of the procedural texture in the shader.
  55426. */
  55427. updateShaderUniforms(): void;
  55428. /**
  55429. * Define if the texture animates or not.
  55430. */
  55431. animate: boolean;
  55432. }
  55433. }
  55434. declare module "babylonjs/Shaders/noise.fragment" {
  55435. /** @hidden */
  55436. export var noisePixelShader: {
  55437. name: string;
  55438. shader: string;
  55439. };
  55440. }
  55441. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55442. import { Nullable } from "babylonjs/types";
  55443. import { Scene } from "babylonjs/scene";
  55444. import { Texture } from "babylonjs/Materials/Textures/texture";
  55445. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55446. import "babylonjs/Shaders/noise.fragment";
  55447. /**
  55448. * Class used to generate noise procedural textures
  55449. */
  55450. export class NoiseProceduralTexture extends ProceduralTexture {
  55451. private _time;
  55452. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55453. brightness: number;
  55454. /** Defines the number of octaves to process */
  55455. octaves: number;
  55456. /** Defines the level of persistence (0.8 by default) */
  55457. persistence: number;
  55458. /** Gets or sets animation speed factor (default is 1) */
  55459. animationSpeedFactor: number;
  55460. /**
  55461. * Creates a new NoiseProceduralTexture
  55462. * @param name defines the name fo the texture
  55463. * @param size defines the size of the texture (default is 256)
  55464. * @param scene defines the hosting scene
  55465. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55466. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55467. */
  55468. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55469. private _updateShaderUniforms;
  55470. protected _getDefines(): string;
  55471. /** Generate the current state of the procedural texture */
  55472. render(useCameraPostProcess?: boolean): void;
  55473. /**
  55474. * Serializes this noise procedural texture
  55475. * @returns a serialized noise procedural texture object
  55476. */
  55477. serialize(): any;
  55478. /**
  55479. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55480. * @param parsedTexture defines parsed texture data
  55481. * @param scene defines the current scene
  55482. * @param rootUrl defines the root URL containing noise procedural texture information
  55483. * @returns a parsed NoiseProceduralTexture
  55484. */
  55485. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55486. }
  55487. }
  55488. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55489. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55490. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55491. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55492. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55493. }
  55494. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55495. import { Nullable } from "babylonjs/types";
  55496. import { Scene } from "babylonjs/scene";
  55497. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55499. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55500. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55501. /**
  55502. * Raw cube texture where the raw buffers are passed in
  55503. */
  55504. export class RawCubeTexture extends CubeTexture {
  55505. /**
  55506. * Creates a cube texture where the raw buffers are passed in.
  55507. * @param scene defines the scene the texture is attached to
  55508. * @param data defines the array of data to use to create each face
  55509. * @param size defines the size of the textures
  55510. * @param format defines the format of the data
  55511. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55512. * @param generateMipMaps defines if the engine should generate the mip levels
  55513. * @param invertY defines if data must be stored with Y axis inverted
  55514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55515. * @param compression defines the compression used (null by default)
  55516. */
  55517. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55518. /**
  55519. * Updates the raw cube texture.
  55520. * @param data defines the data to store
  55521. * @param format defines the data format
  55522. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55523. * @param invertY defines if data must be stored with Y axis inverted
  55524. * @param compression defines the compression used (null by default)
  55525. * @param level defines which level of the texture to update
  55526. */
  55527. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55528. /**
  55529. * Updates a raw cube texture with RGBD encoded data.
  55530. * @param data defines the array of data [mipmap][face] to use to create each face
  55531. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55534. * @returns a promsie that resolves when the operation is complete
  55535. */
  55536. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55537. /**
  55538. * Clones the raw cube texture.
  55539. * @return a new cube texture
  55540. */
  55541. clone(): CubeTexture;
  55542. /** @hidden */
  55543. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55544. }
  55545. }
  55546. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55547. import { Scene } from "babylonjs/scene";
  55548. import { Texture } from "babylonjs/Materials/Textures/texture";
  55549. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55550. /**
  55551. * Class used to store 3D textures containing user data
  55552. */
  55553. export class RawTexture3D extends Texture {
  55554. /** Gets or sets the texture format to use */
  55555. format: number;
  55556. private _engine;
  55557. /**
  55558. * Create a new RawTexture3D
  55559. * @param data defines the data of the texture
  55560. * @param width defines the width of the texture
  55561. * @param height defines the height of the texture
  55562. * @param depth defines the depth of the texture
  55563. * @param format defines the texture format to use
  55564. * @param scene defines the hosting scene
  55565. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55566. * @param invertY defines if texture must be stored with Y axis inverted
  55567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55569. */
  55570. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55571. /** Gets or sets the texture format to use */
  55572. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55573. /**
  55574. * Update the texture with new data
  55575. * @param data defines the data to store in the texture
  55576. */
  55577. update(data: ArrayBufferView): void;
  55578. }
  55579. }
  55580. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55581. import { Scene } from "babylonjs/scene";
  55582. import { Texture } from "babylonjs/Materials/Textures/texture";
  55583. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55584. /**
  55585. * Class used to store 2D array textures containing user data
  55586. */
  55587. export class RawTexture2DArray extends Texture {
  55588. /** Gets or sets the texture format to use */
  55589. format: number;
  55590. private _engine;
  55591. /**
  55592. * Create a new RawTexture2DArray
  55593. * @param data defines the data of the texture
  55594. * @param width defines the width of the texture
  55595. * @param height defines the height of the texture
  55596. * @param depth defines the number of layers of the texture
  55597. * @param format defines the texture format to use
  55598. * @param scene defines the hosting scene
  55599. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55600. * @param invertY defines if texture must be stored with Y axis inverted
  55601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55603. */
  55604. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55605. /** Gets or sets the texture format to use */
  55606. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55607. /**
  55608. * Update the texture with new data
  55609. * @param data defines the data to store in the texture
  55610. */
  55611. update(data: ArrayBufferView): void;
  55612. }
  55613. }
  55614. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55615. import { Scene } from "babylonjs/scene";
  55616. import { Plane } from "babylonjs/Maths/math.plane";
  55617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55618. /**
  55619. * Creates a refraction texture used by refraction channel of the standard material.
  55620. * It is like a mirror but to see through a material.
  55621. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55622. */
  55623. export class RefractionTexture extends RenderTargetTexture {
  55624. /**
  55625. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55626. * 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.
  55627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55628. */
  55629. refractionPlane: Plane;
  55630. /**
  55631. * Define how deep under the surface we should see.
  55632. */
  55633. depth: number;
  55634. /**
  55635. * Creates a refraction texture used by refraction channel of the standard material.
  55636. * It is like a mirror but to see through a material.
  55637. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55638. * @param name Define the texture name
  55639. * @param size Define the size of the underlying texture
  55640. * @param scene Define the scene the refraction belongs to
  55641. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55642. */
  55643. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55644. /**
  55645. * Clone the refraction texture.
  55646. * @returns the cloned texture
  55647. */
  55648. clone(): RefractionTexture;
  55649. /**
  55650. * Serialize the texture to a JSON representation you could use in Parse later on
  55651. * @returns the serialized JSON representation
  55652. */
  55653. serialize(): any;
  55654. }
  55655. }
  55656. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55657. import { Nullable } from "babylonjs/types";
  55658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55659. import { Matrix } from "babylonjs/Maths/math.vector";
  55660. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55661. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55662. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55663. import { Scene } from "babylonjs/scene";
  55664. /**
  55665. * Defines the options related to the creation of an HtmlElementTexture
  55666. */
  55667. export interface IHtmlElementTextureOptions {
  55668. /**
  55669. * Defines wether mip maps should be created or not.
  55670. */
  55671. generateMipMaps?: boolean;
  55672. /**
  55673. * Defines the sampling mode of the texture.
  55674. */
  55675. samplingMode?: number;
  55676. /**
  55677. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55678. */
  55679. engine: Nullable<ThinEngine>;
  55680. /**
  55681. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55682. */
  55683. scene: Nullable<Scene>;
  55684. }
  55685. /**
  55686. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55687. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55688. * is automatically managed.
  55689. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55690. * in your application.
  55691. *
  55692. * As the update is not automatic, you need to call them manually.
  55693. */
  55694. export class HtmlElementTexture extends BaseTexture {
  55695. /**
  55696. * The texture URL.
  55697. */
  55698. element: HTMLVideoElement | HTMLCanvasElement;
  55699. private static readonly DefaultOptions;
  55700. private _textureMatrix;
  55701. private _engine;
  55702. private _isVideo;
  55703. private _generateMipMaps;
  55704. private _samplingMode;
  55705. /**
  55706. * Instantiates a HtmlElementTexture from the following parameters.
  55707. *
  55708. * @param name Defines the name of the texture
  55709. * @param element Defines the video or canvas the texture is filled with
  55710. * @param options Defines the other none mandatory texture creation options
  55711. */
  55712. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55713. private _createInternalTexture;
  55714. /**
  55715. * Returns the texture matrix used in most of the material.
  55716. */
  55717. getTextureMatrix(): Matrix;
  55718. /**
  55719. * Updates the content of the texture.
  55720. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55721. */
  55722. update(invertY?: Nullable<boolean>): void;
  55723. }
  55724. }
  55725. declare module "babylonjs/Materials/Textures/index" {
  55726. export * from "babylonjs/Materials/Textures/baseTexture";
  55727. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55728. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55729. export * from "babylonjs/Materials/Textures/cubeTexture";
  55730. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55731. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55732. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55733. export * from "babylonjs/Materials/Textures/internalTexture";
  55734. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55735. export * from "babylonjs/Materials/Textures/Loaders/index";
  55736. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55737. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55738. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55739. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55740. export * from "babylonjs/Materials/Textures/rawTexture";
  55741. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55742. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55743. export * from "babylonjs/Materials/Textures/refractionTexture";
  55744. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55745. export * from "babylonjs/Materials/Textures/texture";
  55746. export * from "babylonjs/Materials/Textures/videoTexture";
  55747. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55748. }
  55749. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55750. /**
  55751. * Enum used to define the target of a block
  55752. */
  55753. export enum NodeMaterialBlockTargets {
  55754. /** Vertex shader */
  55755. Vertex = 1,
  55756. /** Fragment shader */
  55757. Fragment = 2,
  55758. /** Neutral */
  55759. Neutral = 4,
  55760. /** Vertex and Fragment */
  55761. VertexAndFragment = 3
  55762. }
  55763. }
  55764. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55765. /**
  55766. * Defines the kind of connection point for node based material
  55767. */
  55768. export enum NodeMaterialBlockConnectionPointTypes {
  55769. /** Float */
  55770. Float = 1,
  55771. /** Int */
  55772. Int = 2,
  55773. /** Vector2 */
  55774. Vector2 = 4,
  55775. /** Vector3 */
  55776. Vector3 = 8,
  55777. /** Vector4 */
  55778. Vector4 = 16,
  55779. /** Color3 */
  55780. Color3 = 32,
  55781. /** Color4 */
  55782. Color4 = 64,
  55783. /** Matrix */
  55784. Matrix = 128,
  55785. /** Detect type based on connection */
  55786. AutoDetect = 1024,
  55787. /** Output type that will be defined by input type */
  55788. BasedOnInput = 2048
  55789. }
  55790. }
  55791. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55792. /**
  55793. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55794. */
  55795. export enum NodeMaterialBlockConnectionPointMode {
  55796. /** Value is an uniform */
  55797. Uniform = 0,
  55798. /** Value is a mesh attribute */
  55799. Attribute = 1,
  55800. /** Value is a varying between vertex and fragment shaders */
  55801. Varying = 2,
  55802. /** Mode is undefined */
  55803. Undefined = 3
  55804. }
  55805. }
  55806. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55807. /**
  55808. * Enum used to define system values e.g. values automatically provided by the system
  55809. */
  55810. export enum NodeMaterialSystemValues {
  55811. /** World */
  55812. World = 1,
  55813. /** View */
  55814. View = 2,
  55815. /** Projection */
  55816. Projection = 3,
  55817. /** ViewProjection */
  55818. ViewProjection = 4,
  55819. /** WorldView */
  55820. WorldView = 5,
  55821. /** WorldViewProjection */
  55822. WorldViewProjection = 6,
  55823. /** CameraPosition */
  55824. CameraPosition = 7,
  55825. /** Fog Color */
  55826. FogColor = 8,
  55827. /** Delta time */
  55828. DeltaTime = 9
  55829. }
  55830. }
  55831. declare module "babylonjs/Materials/Node/Enums/index" {
  55832. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55833. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55834. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55835. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55836. }
  55837. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55839. /**
  55840. * Root class for all node material optimizers
  55841. */
  55842. export class NodeMaterialOptimizer {
  55843. /**
  55844. * Function used to optimize a NodeMaterial graph
  55845. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55846. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55847. */
  55848. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55849. }
  55850. }
  55851. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55855. import { Scene } from "babylonjs/scene";
  55856. /**
  55857. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55858. */
  55859. export class TransformBlock extends NodeMaterialBlock {
  55860. /**
  55861. * Defines the value to use to complement W value to transform it to a Vector4
  55862. */
  55863. complementW: number;
  55864. /**
  55865. * Defines the value to use to complement z value to transform it to a Vector4
  55866. */
  55867. complementZ: number;
  55868. /**
  55869. * Creates a new TransformBlock
  55870. * @param name defines the block name
  55871. */
  55872. constructor(name: string);
  55873. /**
  55874. * Gets the current class name
  55875. * @returns the class name
  55876. */
  55877. getClassName(): string;
  55878. /**
  55879. * Gets the vector input
  55880. */
  55881. readonly vector: NodeMaterialConnectionPoint;
  55882. /**
  55883. * Gets the output component
  55884. */
  55885. readonly output: NodeMaterialConnectionPoint;
  55886. /**
  55887. * Gets the matrix transform input
  55888. */
  55889. readonly transform: NodeMaterialConnectionPoint;
  55890. protected _buildBlock(state: NodeMaterialBuildState): this;
  55891. serialize(): any;
  55892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55893. protected _dumpPropertiesCode(): string;
  55894. }
  55895. }
  55896. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55900. /**
  55901. * Block used to output the vertex position
  55902. */
  55903. export class VertexOutputBlock extends NodeMaterialBlock {
  55904. /**
  55905. * Creates a new VertexOutputBlock
  55906. * @param name defines the block name
  55907. */
  55908. constructor(name: string);
  55909. /**
  55910. * Gets the current class name
  55911. * @returns the class name
  55912. */
  55913. getClassName(): string;
  55914. /**
  55915. * Gets the vector input component
  55916. */
  55917. readonly vector: NodeMaterialConnectionPoint;
  55918. protected _buildBlock(state: NodeMaterialBuildState): this;
  55919. }
  55920. }
  55921. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55925. /**
  55926. * Block used to output the final color
  55927. */
  55928. export class FragmentOutputBlock extends NodeMaterialBlock {
  55929. /**
  55930. * Create a new FragmentOutputBlock
  55931. * @param name defines the block name
  55932. */
  55933. constructor(name: string);
  55934. /**
  55935. * Gets the current class name
  55936. * @returns the class name
  55937. */
  55938. getClassName(): string;
  55939. /**
  55940. * Gets the rgba input component
  55941. */
  55942. readonly rgba: NodeMaterialConnectionPoint;
  55943. /**
  55944. * Gets the rgb input component
  55945. */
  55946. readonly rgb: NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the a input component
  55949. */
  55950. readonly a: NodeMaterialConnectionPoint;
  55951. protected _buildBlock(state: NodeMaterialBuildState): this;
  55952. }
  55953. }
  55954. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55960. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55961. import { Effect } from "babylonjs/Materials/effect";
  55962. import { Mesh } from "babylonjs/Meshes/mesh";
  55963. import { Nullable } from "babylonjs/types";
  55964. import { Scene } from "babylonjs/scene";
  55965. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55966. /**
  55967. * Block used to read a reflection texture from a sampler
  55968. */
  55969. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55970. private _define3DName;
  55971. private _defineCubicName;
  55972. private _defineExplicitName;
  55973. private _defineProjectionName;
  55974. private _defineLocalCubicName;
  55975. private _defineSphericalName;
  55976. private _definePlanarName;
  55977. private _defineEquirectangularName;
  55978. private _defineMirroredEquirectangularFixedName;
  55979. private _defineEquirectangularFixedName;
  55980. private _defineSkyboxName;
  55981. private _cubeSamplerName;
  55982. private _2DSamplerName;
  55983. private _positionUVWName;
  55984. private _directionWName;
  55985. private _reflectionCoordsName;
  55986. private _reflection2DCoordsName;
  55987. private _reflectionColorName;
  55988. private _reflectionMatrixName;
  55989. /**
  55990. * Gets or sets the texture associated with the node
  55991. */
  55992. texture: Nullable<BaseTexture>;
  55993. /**
  55994. * Create a new TextureBlock
  55995. * @param name defines the block name
  55996. */
  55997. constructor(name: string);
  55998. /**
  55999. * Gets the current class name
  56000. * @returns the class name
  56001. */
  56002. getClassName(): string;
  56003. /**
  56004. * Gets the world position input component
  56005. */
  56006. readonly position: NodeMaterialConnectionPoint;
  56007. /**
  56008. * Gets the world position input component
  56009. */
  56010. readonly worldPosition: NodeMaterialConnectionPoint;
  56011. /**
  56012. * Gets the world normal input component
  56013. */
  56014. readonly worldNormal: NodeMaterialConnectionPoint;
  56015. /**
  56016. * Gets the world input component
  56017. */
  56018. readonly world: NodeMaterialConnectionPoint;
  56019. /**
  56020. * Gets the camera (or eye) position component
  56021. */
  56022. readonly cameraPosition: NodeMaterialConnectionPoint;
  56023. /**
  56024. * Gets the view input component
  56025. */
  56026. readonly view: NodeMaterialConnectionPoint;
  56027. /**
  56028. * Gets the rgb output component
  56029. */
  56030. readonly rgb: NodeMaterialConnectionPoint;
  56031. /**
  56032. * Gets the r output component
  56033. */
  56034. readonly r: NodeMaterialConnectionPoint;
  56035. /**
  56036. * Gets the g output component
  56037. */
  56038. readonly g: NodeMaterialConnectionPoint;
  56039. /**
  56040. * Gets the b output component
  56041. */
  56042. readonly b: NodeMaterialConnectionPoint;
  56043. autoConfigure(material: NodeMaterial): void;
  56044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56045. isReady(): boolean;
  56046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56047. private _injectVertexCode;
  56048. private _writeOutput;
  56049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56050. protected _dumpPropertiesCode(): string;
  56051. serialize(): any;
  56052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56053. }
  56054. }
  56055. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56057. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56058. import { Scene } from "babylonjs/scene";
  56059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56060. import { Matrix } from "babylonjs/Maths/math.vector";
  56061. import { Mesh } from "babylonjs/Meshes/mesh";
  56062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56063. import { Observable } from "babylonjs/Misc/observable";
  56064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56065. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56066. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56067. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56068. import { Nullable } from "babylonjs/types";
  56069. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56070. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56071. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56072. /**
  56073. * Interface used to configure the node material editor
  56074. */
  56075. export interface INodeMaterialEditorOptions {
  56076. /** Define the URl to load node editor script */
  56077. editorURL?: string;
  56078. }
  56079. /** @hidden */
  56080. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56081. /** BONES */
  56082. NUM_BONE_INFLUENCERS: number;
  56083. BonesPerMesh: number;
  56084. BONETEXTURE: boolean;
  56085. /** MORPH TARGETS */
  56086. MORPHTARGETS: boolean;
  56087. MORPHTARGETS_NORMAL: boolean;
  56088. MORPHTARGETS_TANGENT: boolean;
  56089. MORPHTARGETS_UV: boolean;
  56090. NUM_MORPH_INFLUENCERS: number;
  56091. /** IMAGE PROCESSING */
  56092. IMAGEPROCESSING: boolean;
  56093. VIGNETTE: boolean;
  56094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56095. VIGNETTEBLENDMODEOPAQUE: boolean;
  56096. TONEMAPPING: boolean;
  56097. TONEMAPPING_ACES: boolean;
  56098. CONTRAST: boolean;
  56099. EXPOSURE: boolean;
  56100. COLORCURVES: boolean;
  56101. COLORGRADING: boolean;
  56102. COLORGRADING3D: boolean;
  56103. SAMPLER3DGREENDEPTH: boolean;
  56104. SAMPLER3DBGRMAP: boolean;
  56105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56106. /** MISC. */
  56107. BUMPDIRECTUV: number;
  56108. constructor();
  56109. setValue(name: string, value: boolean): void;
  56110. }
  56111. /**
  56112. * Class used to configure NodeMaterial
  56113. */
  56114. export interface INodeMaterialOptions {
  56115. /**
  56116. * Defines if blocks should emit comments
  56117. */
  56118. emitComments: boolean;
  56119. }
  56120. /**
  56121. * Class used to create a node based material built by assembling shader blocks
  56122. */
  56123. export class NodeMaterial extends PushMaterial {
  56124. private static _BuildIdGenerator;
  56125. private _options;
  56126. private _vertexCompilationState;
  56127. private _fragmentCompilationState;
  56128. private _sharedData;
  56129. private _buildId;
  56130. private _buildWasSuccessful;
  56131. private _cachedWorldViewMatrix;
  56132. private _cachedWorldViewProjectionMatrix;
  56133. private _optimizers;
  56134. private _animationFrame;
  56135. /** Define the URl to load node editor script */
  56136. static EditorURL: string;
  56137. private BJSNODEMATERIALEDITOR;
  56138. /** Get the inspector from bundle or global */
  56139. private _getGlobalNodeMaterialEditor;
  56140. /**
  56141. * 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)
  56142. */
  56143. ignoreAlpha: boolean;
  56144. /**
  56145. * Defines the maximum number of lights that can be used in the material
  56146. */
  56147. maxSimultaneousLights: number;
  56148. /**
  56149. * Observable raised when the material is built
  56150. */
  56151. onBuildObservable: Observable<NodeMaterial>;
  56152. /**
  56153. * Gets or sets the root nodes of the material vertex shader
  56154. */
  56155. _vertexOutputNodes: NodeMaterialBlock[];
  56156. /**
  56157. * Gets or sets the root nodes of the material fragment (pixel) shader
  56158. */
  56159. _fragmentOutputNodes: NodeMaterialBlock[];
  56160. /** Gets or sets options to control the node material overall behavior */
  56161. options: INodeMaterialOptions;
  56162. /**
  56163. * Default configuration related to image processing available in the standard Material.
  56164. */
  56165. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56166. /**
  56167. * Gets the image processing configuration used either in this material.
  56168. */
  56169. /**
  56170. * Sets the Default image processing configuration used either in the this material.
  56171. *
  56172. * If sets to null, the scene one is in use.
  56173. */
  56174. imageProcessingConfiguration: ImageProcessingConfiguration;
  56175. /**
  56176. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56177. */
  56178. attachedBlocks: NodeMaterialBlock[];
  56179. /**
  56180. * Create a new node based material
  56181. * @param name defines the material name
  56182. * @param scene defines the hosting scene
  56183. * @param options defines creation option
  56184. */
  56185. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56186. /**
  56187. * Gets the current class name of the material e.g. "NodeMaterial"
  56188. * @returns the class name
  56189. */
  56190. getClassName(): string;
  56191. /**
  56192. * Keep track of the image processing observer to allow dispose and replace.
  56193. */
  56194. private _imageProcessingObserver;
  56195. /**
  56196. * Attaches a new image processing configuration to the Standard Material.
  56197. * @param configuration
  56198. */
  56199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56200. /**
  56201. * Get a block by its name
  56202. * @param name defines the name of the block to retrieve
  56203. * @returns the required block or null if not found
  56204. */
  56205. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56206. /**
  56207. * Get a block by its name
  56208. * @param predicate defines the predicate used to find the good candidate
  56209. * @returns the required block or null if not found
  56210. */
  56211. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56212. /**
  56213. * Get an input block by its name
  56214. * @param predicate defines the predicate used to find the good candidate
  56215. * @returns the required input block or null if not found
  56216. */
  56217. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56218. /**
  56219. * Gets the list of input blocks attached to this material
  56220. * @returns an array of InputBlocks
  56221. */
  56222. getInputBlocks(): InputBlock[];
  56223. /**
  56224. * Adds a new optimizer to the list of optimizers
  56225. * @param optimizer defines the optimizers to add
  56226. * @returns the current material
  56227. */
  56228. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56229. /**
  56230. * Remove an optimizer from the list of optimizers
  56231. * @param optimizer defines the optimizers to remove
  56232. * @returns the current material
  56233. */
  56234. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56235. /**
  56236. * Add a new block to the list of output nodes
  56237. * @param node defines the node to add
  56238. * @returns the current material
  56239. */
  56240. addOutputNode(node: NodeMaterialBlock): this;
  56241. /**
  56242. * Remove a block from the list of root nodes
  56243. * @param node defines the node to remove
  56244. * @returns the current material
  56245. */
  56246. removeOutputNode(node: NodeMaterialBlock): this;
  56247. private _addVertexOutputNode;
  56248. private _removeVertexOutputNode;
  56249. private _addFragmentOutputNode;
  56250. private _removeFragmentOutputNode;
  56251. /**
  56252. * Specifies if the material will require alpha blending
  56253. * @returns a boolean specifying if alpha blending is needed
  56254. */
  56255. needAlphaBlending(): boolean;
  56256. /**
  56257. * Specifies if this material should be rendered in alpha test mode
  56258. * @returns a boolean specifying if an alpha test is needed.
  56259. */
  56260. needAlphaTesting(): boolean;
  56261. private _initializeBlock;
  56262. private _resetDualBlocks;
  56263. /**
  56264. * Build the material and generates the inner effect
  56265. * @param verbose defines if the build should log activity
  56266. */
  56267. build(verbose?: boolean): void;
  56268. /**
  56269. * Runs an otpimization phase to try to improve the shader code
  56270. */
  56271. optimize(): void;
  56272. private _prepareDefinesForAttributes;
  56273. /**
  56274. * Get if the submesh is ready to be used and all its information available.
  56275. * Child classes can use it to update shaders
  56276. * @param mesh defines the mesh to check
  56277. * @param subMesh defines which submesh to check
  56278. * @param useInstances specifies that instances should be used
  56279. * @returns a boolean indicating that the submesh is ready or not
  56280. */
  56281. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56282. /**
  56283. * Get a string representing the shaders built by the current node graph
  56284. */
  56285. readonly compiledShaders: string;
  56286. /**
  56287. * Binds the world matrix to the material
  56288. * @param world defines the world transformation matrix
  56289. */
  56290. bindOnlyWorldMatrix(world: Matrix): void;
  56291. /**
  56292. * Binds the submesh to this material by preparing the effect and shader to draw
  56293. * @param world defines the world transformation matrix
  56294. * @param mesh defines the mesh containing the submesh
  56295. * @param subMesh defines the submesh to bind the material to
  56296. */
  56297. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56298. /**
  56299. * Gets the active textures from the material
  56300. * @returns an array of textures
  56301. */
  56302. getActiveTextures(): BaseTexture[];
  56303. /**
  56304. * Gets the list of texture blocks
  56305. * @returns an array of texture blocks
  56306. */
  56307. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56308. /**
  56309. * Specifies if the material uses a texture
  56310. * @param texture defines the texture to check against the material
  56311. * @returns a boolean specifying if the material uses the texture
  56312. */
  56313. hasTexture(texture: BaseTexture): boolean;
  56314. /**
  56315. * Disposes the material
  56316. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56317. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56318. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56319. */
  56320. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56321. /** Creates the node editor window. */
  56322. private _createNodeEditor;
  56323. /**
  56324. * Launch the node material editor
  56325. * @param config Define the configuration of the editor
  56326. * @return a promise fulfilled when the node editor is visible
  56327. */
  56328. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56329. /**
  56330. * Clear the current material
  56331. */
  56332. clear(): void;
  56333. /**
  56334. * Clear the current material and set it to a default state
  56335. */
  56336. setToDefault(): void;
  56337. /**
  56338. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56339. * @param url defines the url to load from
  56340. * @returns a promise that will fullfil when the material is fully loaded
  56341. */
  56342. loadAsync(url: string): Promise<void>;
  56343. private _gatherBlocks;
  56344. /**
  56345. * Generate a string containing the code declaration required to create an equivalent of this material
  56346. * @returns a string
  56347. */
  56348. generateCode(): string;
  56349. /**
  56350. * Serializes this material in a JSON representation
  56351. * @returns the serialized material object
  56352. */
  56353. serialize(): any;
  56354. private _restoreConnections;
  56355. /**
  56356. * Clear the current graph and load a new one from a serialization object
  56357. * @param source defines the JSON representation of the material
  56358. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56359. */
  56360. loadFromSerialization(source: any, rootUrl?: string): void;
  56361. /**
  56362. * Creates a node material from parsed material data
  56363. * @param source defines the JSON representation of the material
  56364. * @param scene defines the hosting scene
  56365. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56366. * @returns a new node material
  56367. */
  56368. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56369. /**
  56370. * Creates a new node material set to default basic configuration
  56371. * @param name defines the name of the material
  56372. * @param scene defines the hosting scene
  56373. * @returns a new NodeMaterial
  56374. */
  56375. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56376. }
  56377. }
  56378. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56381. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56384. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56385. import { Effect } from "babylonjs/Materials/effect";
  56386. import { Mesh } from "babylonjs/Meshes/mesh";
  56387. import { Nullable } from "babylonjs/types";
  56388. import { Texture } from "babylonjs/Materials/Textures/texture";
  56389. import { Scene } from "babylonjs/scene";
  56390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56391. /**
  56392. * Block used to read a texture from a sampler
  56393. */
  56394. export class TextureBlock extends NodeMaterialBlock {
  56395. private _defineName;
  56396. private _linearDefineName;
  56397. private _samplerName;
  56398. private _transformedUVName;
  56399. private _textureTransformName;
  56400. private _textureInfoName;
  56401. private _mainUVName;
  56402. private _mainUVDefineName;
  56403. /**
  56404. * Gets or sets the texture associated with the node
  56405. */
  56406. texture: Nullable<Texture>;
  56407. /**
  56408. * Create a new TextureBlock
  56409. * @param name defines the block name
  56410. */
  56411. constructor(name: string);
  56412. /**
  56413. * Gets the current class name
  56414. * @returns the class name
  56415. */
  56416. getClassName(): string;
  56417. /**
  56418. * Gets the uv input component
  56419. */
  56420. readonly uv: NodeMaterialConnectionPoint;
  56421. /**
  56422. * Gets the rgba output component
  56423. */
  56424. readonly rgba: NodeMaterialConnectionPoint;
  56425. /**
  56426. * Gets the rgb output component
  56427. */
  56428. readonly rgb: NodeMaterialConnectionPoint;
  56429. /**
  56430. * Gets the r output component
  56431. */
  56432. readonly r: NodeMaterialConnectionPoint;
  56433. /**
  56434. * Gets the g output component
  56435. */
  56436. readonly g: NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the b output component
  56439. */
  56440. readonly b: NodeMaterialConnectionPoint;
  56441. /**
  56442. * Gets the a output component
  56443. */
  56444. readonly a: NodeMaterialConnectionPoint;
  56445. readonly target: NodeMaterialBlockTargets;
  56446. autoConfigure(material: NodeMaterial): void;
  56447. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56449. isReady(): boolean;
  56450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56451. private readonly _isMixed;
  56452. private _injectVertexCode;
  56453. private _writeOutput;
  56454. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56455. protected _dumpPropertiesCode(): string;
  56456. serialize(): any;
  56457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56458. }
  56459. }
  56460. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56463. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56464. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56465. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56466. import { Scene } from "babylonjs/scene";
  56467. /**
  56468. * Class used to store shared data between 2 NodeMaterialBuildState
  56469. */
  56470. export class NodeMaterialBuildStateSharedData {
  56471. /**
  56472. * Gets the list of emitted varyings
  56473. */
  56474. temps: string[];
  56475. /**
  56476. * Gets the list of emitted varyings
  56477. */
  56478. varyings: string[];
  56479. /**
  56480. * Gets the varying declaration string
  56481. */
  56482. varyingDeclaration: string;
  56483. /**
  56484. * Input blocks
  56485. */
  56486. inputBlocks: InputBlock[];
  56487. /**
  56488. * Input blocks
  56489. */
  56490. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56491. /**
  56492. * Bindable blocks (Blocks that need to set data to the effect)
  56493. */
  56494. bindableBlocks: NodeMaterialBlock[];
  56495. /**
  56496. * List of blocks that can provide a compilation fallback
  56497. */
  56498. blocksWithFallbacks: NodeMaterialBlock[];
  56499. /**
  56500. * List of blocks that can provide a define update
  56501. */
  56502. blocksWithDefines: NodeMaterialBlock[];
  56503. /**
  56504. * List of blocks that can provide a repeatable content
  56505. */
  56506. repeatableContentBlocks: NodeMaterialBlock[];
  56507. /**
  56508. * List of blocks that can provide a dynamic list of uniforms
  56509. */
  56510. dynamicUniformBlocks: NodeMaterialBlock[];
  56511. /**
  56512. * List of blocks that can block the isReady function for the material
  56513. */
  56514. blockingBlocks: NodeMaterialBlock[];
  56515. /**
  56516. * Gets the list of animated inputs
  56517. */
  56518. animatedInputs: InputBlock[];
  56519. /**
  56520. * Build Id used to avoid multiple recompilations
  56521. */
  56522. buildId: number;
  56523. /** List of emitted variables */
  56524. variableNames: {
  56525. [key: string]: number;
  56526. };
  56527. /** List of emitted defines */
  56528. defineNames: {
  56529. [key: string]: number;
  56530. };
  56531. /** Should emit comments? */
  56532. emitComments: boolean;
  56533. /** Emit build activity */
  56534. verbose: boolean;
  56535. /** Gets or sets the hosting scene */
  56536. scene: Scene;
  56537. /**
  56538. * Gets the compilation hints emitted at compilation time
  56539. */
  56540. hints: {
  56541. needWorldViewMatrix: boolean;
  56542. needWorldViewProjectionMatrix: boolean;
  56543. needAlphaBlending: boolean;
  56544. needAlphaTesting: boolean;
  56545. };
  56546. /**
  56547. * List of compilation checks
  56548. */
  56549. checks: {
  56550. emitVertex: boolean;
  56551. emitFragment: boolean;
  56552. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56553. };
  56554. /** Creates a new shared data */
  56555. constructor();
  56556. /**
  56557. * Emits console errors and exceptions if there is a failing check
  56558. */
  56559. emitErrors(): void;
  56560. }
  56561. }
  56562. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56563. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56564. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56565. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56566. /**
  56567. * Class used to store node based material build state
  56568. */
  56569. export class NodeMaterialBuildState {
  56570. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56571. supportUniformBuffers: boolean;
  56572. /**
  56573. * Gets the list of emitted attributes
  56574. */
  56575. attributes: string[];
  56576. /**
  56577. * Gets the list of emitted uniforms
  56578. */
  56579. uniforms: string[];
  56580. /**
  56581. * Gets the list of emitted constants
  56582. */
  56583. constants: string[];
  56584. /**
  56585. * Gets the list of emitted samplers
  56586. */
  56587. samplers: string[];
  56588. /**
  56589. * Gets the list of emitted functions
  56590. */
  56591. functions: {
  56592. [key: string]: string;
  56593. };
  56594. /**
  56595. * Gets the list of emitted extensions
  56596. */
  56597. extensions: {
  56598. [key: string]: string;
  56599. };
  56600. /**
  56601. * Gets the target of the compilation state
  56602. */
  56603. target: NodeMaterialBlockTargets;
  56604. /**
  56605. * Gets the list of emitted counters
  56606. */
  56607. counters: {
  56608. [key: string]: number;
  56609. };
  56610. /**
  56611. * Shared data between multiple NodeMaterialBuildState instances
  56612. */
  56613. sharedData: NodeMaterialBuildStateSharedData;
  56614. /** @hidden */
  56615. _vertexState: NodeMaterialBuildState;
  56616. /** @hidden */
  56617. _attributeDeclaration: string;
  56618. /** @hidden */
  56619. _uniformDeclaration: string;
  56620. /** @hidden */
  56621. _constantDeclaration: string;
  56622. /** @hidden */
  56623. _samplerDeclaration: string;
  56624. /** @hidden */
  56625. _varyingTransfer: string;
  56626. private _repeatableContentAnchorIndex;
  56627. /** @hidden */
  56628. _builtCompilationString: string;
  56629. /**
  56630. * Gets the emitted compilation strings
  56631. */
  56632. compilationString: string;
  56633. /**
  56634. * Finalize the compilation strings
  56635. * @param state defines the current compilation state
  56636. */
  56637. finalize(state: NodeMaterialBuildState): void;
  56638. /** @hidden */
  56639. readonly _repeatableContentAnchor: string;
  56640. /** @hidden */
  56641. _getFreeVariableName(prefix: string): string;
  56642. /** @hidden */
  56643. _getFreeDefineName(prefix: string): string;
  56644. /** @hidden */
  56645. _excludeVariableName(name: string): void;
  56646. /** @hidden */
  56647. _emit2DSampler(name: string): void;
  56648. /** @hidden */
  56649. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56650. /** @hidden */
  56651. _emitExtension(name: string, extension: string): void;
  56652. /** @hidden */
  56653. _emitFunction(name: string, code: string, comments: string): void;
  56654. /** @hidden */
  56655. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56656. replaceStrings?: {
  56657. search: RegExp;
  56658. replace: string;
  56659. }[];
  56660. repeatKey?: string;
  56661. }): string;
  56662. /** @hidden */
  56663. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56664. repeatKey?: string;
  56665. removeAttributes?: boolean;
  56666. removeUniforms?: boolean;
  56667. removeVaryings?: boolean;
  56668. removeIfDef?: boolean;
  56669. replaceStrings?: {
  56670. search: RegExp;
  56671. replace: string;
  56672. }[];
  56673. }, storeKey?: string): void;
  56674. /** @hidden */
  56675. _registerTempVariable(name: string): boolean;
  56676. /** @hidden */
  56677. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56678. /** @hidden */
  56679. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56680. /** @hidden */
  56681. _emitFloat(value: number): string;
  56682. }
  56683. }
  56684. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56685. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56687. import { Nullable } from "babylonjs/types";
  56688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56689. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56690. import { Effect } from "babylonjs/Materials/effect";
  56691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56692. import { Mesh } from "babylonjs/Meshes/mesh";
  56693. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56694. import { Scene } from "babylonjs/scene";
  56695. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56696. /**
  56697. * Defines a block that can be used inside a node based material
  56698. */
  56699. export class NodeMaterialBlock {
  56700. private _buildId;
  56701. private _buildTarget;
  56702. private _target;
  56703. private _isFinalMerger;
  56704. private _isInput;
  56705. protected _isUnique: boolean;
  56706. /** @hidden */
  56707. _codeVariableName: string;
  56708. /** @hidden */
  56709. _inputs: NodeMaterialConnectionPoint[];
  56710. /** @hidden */
  56711. _outputs: NodeMaterialConnectionPoint[];
  56712. /** @hidden */
  56713. _preparationId: number;
  56714. /**
  56715. * Gets or sets the name of the block
  56716. */
  56717. name: string;
  56718. /**
  56719. * Gets or sets the unique id of the node
  56720. */
  56721. uniqueId: number;
  56722. /**
  56723. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56724. */
  56725. readonly isUnique: boolean;
  56726. /**
  56727. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56728. */
  56729. readonly isFinalMerger: boolean;
  56730. /**
  56731. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56732. */
  56733. readonly isInput: boolean;
  56734. /**
  56735. * Gets or sets the build Id
  56736. */
  56737. buildId: number;
  56738. /**
  56739. * Gets or sets the target of the block
  56740. */
  56741. target: NodeMaterialBlockTargets;
  56742. /**
  56743. * Gets the list of input points
  56744. */
  56745. readonly inputs: NodeMaterialConnectionPoint[];
  56746. /** Gets the list of output points */
  56747. readonly outputs: NodeMaterialConnectionPoint[];
  56748. /**
  56749. * Find an input by its name
  56750. * @param name defines the name of the input to look for
  56751. * @returns the input or null if not found
  56752. */
  56753. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56754. /**
  56755. * Find an output by its name
  56756. * @param name defines the name of the outputto look for
  56757. * @returns the output or null if not found
  56758. */
  56759. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56760. /**
  56761. * Creates a new NodeMaterialBlock
  56762. * @param name defines the block name
  56763. * @param target defines the target of that block (Vertex by default)
  56764. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56765. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56766. */
  56767. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56768. /**
  56769. * Initialize the block and prepare the context for build
  56770. * @param state defines the state that will be used for the build
  56771. */
  56772. initialize(state: NodeMaterialBuildState): void;
  56773. /**
  56774. * Bind data to effect. Will only be called for blocks with isBindable === true
  56775. * @param effect defines the effect to bind data to
  56776. * @param nodeMaterial defines the hosting NodeMaterial
  56777. * @param mesh defines the mesh that will be rendered
  56778. */
  56779. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56780. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56781. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56782. protected _writeFloat(value: number): string;
  56783. /**
  56784. * Gets the current class name e.g. "NodeMaterialBlock"
  56785. * @returns the class name
  56786. */
  56787. getClassName(): string;
  56788. /**
  56789. * Register a new input. Must be called inside a block constructor
  56790. * @param name defines the connection point name
  56791. * @param type defines the connection point type
  56792. * @param isOptional defines a boolean indicating that this input can be omitted
  56793. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56794. * @returns the current block
  56795. */
  56796. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56797. /**
  56798. * Register a new output. Must be called inside a block constructor
  56799. * @param name defines the connection point name
  56800. * @param type defines the connection point type
  56801. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56802. * @returns the current block
  56803. */
  56804. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56805. /**
  56806. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56807. * @param forOutput defines an optional connection point to check compatibility with
  56808. * @returns the first available input or null
  56809. */
  56810. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56811. /**
  56812. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56813. * @param forBlock defines an optional block to check compatibility with
  56814. * @returns the first available input or null
  56815. */
  56816. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56817. /**
  56818. * Gets the sibling of the given output
  56819. * @param current defines the current output
  56820. * @returns the next output in the list or null
  56821. */
  56822. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56823. /**
  56824. * Connect current block with another block
  56825. * @param other defines the block to connect with
  56826. * @param options define the various options to help pick the right connections
  56827. * @returns the current block
  56828. */
  56829. connectTo(other: NodeMaterialBlock, options?: {
  56830. input?: string;
  56831. output?: string;
  56832. outputSwizzle?: string;
  56833. }): this | undefined;
  56834. protected _buildBlock(state: NodeMaterialBuildState): void;
  56835. /**
  56836. * Add uniforms, samplers and uniform buffers at compilation time
  56837. * @param state defines the state to update
  56838. * @param nodeMaterial defines the node material requesting the update
  56839. * @param defines defines the material defines to update
  56840. * @param uniformBuffers defines the list of uniform buffer names
  56841. */
  56842. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56843. /**
  56844. * Add potential fallbacks if shader compilation fails
  56845. * @param mesh defines the mesh to be rendered
  56846. * @param fallbacks defines the current prioritized list of fallbacks
  56847. */
  56848. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56849. /**
  56850. * Initialize defines for shader compilation
  56851. * @param mesh defines the mesh to be rendered
  56852. * @param nodeMaterial defines the node material requesting the update
  56853. * @param defines defines the material defines to update
  56854. * @param useInstances specifies that instances should be used
  56855. */
  56856. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56857. /**
  56858. * Update defines for shader compilation
  56859. * @param mesh defines the mesh to be rendered
  56860. * @param nodeMaterial defines the node material requesting the update
  56861. * @param defines defines the material defines to update
  56862. * @param useInstances specifies that instances should be used
  56863. */
  56864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56865. /**
  56866. * Lets the block try to connect some inputs automatically
  56867. * @param material defines the hosting NodeMaterial
  56868. */
  56869. autoConfigure(material: NodeMaterial): void;
  56870. /**
  56871. * Function called when a block is declared as repeatable content generator
  56872. * @param vertexShaderState defines the current compilation state for the vertex shader
  56873. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56874. * @param mesh defines the mesh to be rendered
  56875. * @param defines defines the material defines to update
  56876. */
  56877. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56878. /**
  56879. * Checks if the block is ready
  56880. * @param mesh defines the mesh to be rendered
  56881. * @param nodeMaterial defines the node material requesting the update
  56882. * @param defines defines the material defines to update
  56883. * @param useInstances specifies that instances should be used
  56884. * @returns true if the block is ready
  56885. */
  56886. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56887. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56888. private _processBuild;
  56889. /**
  56890. * Compile the current node and generate the shader code
  56891. * @param state defines the current compilation state (uniforms, samplers, current string)
  56892. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56893. * @returns true if already built
  56894. */
  56895. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56896. protected _inputRename(name: string): string;
  56897. protected _outputRename(name: string): string;
  56898. protected _dumpPropertiesCode(): string;
  56899. /** @hidden */
  56900. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56901. /** @hidden */
  56902. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  56903. /**
  56904. * Clone the current block to a new identical block
  56905. * @param scene defines the hosting scene
  56906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56907. * @returns a copy of the current block
  56908. */
  56909. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56910. /**
  56911. * Serializes this block in a JSON representation
  56912. * @returns the serialized block object
  56913. */
  56914. serialize(): any;
  56915. /** @hidden */
  56916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56917. /**
  56918. * Release resources
  56919. */
  56920. dispose(): void;
  56921. }
  56922. }
  56923. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56924. /**
  56925. * Enum defining the type of animations supported by InputBlock
  56926. */
  56927. export enum AnimatedInputBlockTypes {
  56928. /** No animation */
  56929. None = 0,
  56930. /** Time based animation. Will only work for floats */
  56931. Time = 1
  56932. }
  56933. }
  56934. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56936. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56937. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56938. import { Nullable } from "babylonjs/types";
  56939. import { Effect } from "babylonjs/Materials/effect";
  56940. import { Matrix } from "babylonjs/Maths/math.vector";
  56941. import { Scene } from "babylonjs/scene";
  56942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56944. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56945. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56946. /**
  56947. * Block used to expose an input value
  56948. */
  56949. export class InputBlock extends NodeMaterialBlock {
  56950. private _mode;
  56951. private _associatedVariableName;
  56952. private _storedValue;
  56953. private _valueCallback;
  56954. private _type;
  56955. private _animationType;
  56956. /** Gets or set a value used to limit the range of float values */
  56957. min: number;
  56958. /** Gets or set a value used to limit the range of float values */
  56959. max: number;
  56960. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56961. matrixMode: number;
  56962. /** @hidden */
  56963. _systemValue: Nullable<NodeMaterialSystemValues>;
  56964. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56965. visibleInInspector: boolean;
  56966. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56967. isConstant: boolean;
  56968. /**
  56969. * Gets or sets the connection point type (default is float)
  56970. */
  56971. readonly type: NodeMaterialBlockConnectionPointTypes;
  56972. /**
  56973. * Creates a new InputBlock
  56974. * @param name defines the block name
  56975. * @param target defines the target of that block (Vertex by default)
  56976. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56977. */
  56978. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56979. /**
  56980. * Gets the output component
  56981. */
  56982. readonly output: NodeMaterialConnectionPoint;
  56983. /**
  56984. * Set the source of this connection point to a vertex attribute
  56985. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56986. * @returns the current connection point
  56987. */
  56988. setAsAttribute(attributeName?: string): InputBlock;
  56989. /**
  56990. * Set the source of this connection point to a system value
  56991. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56992. * @returns the current connection point
  56993. */
  56994. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56995. /**
  56996. * Gets or sets the value of that point.
  56997. * Please note that this value will be ignored if valueCallback is defined
  56998. */
  56999. value: any;
  57000. /**
  57001. * Gets or sets a callback used to get the value of that point.
  57002. * Please note that setting this value will force the connection point to ignore the value property
  57003. */
  57004. valueCallback: () => any;
  57005. /**
  57006. * Gets or sets the associated variable name in the shader
  57007. */
  57008. associatedVariableName: string;
  57009. /** Gets or sets the type of animation applied to the input */
  57010. animationType: AnimatedInputBlockTypes;
  57011. /**
  57012. * Gets a boolean indicating that this connection point not defined yet
  57013. */
  57014. readonly isUndefined: boolean;
  57015. /**
  57016. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57017. * In this case the connection point name must be the name of the uniform to use.
  57018. * Can only be set on inputs
  57019. */
  57020. isUniform: boolean;
  57021. /**
  57022. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57023. * In this case the connection point name must be the name of the attribute to use
  57024. * Can only be set on inputs
  57025. */
  57026. isAttribute: boolean;
  57027. /**
  57028. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57029. * Can only be set on exit points
  57030. */
  57031. isVarying: boolean;
  57032. /**
  57033. * Gets a boolean indicating that the current connection point is a system value
  57034. */
  57035. readonly isSystemValue: boolean;
  57036. /**
  57037. * Gets or sets the current well known value or null if not defined as a system value
  57038. */
  57039. systemValue: Nullable<NodeMaterialSystemValues>;
  57040. /**
  57041. * Gets the current class name
  57042. * @returns the class name
  57043. */
  57044. getClassName(): string;
  57045. /**
  57046. * Animate the input if animationType !== None
  57047. * @param scene defines the rendering scene
  57048. */
  57049. animate(scene: Scene): void;
  57050. private _emitDefine;
  57051. initialize(state: NodeMaterialBuildState): void;
  57052. /**
  57053. * Set the input block to its default value (based on its type)
  57054. */
  57055. setDefaultValue(): void;
  57056. private _emitConstant;
  57057. private _emit;
  57058. /** @hidden */
  57059. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57060. /** @hidden */
  57061. _transmit(effect: Effect, scene: Scene): void;
  57062. protected _buildBlock(state: NodeMaterialBuildState): void;
  57063. protected _dumpPropertiesCode(): string;
  57064. serialize(): any;
  57065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57066. }
  57067. }
  57068. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57069. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57070. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57071. import { Nullable } from "babylonjs/types";
  57072. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57073. import { Observable } from "babylonjs/Misc/observable";
  57074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57075. /**
  57076. * Enum used to define the compatibility state between two connection points
  57077. */
  57078. export enum NodeMaterialConnectionPointCompatibilityStates {
  57079. /** Points are compatibles */
  57080. Compatible = 0,
  57081. /** Points are incompatible because of their types */
  57082. TypeIncompatible = 1,
  57083. /** Points are incompatible because of their targets (vertex vs fragment) */
  57084. TargetIncompatible = 2
  57085. }
  57086. /**
  57087. * Defines a connection point for a block
  57088. */
  57089. export class NodeMaterialConnectionPoint {
  57090. /** @hidden */
  57091. _ownerBlock: NodeMaterialBlock;
  57092. /** @hidden */
  57093. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57094. private _endpoints;
  57095. private _associatedVariableName;
  57096. /** @hidden */
  57097. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57098. /** @hidden */
  57099. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57100. private _type;
  57101. /** @hidden */
  57102. _enforceAssociatedVariableName: boolean;
  57103. /**
  57104. * Gets or sets the additional types supported by this connection point
  57105. */
  57106. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57107. /**
  57108. * Gets or sets the additional types excluded by this connection point
  57109. */
  57110. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57111. /**
  57112. * Observable triggered when this point is connected
  57113. */
  57114. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57115. /**
  57116. * Gets or sets the associated variable name in the shader
  57117. */
  57118. associatedVariableName: string;
  57119. /**
  57120. * Gets or sets the connection point type (default is float)
  57121. */
  57122. type: NodeMaterialBlockConnectionPointTypes;
  57123. /**
  57124. * Gets or sets the connection point name
  57125. */
  57126. name: string;
  57127. /**
  57128. * Gets or sets a boolean indicating that this connection point can be omitted
  57129. */
  57130. isOptional: boolean;
  57131. /**
  57132. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57133. */
  57134. define: string;
  57135. /** @hidden */
  57136. _prioritizeVertex: boolean;
  57137. private _target;
  57138. /** Gets or sets the target of that connection point */
  57139. target: NodeMaterialBlockTargets;
  57140. /**
  57141. * Gets a boolean indicating that the current point is connected
  57142. */
  57143. readonly isConnected: boolean;
  57144. /**
  57145. * Gets a boolean indicating that the current point is connected to an input block
  57146. */
  57147. readonly isConnectedToInputBlock: boolean;
  57148. /**
  57149. * Gets a the connected input block (if any)
  57150. */
  57151. readonly connectInputBlock: Nullable<InputBlock>;
  57152. /** Get the other side of the connection (if any) */
  57153. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57154. /** Get the block that owns this connection point */
  57155. readonly ownerBlock: NodeMaterialBlock;
  57156. /** Get the block connected on the other side of this connection (if any) */
  57157. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57158. /** Get the block connected on the endpoints of this connection (if any) */
  57159. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57160. /** Gets the list of connected endpoints */
  57161. readonly endpoints: NodeMaterialConnectionPoint[];
  57162. /** Gets a boolean indicating if that output point is connected to at least one input */
  57163. readonly hasEndpoints: boolean;
  57164. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57165. readonly isConnectedInVertexShader: boolean;
  57166. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57167. readonly isConnectedInFragmentShader: boolean;
  57168. /**
  57169. * Creates a new connection point
  57170. * @param name defines the connection point name
  57171. * @param ownerBlock defines the block hosting this connection point
  57172. */
  57173. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57174. /**
  57175. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57176. * @returns the class name
  57177. */
  57178. getClassName(): string;
  57179. /**
  57180. * Gets a boolean indicating if the current point can be connected to another point
  57181. * @param connectionPoint defines the other connection point
  57182. * @returns a boolean
  57183. */
  57184. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57185. /**
  57186. * Gets a number indicating if the current point can be connected to another point
  57187. * @param connectionPoint defines the other connection point
  57188. * @returns a number defining the compatibility state
  57189. */
  57190. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57191. /**
  57192. * Connect this point to another connection point
  57193. * @param connectionPoint defines the other connection point
  57194. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57195. * @returns the current connection point
  57196. */
  57197. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57198. /**
  57199. * Disconnect this point from one of his endpoint
  57200. * @param endpoint defines the other connection point
  57201. * @returns the current connection point
  57202. */
  57203. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57204. /**
  57205. * Serializes this point in a JSON representation
  57206. * @returns the serialized point object
  57207. */
  57208. serialize(): any;
  57209. /**
  57210. * Release resources
  57211. */
  57212. dispose(): void;
  57213. }
  57214. }
  57215. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57219. import { Mesh } from "babylonjs/Meshes/mesh";
  57220. import { Effect } from "babylonjs/Materials/effect";
  57221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57222. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57223. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57225. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57226. /**
  57227. * Block used to add support for vertex skinning (bones)
  57228. */
  57229. export class BonesBlock extends NodeMaterialBlock {
  57230. /**
  57231. * Creates a new BonesBlock
  57232. * @param name defines the block name
  57233. */
  57234. constructor(name: string);
  57235. /**
  57236. * Initialize the block and prepare the context for build
  57237. * @param state defines the state that will be used for the build
  57238. */
  57239. initialize(state: NodeMaterialBuildState): void;
  57240. /**
  57241. * Gets the current class name
  57242. * @returns the class name
  57243. */
  57244. getClassName(): string;
  57245. /**
  57246. * Gets the matrix indices input component
  57247. */
  57248. readonly matricesIndices: NodeMaterialConnectionPoint;
  57249. /**
  57250. * Gets the matrix weights input component
  57251. */
  57252. readonly matricesWeights: NodeMaterialConnectionPoint;
  57253. /**
  57254. * Gets the extra matrix indices input component
  57255. */
  57256. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the extra matrix weights input component
  57259. */
  57260. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57261. /**
  57262. * Gets the world input component
  57263. */
  57264. readonly world: NodeMaterialConnectionPoint;
  57265. /**
  57266. * Gets the output component
  57267. */
  57268. readonly output: NodeMaterialConnectionPoint;
  57269. autoConfigure(material: NodeMaterial): void;
  57270. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57271. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57273. protected _buildBlock(state: NodeMaterialBuildState): this;
  57274. }
  57275. }
  57276. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57281. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57282. /**
  57283. * Block used to add support for instances
  57284. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57285. */
  57286. export class InstancesBlock extends NodeMaterialBlock {
  57287. /**
  57288. * Creates a new InstancesBlock
  57289. * @param name defines the block name
  57290. */
  57291. constructor(name: string);
  57292. /**
  57293. * Gets the current class name
  57294. * @returns the class name
  57295. */
  57296. getClassName(): string;
  57297. /**
  57298. * Gets the first world row input component
  57299. */
  57300. readonly world0: NodeMaterialConnectionPoint;
  57301. /**
  57302. * Gets the second world row input component
  57303. */
  57304. readonly world1: NodeMaterialConnectionPoint;
  57305. /**
  57306. * Gets the third world row input component
  57307. */
  57308. readonly world2: NodeMaterialConnectionPoint;
  57309. /**
  57310. * Gets the forth world row input component
  57311. */
  57312. readonly world3: NodeMaterialConnectionPoint;
  57313. /**
  57314. * Gets the world input component
  57315. */
  57316. readonly world: NodeMaterialConnectionPoint;
  57317. /**
  57318. * Gets the output component
  57319. */
  57320. readonly output: NodeMaterialConnectionPoint;
  57321. autoConfigure(material: NodeMaterial): void;
  57322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57323. protected _buildBlock(state: NodeMaterialBuildState): this;
  57324. }
  57325. }
  57326. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57332. import { Effect } from "babylonjs/Materials/effect";
  57333. import { Mesh } from "babylonjs/Meshes/mesh";
  57334. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57336. /**
  57337. * Block used to add morph targets support to vertex shader
  57338. */
  57339. export class MorphTargetsBlock extends NodeMaterialBlock {
  57340. private _repeatableContentAnchor;
  57341. private _repeatebleContentGenerated;
  57342. /**
  57343. * Create a new MorphTargetsBlock
  57344. * @param name defines the block name
  57345. */
  57346. constructor(name: string);
  57347. /**
  57348. * Gets the current class name
  57349. * @returns the class name
  57350. */
  57351. getClassName(): string;
  57352. /**
  57353. * Gets the position input component
  57354. */
  57355. readonly position: NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the normal input component
  57358. */
  57359. readonly normal: NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the tangent input component
  57362. */
  57363. readonly tangent: NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the tangent input component
  57366. */
  57367. readonly uv: NodeMaterialConnectionPoint;
  57368. /**
  57369. * Gets the position output component
  57370. */
  57371. readonly positionOutput: NodeMaterialConnectionPoint;
  57372. /**
  57373. * Gets the normal output component
  57374. */
  57375. readonly normalOutput: NodeMaterialConnectionPoint;
  57376. /**
  57377. * Gets the tangent output component
  57378. */
  57379. readonly tangentOutput: NodeMaterialConnectionPoint;
  57380. /**
  57381. * Gets the tangent output component
  57382. */
  57383. readonly uvOutput: NodeMaterialConnectionPoint;
  57384. initialize(state: NodeMaterialBuildState): void;
  57385. autoConfigure(material: NodeMaterial): void;
  57386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57388. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57389. protected _buildBlock(state: NodeMaterialBuildState): this;
  57390. }
  57391. }
  57392. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57396. import { Nullable } from "babylonjs/types";
  57397. import { Scene } from "babylonjs/scene";
  57398. import { Effect } from "babylonjs/Materials/effect";
  57399. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57400. import { Mesh } from "babylonjs/Meshes/mesh";
  57401. import { Light } from "babylonjs/Lights/light";
  57402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57403. /**
  57404. * Block used to get data information from a light
  57405. */
  57406. export class LightInformationBlock extends NodeMaterialBlock {
  57407. private _lightDataUniformName;
  57408. private _lightColorUniformName;
  57409. private _lightTypeDefineName;
  57410. /**
  57411. * Gets or sets the light associated with this block
  57412. */
  57413. light: Nullable<Light>;
  57414. /**
  57415. * Creates a new LightInformationBlock
  57416. * @param name defines the block name
  57417. */
  57418. constructor(name: string);
  57419. /**
  57420. * Gets the current class name
  57421. * @returns the class name
  57422. */
  57423. getClassName(): string;
  57424. /**
  57425. * Gets the world position input component
  57426. */
  57427. readonly worldPosition: NodeMaterialConnectionPoint;
  57428. /**
  57429. * Gets the direction output component
  57430. */
  57431. readonly direction: NodeMaterialConnectionPoint;
  57432. /**
  57433. * Gets the direction output component
  57434. */
  57435. readonly color: NodeMaterialConnectionPoint;
  57436. /**
  57437. * Gets the direction output component
  57438. */
  57439. readonly intensity: NodeMaterialConnectionPoint;
  57440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57442. protected _buildBlock(state: NodeMaterialBuildState): this;
  57443. serialize(): any;
  57444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57445. }
  57446. }
  57447. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57448. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57449. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57450. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57451. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57452. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57453. }
  57454. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57459. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57460. import { Effect } from "babylonjs/Materials/effect";
  57461. import { Mesh } from "babylonjs/Meshes/mesh";
  57462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57463. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57464. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57465. /**
  57466. * Block used to add image processing support to fragment shader
  57467. */
  57468. export class ImageProcessingBlock extends NodeMaterialBlock {
  57469. /**
  57470. * Create a new ImageProcessingBlock
  57471. * @param name defines the block name
  57472. */
  57473. constructor(name: string);
  57474. /**
  57475. * Gets the current class name
  57476. * @returns the class name
  57477. */
  57478. getClassName(): string;
  57479. /**
  57480. * Gets the color input component
  57481. */
  57482. readonly color: NodeMaterialConnectionPoint;
  57483. /**
  57484. * Gets the output component
  57485. */
  57486. readonly output: NodeMaterialConnectionPoint;
  57487. /**
  57488. * Initialize the block and prepare the context for build
  57489. * @param state defines the state that will be used for the build
  57490. */
  57491. initialize(state: NodeMaterialBuildState): void;
  57492. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57495. protected _buildBlock(state: NodeMaterialBuildState): this;
  57496. }
  57497. }
  57498. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57502. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57504. import { Effect } from "babylonjs/Materials/effect";
  57505. import { Mesh } from "babylonjs/Meshes/mesh";
  57506. import { Scene } from "babylonjs/scene";
  57507. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57508. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57509. /**
  57510. * Block used to pertub normals based on a normal map
  57511. */
  57512. export class PerturbNormalBlock extends NodeMaterialBlock {
  57513. private _tangentSpaceParameterName;
  57514. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57515. invertX: boolean;
  57516. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57517. invertY: boolean;
  57518. /**
  57519. * Create a new PerturbNormalBlock
  57520. * @param name defines the block name
  57521. */
  57522. constructor(name: string);
  57523. /**
  57524. * Gets the current class name
  57525. * @returns the class name
  57526. */
  57527. getClassName(): string;
  57528. /**
  57529. * Gets the world position input component
  57530. */
  57531. readonly worldPosition: NodeMaterialConnectionPoint;
  57532. /**
  57533. * Gets the world normal input component
  57534. */
  57535. readonly worldNormal: NodeMaterialConnectionPoint;
  57536. /**
  57537. * Gets the uv input component
  57538. */
  57539. readonly uv: NodeMaterialConnectionPoint;
  57540. /**
  57541. * Gets the normal map color input component
  57542. */
  57543. readonly normalMapColor: NodeMaterialConnectionPoint;
  57544. /**
  57545. * Gets the strength input component
  57546. */
  57547. readonly strength: NodeMaterialConnectionPoint;
  57548. /**
  57549. * Gets the output component
  57550. */
  57551. readonly output: NodeMaterialConnectionPoint;
  57552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57553. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57554. autoConfigure(material: NodeMaterial): void;
  57555. protected _buildBlock(state: NodeMaterialBuildState): this;
  57556. protected _dumpPropertiesCode(): string;
  57557. serialize(): any;
  57558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57559. }
  57560. }
  57561. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57565. /**
  57566. * Block used to discard a pixel if a value is smaller than a cutoff
  57567. */
  57568. export class DiscardBlock extends NodeMaterialBlock {
  57569. /**
  57570. * Create a new DiscardBlock
  57571. * @param name defines the block name
  57572. */
  57573. constructor(name: string);
  57574. /**
  57575. * Gets the current class name
  57576. * @returns the class name
  57577. */
  57578. getClassName(): string;
  57579. /**
  57580. * Gets the color input component
  57581. */
  57582. readonly value: NodeMaterialConnectionPoint;
  57583. /**
  57584. * Gets the cutoff input component
  57585. */
  57586. readonly cutoff: NodeMaterialConnectionPoint;
  57587. protected _buildBlock(state: NodeMaterialBuildState): this;
  57588. }
  57589. }
  57590. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57594. /**
  57595. * Block used to test if the fragment shader is front facing
  57596. */
  57597. export class FrontFacingBlock extends NodeMaterialBlock {
  57598. /**
  57599. * Creates a new FrontFacingBlock
  57600. * @param name defines the block name
  57601. */
  57602. constructor(name: string);
  57603. /**
  57604. * Gets the current class name
  57605. * @returns the class name
  57606. */
  57607. getClassName(): string;
  57608. /**
  57609. * Gets the output component
  57610. */
  57611. readonly output: NodeMaterialConnectionPoint;
  57612. protected _buildBlock(state: NodeMaterialBuildState): this;
  57613. }
  57614. }
  57615. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57616. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57617. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57618. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57619. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57620. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57621. }
  57622. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57625. import { Mesh } from "babylonjs/Meshes/mesh";
  57626. import { Effect } from "babylonjs/Materials/effect";
  57627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57629. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57630. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57631. /**
  57632. * Block used to add support for scene fog
  57633. */
  57634. export class FogBlock extends NodeMaterialBlock {
  57635. private _fogDistanceName;
  57636. private _fogParameters;
  57637. /**
  57638. * Create a new FogBlock
  57639. * @param name defines the block name
  57640. */
  57641. constructor(name: string);
  57642. /**
  57643. * Gets the current class name
  57644. * @returns the class name
  57645. */
  57646. getClassName(): string;
  57647. /**
  57648. * Gets the world position input component
  57649. */
  57650. readonly worldPosition: NodeMaterialConnectionPoint;
  57651. /**
  57652. * Gets the view input component
  57653. */
  57654. readonly view: NodeMaterialConnectionPoint;
  57655. /**
  57656. * Gets the color input component
  57657. */
  57658. readonly input: NodeMaterialConnectionPoint;
  57659. /**
  57660. * Gets the fog color input component
  57661. */
  57662. readonly fogColor: NodeMaterialConnectionPoint;
  57663. /**
  57664. * Gets the output component
  57665. */
  57666. readonly output: NodeMaterialConnectionPoint;
  57667. autoConfigure(material: NodeMaterial): void;
  57668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57670. protected _buildBlock(state: NodeMaterialBuildState): this;
  57671. }
  57672. }
  57673. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57678. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57679. import { Effect } from "babylonjs/Materials/effect";
  57680. import { Mesh } from "babylonjs/Meshes/mesh";
  57681. import { Light } from "babylonjs/Lights/light";
  57682. import { Nullable } from "babylonjs/types";
  57683. import { Scene } from "babylonjs/scene";
  57684. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57685. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57686. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57687. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57688. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57689. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57690. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57691. /**
  57692. * Block used to add light in the fragment shader
  57693. */
  57694. export class LightBlock extends NodeMaterialBlock {
  57695. private _lightId;
  57696. /**
  57697. * Gets or sets the light associated with this block
  57698. */
  57699. light: Nullable<Light>;
  57700. /**
  57701. * Create a new LightBlock
  57702. * @param name defines the block name
  57703. */
  57704. constructor(name: string);
  57705. /**
  57706. * Gets the current class name
  57707. * @returns the class name
  57708. */
  57709. getClassName(): string;
  57710. /**
  57711. * Gets the world position input component
  57712. */
  57713. readonly worldPosition: NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the world normal input component
  57716. */
  57717. readonly worldNormal: NodeMaterialConnectionPoint;
  57718. /**
  57719. * Gets the camera (or eye) position component
  57720. */
  57721. readonly cameraPosition: NodeMaterialConnectionPoint;
  57722. /**
  57723. * Gets the glossiness component
  57724. */
  57725. readonly glossiness: NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the glossinness power component
  57728. */
  57729. readonly glossPower: NodeMaterialConnectionPoint;
  57730. /**
  57731. * Gets the diffuse color component
  57732. */
  57733. readonly diffuseColor: NodeMaterialConnectionPoint;
  57734. /**
  57735. * Gets the specular color component
  57736. */
  57737. readonly specularColor: NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the diffuse output component
  57740. */
  57741. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the specular output component
  57744. */
  57745. readonly specularOutput: NodeMaterialConnectionPoint;
  57746. autoConfigure(material: NodeMaterial): void;
  57747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57748. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57750. private _injectVertexCode;
  57751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57752. serialize(): any;
  57753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57754. }
  57755. }
  57756. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57757. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57758. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57759. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57760. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57761. }
  57762. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57763. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57764. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57765. }
  57766. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57770. /**
  57771. * Block used to multiply 2 values
  57772. */
  57773. export class MultiplyBlock extends NodeMaterialBlock {
  57774. /**
  57775. * Creates a new MultiplyBlock
  57776. * @param name defines the block name
  57777. */
  57778. constructor(name: string);
  57779. /**
  57780. * Gets the current class name
  57781. * @returns the class name
  57782. */
  57783. getClassName(): string;
  57784. /**
  57785. * Gets the left operand input component
  57786. */
  57787. readonly left: NodeMaterialConnectionPoint;
  57788. /**
  57789. * Gets the right operand input component
  57790. */
  57791. readonly right: NodeMaterialConnectionPoint;
  57792. /**
  57793. * Gets the output component
  57794. */
  57795. readonly output: NodeMaterialConnectionPoint;
  57796. protected _buildBlock(state: NodeMaterialBuildState): this;
  57797. }
  57798. }
  57799. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57803. /**
  57804. * Block used to add 2 vectors
  57805. */
  57806. export class AddBlock extends NodeMaterialBlock {
  57807. /**
  57808. * Creates a new AddBlock
  57809. * @param name defines the block name
  57810. */
  57811. constructor(name: string);
  57812. /**
  57813. * Gets the current class name
  57814. * @returns the class name
  57815. */
  57816. getClassName(): string;
  57817. /**
  57818. * Gets the left operand input component
  57819. */
  57820. readonly left: NodeMaterialConnectionPoint;
  57821. /**
  57822. * Gets the right operand input component
  57823. */
  57824. readonly right: NodeMaterialConnectionPoint;
  57825. /**
  57826. * Gets the output component
  57827. */
  57828. readonly output: NodeMaterialConnectionPoint;
  57829. protected _buildBlock(state: NodeMaterialBuildState): this;
  57830. }
  57831. }
  57832. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57836. /**
  57837. * Block used to scale a vector by a float
  57838. */
  57839. export class ScaleBlock extends NodeMaterialBlock {
  57840. /**
  57841. * Creates a new ScaleBlock
  57842. * @param name defines the block name
  57843. */
  57844. constructor(name: string);
  57845. /**
  57846. * Gets the current class name
  57847. * @returns the class name
  57848. */
  57849. getClassName(): string;
  57850. /**
  57851. * Gets the input component
  57852. */
  57853. readonly input: NodeMaterialConnectionPoint;
  57854. /**
  57855. * Gets the factor input component
  57856. */
  57857. readonly factor: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the output component
  57860. */
  57861. readonly output: NodeMaterialConnectionPoint;
  57862. protected _buildBlock(state: NodeMaterialBuildState): this;
  57863. }
  57864. }
  57865. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57869. import { Scene } from "babylonjs/scene";
  57870. /**
  57871. * Block used to clamp a float
  57872. */
  57873. export class ClampBlock extends NodeMaterialBlock {
  57874. /** Gets or sets the minimum range */
  57875. minimum: number;
  57876. /** Gets or sets the maximum range */
  57877. maximum: number;
  57878. /**
  57879. * Creates a new ClampBlock
  57880. * @param name defines the block name
  57881. */
  57882. constructor(name: string);
  57883. /**
  57884. * Gets the current class name
  57885. * @returns the class name
  57886. */
  57887. getClassName(): string;
  57888. /**
  57889. * Gets the value input component
  57890. */
  57891. readonly value: NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the output component
  57894. */
  57895. readonly output: NodeMaterialConnectionPoint;
  57896. protected _buildBlock(state: NodeMaterialBuildState): this;
  57897. protected _dumpPropertiesCode(): string;
  57898. serialize(): any;
  57899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57900. }
  57901. }
  57902. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57906. /**
  57907. * Block used to apply a cross product between 2 vectors
  57908. */
  57909. export class CrossBlock extends NodeMaterialBlock {
  57910. /**
  57911. * Creates a new CrossBlock
  57912. * @param name defines the block name
  57913. */
  57914. constructor(name: string);
  57915. /**
  57916. * Gets the current class name
  57917. * @returns the class name
  57918. */
  57919. getClassName(): string;
  57920. /**
  57921. * Gets the left operand input component
  57922. */
  57923. readonly left: NodeMaterialConnectionPoint;
  57924. /**
  57925. * Gets the right operand input component
  57926. */
  57927. readonly right: NodeMaterialConnectionPoint;
  57928. /**
  57929. * Gets the output component
  57930. */
  57931. readonly output: NodeMaterialConnectionPoint;
  57932. protected _buildBlock(state: NodeMaterialBuildState): this;
  57933. }
  57934. }
  57935. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57939. /**
  57940. * Block used to apply a dot product between 2 vectors
  57941. */
  57942. export class DotBlock extends NodeMaterialBlock {
  57943. /**
  57944. * Creates a new DotBlock
  57945. * @param name defines the block name
  57946. */
  57947. constructor(name: string);
  57948. /**
  57949. * Gets the current class name
  57950. * @returns the class name
  57951. */
  57952. getClassName(): string;
  57953. /**
  57954. * Gets the left operand input component
  57955. */
  57956. readonly left: NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the right operand input component
  57959. */
  57960. readonly right: NodeMaterialConnectionPoint;
  57961. /**
  57962. * Gets the output component
  57963. */
  57964. readonly output: NodeMaterialConnectionPoint;
  57965. protected _buildBlock(state: NodeMaterialBuildState): this;
  57966. }
  57967. }
  57968. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57972. import { Vector2 } from "babylonjs/Maths/math.vector";
  57973. import { Scene } from "babylonjs/scene";
  57974. /**
  57975. * Block used to remap a float from a range to a new one
  57976. */
  57977. export class RemapBlock extends NodeMaterialBlock {
  57978. /**
  57979. * Gets or sets the source range
  57980. */
  57981. sourceRange: Vector2;
  57982. /**
  57983. * Gets or sets the target range
  57984. */
  57985. targetRange: Vector2;
  57986. /**
  57987. * Creates a new RemapBlock
  57988. * @param name defines the block name
  57989. */
  57990. constructor(name: string);
  57991. /**
  57992. * Gets the current class name
  57993. * @returns the class name
  57994. */
  57995. getClassName(): string;
  57996. /**
  57997. * Gets the input component
  57998. */
  57999. readonly input: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the source min input component
  58002. */
  58003. readonly sourceMin: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the source max input component
  58006. */
  58007. readonly sourceMax: NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the target min input component
  58010. */
  58011. readonly targetMin: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the target max input component
  58014. */
  58015. readonly targetMax: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the output component
  58018. */
  58019. readonly output: NodeMaterialConnectionPoint;
  58020. protected _buildBlock(state: NodeMaterialBuildState): this;
  58021. protected _dumpPropertiesCode(): string;
  58022. serialize(): any;
  58023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58024. }
  58025. }
  58026. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58027. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58030. /**
  58031. * Block used to normalize a vector
  58032. */
  58033. export class NormalizeBlock extends NodeMaterialBlock {
  58034. /**
  58035. * Creates a new NormalizeBlock
  58036. * @param name defines the block name
  58037. */
  58038. constructor(name: string);
  58039. /**
  58040. * Gets the current class name
  58041. * @returns the class name
  58042. */
  58043. getClassName(): string;
  58044. /**
  58045. * Gets the input component
  58046. */
  58047. readonly input: NodeMaterialConnectionPoint;
  58048. /**
  58049. * Gets the output component
  58050. */
  58051. readonly output: NodeMaterialConnectionPoint;
  58052. protected _buildBlock(state: NodeMaterialBuildState): this;
  58053. }
  58054. }
  58055. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58059. import { Scene } from "babylonjs/scene";
  58060. /**
  58061. * Operations supported by the Trigonometry block
  58062. */
  58063. export enum TrigonometryBlockOperations {
  58064. /** Cos */
  58065. Cos = 0,
  58066. /** Sin */
  58067. Sin = 1,
  58068. /** Abs */
  58069. Abs = 2,
  58070. /** Exp */
  58071. Exp = 3,
  58072. /** Exp2 */
  58073. Exp2 = 4,
  58074. /** Round */
  58075. Round = 5,
  58076. /** Floor */
  58077. Floor = 6,
  58078. /** Ceiling */
  58079. Ceiling = 7,
  58080. /** Square root */
  58081. Sqrt = 8,
  58082. /** Log */
  58083. Log = 9,
  58084. /** Tangent */
  58085. Tan = 10,
  58086. /** Arc tangent */
  58087. ArcTan = 11,
  58088. /** Arc cosinus */
  58089. ArcCos = 12,
  58090. /** Arc sinus */
  58091. ArcSin = 13,
  58092. /** Fraction */
  58093. Fract = 14,
  58094. /** Sign */
  58095. Sign = 15,
  58096. /** To radians (from degrees) */
  58097. Radians = 16,
  58098. /** To degrees (from radians) */
  58099. Degrees = 17
  58100. }
  58101. /**
  58102. * Block used to apply trigonometry operation to floats
  58103. */
  58104. export class TrigonometryBlock extends NodeMaterialBlock {
  58105. /**
  58106. * Gets or sets the operation applied by the block
  58107. */
  58108. operation: TrigonometryBlockOperations;
  58109. /**
  58110. * Creates a new TrigonometryBlock
  58111. * @param name defines the block name
  58112. */
  58113. constructor(name: string);
  58114. /**
  58115. * Gets the current class name
  58116. * @returns the class name
  58117. */
  58118. getClassName(): string;
  58119. /**
  58120. * Gets the input component
  58121. */
  58122. readonly input: NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the output component
  58125. */
  58126. readonly output: NodeMaterialConnectionPoint;
  58127. protected _buildBlock(state: NodeMaterialBuildState): this;
  58128. serialize(): any;
  58129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58130. }
  58131. }
  58132. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58136. /**
  58137. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58138. */
  58139. export class ColorMergerBlock extends NodeMaterialBlock {
  58140. /**
  58141. * Create a new ColorMergerBlock
  58142. * @param name defines the block name
  58143. */
  58144. constructor(name: string);
  58145. /**
  58146. * Gets the current class name
  58147. * @returns the class name
  58148. */
  58149. getClassName(): string;
  58150. /**
  58151. * Gets the r component (input)
  58152. */
  58153. readonly r: NodeMaterialConnectionPoint;
  58154. /**
  58155. * Gets the g component (input)
  58156. */
  58157. readonly g: NodeMaterialConnectionPoint;
  58158. /**
  58159. * Gets the b component (input)
  58160. */
  58161. readonly b: NodeMaterialConnectionPoint;
  58162. /**
  58163. * Gets the a component (input)
  58164. */
  58165. readonly a: NodeMaterialConnectionPoint;
  58166. /**
  58167. * Gets the rgba component (output)
  58168. */
  58169. readonly rgba: NodeMaterialConnectionPoint;
  58170. /**
  58171. * Gets the rgb component (output)
  58172. */
  58173. readonly rgb: NodeMaterialConnectionPoint;
  58174. protected _buildBlock(state: NodeMaterialBuildState): this;
  58175. }
  58176. }
  58177. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58181. /**
  58182. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58183. */
  58184. export class VectorMergerBlock extends NodeMaterialBlock {
  58185. /**
  58186. * Create a new VectorMergerBlock
  58187. * @param name defines the block name
  58188. */
  58189. constructor(name: string);
  58190. /**
  58191. * Gets the current class name
  58192. * @returns the class name
  58193. */
  58194. getClassName(): string;
  58195. /**
  58196. * Gets the x component (input)
  58197. */
  58198. readonly x: NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the y component (input)
  58201. */
  58202. readonly y: NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the z component (input)
  58205. */
  58206. readonly z: NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the w component (input)
  58209. */
  58210. readonly w: NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the xyzw component (output)
  58213. */
  58214. readonly xyzw: NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the xyz component (output)
  58217. */
  58218. readonly xyz: NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the xy component (output)
  58221. */
  58222. readonly xy: NodeMaterialConnectionPoint;
  58223. protected _buildBlock(state: NodeMaterialBuildState): this;
  58224. }
  58225. }
  58226. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58230. /**
  58231. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58232. */
  58233. export class ColorSplitterBlock extends NodeMaterialBlock {
  58234. /**
  58235. * Create a new ColorSplitterBlock
  58236. * @param name defines the block name
  58237. */
  58238. constructor(name: string);
  58239. /**
  58240. * Gets the current class name
  58241. * @returns the class name
  58242. */
  58243. getClassName(): string;
  58244. /**
  58245. * Gets the rgba component (input)
  58246. */
  58247. readonly rgba: NodeMaterialConnectionPoint;
  58248. /**
  58249. * Gets the rgb component (input)
  58250. */
  58251. readonly rgbIn: NodeMaterialConnectionPoint;
  58252. /**
  58253. * Gets the rgb component (output)
  58254. */
  58255. readonly rgbOut: NodeMaterialConnectionPoint;
  58256. /**
  58257. * Gets the r component (output)
  58258. */
  58259. readonly r: NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the g component (output)
  58262. */
  58263. readonly g: NodeMaterialConnectionPoint;
  58264. /**
  58265. * Gets the b component (output)
  58266. */
  58267. readonly b: NodeMaterialConnectionPoint;
  58268. /**
  58269. * Gets the a component (output)
  58270. */
  58271. readonly a: NodeMaterialConnectionPoint;
  58272. protected _inputRename(name: string): string;
  58273. protected _outputRename(name: string): string;
  58274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58275. }
  58276. }
  58277. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58281. /**
  58282. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58283. */
  58284. export class VectorSplitterBlock extends NodeMaterialBlock {
  58285. /**
  58286. * Create a new VectorSplitterBlock
  58287. * @param name defines the block name
  58288. */
  58289. constructor(name: string);
  58290. /**
  58291. * Gets the current class name
  58292. * @returns the class name
  58293. */
  58294. getClassName(): string;
  58295. /**
  58296. * Gets the xyzw component (input)
  58297. */
  58298. readonly xyzw: NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the xyz component (input)
  58301. */
  58302. readonly xyzIn: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the xy component (input)
  58305. */
  58306. readonly xyIn: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the xyz component (output)
  58309. */
  58310. readonly xyzOut: NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the xy component (output)
  58313. */
  58314. readonly xyOut: NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the x component (output)
  58317. */
  58318. readonly x: NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the y component (output)
  58321. */
  58322. readonly y: NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the z component (output)
  58325. */
  58326. readonly z: NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the w component (output)
  58329. */
  58330. readonly w: NodeMaterialConnectionPoint;
  58331. protected _inputRename(name: string): string;
  58332. protected _outputRename(name: string): string;
  58333. protected _buildBlock(state: NodeMaterialBuildState): this;
  58334. }
  58335. }
  58336. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58340. /**
  58341. * Block used to lerp between 2 values
  58342. */
  58343. export class LerpBlock extends NodeMaterialBlock {
  58344. /**
  58345. * Creates a new LerpBlock
  58346. * @param name defines the block name
  58347. */
  58348. constructor(name: string);
  58349. /**
  58350. * Gets the current class name
  58351. * @returns the class name
  58352. */
  58353. getClassName(): string;
  58354. /**
  58355. * Gets the left operand input component
  58356. */
  58357. readonly left: NodeMaterialConnectionPoint;
  58358. /**
  58359. * Gets the right operand input component
  58360. */
  58361. readonly right: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the gradient operand input component
  58364. */
  58365. readonly gradient: NodeMaterialConnectionPoint;
  58366. /**
  58367. * Gets the output component
  58368. */
  58369. readonly output: NodeMaterialConnectionPoint;
  58370. protected _buildBlock(state: NodeMaterialBuildState): this;
  58371. }
  58372. }
  58373. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58377. /**
  58378. * Block used to divide 2 vectors
  58379. */
  58380. export class DivideBlock extends NodeMaterialBlock {
  58381. /**
  58382. * Creates a new DivideBlock
  58383. * @param name defines the block name
  58384. */
  58385. constructor(name: string);
  58386. /**
  58387. * Gets the current class name
  58388. * @returns the class name
  58389. */
  58390. getClassName(): string;
  58391. /**
  58392. * Gets the left operand input component
  58393. */
  58394. readonly left: NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the right operand input component
  58397. */
  58398. readonly right: NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the output component
  58401. */
  58402. readonly output: NodeMaterialConnectionPoint;
  58403. protected _buildBlock(state: NodeMaterialBuildState): this;
  58404. }
  58405. }
  58406. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58410. /**
  58411. * Block used to subtract 2 vectors
  58412. */
  58413. export class SubtractBlock extends NodeMaterialBlock {
  58414. /**
  58415. * Creates a new SubtractBlock
  58416. * @param name defines the block name
  58417. */
  58418. constructor(name: string);
  58419. /**
  58420. * Gets the current class name
  58421. * @returns the class name
  58422. */
  58423. getClassName(): string;
  58424. /**
  58425. * Gets the left operand input component
  58426. */
  58427. readonly left: NodeMaterialConnectionPoint;
  58428. /**
  58429. * Gets the right operand input component
  58430. */
  58431. readonly right: NodeMaterialConnectionPoint;
  58432. /**
  58433. * Gets the output component
  58434. */
  58435. readonly output: NodeMaterialConnectionPoint;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this;
  58437. }
  58438. }
  58439. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58443. /**
  58444. * Block used to step a value
  58445. */
  58446. export class StepBlock extends NodeMaterialBlock {
  58447. /**
  58448. * Creates a new StepBlock
  58449. * @param name defines the block name
  58450. */
  58451. constructor(name: string);
  58452. /**
  58453. * Gets the current class name
  58454. * @returns the class name
  58455. */
  58456. getClassName(): string;
  58457. /**
  58458. * Gets the value operand input component
  58459. */
  58460. readonly value: NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the edge operand input component
  58463. */
  58464. readonly edge: NodeMaterialConnectionPoint;
  58465. /**
  58466. * Gets the output component
  58467. */
  58468. readonly output: NodeMaterialConnectionPoint;
  58469. protected _buildBlock(state: NodeMaterialBuildState): this;
  58470. }
  58471. }
  58472. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58476. /**
  58477. * Block used to get the opposite (1 - x) of a value
  58478. */
  58479. export class OneMinusBlock extends NodeMaterialBlock {
  58480. /**
  58481. * Creates a new OneMinusBlock
  58482. * @param name defines the block name
  58483. */
  58484. constructor(name: string);
  58485. /**
  58486. * Gets the current class name
  58487. * @returns the class name
  58488. */
  58489. getClassName(): string;
  58490. /**
  58491. * Gets the input component
  58492. */
  58493. readonly input: NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the output component
  58496. */
  58497. readonly output: NodeMaterialConnectionPoint;
  58498. protected _buildBlock(state: NodeMaterialBuildState): this;
  58499. }
  58500. }
  58501. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58503. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58505. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58506. /**
  58507. * Block used to get the view direction
  58508. */
  58509. export class ViewDirectionBlock extends NodeMaterialBlock {
  58510. /**
  58511. * Creates a new ViewDirectionBlock
  58512. * @param name defines the block name
  58513. */
  58514. constructor(name: string);
  58515. /**
  58516. * Gets the current class name
  58517. * @returns the class name
  58518. */
  58519. getClassName(): string;
  58520. /**
  58521. * Gets the world position component
  58522. */
  58523. readonly worldPosition: NodeMaterialConnectionPoint;
  58524. /**
  58525. * Gets the camera position component
  58526. */
  58527. readonly cameraPosition: NodeMaterialConnectionPoint;
  58528. /**
  58529. * Gets the output component
  58530. */
  58531. readonly output: NodeMaterialConnectionPoint;
  58532. autoConfigure(material: NodeMaterial): void;
  58533. protected _buildBlock(state: NodeMaterialBuildState): this;
  58534. }
  58535. }
  58536. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58540. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58541. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58542. /**
  58543. * Block used to compute fresnel value
  58544. */
  58545. export class FresnelBlock extends NodeMaterialBlock {
  58546. /**
  58547. * Create a new FresnelBlock
  58548. * @param name defines the block name
  58549. */
  58550. constructor(name: string);
  58551. /**
  58552. * Gets the current class name
  58553. * @returns the class name
  58554. */
  58555. getClassName(): string;
  58556. /**
  58557. * Gets the world normal input component
  58558. */
  58559. readonly worldNormal: NodeMaterialConnectionPoint;
  58560. /**
  58561. * Gets the view direction input component
  58562. */
  58563. readonly viewDirection: NodeMaterialConnectionPoint;
  58564. /**
  58565. * Gets the bias input component
  58566. */
  58567. readonly bias: NodeMaterialConnectionPoint;
  58568. /**
  58569. * Gets the camera (or eye) position component
  58570. */
  58571. readonly power: NodeMaterialConnectionPoint;
  58572. /**
  58573. * Gets the fresnel output component
  58574. */
  58575. readonly fresnel: NodeMaterialConnectionPoint;
  58576. autoConfigure(material: NodeMaterial): void;
  58577. protected _buildBlock(state: NodeMaterialBuildState): this;
  58578. }
  58579. }
  58580. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58584. /**
  58585. * Block used to get the max of 2 values
  58586. */
  58587. export class MaxBlock extends NodeMaterialBlock {
  58588. /**
  58589. * Creates a new MaxBlock
  58590. * @param name defines the block name
  58591. */
  58592. constructor(name: string);
  58593. /**
  58594. * Gets the current class name
  58595. * @returns the class name
  58596. */
  58597. getClassName(): string;
  58598. /**
  58599. * Gets the left operand input component
  58600. */
  58601. readonly left: NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the right operand input component
  58604. */
  58605. readonly right: NodeMaterialConnectionPoint;
  58606. /**
  58607. * Gets the output component
  58608. */
  58609. readonly output: NodeMaterialConnectionPoint;
  58610. protected _buildBlock(state: NodeMaterialBuildState): this;
  58611. }
  58612. }
  58613. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58617. /**
  58618. * Block used to get the min of 2 values
  58619. */
  58620. export class MinBlock extends NodeMaterialBlock {
  58621. /**
  58622. * Creates a new MinBlock
  58623. * @param name defines the block name
  58624. */
  58625. constructor(name: string);
  58626. /**
  58627. * Gets the current class name
  58628. * @returns the class name
  58629. */
  58630. getClassName(): string;
  58631. /**
  58632. * Gets the left operand input component
  58633. */
  58634. readonly left: NodeMaterialConnectionPoint;
  58635. /**
  58636. * Gets the right operand input component
  58637. */
  58638. readonly right: NodeMaterialConnectionPoint;
  58639. /**
  58640. * Gets the output component
  58641. */
  58642. readonly output: NodeMaterialConnectionPoint;
  58643. protected _buildBlock(state: NodeMaterialBuildState): this;
  58644. }
  58645. }
  58646. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58650. /**
  58651. * Block used to get the distance between 2 values
  58652. */
  58653. export class DistanceBlock extends NodeMaterialBlock {
  58654. /**
  58655. * Creates a new DistanceBlock
  58656. * @param name defines the block name
  58657. */
  58658. constructor(name: string);
  58659. /**
  58660. * Gets the current class name
  58661. * @returns the class name
  58662. */
  58663. getClassName(): string;
  58664. /**
  58665. * Gets the left operand input component
  58666. */
  58667. readonly left: NodeMaterialConnectionPoint;
  58668. /**
  58669. * Gets the right operand input component
  58670. */
  58671. readonly right: NodeMaterialConnectionPoint;
  58672. /**
  58673. * Gets the output component
  58674. */
  58675. readonly output: NodeMaterialConnectionPoint;
  58676. protected _buildBlock(state: NodeMaterialBuildState): this;
  58677. }
  58678. }
  58679. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58683. /**
  58684. * Block used to get the length of a vector
  58685. */
  58686. export class LengthBlock extends NodeMaterialBlock {
  58687. /**
  58688. * Creates a new LengthBlock
  58689. * @param name defines the block name
  58690. */
  58691. constructor(name: string);
  58692. /**
  58693. * Gets the current class name
  58694. * @returns the class name
  58695. */
  58696. getClassName(): string;
  58697. /**
  58698. * Gets the value input component
  58699. */
  58700. readonly value: NodeMaterialConnectionPoint;
  58701. /**
  58702. * Gets the output component
  58703. */
  58704. readonly output: NodeMaterialConnectionPoint;
  58705. protected _buildBlock(state: NodeMaterialBuildState): this;
  58706. }
  58707. }
  58708. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58712. /**
  58713. * Block used to get negative version of a value (i.e. x * -1)
  58714. */
  58715. export class NegateBlock extends NodeMaterialBlock {
  58716. /**
  58717. * Creates a new NegateBlock
  58718. * @param name defines the block name
  58719. */
  58720. constructor(name: string);
  58721. /**
  58722. * Gets the current class name
  58723. * @returns the class name
  58724. */
  58725. getClassName(): string;
  58726. /**
  58727. * Gets the value input component
  58728. */
  58729. readonly value: NodeMaterialConnectionPoint;
  58730. /**
  58731. * Gets the output component
  58732. */
  58733. readonly output: NodeMaterialConnectionPoint;
  58734. protected _buildBlock(state: NodeMaterialBuildState): this;
  58735. }
  58736. }
  58737. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58741. /**
  58742. * Block used to get the value of the first parameter raised to the power of the second
  58743. */
  58744. export class PowBlock extends NodeMaterialBlock {
  58745. /**
  58746. * Creates a new PowBlock
  58747. * @param name defines the block name
  58748. */
  58749. constructor(name: string);
  58750. /**
  58751. * Gets the current class name
  58752. * @returns the class name
  58753. */
  58754. getClassName(): string;
  58755. /**
  58756. * Gets the value operand input component
  58757. */
  58758. readonly value: NodeMaterialConnectionPoint;
  58759. /**
  58760. * Gets the power operand input component
  58761. */
  58762. readonly power: NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the output component
  58765. */
  58766. readonly output: NodeMaterialConnectionPoint;
  58767. protected _buildBlock(state: NodeMaterialBuildState): this;
  58768. }
  58769. }
  58770. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58775. /**
  58776. * Block used to get a random number
  58777. */
  58778. export class RandomNumberBlock extends NodeMaterialBlock {
  58779. /**
  58780. * Creates a new RandomNumberBlock
  58781. * @param name defines the block name
  58782. */
  58783. constructor(name: string);
  58784. /**
  58785. * Gets the current class name
  58786. * @returns the class name
  58787. */
  58788. getClassName(): string;
  58789. /**
  58790. * Gets the seed input component
  58791. */
  58792. readonly seed: NodeMaterialConnectionPoint;
  58793. /**
  58794. * Gets the output component
  58795. */
  58796. readonly output: NodeMaterialConnectionPoint;
  58797. protected _buildBlock(state: NodeMaterialBuildState): this;
  58798. }
  58799. }
  58800. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58804. /**
  58805. * Block used to compute arc tangent of 2 values
  58806. */
  58807. export class ArcTan2Block extends NodeMaterialBlock {
  58808. /**
  58809. * Creates a new ArcTan2Block
  58810. * @param name defines the block name
  58811. */
  58812. constructor(name: string);
  58813. /**
  58814. * Gets the current class name
  58815. * @returns the class name
  58816. */
  58817. getClassName(): string;
  58818. /**
  58819. * Gets the x operand input component
  58820. */
  58821. readonly x: NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the y operand input component
  58824. */
  58825. readonly y: NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the output component
  58828. */
  58829. readonly output: NodeMaterialConnectionPoint;
  58830. protected _buildBlock(state: NodeMaterialBuildState): this;
  58831. }
  58832. }
  58833. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58837. /**
  58838. * Block used to smooth step a value
  58839. */
  58840. export class SmoothStepBlock extends NodeMaterialBlock {
  58841. /**
  58842. * Creates a new SmoothStepBlock
  58843. * @param name defines the block name
  58844. */
  58845. constructor(name: string);
  58846. /**
  58847. * Gets the current class name
  58848. * @returns the class name
  58849. */
  58850. getClassName(): string;
  58851. /**
  58852. * Gets the value operand input component
  58853. */
  58854. readonly value: NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the first edge operand input component
  58857. */
  58858. readonly edge0: NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the second edge operand input component
  58861. */
  58862. readonly edge1: NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the output component
  58865. */
  58866. readonly output: NodeMaterialConnectionPoint;
  58867. protected _buildBlock(state: NodeMaterialBuildState): this;
  58868. }
  58869. }
  58870. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58874. /**
  58875. * Block used to get the reciprocal (1 / x) of a value
  58876. */
  58877. export class ReciprocalBlock extends NodeMaterialBlock {
  58878. /**
  58879. * Creates a new ReciprocalBlock
  58880. * @param name defines the block name
  58881. */
  58882. constructor(name: string);
  58883. /**
  58884. * Gets the current class name
  58885. * @returns the class name
  58886. */
  58887. getClassName(): string;
  58888. /**
  58889. * Gets the input component
  58890. */
  58891. readonly input: NodeMaterialConnectionPoint;
  58892. /**
  58893. * Gets the output component
  58894. */
  58895. readonly output: NodeMaterialConnectionPoint;
  58896. protected _buildBlock(state: NodeMaterialBuildState): this;
  58897. }
  58898. }
  58899. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58903. /**
  58904. * Block used to replace a color by another one
  58905. */
  58906. export class ReplaceColorBlock extends NodeMaterialBlock {
  58907. /**
  58908. * Creates a new ReplaceColorBlock
  58909. * @param name defines the block name
  58910. */
  58911. constructor(name: string);
  58912. /**
  58913. * Gets the current class name
  58914. * @returns the class name
  58915. */
  58916. getClassName(): string;
  58917. /**
  58918. * Gets the value input component
  58919. */
  58920. readonly value: NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the reference input component
  58923. */
  58924. readonly reference: NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the distance input component
  58927. */
  58928. readonly distance: NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the replacement input component
  58931. */
  58932. readonly replacement: NodeMaterialConnectionPoint;
  58933. /**
  58934. * Gets the output component
  58935. */
  58936. readonly output: NodeMaterialConnectionPoint;
  58937. protected _buildBlock(state: NodeMaterialBuildState): this;
  58938. }
  58939. }
  58940. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58944. /**
  58945. * Block used to posterize a value
  58946. * @see https://en.wikipedia.org/wiki/Posterization
  58947. */
  58948. export class PosterizeBlock extends NodeMaterialBlock {
  58949. /**
  58950. * Creates a new PosterizeBlock
  58951. * @param name defines the block name
  58952. */
  58953. constructor(name: string);
  58954. /**
  58955. * Gets the current class name
  58956. * @returns the class name
  58957. */
  58958. getClassName(): string;
  58959. /**
  58960. * Gets the value input component
  58961. */
  58962. readonly value: NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the steps input component
  58965. */
  58966. readonly steps: NodeMaterialConnectionPoint;
  58967. /**
  58968. * Gets the output component
  58969. */
  58970. readonly output: NodeMaterialConnectionPoint;
  58971. protected _buildBlock(state: NodeMaterialBuildState): this;
  58972. }
  58973. }
  58974. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58978. import { Scene } from "babylonjs/scene";
  58979. /**
  58980. * Operations supported by the Wave block
  58981. */
  58982. export enum WaveBlockKind {
  58983. /** SawTooth */
  58984. SawTooth = 0,
  58985. /** Square */
  58986. Square = 1,
  58987. /** Triangle */
  58988. Triangle = 2
  58989. }
  58990. /**
  58991. * Block used to apply wave operation to floats
  58992. */
  58993. export class WaveBlock extends NodeMaterialBlock {
  58994. /**
  58995. * Gets or sets the kibnd of wave to be applied by the block
  58996. */
  58997. kind: WaveBlockKind;
  58998. /**
  58999. * Creates a new WaveBlock
  59000. * @param name defines the block name
  59001. */
  59002. constructor(name: string);
  59003. /**
  59004. * Gets the current class name
  59005. * @returns the class name
  59006. */
  59007. getClassName(): string;
  59008. /**
  59009. * Gets the input component
  59010. */
  59011. readonly input: NodeMaterialConnectionPoint;
  59012. /**
  59013. * Gets the output component
  59014. */
  59015. readonly output: NodeMaterialConnectionPoint;
  59016. protected _buildBlock(state: NodeMaterialBuildState): this;
  59017. serialize(): any;
  59018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59019. }
  59020. }
  59021. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59025. import { Color3 } from "babylonjs/Maths/math.color";
  59026. import { Scene } from "babylonjs/scene";
  59027. /**
  59028. * Class used to store a color step for the GradientBlock
  59029. */
  59030. export class GradientBlockColorStep {
  59031. /**
  59032. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59033. */
  59034. step: number;
  59035. /**
  59036. * Gets or sets the color associated with this step
  59037. */
  59038. color: Color3;
  59039. /**
  59040. * Creates a new GradientBlockColorStep
  59041. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59042. * @param color defines the color associated with this step
  59043. */
  59044. constructor(
  59045. /**
  59046. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59047. */
  59048. step: number,
  59049. /**
  59050. * Gets or sets the color associated with this step
  59051. */
  59052. color: Color3);
  59053. }
  59054. /**
  59055. * Block used to return a color from a gradient based on an input value between 0 and 1
  59056. */
  59057. export class GradientBlock extends NodeMaterialBlock {
  59058. /**
  59059. * Gets or sets the list of color steps
  59060. */
  59061. colorSteps: GradientBlockColorStep[];
  59062. /**
  59063. * Creates a new GradientBlock
  59064. * @param name defines the block name
  59065. */
  59066. constructor(name: string);
  59067. /**
  59068. * Gets the current class name
  59069. * @returns the class name
  59070. */
  59071. getClassName(): string;
  59072. /**
  59073. * Gets the gradient input component
  59074. */
  59075. readonly gradient: NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the output component
  59078. */
  59079. readonly output: NodeMaterialConnectionPoint;
  59080. private _writeColorConstant;
  59081. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59082. serialize(): any;
  59083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59084. protected _dumpPropertiesCode(): string;
  59085. }
  59086. }
  59087. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59091. /**
  59092. * Block used to normalize lerp between 2 values
  59093. */
  59094. export class NLerpBlock extends NodeMaterialBlock {
  59095. /**
  59096. * Creates a new NLerpBlock
  59097. * @param name defines the block name
  59098. */
  59099. constructor(name: string);
  59100. /**
  59101. * Gets the current class name
  59102. * @returns the class name
  59103. */
  59104. getClassName(): string;
  59105. /**
  59106. * Gets the left operand input component
  59107. */
  59108. readonly left: NodeMaterialConnectionPoint;
  59109. /**
  59110. * Gets the right operand input component
  59111. */
  59112. readonly right: NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the gradient operand input component
  59115. */
  59116. readonly gradient: NodeMaterialConnectionPoint;
  59117. /**
  59118. * Gets the output component
  59119. */
  59120. readonly output: NodeMaterialConnectionPoint;
  59121. protected _buildBlock(state: NodeMaterialBuildState): this;
  59122. }
  59123. }
  59124. declare module "babylonjs/Materials/Node/Blocks/index" {
  59125. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59126. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59127. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59128. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59129. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59130. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59131. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59132. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59133. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59134. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59135. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59136. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59137. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59138. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59139. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59140. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59141. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59142. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59143. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59144. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59145. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59146. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59147. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59148. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59149. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59150. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59151. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59152. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59153. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59154. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59155. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59156. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59157. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59158. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59159. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59160. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59161. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59162. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59163. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59164. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59165. }
  59166. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59167. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59168. }
  59169. declare module "babylonjs/Materials/Node/index" {
  59170. export * from "babylonjs/Materials/Node/Enums/index";
  59171. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59172. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59173. export * from "babylonjs/Materials/Node/nodeMaterial";
  59174. export * from "babylonjs/Materials/Node/Blocks/index";
  59175. export * from "babylonjs/Materials/Node/Optimizers/index";
  59176. }
  59177. declare module "babylonjs/Materials/effectRenderer" {
  59178. import { Nullable } from "babylonjs/types";
  59179. import { Texture } from "babylonjs/Materials/Textures/texture";
  59180. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59181. import { Viewport } from "babylonjs/Maths/math.viewport";
  59182. import { Observable } from "babylonjs/Misc/observable";
  59183. import { Effect } from "babylonjs/Materials/effect";
  59184. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59185. import "babylonjs/Shaders/postprocess.vertex";
  59186. /**
  59187. * Effect Render Options
  59188. */
  59189. export interface IEffectRendererOptions {
  59190. /**
  59191. * Defines the vertices positions.
  59192. */
  59193. positions?: number[];
  59194. /**
  59195. * Defines the indices.
  59196. */
  59197. indices?: number[];
  59198. }
  59199. /**
  59200. * Helper class to render one or more effects
  59201. */
  59202. export class EffectRenderer {
  59203. private engine;
  59204. private static _DefaultOptions;
  59205. private _vertexBuffers;
  59206. private _indexBuffer;
  59207. private _ringBufferIndex;
  59208. private _ringScreenBuffer;
  59209. private _fullscreenViewport;
  59210. private _getNextFrameBuffer;
  59211. /**
  59212. * Creates an effect renderer
  59213. * @param engine the engine to use for rendering
  59214. * @param options defines the options of the effect renderer
  59215. */
  59216. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59217. /**
  59218. * Sets the current viewport in normalized coordinates 0-1
  59219. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59220. */
  59221. setViewport(viewport?: Viewport): void;
  59222. /**
  59223. * Binds the embedded attributes buffer to the effect.
  59224. * @param effect Defines the effect to bind the attributes for
  59225. */
  59226. bindBuffers(effect: Effect): void;
  59227. /**
  59228. * Sets the current effect wrapper to use during draw.
  59229. * The effect needs to be ready before calling this api.
  59230. * This also sets the default full screen position attribute.
  59231. * @param effectWrapper Defines the effect to draw with
  59232. */
  59233. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59234. /**
  59235. * Draws a full screen quad.
  59236. */
  59237. draw(): void;
  59238. /**
  59239. * renders one or more effects to a specified texture
  59240. * @param effectWrappers list of effects to renderer
  59241. * @param outputTexture texture to draw to, if null it will render to the screen
  59242. */
  59243. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59244. /**
  59245. * Disposes of the effect renderer
  59246. */
  59247. dispose(): void;
  59248. }
  59249. /**
  59250. * Options to create an EffectWrapper
  59251. */
  59252. interface EffectWrapperCreationOptions {
  59253. /**
  59254. * Engine to use to create the effect
  59255. */
  59256. engine: ThinEngine;
  59257. /**
  59258. * Fragment shader for the effect
  59259. */
  59260. fragmentShader: string;
  59261. /**
  59262. * Vertex shader for the effect
  59263. */
  59264. vertexShader?: string;
  59265. /**
  59266. * Attributes to use in the shader
  59267. */
  59268. attributeNames?: Array<string>;
  59269. /**
  59270. * Uniforms to use in the shader
  59271. */
  59272. uniformNames?: Array<string>;
  59273. /**
  59274. * Texture sampler names to use in the shader
  59275. */
  59276. samplerNames?: Array<string>;
  59277. /**
  59278. * The friendly name of the effect displayed in Spector.
  59279. */
  59280. name?: string;
  59281. }
  59282. /**
  59283. * Wraps an effect to be used for rendering
  59284. */
  59285. export class EffectWrapper {
  59286. /**
  59287. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59288. */
  59289. onApplyObservable: Observable<{}>;
  59290. /**
  59291. * The underlying effect
  59292. */
  59293. effect: Effect;
  59294. /**
  59295. * Creates an effect to be renderer
  59296. * @param creationOptions options to create the effect
  59297. */
  59298. constructor(creationOptions: EffectWrapperCreationOptions);
  59299. /**
  59300. * Disposes of the effect wrapper
  59301. */
  59302. dispose(): void;
  59303. }
  59304. }
  59305. declare module "babylonjs/Materials/index" {
  59306. export * from "babylonjs/Materials/Background/index";
  59307. export * from "babylonjs/Materials/colorCurves";
  59308. export * from "babylonjs/Materials/iEffectFallbacks";
  59309. export * from "babylonjs/Materials/effectFallbacks";
  59310. export * from "babylonjs/Materials/effect";
  59311. export * from "babylonjs/Materials/fresnelParameters";
  59312. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59313. export * from "babylonjs/Materials/material";
  59314. export * from "babylonjs/Materials/materialDefines";
  59315. export * from "babylonjs/Materials/materialHelper";
  59316. export * from "babylonjs/Materials/multiMaterial";
  59317. export * from "babylonjs/Materials/PBR/index";
  59318. export * from "babylonjs/Materials/pushMaterial";
  59319. export * from "babylonjs/Materials/shaderMaterial";
  59320. export * from "babylonjs/Materials/standardMaterial";
  59321. export * from "babylonjs/Materials/Textures/index";
  59322. export * from "babylonjs/Materials/uniformBuffer";
  59323. export * from "babylonjs/Materials/materialFlags";
  59324. export * from "babylonjs/Materials/Node/index";
  59325. export * from "babylonjs/Materials/effectRenderer";
  59326. }
  59327. declare module "babylonjs/Maths/index" {
  59328. export * from "babylonjs/Maths/math.scalar";
  59329. export * from "babylonjs/Maths/math";
  59330. export * from "babylonjs/Maths/sphericalPolynomial";
  59331. }
  59332. declare module "babylonjs/Misc/workerPool" {
  59333. import { IDisposable } from "babylonjs/scene";
  59334. /**
  59335. * Helper class to push actions to a pool of workers.
  59336. */
  59337. export class WorkerPool implements IDisposable {
  59338. private _workerInfos;
  59339. private _pendingActions;
  59340. /**
  59341. * Constructor
  59342. * @param workers Array of workers to use for actions
  59343. */
  59344. constructor(workers: Array<Worker>);
  59345. /**
  59346. * Terminates all workers and clears any pending actions.
  59347. */
  59348. dispose(): void;
  59349. /**
  59350. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59351. * pended until a worker has completed its action.
  59352. * @param action The action to perform. Call onComplete when the action is complete.
  59353. */
  59354. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59355. private _execute;
  59356. }
  59357. }
  59358. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59359. import { IDisposable } from "babylonjs/scene";
  59360. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59361. /**
  59362. * Configuration for Draco compression
  59363. */
  59364. export interface IDracoCompressionConfiguration {
  59365. /**
  59366. * Configuration for the decoder.
  59367. */
  59368. decoder: {
  59369. /**
  59370. * The url to the WebAssembly module.
  59371. */
  59372. wasmUrl?: string;
  59373. /**
  59374. * The url to the WebAssembly binary.
  59375. */
  59376. wasmBinaryUrl?: string;
  59377. /**
  59378. * The url to the fallback JavaScript module.
  59379. */
  59380. fallbackUrl?: string;
  59381. };
  59382. }
  59383. /**
  59384. * Draco compression (https://google.github.io/draco/)
  59385. *
  59386. * This class wraps the Draco module.
  59387. *
  59388. * **Encoder**
  59389. *
  59390. * The encoder is not currently implemented.
  59391. *
  59392. * **Decoder**
  59393. *
  59394. * 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.
  59395. *
  59396. * To update the configuration, use the following code:
  59397. * ```javascript
  59398. * DracoCompression.Configuration = {
  59399. * decoder: {
  59400. * wasmUrl: "<url to the WebAssembly library>",
  59401. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59402. * fallbackUrl: "<url to the fallback JavaScript library>",
  59403. * }
  59404. * };
  59405. * ```
  59406. *
  59407. * 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.
  59408. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59409. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59410. *
  59411. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59412. * ```javascript
  59413. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59414. * ```
  59415. *
  59416. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59417. */
  59418. export class DracoCompression implements IDisposable {
  59419. private _workerPoolPromise?;
  59420. private _decoderModulePromise?;
  59421. /**
  59422. * The configuration. Defaults to the following urls:
  59423. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59424. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59425. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59426. */
  59427. static Configuration: IDracoCompressionConfiguration;
  59428. /**
  59429. * Returns true if the decoder configuration is available.
  59430. */
  59431. static readonly DecoderAvailable: boolean;
  59432. /**
  59433. * Default number of workers to create when creating the draco compression object.
  59434. */
  59435. static DefaultNumWorkers: number;
  59436. private static GetDefaultNumWorkers;
  59437. private static _Default;
  59438. /**
  59439. * Default instance for the draco compression object.
  59440. */
  59441. static readonly Default: DracoCompression;
  59442. /**
  59443. * Constructor
  59444. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59445. */
  59446. constructor(numWorkers?: number);
  59447. /**
  59448. * Stop all async operations and release resources.
  59449. */
  59450. dispose(): void;
  59451. /**
  59452. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59453. * @returns a promise that resolves when ready
  59454. */
  59455. whenReadyAsync(): Promise<void>;
  59456. /**
  59457. * Decode Draco compressed mesh data to vertex data.
  59458. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59459. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59460. * @returns A promise that resolves with the decoded vertex data
  59461. */
  59462. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59463. [kind: string]: number;
  59464. }): Promise<VertexData>;
  59465. }
  59466. }
  59467. declare module "babylonjs/Meshes/Compression/index" {
  59468. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59469. }
  59470. declare module "babylonjs/Meshes/csg" {
  59471. import { Nullable } from "babylonjs/types";
  59472. import { Scene } from "babylonjs/scene";
  59473. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59474. import { Mesh } from "babylonjs/Meshes/mesh";
  59475. import { Material } from "babylonjs/Materials/material";
  59476. /**
  59477. * Class for building Constructive Solid Geometry
  59478. */
  59479. export class CSG {
  59480. private polygons;
  59481. /**
  59482. * The world matrix
  59483. */
  59484. matrix: Matrix;
  59485. /**
  59486. * Stores the position
  59487. */
  59488. position: Vector3;
  59489. /**
  59490. * Stores the rotation
  59491. */
  59492. rotation: Vector3;
  59493. /**
  59494. * Stores the rotation quaternion
  59495. */
  59496. rotationQuaternion: Nullable<Quaternion>;
  59497. /**
  59498. * Stores the scaling vector
  59499. */
  59500. scaling: Vector3;
  59501. /**
  59502. * Convert the Mesh to CSG
  59503. * @param mesh The Mesh to convert to CSG
  59504. * @returns A new CSG from the Mesh
  59505. */
  59506. static FromMesh(mesh: Mesh): CSG;
  59507. /**
  59508. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59509. * @param polygons Polygons used to construct a CSG solid
  59510. */
  59511. private static FromPolygons;
  59512. /**
  59513. * Clones, or makes a deep copy, of the CSG
  59514. * @returns A new CSG
  59515. */
  59516. clone(): CSG;
  59517. /**
  59518. * Unions this CSG with another CSG
  59519. * @param csg The CSG to union against this CSG
  59520. * @returns The unioned CSG
  59521. */
  59522. union(csg: CSG): CSG;
  59523. /**
  59524. * Unions this CSG with another CSG in place
  59525. * @param csg The CSG to union against this CSG
  59526. */
  59527. unionInPlace(csg: CSG): void;
  59528. /**
  59529. * Subtracts this CSG with another CSG
  59530. * @param csg The CSG to subtract against this CSG
  59531. * @returns A new CSG
  59532. */
  59533. subtract(csg: CSG): CSG;
  59534. /**
  59535. * Subtracts this CSG with another CSG in place
  59536. * @param csg The CSG to subtact against this CSG
  59537. */
  59538. subtractInPlace(csg: CSG): void;
  59539. /**
  59540. * Intersect this CSG with another CSG
  59541. * @param csg The CSG to intersect against this CSG
  59542. * @returns A new CSG
  59543. */
  59544. intersect(csg: CSG): CSG;
  59545. /**
  59546. * Intersects this CSG with another CSG in place
  59547. * @param csg The CSG to intersect against this CSG
  59548. */
  59549. intersectInPlace(csg: CSG): void;
  59550. /**
  59551. * Return a new CSG solid with solid and empty space switched. This solid is
  59552. * not modified.
  59553. * @returns A new CSG solid with solid and empty space switched
  59554. */
  59555. inverse(): CSG;
  59556. /**
  59557. * Inverses the CSG in place
  59558. */
  59559. inverseInPlace(): void;
  59560. /**
  59561. * This is used to keep meshes transformations so they can be restored
  59562. * when we build back a Babylon Mesh
  59563. * NB : All CSG operations are performed in world coordinates
  59564. * @param csg The CSG to copy the transform attributes from
  59565. * @returns This CSG
  59566. */
  59567. copyTransformAttributes(csg: CSG): CSG;
  59568. /**
  59569. * Build Raw mesh from CSG
  59570. * Coordinates here are in world space
  59571. * @param name The name of the mesh geometry
  59572. * @param scene The Scene
  59573. * @param keepSubMeshes Specifies if the submeshes should be kept
  59574. * @returns A new Mesh
  59575. */
  59576. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59577. /**
  59578. * Build Mesh from CSG taking material and transforms into account
  59579. * @param name The name of the Mesh
  59580. * @param material The material of the Mesh
  59581. * @param scene The Scene
  59582. * @param keepSubMeshes Specifies if submeshes should be kept
  59583. * @returns The new Mesh
  59584. */
  59585. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59586. }
  59587. }
  59588. declare module "babylonjs/Meshes/trailMesh" {
  59589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59590. import { Mesh } from "babylonjs/Meshes/mesh";
  59591. import { Scene } from "babylonjs/scene";
  59592. /**
  59593. * Class used to create a trail following a mesh
  59594. */
  59595. export class TrailMesh extends Mesh {
  59596. private _generator;
  59597. private _autoStart;
  59598. private _running;
  59599. private _diameter;
  59600. private _length;
  59601. private _sectionPolygonPointsCount;
  59602. private _sectionVectors;
  59603. private _sectionNormalVectors;
  59604. private _beforeRenderObserver;
  59605. /**
  59606. * @constructor
  59607. * @param name The value used by scene.getMeshByName() to do a lookup.
  59608. * @param generator The mesh to generate a trail.
  59609. * @param scene The scene to add this mesh to.
  59610. * @param diameter Diameter of trailing mesh. Default is 1.
  59611. * @param length Length of trailing mesh. Default is 60.
  59612. * @param autoStart Automatically start trailing mesh. Default true.
  59613. */
  59614. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59615. /**
  59616. * "TrailMesh"
  59617. * @returns "TrailMesh"
  59618. */
  59619. getClassName(): string;
  59620. private _createMesh;
  59621. /**
  59622. * Start trailing mesh.
  59623. */
  59624. start(): void;
  59625. /**
  59626. * Stop trailing mesh.
  59627. */
  59628. stop(): void;
  59629. /**
  59630. * Update trailing mesh geometry.
  59631. */
  59632. update(): void;
  59633. /**
  59634. * Returns a new TrailMesh object.
  59635. * @param name is a string, the name given to the new mesh
  59636. * @param newGenerator use new generator object for cloned trail mesh
  59637. * @returns a new mesh
  59638. */
  59639. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59640. /**
  59641. * Serializes this trail mesh
  59642. * @param serializationObject object to write serialization to
  59643. */
  59644. serialize(serializationObject: any): void;
  59645. /**
  59646. * Parses a serialized trail mesh
  59647. * @param parsedMesh the serialized mesh
  59648. * @param scene the scene to create the trail mesh in
  59649. * @returns the created trail mesh
  59650. */
  59651. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59652. }
  59653. }
  59654. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59655. import { Nullable } from "babylonjs/types";
  59656. import { Scene } from "babylonjs/scene";
  59657. import { Vector4 } from "babylonjs/Maths/math.vector";
  59658. import { Color4 } from "babylonjs/Maths/math.color";
  59659. import { Mesh } from "babylonjs/Meshes/mesh";
  59660. /**
  59661. * Class containing static functions to help procedurally build meshes
  59662. */
  59663. export class TiledBoxBuilder {
  59664. /**
  59665. * Creates a box mesh
  59666. * 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)
  59667. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59671. * @param name defines the name of the mesh
  59672. * @param options defines the options used to create the mesh
  59673. * @param scene defines the hosting scene
  59674. * @returns the box mesh
  59675. */
  59676. static CreateTiledBox(name: string, options: {
  59677. pattern?: number;
  59678. width?: number;
  59679. height?: number;
  59680. depth?: number;
  59681. tileSize?: number;
  59682. tileWidth?: number;
  59683. tileHeight?: number;
  59684. alignHorizontal?: number;
  59685. alignVertical?: number;
  59686. faceUV?: Vector4[];
  59687. faceColors?: Color4[];
  59688. sideOrientation?: number;
  59689. updatable?: boolean;
  59690. }, scene?: Nullable<Scene>): Mesh;
  59691. }
  59692. }
  59693. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59694. import { Vector4 } from "babylonjs/Maths/math.vector";
  59695. import { Mesh } from "babylonjs/Meshes/mesh";
  59696. /**
  59697. * Class containing static functions to help procedurally build meshes
  59698. */
  59699. export class TorusKnotBuilder {
  59700. /**
  59701. * Creates a torus knot mesh
  59702. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59703. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59704. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59705. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59709. * @param name defines the name of the mesh
  59710. * @param options defines the options used to create the mesh
  59711. * @param scene defines the hosting scene
  59712. * @returns the torus knot mesh
  59713. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59714. */
  59715. static CreateTorusKnot(name: string, options: {
  59716. radius?: number;
  59717. tube?: number;
  59718. radialSegments?: number;
  59719. tubularSegments?: number;
  59720. p?: number;
  59721. q?: number;
  59722. updatable?: boolean;
  59723. sideOrientation?: number;
  59724. frontUVs?: Vector4;
  59725. backUVs?: Vector4;
  59726. }, scene: any): Mesh;
  59727. }
  59728. }
  59729. declare module "babylonjs/Meshes/polygonMesh" {
  59730. import { Scene } from "babylonjs/scene";
  59731. import { Vector2 } from "babylonjs/Maths/math.vector";
  59732. import { Mesh } from "babylonjs/Meshes/mesh";
  59733. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59734. import { Path2 } from "babylonjs/Maths/math.path";
  59735. /**
  59736. * Polygon
  59737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59738. */
  59739. export class Polygon {
  59740. /**
  59741. * Creates a rectangle
  59742. * @param xmin bottom X coord
  59743. * @param ymin bottom Y coord
  59744. * @param xmax top X coord
  59745. * @param ymax top Y coord
  59746. * @returns points that make the resulting rectation
  59747. */
  59748. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59749. /**
  59750. * Creates a circle
  59751. * @param radius radius of circle
  59752. * @param cx scale in x
  59753. * @param cy scale in y
  59754. * @param numberOfSides number of sides that make up the circle
  59755. * @returns points that make the resulting circle
  59756. */
  59757. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59758. /**
  59759. * Creates a polygon from input string
  59760. * @param input Input polygon data
  59761. * @returns the parsed points
  59762. */
  59763. static Parse(input: string): Vector2[];
  59764. /**
  59765. * Starts building a polygon from x and y coordinates
  59766. * @param x x coordinate
  59767. * @param y y coordinate
  59768. * @returns the started path2
  59769. */
  59770. static StartingAt(x: number, y: number): Path2;
  59771. }
  59772. /**
  59773. * Builds a polygon
  59774. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59775. */
  59776. export class PolygonMeshBuilder {
  59777. private _points;
  59778. private _outlinepoints;
  59779. private _holes;
  59780. private _name;
  59781. private _scene;
  59782. private _epoints;
  59783. private _eholes;
  59784. private _addToepoint;
  59785. /**
  59786. * Babylon reference to the earcut plugin.
  59787. */
  59788. bjsEarcut: any;
  59789. /**
  59790. * Creates a PolygonMeshBuilder
  59791. * @param name name of the builder
  59792. * @param contours Path of the polygon
  59793. * @param scene scene to add to when creating the mesh
  59794. * @param earcutInjection can be used to inject your own earcut reference
  59795. */
  59796. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59797. /**
  59798. * Adds a whole within the polygon
  59799. * @param hole Array of points defining the hole
  59800. * @returns this
  59801. */
  59802. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59803. /**
  59804. * Creates the polygon
  59805. * @param updatable If the mesh should be updatable
  59806. * @param depth The depth of the mesh created
  59807. * @returns the created mesh
  59808. */
  59809. build(updatable?: boolean, depth?: number): Mesh;
  59810. /**
  59811. * Creates the polygon
  59812. * @param depth The depth of the mesh created
  59813. * @returns the created VertexData
  59814. */
  59815. buildVertexData(depth?: number): VertexData;
  59816. /**
  59817. * Adds a side to the polygon
  59818. * @param positions points that make the polygon
  59819. * @param normals normals of the polygon
  59820. * @param uvs uvs of the polygon
  59821. * @param indices indices of the polygon
  59822. * @param bounds bounds of the polygon
  59823. * @param points points of the polygon
  59824. * @param depth depth of the polygon
  59825. * @param flip flip of the polygon
  59826. */
  59827. private addSide;
  59828. }
  59829. }
  59830. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59831. import { Scene } from "babylonjs/scene";
  59832. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59833. import { Color4 } from "babylonjs/Maths/math.color";
  59834. import { Mesh } from "babylonjs/Meshes/mesh";
  59835. import { Nullable } from "babylonjs/types";
  59836. /**
  59837. * Class containing static functions to help procedurally build meshes
  59838. */
  59839. export class PolygonBuilder {
  59840. /**
  59841. * Creates a polygon mesh
  59842. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59843. * * 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
  59844. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59847. * * Remember you can only change the shape positions, not their number when updating a polygon
  59848. * @param name defines the name of the mesh
  59849. * @param options defines the options used to create the mesh
  59850. * @param scene defines the hosting scene
  59851. * @param earcutInjection can be used to inject your own earcut reference
  59852. * @returns the polygon mesh
  59853. */
  59854. static CreatePolygon(name: string, options: {
  59855. shape: Vector3[];
  59856. holes?: Vector3[][];
  59857. depth?: number;
  59858. faceUV?: Vector4[];
  59859. faceColors?: Color4[];
  59860. updatable?: boolean;
  59861. sideOrientation?: number;
  59862. frontUVs?: Vector4;
  59863. backUVs?: Vector4;
  59864. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59865. /**
  59866. * Creates an extruded polygon mesh, with depth in the Y direction.
  59867. * * 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)
  59868. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59869. * @param name defines the name of the mesh
  59870. * @param options defines the options used to create the mesh
  59871. * @param scene defines the hosting scene
  59872. * @param earcutInjection can be used to inject your own earcut reference
  59873. * @returns the polygon mesh
  59874. */
  59875. static ExtrudePolygon(name: string, options: {
  59876. shape: Vector3[];
  59877. holes?: Vector3[][];
  59878. depth?: number;
  59879. faceUV?: Vector4[];
  59880. faceColors?: Color4[];
  59881. updatable?: boolean;
  59882. sideOrientation?: number;
  59883. frontUVs?: Vector4;
  59884. backUVs?: Vector4;
  59885. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59886. }
  59887. }
  59888. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59889. import { Scene } from "babylonjs/scene";
  59890. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59891. import { Mesh } from "babylonjs/Meshes/mesh";
  59892. import { Nullable } from "babylonjs/types";
  59893. /**
  59894. * Class containing static functions to help procedurally build meshes
  59895. */
  59896. export class LatheBuilder {
  59897. /**
  59898. * Creates lathe mesh.
  59899. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59900. * * 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
  59901. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59902. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59903. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59904. * * 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
  59905. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59906. * * 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
  59907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59911. * @param name defines the name of the mesh
  59912. * @param options defines the options used to create the mesh
  59913. * @param scene defines the hosting scene
  59914. * @returns the lathe mesh
  59915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59916. */
  59917. static CreateLathe(name: string, options: {
  59918. shape: Vector3[];
  59919. radius?: number;
  59920. tessellation?: number;
  59921. clip?: number;
  59922. arc?: number;
  59923. closed?: boolean;
  59924. updatable?: boolean;
  59925. sideOrientation?: number;
  59926. frontUVs?: Vector4;
  59927. backUVs?: Vector4;
  59928. cap?: number;
  59929. invertUV?: boolean;
  59930. }, scene?: Nullable<Scene>): Mesh;
  59931. }
  59932. }
  59933. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59934. import { Nullable } from "babylonjs/types";
  59935. import { Scene } from "babylonjs/scene";
  59936. import { Vector4 } from "babylonjs/Maths/math.vector";
  59937. import { Mesh } from "babylonjs/Meshes/mesh";
  59938. /**
  59939. * Class containing static functions to help procedurally build meshes
  59940. */
  59941. export class TiledPlaneBuilder {
  59942. /**
  59943. * Creates a tiled plane mesh
  59944. * * The parameter `pattern` will, depending on value, do nothing or
  59945. * * * flip (reflect about central vertical) alternate tiles across and up
  59946. * * * flip every tile on alternate rows
  59947. * * * rotate (180 degs) alternate tiles across and up
  59948. * * * rotate every tile on alternate rows
  59949. * * * flip and rotate alternate tiles across and up
  59950. * * * flip and rotate every tile on alternate rows
  59951. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59952. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59955. * * 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)
  59956. * * 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)
  59957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59958. * @param name defines the name of the mesh
  59959. * @param options defines the options used to create the mesh
  59960. * @param scene defines the hosting scene
  59961. * @returns the box mesh
  59962. */
  59963. static CreateTiledPlane(name: string, options: {
  59964. pattern?: number;
  59965. tileSize?: number;
  59966. tileWidth?: number;
  59967. tileHeight?: number;
  59968. size?: number;
  59969. width?: number;
  59970. height?: number;
  59971. alignHorizontal?: number;
  59972. alignVertical?: number;
  59973. sideOrientation?: number;
  59974. frontUVs?: Vector4;
  59975. backUVs?: Vector4;
  59976. updatable?: boolean;
  59977. }, scene?: Nullable<Scene>): Mesh;
  59978. }
  59979. }
  59980. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59981. import { Nullable } from "babylonjs/types";
  59982. import { Scene } from "babylonjs/scene";
  59983. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59984. import { Mesh } from "babylonjs/Meshes/mesh";
  59985. /**
  59986. * Class containing static functions to help procedurally build meshes
  59987. */
  59988. export class TubeBuilder {
  59989. /**
  59990. * Creates a tube mesh.
  59991. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59992. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59993. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59994. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59995. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59996. * * 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)
  59997. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59998. * * 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
  59999. * * 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
  60000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60002. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60004. * @param name defines the name of the mesh
  60005. * @param options defines the options used to create the mesh
  60006. * @param scene defines the hosting scene
  60007. * @returns the tube mesh
  60008. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60009. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60010. */
  60011. static CreateTube(name: string, options: {
  60012. path: Vector3[];
  60013. radius?: number;
  60014. tessellation?: number;
  60015. radiusFunction?: {
  60016. (i: number, distance: number): number;
  60017. };
  60018. cap?: number;
  60019. arc?: number;
  60020. updatable?: boolean;
  60021. sideOrientation?: number;
  60022. frontUVs?: Vector4;
  60023. backUVs?: Vector4;
  60024. instance?: Mesh;
  60025. invertUV?: boolean;
  60026. }, scene?: Nullable<Scene>): Mesh;
  60027. }
  60028. }
  60029. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60030. import { Scene } from "babylonjs/scene";
  60031. import { Vector4 } from "babylonjs/Maths/math.vector";
  60032. import { Mesh } from "babylonjs/Meshes/mesh";
  60033. import { Nullable } from "babylonjs/types";
  60034. /**
  60035. * Class containing static functions to help procedurally build meshes
  60036. */
  60037. export class IcoSphereBuilder {
  60038. /**
  60039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60041. * * 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`)
  60042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60043. * * 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
  60044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60047. * @param name defines the name of the mesh
  60048. * @param options defines the options used to create the mesh
  60049. * @param scene defines the hosting scene
  60050. * @returns the icosahedron mesh
  60051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60052. */
  60053. static CreateIcoSphere(name: string, options: {
  60054. radius?: number;
  60055. radiusX?: number;
  60056. radiusY?: number;
  60057. radiusZ?: number;
  60058. flat?: boolean;
  60059. subdivisions?: number;
  60060. sideOrientation?: number;
  60061. frontUVs?: Vector4;
  60062. backUVs?: Vector4;
  60063. updatable?: boolean;
  60064. }, scene?: Nullable<Scene>): Mesh;
  60065. }
  60066. }
  60067. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60068. import { Vector3 } from "babylonjs/Maths/math.vector";
  60069. import { Mesh } from "babylonjs/Meshes/mesh";
  60070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60071. /**
  60072. * Class containing static functions to help procedurally build meshes
  60073. */
  60074. export class DecalBuilder {
  60075. /**
  60076. * Creates a decal mesh.
  60077. * 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
  60078. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60079. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60080. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60081. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60082. * @param name defines the name of the mesh
  60083. * @param sourceMesh defines the mesh where the decal must be applied
  60084. * @param options defines the options used to create the mesh
  60085. * @param scene defines the hosting scene
  60086. * @returns the decal mesh
  60087. * @see https://doc.babylonjs.com/how_to/decals
  60088. */
  60089. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60090. position?: Vector3;
  60091. normal?: Vector3;
  60092. size?: Vector3;
  60093. angle?: number;
  60094. }): Mesh;
  60095. }
  60096. }
  60097. declare module "babylonjs/Meshes/meshBuilder" {
  60098. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60099. import { Nullable } from "babylonjs/types";
  60100. import { Scene } from "babylonjs/scene";
  60101. import { Mesh } from "babylonjs/Meshes/mesh";
  60102. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60103. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60105. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60106. import { Plane } from "babylonjs/Maths/math.plane";
  60107. /**
  60108. * Class containing static functions to help procedurally build meshes
  60109. */
  60110. export class MeshBuilder {
  60111. /**
  60112. * Creates a box mesh
  60113. * * The parameter `size` sets the size (float) of each box side (default 1)
  60114. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60115. * * 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)
  60116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60120. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60121. * @param name defines the name of the mesh
  60122. * @param options defines the options used to create the mesh
  60123. * @param scene defines the hosting scene
  60124. * @returns the box mesh
  60125. */
  60126. static CreateBox(name: string, options: {
  60127. size?: number;
  60128. width?: number;
  60129. height?: number;
  60130. depth?: number;
  60131. faceUV?: Vector4[];
  60132. faceColors?: Color4[];
  60133. sideOrientation?: number;
  60134. frontUVs?: Vector4;
  60135. backUVs?: Vector4;
  60136. updatable?: boolean;
  60137. }, scene?: Nullable<Scene>): Mesh;
  60138. /**
  60139. * Creates a tiled box mesh
  60140. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60142. * @param name defines the name of the mesh
  60143. * @param options defines the options used to create the mesh
  60144. * @param scene defines the hosting scene
  60145. * @returns the tiled box mesh
  60146. */
  60147. static CreateTiledBox(name: string, options: {
  60148. pattern?: number;
  60149. size?: number;
  60150. width?: number;
  60151. height?: number;
  60152. depth: number;
  60153. tileSize?: number;
  60154. tileWidth?: number;
  60155. tileHeight?: number;
  60156. faceUV?: Vector4[];
  60157. faceColors?: Color4[];
  60158. alignHorizontal?: number;
  60159. alignVertical?: number;
  60160. sideOrientation?: number;
  60161. updatable?: boolean;
  60162. }, scene?: Nullable<Scene>): Mesh;
  60163. /**
  60164. * Creates a sphere mesh
  60165. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60166. * * 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`)
  60167. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60168. * * 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
  60169. * * 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)
  60170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60173. * @param name defines the name of the mesh
  60174. * @param options defines the options used to create the mesh
  60175. * @param scene defines the hosting scene
  60176. * @returns the sphere mesh
  60177. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60178. */
  60179. static CreateSphere(name: string, options: {
  60180. segments?: number;
  60181. diameter?: number;
  60182. diameterX?: number;
  60183. diameterY?: number;
  60184. diameterZ?: number;
  60185. arc?: number;
  60186. slice?: number;
  60187. sideOrientation?: number;
  60188. frontUVs?: Vector4;
  60189. backUVs?: Vector4;
  60190. updatable?: boolean;
  60191. }, scene?: Nullable<Scene>): Mesh;
  60192. /**
  60193. * Creates a plane polygonal mesh. By default, this is a disc
  60194. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60195. * * 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
  60196. * * 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
  60197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60200. * @param name defines the name of the mesh
  60201. * @param options defines the options used to create the mesh
  60202. * @param scene defines the hosting scene
  60203. * @returns the plane polygonal mesh
  60204. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60205. */
  60206. static CreateDisc(name: string, options: {
  60207. radius?: number;
  60208. tessellation?: number;
  60209. arc?: number;
  60210. updatable?: boolean;
  60211. sideOrientation?: number;
  60212. frontUVs?: Vector4;
  60213. backUVs?: Vector4;
  60214. }, scene?: Nullable<Scene>): Mesh;
  60215. /**
  60216. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60217. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60218. * * 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`)
  60219. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60220. * * 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
  60221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60224. * @param name defines the name of the mesh
  60225. * @param options defines the options used to create the mesh
  60226. * @param scene defines the hosting scene
  60227. * @returns the icosahedron mesh
  60228. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60229. */
  60230. static CreateIcoSphere(name: string, options: {
  60231. radius?: number;
  60232. radiusX?: number;
  60233. radiusY?: number;
  60234. radiusZ?: number;
  60235. flat?: boolean;
  60236. subdivisions?: number;
  60237. sideOrientation?: number;
  60238. frontUVs?: Vector4;
  60239. backUVs?: Vector4;
  60240. updatable?: boolean;
  60241. }, scene?: Nullable<Scene>): Mesh;
  60242. /**
  60243. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60244. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60245. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60246. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60247. * * 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
  60248. * * 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
  60249. * * 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
  60250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60252. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60253. * * 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
  60254. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60255. * * 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
  60256. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60258. * @param name defines the name of the mesh
  60259. * @param options defines the options used to create the mesh
  60260. * @param scene defines the hosting scene
  60261. * @returns the ribbon mesh
  60262. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60264. */
  60265. static CreateRibbon(name: string, options: {
  60266. pathArray: Vector3[][];
  60267. closeArray?: boolean;
  60268. closePath?: boolean;
  60269. offset?: number;
  60270. updatable?: boolean;
  60271. sideOrientation?: number;
  60272. frontUVs?: Vector4;
  60273. backUVs?: Vector4;
  60274. instance?: Mesh;
  60275. invertUV?: boolean;
  60276. uvs?: Vector2[];
  60277. colors?: Color4[];
  60278. }, scene?: Nullable<Scene>): Mesh;
  60279. /**
  60280. * Creates a cylinder or a cone mesh
  60281. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60282. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60283. * * 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.
  60284. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60285. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60286. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60287. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60288. * * 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).
  60289. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60290. * * 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).
  60291. * * 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
  60292. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60293. * * 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
  60294. * * 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.
  60295. * * If `enclose` is false, a ring surface is one element.
  60296. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60297. * * 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
  60298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60301. * @param name defines the name of the mesh
  60302. * @param options defines the options used to create the mesh
  60303. * @param scene defines the hosting scene
  60304. * @returns the cylinder mesh
  60305. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60306. */
  60307. static CreateCylinder(name: string, options: {
  60308. height?: number;
  60309. diameterTop?: number;
  60310. diameterBottom?: number;
  60311. diameter?: number;
  60312. tessellation?: number;
  60313. subdivisions?: number;
  60314. arc?: number;
  60315. faceColors?: Color4[];
  60316. faceUV?: Vector4[];
  60317. updatable?: boolean;
  60318. hasRings?: boolean;
  60319. enclose?: boolean;
  60320. cap?: number;
  60321. sideOrientation?: number;
  60322. frontUVs?: Vector4;
  60323. backUVs?: Vector4;
  60324. }, scene?: Nullable<Scene>): Mesh;
  60325. /**
  60326. * Creates a torus mesh
  60327. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60328. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60329. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60333. * @param name defines the name of the mesh
  60334. * @param options defines the options used to create the mesh
  60335. * @param scene defines the hosting scene
  60336. * @returns the torus mesh
  60337. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60338. */
  60339. static CreateTorus(name: string, options: {
  60340. diameter?: number;
  60341. thickness?: number;
  60342. tessellation?: number;
  60343. updatable?: boolean;
  60344. sideOrientation?: number;
  60345. frontUVs?: Vector4;
  60346. backUVs?: Vector4;
  60347. }, scene?: Nullable<Scene>): Mesh;
  60348. /**
  60349. * Creates a torus knot mesh
  60350. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60351. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60352. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60353. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60357. * @param name defines the name of the mesh
  60358. * @param options defines the options used to create the mesh
  60359. * @param scene defines the hosting scene
  60360. * @returns the torus knot mesh
  60361. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60362. */
  60363. static CreateTorusKnot(name: string, options: {
  60364. radius?: number;
  60365. tube?: number;
  60366. radialSegments?: number;
  60367. tubularSegments?: number;
  60368. p?: number;
  60369. q?: number;
  60370. updatable?: boolean;
  60371. sideOrientation?: number;
  60372. frontUVs?: Vector4;
  60373. backUVs?: Vector4;
  60374. }, scene?: Nullable<Scene>): Mesh;
  60375. /**
  60376. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60377. * * 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
  60378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60379. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60380. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60381. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60383. * * 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
  60384. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60387. * @param name defines the name of the new line system
  60388. * @param options defines the options used to create the line system
  60389. * @param scene defines the hosting scene
  60390. * @returns a new line system mesh
  60391. */
  60392. static CreateLineSystem(name: string, options: {
  60393. lines: Vector3[][];
  60394. updatable?: boolean;
  60395. instance?: Nullable<LinesMesh>;
  60396. colors?: Nullable<Color4[][]>;
  60397. useVertexAlpha?: boolean;
  60398. }, scene: Nullable<Scene>): LinesMesh;
  60399. /**
  60400. * Creates a line mesh
  60401. * 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
  60402. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60403. * * The parameter `points` is an array successive Vector3
  60404. * * 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
  60405. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60406. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60407. * * When updating an instance, remember that only point positions can change, not the number of points
  60408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60410. * @param name defines the name of the new line system
  60411. * @param options defines the options used to create the line system
  60412. * @param scene defines the hosting scene
  60413. * @returns a new line mesh
  60414. */
  60415. static CreateLines(name: string, options: {
  60416. points: Vector3[];
  60417. updatable?: boolean;
  60418. instance?: Nullable<LinesMesh>;
  60419. colors?: Color4[];
  60420. useVertexAlpha?: boolean;
  60421. }, scene?: Nullable<Scene>): LinesMesh;
  60422. /**
  60423. * Creates a dashed line mesh
  60424. * * 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
  60425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60426. * * The parameter `points` is an array successive Vector3
  60427. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60428. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60429. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60430. * * 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
  60431. * * When updating an instance, remember that only point positions can change, not the number of points
  60432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60433. * @param name defines the name of the mesh
  60434. * @param options defines the options used to create the mesh
  60435. * @param scene defines the hosting scene
  60436. * @returns the dashed line mesh
  60437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60438. */
  60439. static CreateDashedLines(name: string, options: {
  60440. points: Vector3[];
  60441. dashSize?: number;
  60442. gapSize?: number;
  60443. dashNb?: number;
  60444. updatable?: boolean;
  60445. instance?: LinesMesh;
  60446. }, scene?: Nullable<Scene>): LinesMesh;
  60447. /**
  60448. * 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.
  60449. * * 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.
  60450. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60451. * * 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.
  60452. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60453. * * 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
  60454. * * 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
  60455. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60460. * @param name defines the name of the mesh
  60461. * @param options defines the options used to create the mesh
  60462. * @param scene defines the hosting scene
  60463. * @returns the extruded shape mesh
  60464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60466. */
  60467. static ExtrudeShape(name: string, options: {
  60468. shape: Vector3[];
  60469. path: Vector3[];
  60470. scale?: number;
  60471. rotation?: number;
  60472. cap?: number;
  60473. updatable?: boolean;
  60474. sideOrientation?: number;
  60475. frontUVs?: Vector4;
  60476. backUVs?: Vector4;
  60477. instance?: Mesh;
  60478. invertUV?: boolean;
  60479. }, scene?: Nullable<Scene>): Mesh;
  60480. /**
  60481. * Creates an custom extruded shape mesh.
  60482. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60483. * * 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.
  60484. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60485. * * 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
  60486. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60487. * * 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
  60488. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60489. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60490. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60491. * * 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
  60492. * * 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
  60493. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60498. * @param name defines the name of the mesh
  60499. * @param options defines the options used to create the mesh
  60500. * @param scene defines the hosting scene
  60501. * @returns the custom extruded shape mesh
  60502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60503. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60505. */
  60506. static ExtrudeShapeCustom(name: string, options: {
  60507. shape: Vector3[];
  60508. path: Vector3[];
  60509. scaleFunction?: any;
  60510. rotationFunction?: any;
  60511. ribbonCloseArray?: boolean;
  60512. ribbonClosePath?: boolean;
  60513. cap?: number;
  60514. updatable?: boolean;
  60515. sideOrientation?: number;
  60516. frontUVs?: Vector4;
  60517. backUVs?: Vector4;
  60518. instance?: Mesh;
  60519. invertUV?: boolean;
  60520. }, scene?: Nullable<Scene>): Mesh;
  60521. /**
  60522. * Creates lathe mesh.
  60523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60524. * * 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
  60525. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60526. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60527. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60528. * * 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
  60529. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60530. * * 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
  60531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60535. * @param name defines the name of the mesh
  60536. * @param options defines the options used to create the mesh
  60537. * @param scene defines the hosting scene
  60538. * @returns the lathe mesh
  60539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60540. */
  60541. static CreateLathe(name: string, options: {
  60542. shape: Vector3[];
  60543. radius?: number;
  60544. tessellation?: number;
  60545. clip?: number;
  60546. arc?: number;
  60547. closed?: boolean;
  60548. updatable?: boolean;
  60549. sideOrientation?: number;
  60550. frontUVs?: Vector4;
  60551. backUVs?: Vector4;
  60552. cap?: number;
  60553. invertUV?: boolean;
  60554. }, scene?: Nullable<Scene>): Mesh;
  60555. /**
  60556. * Creates a tiled plane mesh
  60557. * * You can set a limited pattern arrangement with the tiles
  60558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60561. * @param name defines the name of the mesh
  60562. * @param options defines the options used to create the mesh
  60563. * @param scene defines the hosting scene
  60564. * @returns the plane mesh
  60565. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60566. */
  60567. static CreateTiledPlane(name: string, options: {
  60568. pattern?: number;
  60569. tileSize?: number;
  60570. tileWidth?: number;
  60571. tileHeight?: number;
  60572. size?: number;
  60573. width?: number;
  60574. height?: number;
  60575. alignHorizontal?: number;
  60576. alignVertical?: number;
  60577. sideOrientation?: number;
  60578. frontUVs?: Vector4;
  60579. backUVs?: Vector4;
  60580. updatable?: boolean;
  60581. }, scene?: Nullable<Scene>): Mesh;
  60582. /**
  60583. * Creates a plane mesh
  60584. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60585. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60586. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60590. * @param name defines the name of the mesh
  60591. * @param options defines the options used to create the mesh
  60592. * @param scene defines the hosting scene
  60593. * @returns the plane mesh
  60594. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60595. */
  60596. static CreatePlane(name: string, options: {
  60597. size?: number;
  60598. width?: number;
  60599. height?: number;
  60600. sideOrientation?: number;
  60601. frontUVs?: Vector4;
  60602. backUVs?: Vector4;
  60603. updatable?: boolean;
  60604. sourcePlane?: Plane;
  60605. }, scene?: Nullable<Scene>): Mesh;
  60606. /**
  60607. * Creates a ground mesh
  60608. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60609. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60611. * @param name defines the name of the mesh
  60612. * @param options defines the options used to create the mesh
  60613. * @param scene defines the hosting scene
  60614. * @returns the ground mesh
  60615. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60616. */
  60617. static CreateGround(name: string, options: {
  60618. width?: number;
  60619. height?: number;
  60620. subdivisions?: number;
  60621. subdivisionsX?: number;
  60622. subdivisionsY?: number;
  60623. updatable?: boolean;
  60624. }, scene?: Nullable<Scene>): Mesh;
  60625. /**
  60626. * Creates a tiled ground mesh
  60627. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60628. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60629. * * 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
  60630. * * 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
  60631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60632. * @param name defines the name of the mesh
  60633. * @param options defines the options used to create the mesh
  60634. * @param scene defines the hosting scene
  60635. * @returns the tiled ground mesh
  60636. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60637. */
  60638. static CreateTiledGround(name: string, options: {
  60639. xmin: number;
  60640. zmin: number;
  60641. xmax: number;
  60642. zmax: number;
  60643. subdivisions?: {
  60644. w: number;
  60645. h: number;
  60646. };
  60647. precision?: {
  60648. w: number;
  60649. h: number;
  60650. };
  60651. updatable?: boolean;
  60652. }, scene?: Nullable<Scene>): Mesh;
  60653. /**
  60654. * Creates a ground mesh from a height map
  60655. * * The parameter `url` sets the URL of the height map image resource.
  60656. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60657. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60658. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60659. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60660. * * 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.
  60661. * * 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).
  60662. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60664. * @param name defines the name of the mesh
  60665. * @param url defines the url to the height map
  60666. * @param options defines the options used to create the mesh
  60667. * @param scene defines the hosting scene
  60668. * @returns the ground mesh
  60669. * @see https://doc.babylonjs.com/babylon101/height_map
  60670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60671. */
  60672. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60673. width?: number;
  60674. height?: number;
  60675. subdivisions?: number;
  60676. minHeight?: number;
  60677. maxHeight?: number;
  60678. colorFilter?: Color3;
  60679. alphaFilter?: number;
  60680. updatable?: boolean;
  60681. onReady?: (mesh: GroundMesh) => void;
  60682. }, scene?: Nullable<Scene>): GroundMesh;
  60683. /**
  60684. * Creates a polygon mesh
  60685. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60686. * * 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
  60687. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60690. * * Remember you can only change the shape positions, not their number when updating a polygon
  60691. * @param name defines the name of the mesh
  60692. * @param options defines the options used to create the mesh
  60693. * @param scene defines the hosting scene
  60694. * @param earcutInjection can be used to inject your own earcut reference
  60695. * @returns the polygon mesh
  60696. */
  60697. static CreatePolygon(name: string, options: {
  60698. shape: Vector3[];
  60699. holes?: Vector3[][];
  60700. depth?: number;
  60701. faceUV?: Vector4[];
  60702. faceColors?: Color4[];
  60703. updatable?: boolean;
  60704. sideOrientation?: number;
  60705. frontUVs?: Vector4;
  60706. backUVs?: Vector4;
  60707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60708. /**
  60709. * Creates an extruded polygon mesh, with depth in the Y direction.
  60710. * * 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)
  60711. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60712. * @param name defines the name of the mesh
  60713. * @param options defines the options used to create the mesh
  60714. * @param scene defines the hosting scene
  60715. * @param earcutInjection can be used to inject your own earcut reference
  60716. * @returns the polygon mesh
  60717. */
  60718. static ExtrudePolygon(name: string, options: {
  60719. shape: Vector3[];
  60720. holes?: Vector3[][];
  60721. depth?: number;
  60722. faceUV?: Vector4[];
  60723. faceColors?: Color4[];
  60724. updatable?: boolean;
  60725. sideOrientation?: number;
  60726. frontUVs?: Vector4;
  60727. backUVs?: Vector4;
  60728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60729. /**
  60730. * Creates a tube mesh.
  60731. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60732. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60733. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60734. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60735. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60736. * * 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)
  60737. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60738. * * 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
  60739. * * 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
  60740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60744. * @param name defines the name of the mesh
  60745. * @param options defines the options used to create the mesh
  60746. * @param scene defines the hosting scene
  60747. * @returns the tube mesh
  60748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60749. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60750. */
  60751. static CreateTube(name: string, options: {
  60752. path: Vector3[];
  60753. radius?: number;
  60754. tessellation?: number;
  60755. radiusFunction?: {
  60756. (i: number, distance: number): number;
  60757. };
  60758. cap?: number;
  60759. arc?: number;
  60760. updatable?: boolean;
  60761. sideOrientation?: number;
  60762. frontUVs?: Vector4;
  60763. backUVs?: Vector4;
  60764. instance?: Mesh;
  60765. invertUV?: boolean;
  60766. }, scene?: Nullable<Scene>): Mesh;
  60767. /**
  60768. * Creates a polyhedron mesh
  60769. * * 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
  60770. * * The parameter `size` (positive float, default 1) sets the polygon size
  60771. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60772. * * 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`
  60773. * * 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
  60774. * * 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)`)
  60775. * * 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
  60776. * * 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
  60777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60780. * @param name defines the name of the mesh
  60781. * @param options defines the options used to create the mesh
  60782. * @param scene defines the hosting scene
  60783. * @returns the polyhedron mesh
  60784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60785. */
  60786. static CreatePolyhedron(name: string, options: {
  60787. type?: number;
  60788. size?: number;
  60789. sizeX?: number;
  60790. sizeY?: number;
  60791. sizeZ?: number;
  60792. custom?: any;
  60793. faceUV?: Vector4[];
  60794. faceColors?: Color4[];
  60795. flat?: boolean;
  60796. updatable?: boolean;
  60797. sideOrientation?: number;
  60798. frontUVs?: Vector4;
  60799. backUVs?: Vector4;
  60800. }, scene?: Nullable<Scene>): Mesh;
  60801. /**
  60802. * Creates a decal mesh.
  60803. * 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
  60804. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60805. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60806. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60807. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60808. * @param name defines the name of the mesh
  60809. * @param sourceMesh defines the mesh where the decal must be applied
  60810. * @param options defines the options used to create the mesh
  60811. * @param scene defines the hosting scene
  60812. * @returns the decal mesh
  60813. * @see https://doc.babylonjs.com/how_to/decals
  60814. */
  60815. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60816. position?: Vector3;
  60817. normal?: Vector3;
  60818. size?: Vector3;
  60819. angle?: number;
  60820. }): Mesh;
  60821. }
  60822. }
  60823. declare module "babylonjs/Meshes/meshSimplification" {
  60824. import { Mesh } from "babylonjs/Meshes/mesh";
  60825. /**
  60826. * A simplifier interface for future simplification implementations
  60827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60828. */
  60829. export interface ISimplifier {
  60830. /**
  60831. * Simplification of a given mesh according to the given settings.
  60832. * Since this requires computation, it is assumed that the function runs async.
  60833. * @param settings The settings of the simplification, including quality and distance
  60834. * @param successCallback A callback that will be called after the mesh was simplified.
  60835. * @param errorCallback in case of an error, this callback will be called. optional.
  60836. */
  60837. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60838. }
  60839. /**
  60840. * Expected simplification settings.
  60841. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60843. */
  60844. export interface ISimplificationSettings {
  60845. /**
  60846. * Gets or sets the expected quality
  60847. */
  60848. quality: number;
  60849. /**
  60850. * Gets or sets the distance when this optimized version should be used
  60851. */
  60852. distance: number;
  60853. /**
  60854. * Gets an already optimized mesh
  60855. */
  60856. optimizeMesh?: boolean;
  60857. }
  60858. /**
  60859. * Class used to specify simplification options
  60860. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60861. */
  60862. export class SimplificationSettings implements ISimplificationSettings {
  60863. /** expected quality */
  60864. quality: number;
  60865. /** distance when this optimized version should be used */
  60866. distance: number;
  60867. /** already optimized mesh */
  60868. optimizeMesh?: boolean | undefined;
  60869. /**
  60870. * Creates a SimplificationSettings
  60871. * @param quality expected quality
  60872. * @param distance distance when this optimized version should be used
  60873. * @param optimizeMesh already optimized mesh
  60874. */
  60875. constructor(
  60876. /** expected quality */
  60877. quality: number,
  60878. /** distance when this optimized version should be used */
  60879. distance: number,
  60880. /** already optimized mesh */
  60881. optimizeMesh?: boolean | undefined);
  60882. }
  60883. /**
  60884. * Interface used to define a simplification task
  60885. */
  60886. export interface ISimplificationTask {
  60887. /**
  60888. * Array of settings
  60889. */
  60890. settings: Array<ISimplificationSettings>;
  60891. /**
  60892. * Simplification type
  60893. */
  60894. simplificationType: SimplificationType;
  60895. /**
  60896. * Mesh to simplify
  60897. */
  60898. mesh: Mesh;
  60899. /**
  60900. * Callback called on success
  60901. */
  60902. successCallback?: () => void;
  60903. /**
  60904. * Defines if parallel processing can be used
  60905. */
  60906. parallelProcessing: boolean;
  60907. }
  60908. /**
  60909. * Queue used to order the simplification tasks
  60910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60911. */
  60912. export class SimplificationQueue {
  60913. private _simplificationArray;
  60914. /**
  60915. * Gets a boolean indicating that the process is still running
  60916. */
  60917. running: boolean;
  60918. /**
  60919. * Creates a new queue
  60920. */
  60921. constructor();
  60922. /**
  60923. * Adds a new simplification task
  60924. * @param task defines a task to add
  60925. */
  60926. addTask(task: ISimplificationTask): void;
  60927. /**
  60928. * Execute next task
  60929. */
  60930. executeNext(): void;
  60931. /**
  60932. * Execute a simplification task
  60933. * @param task defines the task to run
  60934. */
  60935. runSimplification(task: ISimplificationTask): void;
  60936. private getSimplifier;
  60937. }
  60938. /**
  60939. * The implemented types of simplification
  60940. * At the moment only Quadratic Error Decimation is implemented
  60941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60942. */
  60943. export enum SimplificationType {
  60944. /** Quadratic error decimation */
  60945. QUADRATIC = 0
  60946. }
  60947. }
  60948. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60949. import { Scene } from "babylonjs/scene";
  60950. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60951. import { ISceneComponent } from "babylonjs/sceneComponent";
  60952. module "babylonjs/scene" {
  60953. interface Scene {
  60954. /** @hidden (Backing field) */
  60955. _simplificationQueue: SimplificationQueue;
  60956. /**
  60957. * Gets or sets the simplification queue attached to the scene
  60958. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60959. */
  60960. simplificationQueue: SimplificationQueue;
  60961. }
  60962. }
  60963. module "babylonjs/Meshes/mesh" {
  60964. interface Mesh {
  60965. /**
  60966. * Simplify the mesh according to the given array of settings.
  60967. * Function will return immediately and will simplify async
  60968. * @param settings a collection of simplification settings
  60969. * @param parallelProcessing should all levels calculate parallel or one after the other
  60970. * @param simplificationType the type of simplification to run
  60971. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60972. * @returns the current mesh
  60973. */
  60974. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60975. }
  60976. }
  60977. /**
  60978. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60979. * created in a scene
  60980. */
  60981. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60982. /**
  60983. * The component name helpfull to identify the component in the list of scene components.
  60984. */
  60985. readonly name: string;
  60986. /**
  60987. * The scene the component belongs to.
  60988. */
  60989. scene: Scene;
  60990. /**
  60991. * Creates a new instance of the component for the given scene
  60992. * @param scene Defines the scene to register the component in
  60993. */
  60994. constructor(scene: Scene);
  60995. /**
  60996. * Registers the component in a given scene
  60997. */
  60998. register(): void;
  60999. /**
  61000. * Rebuilds the elements related to this component in case of
  61001. * context lost for instance.
  61002. */
  61003. rebuild(): void;
  61004. /**
  61005. * Disposes the component and the associated ressources
  61006. */
  61007. dispose(): void;
  61008. private _beforeCameraUpdate;
  61009. }
  61010. }
  61011. declare module "babylonjs/Meshes/Builders/index" {
  61012. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61013. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61014. export * from "babylonjs/Meshes/Builders/discBuilder";
  61015. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61016. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61017. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61018. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61019. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61020. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61021. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61022. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61023. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61024. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61025. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61026. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61027. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61028. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61029. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61030. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61031. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61032. }
  61033. declare module "babylonjs/Meshes/index" {
  61034. export * from "babylonjs/Meshes/abstractMesh";
  61035. export * from "babylonjs/Meshes/buffer";
  61036. export * from "babylonjs/Meshes/Compression/index";
  61037. export * from "babylonjs/Meshes/csg";
  61038. export * from "babylonjs/Meshes/geometry";
  61039. export * from "babylonjs/Meshes/groundMesh";
  61040. export * from "babylonjs/Meshes/trailMesh";
  61041. export * from "babylonjs/Meshes/instancedMesh";
  61042. export * from "babylonjs/Meshes/linesMesh";
  61043. export * from "babylonjs/Meshes/mesh";
  61044. export * from "babylonjs/Meshes/mesh.vertexData";
  61045. export * from "babylonjs/Meshes/meshBuilder";
  61046. export * from "babylonjs/Meshes/meshSimplification";
  61047. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61048. export * from "babylonjs/Meshes/polygonMesh";
  61049. export * from "babylonjs/Meshes/subMesh";
  61050. export * from "babylonjs/Meshes/meshLODLevel";
  61051. export * from "babylonjs/Meshes/transformNode";
  61052. export * from "babylonjs/Meshes/Builders/index";
  61053. export * from "babylonjs/Meshes/dataBuffer";
  61054. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61055. }
  61056. declare module "babylonjs/Morph/index" {
  61057. export * from "babylonjs/Morph/morphTarget";
  61058. export * from "babylonjs/Morph/morphTargetManager";
  61059. }
  61060. declare module "babylonjs/Navigation/INavigationEngine" {
  61061. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61062. import { Vector3 } from "babylonjs/Maths/math";
  61063. import { Mesh } from "babylonjs/Meshes/mesh";
  61064. import { Scene } from "babylonjs/scene";
  61065. /**
  61066. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61067. */
  61068. export interface INavigationEnginePlugin {
  61069. /**
  61070. * plugin name
  61071. */
  61072. name: string;
  61073. /**
  61074. * Creates a navigation mesh
  61075. * @param meshes array of all the geometry used to compute the navigatio mesh
  61076. * @param parameters bunch of parameters used to filter geometry
  61077. */
  61078. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61079. /**
  61080. * Create a navigation mesh debug mesh
  61081. * @param scene is where the mesh will be added
  61082. * @returns debug display mesh
  61083. */
  61084. createDebugNavMesh(scene: Scene): Mesh;
  61085. /**
  61086. * Get a navigation mesh constrained position, closest to the parameter position
  61087. * @param position world position
  61088. * @returns the closest point to position constrained by the navigation mesh
  61089. */
  61090. getClosestPoint(position: Vector3): Vector3;
  61091. /**
  61092. * Get a navigation mesh constrained position, within a particular radius
  61093. * @param position world position
  61094. * @param maxRadius the maximum distance to the constrained world position
  61095. * @returns the closest point to position constrained by the navigation mesh
  61096. */
  61097. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61098. /**
  61099. * Compute the final position from a segment made of destination-position
  61100. * @param position world position
  61101. * @param destination world position
  61102. * @returns the resulting point along the navmesh
  61103. */
  61104. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61105. /**
  61106. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61107. * @param start world position
  61108. * @param end world position
  61109. * @returns array containing world position composing the path
  61110. */
  61111. computePath(start: Vector3, end: Vector3): Vector3[];
  61112. /**
  61113. * If this plugin is supported
  61114. * @returns true if plugin is supported
  61115. */
  61116. isSupported(): boolean;
  61117. /**
  61118. * Create a new Crowd so you can add agents
  61119. * @param maxAgents the maximum agent count in the crowd
  61120. * @param maxAgentRadius the maximum radius an agent can have
  61121. * @param scene to attach the crowd to
  61122. * @returns the crowd you can add agents to
  61123. */
  61124. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61125. /**
  61126. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61127. * The queries will try to find a solution within those bounds
  61128. * default is (1,1,1)
  61129. * @param extent x,y,z value that define the extent around the queries point of reference
  61130. */
  61131. setDefaultQueryExtent(extent: Vector3): void;
  61132. /**
  61133. * Get the Bounding box extent specified by setDefaultQueryExtent
  61134. * @returns the box extent values
  61135. */
  61136. getDefaultQueryExtent(): Vector3;
  61137. /**
  61138. * Release all resources
  61139. */
  61140. dispose(): void;
  61141. }
  61142. /**
  61143. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61144. */
  61145. export interface ICrowd {
  61146. /**
  61147. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61148. * You can attach anything to that node. The node position is updated in the scene update tick.
  61149. * @param pos world position that will be constrained by the navigation mesh
  61150. * @param parameters agent parameters
  61151. * @param transform hooked to the agent that will be update by the scene
  61152. * @returns agent index
  61153. */
  61154. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61155. /**
  61156. * Returns the agent position in world space
  61157. * @param index agent index returned by addAgent
  61158. * @returns world space position
  61159. */
  61160. getAgentPosition(index: number): Vector3;
  61161. /**
  61162. * Gets the agent velocity in world space
  61163. * @param index agent index returned by addAgent
  61164. * @returns world space velocity
  61165. */
  61166. getAgentVelocity(index: number): Vector3;
  61167. /**
  61168. * remove a particular agent previously created
  61169. * @param index agent index returned by addAgent
  61170. */
  61171. removeAgent(index: number): void;
  61172. /**
  61173. * get the list of all agents attached to this crowd
  61174. * @returns list of agent indices
  61175. */
  61176. getAgents(): number[];
  61177. /**
  61178. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61179. * @param deltaTime in seconds
  61180. */
  61181. update(deltaTime: number): void;
  61182. /**
  61183. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61184. * @param index agent index returned by addAgent
  61185. * @param destination targeted world position
  61186. */
  61187. agentGoto(index: number, destination: Vector3): void;
  61188. /**
  61189. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61190. * The queries will try to find a solution within those bounds
  61191. * default is (1,1,1)
  61192. * @param extent x,y,z value that define the extent around the queries point of reference
  61193. */
  61194. setDefaultQueryExtent(extent: Vector3): void;
  61195. /**
  61196. * Get the Bounding box extent specified by setDefaultQueryExtent
  61197. * @returns the box extent values
  61198. */
  61199. getDefaultQueryExtent(): Vector3;
  61200. /**
  61201. * Release all resources
  61202. */
  61203. dispose(): void;
  61204. }
  61205. /**
  61206. * Configures an agent
  61207. */
  61208. export interface IAgentParameters {
  61209. /**
  61210. * Agent radius. [Limit: >= 0]
  61211. */
  61212. radius: number;
  61213. /**
  61214. * Agent height. [Limit: > 0]
  61215. */
  61216. height: number;
  61217. /**
  61218. * Maximum allowed acceleration. [Limit: >= 0]
  61219. */
  61220. maxAcceleration: number;
  61221. /**
  61222. * Maximum allowed speed. [Limit: >= 0]
  61223. */
  61224. maxSpeed: number;
  61225. /**
  61226. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61227. */
  61228. collisionQueryRange: number;
  61229. /**
  61230. * The path visibility optimization range. [Limit: > 0]
  61231. */
  61232. pathOptimizationRange: number;
  61233. /**
  61234. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61235. */
  61236. separationWeight: number;
  61237. }
  61238. /**
  61239. * Configures the navigation mesh creation
  61240. */
  61241. export interface INavMeshParameters {
  61242. /**
  61243. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61244. */
  61245. cs: number;
  61246. /**
  61247. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61248. */
  61249. ch: number;
  61250. /**
  61251. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61252. */
  61253. walkableSlopeAngle: number;
  61254. /**
  61255. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61256. * be considered walkable. [Limit: >= 3] [Units: vx]
  61257. */
  61258. walkableHeight: number;
  61259. /**
  61260. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61261. */
  61262. walkableClimb: number;
  61263. /**
  61264. * The distance to erode/shrink the walkable area of the heightfield away from
  61265. * obstructions. [Limit: >=0] [Units: vx]
  61266. */
  61267. walkableRadius: number;
  61268. /**
  61269. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61270. */
  61271. maxEdgeLen: number;
  61272. /**
  61273. * The maximum distance a simplfied contour's border edges should deviate
  61274. * the original raw contour. [Limit: >=0] [Units: vx]
  61275. */
  61276. maxSimplificationError: number;
  61277. /**
  61278. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61279. */
  61280. minRegionArea: number;
  61281. /**
  61282. * Any regions with a span count smaller than this value will, if possible,
  61283. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61284. */
  61285. mergeRegionArea: number;
  61286. /**
  61287. * The maximum number of vertices allowed for polygons generated during the
  61288. * contour to polygon conversion process. [Limit: >= 3]
  61289. */
  61290. maxVertsPerPoly: number;
  61291. /**
  61292. * Sets the sampling distance to use when generating the detail mesh.
  61293. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61294. */
  61295. detailSampleDist: number;
  61296. /**
  61297. * The maximum distance the detail mesh surface should deviate from heightfield
  61298. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61299. */
  61300. detailSampleMaxError: number;
  61301. }
  61302. }
  61303. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61304. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61305. import { Mesh } from "babylonjs/Meshes/mesh";
  61306. import { Scene } from "babylonjs/scene";
  61307. import { Vector3 } from "babylonjs/Maths/math";
  61308. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61309. /**
  61310. * RecastJS navigation plugin
  61311. */
  61312. export class RecastJSPlugin implements INavigationEnginePlugin {
  61313. /**
  61314. * Reference to the Recast library
  61315. */
  61316. bjsRECAST: any;
  61317. /**
  61318. * plugin name
  61319. */
  61320. name: string;
  61321. /**
  61322. * the first navmesh created. We might extend this to support multiple navmeshes
  61323. */
  61324. navMesh: any;
  61325. /**
  61326. * Initializes the recastJS plugin
  61327. * @param recastInjection can be used to inject your own recast reference
  61328. */
  61329. constructor(recastInjection?: any);
  61330. /**
  61331. * Creates a navigation mesh
  61332. * @param meshes array of all the geometry used to compute the navigatio mesh
  61333. * @param parameters bunch of parameters used to filter geometry
  61334. */
  61335. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61336. /**
  61337. * Create a navigation mesh debug mesh
  61338. * @param scene is where the mesh will be added
  61339. * @returns debug display mesh
  61340. */
  61341. createDebugNavMesh(scene: Scene): Mesh;
  61342. /**
  61343. * Get a navigation mesh constrained position, closest to the parameter position
  61344. * @param position world position
  61345. * @returns the closest point to position constrained by the navigation mesh
  61346. */
  61347. getClosestPoint(position: Vector3): Vector3;
  61348. /**
  61349. * Get a navigation mesh constrained position, within a particular radius
  61350. * @param position world position
  61351. * @param maxRadius the maximum distance to the constrained world position
  61352. * @returns the closest point to position constrained by the navigation mesh
  61353. */
  61354. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61355. /**
  61356. * Compute the final position from a segment made of destination-position
  61357. * @param position world position
  61358. * @param destination world position
  61359. * @returns the resulting point along the navmesh
  61360. */
  61361. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61362. /**
  61363. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61364. * @param start world position
  61365. * @param end world position
  61366. * @returns array containing world position composing the path
  61367. */
  61368. computePath(start: Vector3, end: Vector3): Vector3[];
  61369. /**
  61370. * Create a new Crowd so you can add agents
  61371. * @param maxAgents the maximum agent count in the crowd
  61372. * @param maxAgentRadius the maximum radius an agent can have
  61373. * @param scene to attach the crowd to
  61374. * @returns the crowd you can add agents to
  61375. */
  61376. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61377. /**
  61378. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61379. * The queries will try to find a solution within those bounds
  61380. * default is (1,1,1)
  61381. * @param extent x,y,z value that define the extent around the queries point of reference
  61382. */
  61383. setDefaultQueryExtent(extent: Vector3): void;
  61384. /**
  61385. * Get the Bounding box extent specified by setDefaultQueryExtent
  61386. * @returns the box extent values
  61387. */
  61388. getDefaultQueryExtent(): Vector3;
  61389. /**
  61390. * Disposes
  61391. */
  61392. dispose(): void;
  61393. /**
  61394. * If this plugin is supported
  61395. * @returns true if plugin is supported
  61396. */
  61397. isSupported(): boolean;
  61398. }
  61399. /**
  61400. * Recast detour crowd implementation
  61401. */
  61402. export class RecastJSCrowd implements ICrowd {
  61403. /**
  61404. * Recast/detour plugin
  61405. */
  61406. bjsRECASTPlugin: RecastJSPlugin;
  61407. /**
  61408. * Link to the detour crowd
  61409. */
  61410. recastCrowd: any;
  61411. /**
  61412. * One transform per agent
  61413. */
  61414. transforms: TransformNode[];
  61415. /**
  61416. * All agents created
  61417. */
  61418. agents: number[];
  61419. /**
  61420. * Link to the scene is kept to unregister the crowd from the scene
  61421. */
  61422. private _scene;
  61423. /**
  61424. * Observer for crowd updates
  61425. */
  61426. private _onBeforeAnimationsObserver;
  61427. /**
  61428. * Constructor
  61429. * @param plugin recastJS plugin
  61430. * @param maxAgents the maximum agent count in the crowd
  61431. * @param maxAgentRadius the maximum radius an agent can have
  61432. * @param scene to attach the crowd to
  61433. * @returns the crowd you can add agents to
  61434. */
  61435. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61436. /**
  61437. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61438. * You can attach anything to that node. The node position is updated in the scene update tick.
  61439. * @param pos world position that will be constrained by the navigation mesh
  61440. * @param parameters agent parameters
  61441. * @param transform hooked to the agent that will be update by the scene
  61442. * @returns agent index
  61443. */
  61444. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61445. /**
  61446. * Returns the agent position in world space
  61447. * @param index agent index returned by addAgent
  61448. * @returns world space position
  61449. */
  61450. getAgentPosition(index: number): Vector3;
  61451. /**
  61452. * Returns the agent velocity in world space
  61453. * @param index agent index returned by addAgent
  61454. * @returns world space velocity
  61455. */
  61456. getAgentVelocity(index: number): Vector3;
  61457. /**
  61458. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61459. * @param index agent index returned by addAgent
  61460. * @param destination targeted world position
  61461. */
  61462. agentGoto(index: number, destination: Vector3): void;
  61463. /**
  61464. * remove a particular agent previously created
  61465. * @param index agent index returned by addAgent
  61466. */
  61467. removeAgent(index: number): void;
  61468. /**
  61469. * get the list of all agents attached to this crowd
  61470. * @returns list of agent indices
  61471. */
  61472. getAgents(): number[];
  61473. /**
  61474. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61475. * @param deltaTime in seconds
  61476. */
  61477. update(deltaTime: number): void;
  61478. /**
  61479. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61480. * The queries will try to find a solution within those bounds
  61481. * default is (1,1,1)
  61482. * @param extent x,y,z value that define the extent around the queries point of reference
  61483. */
  61484. setDefaultQueryExtent(extent: Vector3): void;
  61485. /**
  61486. * Get the Bounding box extent specified by setDefaultQueryExtent
  61487. * @returns the box extent values
  61488. */
  61489. getDefaultQueryExtent(): Vector3;
  61490. /**
  61491. * Release all resources
  61492. */
  61493. dispose(): void;
  61494. }
  61495. }
  61496. declare module "babylonjs/Navigation/Plugins/index" {
  61497. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61498. }
  61499. declare module "babylonjs/Navigation/index" {
  61500. export * from "babylonjs/Navigation/INavigationEngine";
  61501. export * from "babylonjs/Navigation/Plugins/index";
  61502. }
  61503. declare module "babylonjs/Offline/database" {
  61504. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61505. /**
  61506. * Class used to enable access to IndexedDB
  61507. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61508. */
  61509. export class Database implements IOfflineProvider {
  61510. private _callbackManifestChecked;
  61511. private _currentSceneUrl;
  61512. private _db;
  61513. private _enableSceneOffline;
  61514. private _enableTexturesOffline;
  61515. private _manifestVersionFound;
  61516. private _mustUpdateRessources;
  61517. private _hasReachedQuota;
  61518. private _isSupported;
  61519. private _idbFactory;
  61520. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61521. private static IsUASupportingBlobStorage;
  61522. /**
  61523. * Gets a boolean indicating if Database storate is enabled (off by default)
  61524. */
  61525. static IDBStorageEnabled: boolean;
  61526. /**
  61527. * Gets a boolean indicating if scene must be saved in the database
  61528. */
  61529. readonly enableSceneOffline: boolean;
  61530. /**
  61531. * Gets a boolean indicating if textures must be saved in the database
  61532. */
  61533. readonly enableTexturesOffline: boolean;
  61534. /**
  61535. * Creates a new Database
  61536. * @param urlToScene defines the url to load the scene
  61537. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61538. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61539. */
  61540. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61541. private static _ParseURL;
  61542. private static _ReturnFullUrlLocation;
  61543. private _checkManifestFile;
  61544. /**
  61545. * Open the database and make it available
  61546. * @param successCallback defines the callback to call on success
  61547. * @param errorCallback defines the callback to call on error
  61548. */
  61549. open(successCallback: () => void, errorCallback: () => void): void;
  61550. /**
  61551. * Loads an image from the database
  61552. * @param url defines the url to load from
  61553. * @param image defines the target DOM image
  61554. */
  61555. loadImage(url: string, image: HTMLImageElement): void;
  61556. private _loadImageFromDBAsync;
  61557. private _saveImageIntoDBAsync;
  61558. private _checkVersionFromDB;
  61559. private _loadVersionFromDBAsync;
  61560. private _saveVersionIntoDBAsync;
  61561. /**
  61562. * Loads a file from database
  61563. * @param url defines the URL to load from
  61564. * @param sceneLoaded defines a callback to call on success
  61565. * @param progressCallBack defines a callback to call when progress changed
  61566. * @param errorCallback defines a callback to call on error
  61567. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61568. */
  61569. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61570. private _loadFileAsync;
  61571. private _saveFileAsync;
  61572. /**
  61573. * Validates if xhr data is correct
  61574. * @param xhr defines the request to validate
  61575. * @param dataType defines the expected data type
  61576. * @returns true if data is correct
  61577. */
  61578. private static _ValidateXHRData;
  61579. }
  61580. }
  61581. declare module "babylonjs/Offline/index" {
  61582. export * from "babylonjs/Offline/database";
  61583. export * from "babylonjs/Offline/IOfflineProvider";
  61584. }
  61585. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61586. /** @hidden */
  61587. export var gpuUpdateParticlesPixelShader: {
  61588. name: string;
  61589. shader: string;
  61590. };
  61591. }
  61592. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61593. /** @hidden */
  61594. export var gpuUpdateParticlesVertexShader: {
  61595. name: string;
  61596. shader: string;
  61597. };
  61598. }
  61599. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61600. /** @hidden */
  61601. export var clipPlaneFragmentDeclaration2: {
  61602. name: string;
  61603. shader: string;
  61604. };
  61605. }
  61606. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61608. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61610. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61611. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61612. /** @hidden */
  61613. export var gpuRenderParticlesPixelShader: {
  61614. name: string;
  61615. shader: string;
  61616. };
  61617. }
  61618. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61619. /** @hidden */
  61620. export var clipPlaneVertexDeclaration2: {
  61621. name: string;
  61622. shader: string;
  61623. };
  61624. }
  61625. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61626. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61627. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61628. /** @hidden */
  61629. export var gpuRenderParticlesVertexShader: {
  61630. name: string;
  61631. shader: string;
  61632. };
  61633. }
  61634. declare module "babylonjs/Particles/gpuParticleSystem" {
  61635. import { Nullable } from "babylonjs/types";
  61636. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61637. import { Observable } from "babylonjs/Misc/observable";
  61638. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61639. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61640. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61641. import { Scene, IDisposable } from "babylonjs/scene";
  61642. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61643. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61644. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61645. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61646. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61647. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61648. /**
  61649. * This represents a GPU particle system in Babylon
  61650. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61651. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61652. */
  61653. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61654. /**
  61655. * The layer mask we are rendering the particles through.
  61656. */
  61657. layerMask: number;
  61658. private _capacity;
  61659. private _activeCount;
  61660. private _currentActiveCount;
  61661. private _accumulatedCount;
  61662. private _renderEffect;
  61663. private _updateEffect;
  61664. private _buffer0;
  61665. private _buffer1;
  61666. private _spriteBuffer;
  61667. private _updateVAO;
  61668. private _renderVAO;
  61669. private _targetIndex;
  61670. private _sourceBuffer;
  61671. private _targetBuffer;
  61672. private _engine;
  61673. private _currentRenderId;
  61674. private _started;
  61675. private _stopped;
  61676. private _timeDelta;
  61677. private _randomTexture;
  61678. private _randomTexture2;
  61679. private _attributesStrideSize;
  61680. private _updateEffectOptions;
  61681. private _randomTextureSize;
  61682. private _actualFrame;
  61683. private readonly _rawTextureWidth;
  61684. /**
  61685. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61686. */
  61687. static readonly IsSupported: boolean;
  61688. /**
  61689. * An event triggered when the system is disposed.
  61690. */
  61691. onDisposeObservable: Observable<GPUParticleSystem>;
  61692. /**
  61693. * Gets the maximum number of particles active at the same time.
  61694. * @returns The max number of active particles.
  61695. */
  61696. getCapacity(): number;
  61697. /**
  61698. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61699. * to override the particles.
  61700. */
  61701. forceDepthWrite: boolean;
  61702. /**
  61703. * Gets or set the number of active particles
  61704. */
  61705. activeParticleCount: number;
  61706. private _preWarmDone;
  61707. /**
  61708. * Is this system ready to be used/rendered
  61709. * @return true if the system is ready
  61710. */
  61711. isReady(): boolean;
  61712. /**
  61713. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61714. * @returns True if it has been started, otherwise false.
  61715. */
  61716. isStarted(): boolean;
  61717. /**
  61718. * Starts the particle system and begins to emit
  61719. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61720. */
  61721. start(delay?: number): void;
  61722. /**
  61723. * Stops the particle system.
  61724. */
  61725. stop(): void;
  61726. /**
  61727. * Remove all active particles
  61728. */
  61729. reset(): void;
  61730. /**
  61731. * Returns the string "GPUParticleSystem"
  61732. * @returns a string containing the class name
  61733. */
  61734. getClassName(): string;
  61735. private _colorGradientsTexture;
  61736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61737. /**
  61738. * Adds a new color gradient
  61739. * @param gradient defines the gradient to use (between 0 and 1)
  61740. * @param color1 defines the color to affect to the specified gradient
  61741. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61742. * @returns the current particle system
  61743. */
  61744. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61745. /**
  61746. * Remove a specific color gradient
  61747. * @param gradient defines the gradient to remove
  61748. * @returns the current particle system
  61749. */
  61750. removeColorGradient(gradient: number): GPUParticleSystem;
  61751. private _angularSpeedGradientsTexture;
  61752. private _sizeGradientsTexture;
  61753. private _velocityGradientsTexture;
  61754. private _limitVelocityGradientsTexture;
  61755. private _dragGradientsTexture;
  61756. private _addFactorGradient;
  61757. /**
  61758. * Adds a new size gradient
  61759. * @param gradient defines the gradient to use (between 0 and 1)
  61760. * @param factor defines the size factor to affect to the specified gradient
  61761. * @returns the current particle system
  61762. */
  61763. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61764. /**
  61765. * Remove a specific size gradient
  61766. * @param gradient defines the gradient to remove
  61767. * @returns the current particle system
  61768. */
  61769. removeSizeGradient(gradient: number): GPUParticleSystem;
  61770. /**
  61771. * Adds a new angular speed gradient
  61772. * @param gradient defines the gradient to use (between 0 and 1)
  61773. * @param factor defines the angular speed to affect to the specified gradient
  61774. * @returns the current particle system
  61775. */
  61776. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61777. /**
  61778. * Remove a specific angular speed gradient
  61779. * @param gradient defines the gradient to remove
  61780. * @returns the current particle system
  61781. */
  61782. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61783. /**
  61784. * Adds a new velocity gradient
  61785. * @param gradient defines the gradient to use (between 0 and 1)
  61786. * @param factor defines the velocity to affect to the specified gradient
  61787. * @returns the current particle system
  61788. */
  61789. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61790. /**
  61791. * Remove a specific velocity gradient
  61792. * @param gradient defines the gradient to remove
  61793. * @returns the current particle system
  61794. */
  61795. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61796. /**
  61797. * Adds a new limit velocity gradient
  61798. * @param gradient defines the gradient to use (between 0 and 1)
  61799. * @param factor defines the limit velocity value to affect to the specified gradient
  61800. * @returns the current particle system
  61801. */
  61802. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61803. /**
  61804. * Remove a specific limit velocity gradient
  61805. * @param gradient defines the gradient to remove
  61806. * @returns the current particle system
  61807. */
  61808. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61809. /**
  61810. * Adds a new drag gradient
  61811. * @param gradient defines the gradient to use (between 0 and 1)
  61812. * @param factor defines the drag value to affect to the specified gradient
  61813. * @returns the current particle system
  61814. */
  61815. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61816. /**
  61817. * Remove a specific drag gradient
  61818. * @param gradient defines the gradient to remove
  61819. * @returns the current particle system
  61820. */
  61821. removeDragGradient(gradient: number): GPUParticleSystem;
  61822. /**
  61823. * Not supported by GPUParticleSystem
  61824. * @param gradient defines the gradient to use (between 0 and 1)
  61825. * @param factor defines the emit rate value to affect to the specified gradient
  61826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61827. * @returns the current particle system
  61828. */
  61829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61830. /**
  61831. * Not supported by GPUParticleSystem
  61832. * @param gradient defines the gradient to remove
  61833. * @returns the current particle system
  61834. */
  61835. removeEmitRateGradient(gradient: number): IParticleSystem;
  61836. /**
  61837. * Not supported by GPUParticleSystem
  61838. * @param gradient defines the gradient to use (between 0 and 1)
  61839. * @param factor defines the start size value to affect to the specified gradient
  61840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61841. * @returns the current particle system
  61842. */
  61843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61844. /**
  61845. * Not supported by GPUParticleSystem
  61846. * @param gradient defines the gradient to remove
  61847. * @returns the current particle system
  61848. */
  61849. removeStartSizeGradient(gradient: number): IParticleSystem;
  61850. /**
  61851. * Not supported by GPUParticleSystem
  61852. * @param gradient defines the gradient to use (between 0 and 1)
  61853. * @param min defines the color remap minimal range
  61854. * @param max defines the color remap maximal range
  61855. * @returns the current particle system
  61856. */
  61857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61858. /**
  61859. * Not supported by GPUParticleSystem
  61860. * @param gradient defines the gradient to remove
  61861. * @returns the current particle system
  61862. */
  61863. removeColorRemapGradient(): IParticleSystem;
  61864. /**
  61865. * Not supported by GPUParticleSystem
  61866. * @param gradient defines the gradient to use (between 0 and 1)
  61867. * @param min defines the alpha remap minimal range
  61868. * @param max defines the alpha remap maximal range
  61869. * @returns the current particle system
  61870. */
  61871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61872. /**
  61873. * Not supported by GPUParticleSystem
  61874. * @param gradient defines the gradient to remove
  61875. * @returns the current particle system
  61876. */
  61877. removeAlphaRemapGradient(): IParticleSystem;
  61878. /**
  61879. * Not supported by GPUParticleSystem
  61880. * @param gradient defines the gradient to use (between 0 and 1)
  61881. * @param color defines the color to affect to the specified gradient
  61882. * @returns the current particle system
  61883. */
  61884. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61885. /**
  61886. * Not supported by GPUParticleSystem
  61887. * @param gradient defines the gradient to remove
  61888. * @returns the current particle system
  61889. */
  61890. removeRampGradient(): IParticleSystem;
  61891. /**
  61892. * Not supported by GPUParticleSystem
  61893. * @returns the list of ramp gradients
  61894. */
  61895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61896. /**
  61897. * Not supported by GPUParticleSystem
  61898. * Gets or sets a boolean indicating that ramp gradients must be used
  61899. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61900. */
  61901. useRampGradients: boolean;
  61902. /**
  61903. * Not supported by GPUParticleSystem
  61904. * @param gradient defines the gradient to use (between 0 and 1)
  61905. * @param factor defines the life time factor to affect to the specified gradient
  61906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61907. * @returns the current particle system
  61908. */
  61909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61910. /**
  61911. * Not supported by GPUParticleSystem
  61912. * @param gradient defines the gradient to remove
  61913. * @returns the current particle system
  61914. */
  61915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61916. /**
  61917. * Instantiates a GPU particle system.
  61918. * 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.
  61919. * @param name The name of the particle system
  61920. * @param options The options used to create the system
  61921. * @param scene The scene the particle system belongs to
  61922. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61923. */
  61924. constructor(name: string, options: Partial<{
  61925. capacity: number;
  61926. randomTextureSize: number;
  61927. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61928. protected _reset(): void;
  61929. private _createUpdateVAO;
  61930. private _createRenderVAO;
  61931. private _initialize;
  61932. /** @hidden */
  61933. _recreateUpdateEffect(): void;
  61934. /** @hidden */
  61935. _recreateRenderEffect(): void;
  61936. /**
  61937. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61938. * @param preWarm defines if we are in the pre-warmimg phase
  61939. */
  61940. animate(preWarm?: boolean): void;
  61941. private _createFactorGradientTexture;
  61942. private _createSizeGradientTexture;
  61943. private _createAngularSpeedGradientTexture;
  61944. private _createVelocityGradientTexture;
  61945. private _createLimitVelocityGradientTexture;
  61946. private _createDragGradientTexture;
  61947. private _createColorGradientTexture;
  61948. /**
  61949. * Renders the particle system in its current state
  61950. * @param preWarm defines if the system should only update the particles but not render them
  61951. * @returns the current number of particles
  61952. */
  61953. render(preWarm?: boolean): number;
  61954. /**
  61955. * Rebuilds the particle system
  61956. */
  61957. rebuild(): void;
  61958. private _releaseBuffers;
  61959. private _releaseVAOs;
  61960. /**
  61961. * Disposes the particle system and free the associated resources
  61962. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61963. */
  61964. dispose(disposeTexture?: boolean): void;
  61965. /**
  61966. * Clones the particle system.
  61967. * @param name The name of the cloned object
  61968. * @param newEmitter The new emitter to use
  61969. * @returns the cloned particle system
  61970. */
  61971. clone(name: string, newEmitter: any): GPUParticleSystem;
  61972. /**
  61973. * Serializes the particle system to a JSON object.
  61974. * @returns the JSON object
  61975. */
  61976. serialize(): any;
  61977. /**
  61978. * Parses a JSON object to create a GPU particle system.
  61979. * @param parsedParticleSystem The JSON object to parse
  61980. * @param scene The scene to create the particle system in
  61981. * @param rootUrl The root url to use to load external dependencies like texture
  61982. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61983. * @returns the parsed GPU particle system
  61984. */
  61985. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61986. }
  61987. }
  61988. declare module "babylonjs/Particles/particleSystemSet" {
  61989. import { Nullable } from "babylonjs/types";
  61990. import { Color3 } from "babylonjs/Maths/math.color";
  61991. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61994. import { Scene, IDisposable } from "babylonjs/scene";
  61995. /**
  61996. * Represents a set of particle systems working together to create a specific effect
  61997. */
  61998. export class ParticleSystemSet implements IDisposable {
  61999. /**
  62000. * Gets or sets base Assets URL
  62001. */
  62002. static BaseAssetsUrl: string;
  62003. private _emitterCreationOptions;
  62004. private _emitterNode;
  62005. /**
  62006. * Gets the particle system list
  62007. */
  62008. systems: IParticleSystem[];
  62009. /**
  62010. * Gets the emitter node used with this set
  62011. */
  62012. readonly emitterNode: Nullable<TransformNode>;
  62013. /**
  62014. * Creates a new emitter mesh as a sphere
  62015. * @param options defines the options used to create the sphere
  62016. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62017. * @param scene defines the hosting scene
  62018. */
  62019. setEmitterAsSphere(options: {
  62020. diameter: number;
  62021. segments: number;
  62022. color: Color3;
  62023. }, renderingGroupId: number, scene: Scene): void;
  62024. /**
  62025. * Starts all particle systems of the set
  62026. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62027. */
  62028. start(emitter?: AbstractMesh): void;
  62029. /**
  62030. * Release all associated resources
  62031. */
  62032. dispose(): void;
  62033. /**
  62034. * Serialize the set into a JSON compatible object
  62035. * @returns a JSON compatible representation of the set
  62036. */
  62037. serialize(): any;
  62038. /**
  62039. * Parse a new ParticleSystemSet from a serialized source
  62040. * @param data defines a JSON compatible representation of the set
  62041. * @param scene defines the hosting scene
  62042. * @param gpu defines if we want GPU particles or CPU particles
  62043. * @returns a new ParticleSystemSet
  62044. */
  62045. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62046. }
  62047. }
  62048. declare module "babylonjs/Particles/particleHelper" {
  62049. import { Nullable } from "babylonjs/types";
  62050. import { Scene } from "babylonjs/scene";
  62051. import { Vector3 } from "babylonjs/Maths/math.vector";
  62052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62053. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62054. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62055. /**
  62056. * This class is made for on one-liner static method to help creating particle system set.
  62057. */
  62058. export class ParticleHelper {
  62059. /**
  62060. * Gets or sets base Assets URL
  62061. */
  62062. static BaseAssetsUrl: string;
  62063. /**
  62064. * Create a default particle system that you can tweak
  62065. * @param emitter defines the emitter to use
  62066. * @param capacity defines the system capacity (default is 500 particles)
  62067. * @param scene defines the hosting scene
  62068. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62069. * @returns the new Particle system
  62070. */
  62071. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62072. /**
  62073. * This is the main static method (one-liner) of this helper to create different particle systems
  62074. * @param type This string represents the type to the particle system to create
  62075. * @param scene The scene where the particle system should live
  62076. * @param gpu If the system will use gpu
  62077. * @returns the ParticleSystemSet created
  62078. */
  62079. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62080. /**
  62081. * Static function used to export a particle system to a ParticleSystemSet variable.
  62082. * Please note that the emitter shape is not exported
  62083. * @param systems defines the particle systems to export
  62084. * @returns the created particle system set
  62085. */
  62086. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62087. }
  62088. }
  62089. declare module "babylonjs/Particles/particleSystemComponent" {
  62090. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62091. import { Effect } from "babylonjs/Materials/effect";
  62092. import "babylonjs/Shaders/particles.vertex";
  62093. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62094. module "babylonjs/Engines/engine" {
  62095. interface Engine {
  62096. /**
  62097. * Create an effect to use with particle systems.
  62098. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62099. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62100. * @param uniformsNames defines a list of attribute names
  62101. * @param samplers defines an array of string used to represent textures
  62102. * @param defines defines the string containing the defines to use to compile the shaders
  62103. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62104. * @param onCompiled defines a function to call when the effect creation is successful
  62105. * @param onError defines a function to call when the effect creation has failed
  62106. * @returns the new Effect
  62107. */
  62108. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62109. }
  62110. }
  62111. module "babylonjs/Meshes/mesh" {
  62112. interface Mesh {
  62113. /**
  62114. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62115. * @returns an array of IParticleSystem
  62116. */
  62117. getEmittedParticleSystems(): IParticleSystem[];
  62118. /**
  62119. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62120. * @returns an array of IParticleSystem
  62121. */
  62122. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62123. }
  62124. }
  62125. /**
  62126. * @hidden
  62127. */
  62128. export var _IDoNeedToBeInTheBuild: number;
  62129. }
  62130. declare module "babylonjs/Particles/pointsCloudSystem" {
  62131. import { Color4 } from "babylonjs/Maths/math";
  62132. import { Mesh } from "babylonjs/Meshes/mesh";
  62133. import { Scene, IDisposable } from "babylonjs/scene";
  62134. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62135. /** Defines the 4 color options */
  62136. export enum PointColor {
  62137. /** color value */
  62138. Color = 2,
  62139. /** uv value */
  62140. UV = 1,
  62141. /** random value */
  62142. Random = 0,
  62143. /** stated value */
  62144. Stated = 3
  62145. }
  62146. /**
  62147. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62148. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  62149. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62150. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62151. *
  62152. * Full documentation here : TO BE ENTERED
  62153. */
  62154. export class PointsCloudSystem implements IDisposable {
  62155. /**
  62156. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62157. * Example : var p = SPS.particles[i];
  62158. */
  62159. particles: CloudPoint[];
  62160. /**
  62161. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62162. */
  62163. nbParticles: number;
  62164. /**
  62165. * This a counter for your own usage. It's not set by any SPS functions.
  62166. */
  62167. counter: number;
  62168. /**
  62169. * The PCS name. This name is also given to the underlying mesh.
  62170. */
  62171. name: string;
  62172. /**
  62173. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62174. */
  62175. mesh: Mesh;
  62176. /**
  62177. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62178. * Please read :
  62179. */
  62180. vars: any;
  62181. /**
  62182. * @hidden
  62183. */
  62184. _size: number;
  62185. private _scene;
  62186. private _promises;
  62187. private _positions;
  62188. private _indices;
  62189. private _normals;
  62190. private _colors;
  62191. private _uvs;
  62192. private _indices32;
  62193. private _positions32;
  62194. private _colors32;
  62195. private _uvs32;
  62196. private _updatable;
  62197. private _isVisibilityBoxLocked;
  62198. private _alwaysVisible;
  62199. private _groups;
  62200. private _groupCounter;
  62201. private _computeParticleColor;
  62202. private _computeParticleTexture;
  62203. private _computeParticleRotation;
  62204. private _computeBoundingBox;
  62205. private _isReady;
  62206. /**
  62207. * Creates a PCS (Points Cloud System) object
  62208. * @param name (String) is the PCS name, this will be the underlying mesh name
  62209. * @param pointSize (number) is the size for each point
  62210. * @param scene (Scene) is the scene in which the PCS is added
  62211. * @param options defines the options of the PCS e.g.
  62212. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62213. */
  62214. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62215. updatable?: boolean;
  62216. });
  62217. /**
  62218. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62219. * If no points were added to the PCS, the returned mesh is just a single point.
  62220. * @returns a promise for the created mesh
  62221. */
  62222. buildMeshAsync(): Promise<Mesh>;
  62223. /**
  62224. * @hidden
  62225. */
  62226. private _buildMesh;
  62227. private _addParticle;
  62228. private _randomUnitVector;
  62229. private _getColorIndicesForCoord;
  62230. private _setPointsColorOrUV;
  62231. private _colorFromTexture;
  62232. private _calculateDensity;
  62233. /**
  62234. * Adds points to the PCS in random positions within a unit sphere
  62235. * @param nb (positive integer) the number of particles to be created from this model
  62236. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62237. * @returns the number of groups in the system
  62238. */
  62239. addPoints(nb: number, pointFunction?: any): number;
  62240. /**
  62241. * Adds points to the PCS from the surface of the model shape
  62242. * @param mesh is any Mesh object that will be used as a surface model for the points
  62243. * @param nb (positive integer) the number of particles to be created from this model
  62244. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62245. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62246. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62247. * @returns the number of groups in the system
  62248. */
  62249. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62250. /**
  62251. * Adds points to the PCS inside the model shape
  62252. * @param mesh is any Mesh object that will be used as a surface model for the points
  62253. * @param nb (positive integer) the number of particles to be created from this model
  62254. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62255. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62256. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62257. * @returns the number of groups in the system
  62258. */
  62259. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62260. /**
  62261. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62262. * This method calls `updateParticle()` for each particle of the SPS.
  62263. * For an animated SPS, it is usually called within the render loop.
  62264. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62265. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62266. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62267. * @returns the PCS.
  62268. */
  62269. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62270. /**
  62271. * Disposes the PCS.
  62272. */
  62273. dispose(): void;
  62274. /**
  62275. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62276. * doc :
  62277. * @returns the PCS.
  62278. */
  62279. refreshVisibleSize(): PointsCloudSystem;
  62280. /**
  62281. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62282. * @param size the size (float) of the visibility box
  62283. * note : this doesn't lock the PCS mesh bounding box.
  62284. * doc :
  62285. */
  62286. setVisibilityBox(size: number): void;
  62287. /**
  62288. * Gets whether the PCS is always visible or not
  62289. * doc :
  62290. */
  62291. /**
  62292. * Sets the PCS as always visible or not
  62293. * doc :
  62294. */
  62295. isAlwaysVisible: boolean;
  62296. /**
  62297. * Tells to `setParticles()` to compute the particle rotations or not
  62298. * Default value : false. The PCS is faster when it's set to false
  62299. * Note : particle rotations are only applied to parent particles
  62300. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62301. */
  62302. computeParticleRotation: boolean;
  62303. /**
  62304. * Tells to `setParticles()` to compute the particle colors or not.
  62305. * Default value : true. The PCS is faster when it's set to false.
  62306. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62307. */
  62308. /**
  62309. * Gets if `setParticles()` computes the particle colors or not.
  62310. * Default value : false. The PCS is faster when it's set to false.
  62311. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62312. */
  62313. computeParticleColor: boolean;
  62314. /**
  62315. * Gets if `setParticles()` computes the particle textures or not.
  62316. * Default value : false. The PCS is faster when it's set to false.
  62317. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62318. */
  62319. computeParticleTexture: boolean;
  62320. /**
  62321. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62322. */
  62323. /**
  62324. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62325. */
  62326. computeBoundingBox: boolean;
  62327. /**
  62328. * This function does nothing. It may be overwritten to set all the particle first values.
  62329. * The PCS doesn't call this function, you may have to call it by your own.
  62330. * doc :
  62331. */
  62332. initParticles(): void;
  62333. /**
  62334. * This function does nothing. It may be overwritten to recycle a particle
  62335. * The PCS doesn't call this function, you can to call it
  62336. * doc :
  62337. * @param particle The particle to recycle
  62338. * @returns the recycled particle
  62339. */
  62340. recycleParticle(particle: CloudPoint): CloudPoint;
  62341. /**
  62342. * Updates a particle : this function should be overwritten by the user.
  62343. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62344. * doc :
  62345. * @example : just set a particle position or velocity and recycle conditions
  62346. * @param particle The particle to update
  62347. * @returns the updated particle
  62348. */
  62349. updateParticle(particle: CloudPoint): CloudPoint;
  62350. /**
  62351. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62352. * This does nothing and may be overwritten by the user.
  62353. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62354. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62355. * @param update the boolean update value actually passed to setParticles()
  62356. */
  62357. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62358. /**
  62359. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62360. * This will be passed three parameters.
  62361. * This does nothing and may be overwritten by the user.
  62362. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62363. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62364. * @param update the boolean update value actually passed to setParticles()
  62365. */
  62366. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62367. }
  62368. }
  62369. declare module "babylonjs/Particles/cloudPoint" {
  62370. import { Nullable } from "babylonjs/types";
  62371. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62372. import { Mesh } from "babylonjs/Meshes/mesh";
  62373. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62374. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62375. /**
  62376. * Represents one particle of a points cloud system.
  62377. */
  62378. export class CloudPoint {
  62379. /**
  62380. * particle global index
  62381. */
  62382. idx: number;
  62383. /**
  62384. * The color of the particle
  62385. */
  62386. color: Nullable<Color4>;
  62387. /**
  62388. * The world space position of the particle.
  62389. */
  62390. position: Vector3;
  62391. /**
  62392. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62393. */
  62394. rotation: Vector3;
  62395. /**
  62396. * The world space rotation quaternion of the particle.
  62397. */
  62398. rotationQuaternion: Nullable<Quaternion>;
  62399. /**
  62400. * The uv of the particle.
  62401. */
  62402. uv: Nullable<Vector2>;
  62403. /**
  62404. * The current speed of the particle.
  62405. */
  62406. velocity: Vector3;
  62407. /**
  62408. * The pivot point in the particle local space.
  62409. */
  62410. pivot: Vector3;
  62411. /**
  62412. * Must the particle be translated from its pivot point in its local space ?
  62413. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62414. * Default : false
  62415. */
  62416. translateFromPivot: boolean;
  62417. /**
  62418. * Index of this particle in the global "positions" array (Internal use)
  62419. * @hidden
  62420. */
  62421. _pos: number;
  62422. /**
  62423. * @hidden Index of this particle in the global "indices" array (Internal use)
  62424. */
  62425. _ind: number;
  62426. /**
  62427. * Group this particle belongs to
  62428. */
  62429. _group: PointsGroup;
  62430. /**
  62431. * Group id of this particle
  62432. */
  62433. groupId: number;
  62434. /**
  62435. * Index of the particle in its group id (Internal use)
  62436. */
  62437. idxInGroup: number;
  62438. /**
  62439. * @hidden Particle BoundingInfo object (Internal use)
  62440. */
  62441. _boundingInfo: BoundingInfo;
  62442. /**
  62443. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62444. */
  62445. _pcs: PointsCloudSystem;
  62446. /**
  62447. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62448. */
  62449. _stillInvisible: boolean;
  62450. /**
  62451. * @hidden Last computed particle rotation matrix
  62452. */
  62453. _rotationMatrix: number[];
  62454. /**
  62455. * Parent particle Id, if any.
  62456. * Default null.
  62457. */
  62458. parentId: Nullable<number>;
  62459. /**
  62460. * @hidden Internal global position in the PCS.
  62461. */
  62462. _globalPosition: Vector3;
  62463. /**
  62464. * Creates a Point Cloud object.
  62465. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62466. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62467. * @param group (PointsGroup) is the group the particle belongs to
  62468. * @param groupId (integer) is the group identifier in the PCS.
  62469. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62470. * @param pcs defines the PCS it is associated to
  62471. */
  62472. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62473. /**
  62474. * get point size
  62475. */
  62476. /**
  62477. * Set point size
  62478. */
  62479. size: Vector3;
  62480. /**
  62481. * Legacy support, changed quaternion to rotationQuaternion
  62482. */
  62483. /**
  62484. * Legacy support, changed quaternion to rotationQuaternion
  62485. */
  62486. quaternion: Nullable<Quaternion>;
  62487. /**
  62488. * Returns a boolean. True if the particle intersects a mesh, else false
  62489. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62490. * @param target is the object (point or mesh) what the intersection is computed against
  62491. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62492. * @returns true if it intersects
  62493. */
  62494. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62495. /**
  62496. * get the rotation matrix of the particle
  62497. * @hidden
  62498. */
  62499. getRotationMatrix(m: Matrix): void;
  62500. }
  62501. /**
  62502. * Represents a group of points in a points cloud system
  62503. * * PCS internal tool, don't use it manually.
  62504. */
  62505. export class PointsGroup {
  62506. /**
  62507. * The group id
  62508. * @hidden
  62509. */
  62510. groupID: number;
  62511. /**
  62512. * image data for group (internal use)
  62513. * @hidden
  62514. */
  62515. _groupImageData: Nullable<ArrayBufferView>;
  62516. /**
  62517. * Image Width (internal use)
  62518. * @hidden
  62519. */
  62520. _groupImgWidth: number;
  62521. /**
  62522. * Image Height (internal use)
  62523. * @hidden
  62524. */
  62525. _groupImgHeight: number;
  62526. /**
  62527. * Custom position function (internal use)
  62528. * @hidden
  62529. */
  62530. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62531. /**
  62532. * density per facet for surface points
  62533. * @hidden
  62534. */
  62535. _groupDensity: number[];
  62536. /**
  62537. * Only when points are colored by texture carries pointer to texture list array
  62538. * @hidden
  62539. */
  62540. _textureNb: number;
  62541. /**
  62542. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62543. * PCS internal tool, don't use it manually.
  62544. * @hidden
  62545. */
  62546. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62547. }
  62548. }
  62549. declare module "babylonjs/Particles/index" {
  62550. export * from "babylonjs/Particles/baseParticleSystem";
  62551. export * from "babylonjs/Particles/EmitterTypes/index";
  62552. export * from "babylonjs/Particles/gpuParticleSystem";
  62553. export * from "babylonjs/Particles/IParticleSystem";
  62554. export * from "babylonjs/Particles/particle";
  62555. export * from "babylonjs/Particles/particleHelper";
  62556. export * from "babylonjs/Particles/particleSystem";
  62557. export * from "babylonjs/Particles/particleSystemComponent";
  62558. export * from "babylonjs/Particles/particleSystemSet";
  62559. export * from "babylonjs/Particles/solidParticle";
  62560. export * from "babylonjs/Particles/solidParticleSystem";
  62561. export * from "babylonjs/Particles/cloudPoint";
  62562. export * from "babylonjs/Particles/pointsCloudSystem";
  62563. export * from "babylonjs/Particles/subEmitter";
  62564. }
  62565. declare module "babylonjs/Physics/physicsEngineComponent" {
  62566. import { Nullable } from "babylonjs/types";
  62567. import { Observable, Observer } from "babylonjs/Misc/observable";
  62568. import { Vector3 } from "babylonjs/Maths/math.vector";
  62569. import { Mesh } from "babylonjs/Meshes/mesh";
  62570. import { ISceneComponent } from "babylonjs/sceneComponent";
  62571. import { Scene } from "babylonjs/scene";
  62572. import { Node } from "babylonjs/node";
  62573. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62574. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62575. module "babylonjs/scene" {
  62576. interface Scene {
  62577. /** @hidden (Backing field) */
  62578. _physicsEngine: Nullable<IPhysicsEngine>;
  62579. /**
  62580. * Gets the current physics engine
  62581. * @returns a IPhysicsEngine or null if none attached
  62582. */
  62583. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62584. /**
  62585. * Enables physics to the current scene
  62586. * @param gravity defines the scene's gravity for the physics engine
  62587. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62588. * @return a boolean indicating if the physics engine was initialized
  62589. */
  62590. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62591. /**
  62592. * Disables and disposes the physics engine associated with the scene
  62593. */
  62594. disablePhysicsEngine(): void;
  62595. /**
  62596. * Gets a boolean indicating if there is an active physics engine
  62597. * @returns a boolean indicating if there is an active physics engine
  62598. */
  62599. isPhysicsEnabled(): boolean;
  62600. /**
  62601. * Deletes a physics compound impostor
  62602. * @param compound defines the compound to delete
  62603. */
  62604. deleteCompoundImpostor(compound: any): void;
  62605. /**
  62606. * An event triggered when physic simulation is about to be run
  62607. */
  62608. onBeforePhysicsObservable: Observable<Scene>;
  62609. /**
  62610. * An event triggered when physic simulation has been done
  62611. */
  62612. onAfterPhysicsObservable: Observable<Scene>;
  62613. }
  62614. }
  62615. module "babylonjs/Meshes/abstractMesh" {
  62616. interface AbstractMesh {
  62617. /** @hidden */
  62618. _physicsImpostor: Nullable<PhysicsImpostor>;
  62619. /**
  62620. * Gets or sets impostor used for physic simulation
  62621. * @see http://doc.babylonjs.com/features/physics_engine
  62622. */
  62623. physicsImpostor: Nullable<PhysicsImpostor>;
  62624. /**
  62625. * Gets the current physics impostor
  62626. * @see http://doc.babylonjs.com/features/physics_engine
  62627. * @returns a physics impostor or null
  62628. */
  62629. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62630. /** Apply a physic impulse to the mesh
  62631. * @param force defines the force to apply
  62632. * @param contactPoint defines where to apply the force
  62633. * @returns the current mesh
  62634. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62635. */
  62636. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62637. /**
  62638. * Creates a physic joint between two meshes
  62639. * @param otherMesh defines the other mesh to use
  62640. * @param pivot1 defines the pivot to use on this mesh
  62641. * @param pivot2 defines the pivot to use on the other mesh
  62642. * @param options defines additional options (can be plugin dependent)
  62643. * @returns the current mesh
  62644. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62645. */
  62646. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62647. /** @hidden */
  62648. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62649. }
  62650. }
  62651. /**
  62652. * Defines the physics engine scene component responsible to manage a physics engine
  62653. */
  62654. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62655. /**
  62656. * The component name helpful to identify the component in the list of scene components.
  62657. */
  62658. readonly name: string;
  62659. /**
  62660. * The scene the component belongs to.
  62661. */
  62662. scene: Scene;
  62663. /**
  62664. * Creates a new instance of the component for the given scene
  62665. * @param scene Defines the scene to register the component in
  62666. */
  62667. constructor(scene: Scene);
  62668. /**
  62669. * Registers the component in a given scene
  62670. */
  62671. register(): void;
  62672. /**
  62673. * Rebuilds the elements related to this component in case of
  62674. * context lost for instance.
  62675. */
  62676. rebuild(): void;
  62677. /**
  62678. * Disposes the component and the associated ressources
  62679. */
  62680. dispose(): void;
  62681. }
  62682. }
  62683. declare module "babylonjs/Physics/physicsHelper" {
  62684. import { Nullable } from "babylonjs/types";
  62685. import { Vector3 } from "babylonjs/Maths/math.vector";
  62686. import { Mesh } from "babylonjs/Meshes/mesh";
  62687. import { Scene } from "babylonjs/scene";
  62688. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62689. /**
  62690. * A helper for physics simulations
  62691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62692. */
  62693. export class PhysicsHelper {
  62694. private _scene;
  62695. private _physicsEngine;
  62696. /**
  62697. * Initializes the Physics helper
  62698. * @param scene Babylon.js scene
  62699. */
  62700. constructor(scene: Scene);
  62701. /**
  62702. * Applies a radial explosion impulse
  62703. * @param origin the origin of the explosion
  62704. * @param radiusOrEventOptions the radius or the options of radial explosion
  62705. * @param strength the explosion strength
  62706. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62707. * @returns A physics radial explosion event, or null
  62708. */
  62709. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62710. /**
  62711. * Applies a radial explosion force
  62712. * @param origin the origin of the explosion
  62713. * @param radiusOrEventOptions the radius or the options of radial explosion
  62714. * @param strength the explosion strength
  62715. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62716. * @returns A physics radial explosion event, or null
  62717. */
  62718. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62719. /**
  62720. * Creates a gravitational field
  62721. * @param origin the origin of the explosion
  62722. * @param radiusOrEventOptions the radius or the options of radial explosion
  62723. * @param strength the explosion strength
  62724. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62725. * @returns A physics gravitational field event, or null
  62726. */
  62727. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62728. /**
  62729. * Creates a physics updraft event
  62730. * @param origin the origin of the updraft
  62731. * @param radiusOrEventOptions the radius or the options of the updraft
  62732. * @param strength the strength of the updraft
  62733. * @param height the height of the updraft
  62734. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62735. * @returns A physics updraft event, or null
  62736. */
  62737. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62738. /**
  62739. * Creates a physics vortex event
  62740. * @param origin the of the vortex
  62741. * @param radiusOrEventOptions the radius or the options of the vortex
  62742. * @param strength the strength of the vortex
  62743. * @param height the height of the vortex
  62744. * @returns a Physics vortex event, or null
  62745. * A physics vortex event or null
  62746. */
  62747. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62748. }
  62749. /**
  62750. * Represents a physics radial explosion event
  62751. */
  62752. class PhysicsRadialExplosionEvent {
  62753. private _scene;
  62754. private _options;
  62755. private _sphere;
  62756. private _dataFetched;
  62757. /**
  62758. * Initializes a radial explosioin event
  62759. * @param _scene BabylonJS scene
  62760. * @param _options The options for the vortex event
  62761. */
  62762. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62763. /**
  62764. * Returns the data related to the radial explosion event (sphere).
  62765. * @returns The radial explosion event data
  62766. */
  62767. getData(): PhysicsRadialExplosionEventData;
  62768. /**
  62769. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62770. * @param impostor A physics imposter
  62771. * @param origin the origin of the explosion
  62772. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62773. */
  62774. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62775. /**
  62776. * Triggers affecterd impostors callbacks
  62777. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62778. */
  62779. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62780. /**
  62781. * Disposes the sphere.
  62782. * @param force Specifies if the sphere should be disposed by force
  62783. */
  62784. dispose(force?: boolean): void;
  62785. /*** Helpers ***/
  62786. private _prepareSphere;
  62787. private _intersectsWithSphere;
  62788. }
  62789. /**
  62790. * Represents a gravitational field event
  62791. */
  62792. class PhysicsGravitationalFieldEvent {
  62793. private _physicsHelper;
  62794. private _scene;
  62795. private _origin;
  62796. private _options;
  62797. private _tickCallback;
  62798. private _sphere;
  62799. private _dataFetched;
  62800. /**
  62801. * Initializes the physics gravitational field event
  62802. * @param _physicsHelper A physics helper
  62803. * @param _scene BabylonJS scene
  62804. * @param _origin The origin position of the gravitational field event
  62805. * @param _options The options for the vortex event
  62806. */
  62807. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62808. /**
  62809. * Returns the data related to the gravitational field event (sphere).
  62810. * @returns A gravitational field event
  62811. */
  62812. getData(): PhysicsGravitationalFieldEventData;
  62813. /**
  62814. * Enables the gravitational field.
  62815. */
  62816. enable(): void;
  62817. /**
  62818. * Disables the gravitational field.
  62819. */
  62820. disable(): void;
  62821. /**
  62822. * Disposes the sphere.
  62823. * @param force The force to dispose from the gravitational field event
  62824. */
  62825. dispose(force?: boolean): void;
  62826. private _tick;
  62827. }
  62828. /**
  62829. * Represents a physics updraft event
  62830. */
  62831. class PhysicsUpdraftEvent {
  62832. private _scene;
  62833. private _origin;
  62834. private _options;
  62835. private _physicsEngine;
  62836. private _originTop;
  62837. private _originDirection;
  62838. private _tickCallback;
  62839. private _cylinder;
  62840. private _cylinderPosition;
  62841. private _dataFetched;
  62842. /**
  62843. * Initializes the physics updraft event
  62844. * @param _scene BabylonJS scene
  62845. * @param _origin The origin position of the updraft
  62846. * @param _options The options for the updraft event
  62847. */
  62848. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62849. /**
  62850. * Returns the data related to the updraft event (cylinder).
  62851. * @returns A physics updraft event
  62852. */
  62853. getData(): PhysicsUpdraftEventData;
  62854. /**
  62855. * Enables the updraft.
  62856. */
  62857. enable(): void;
  62858. /**
  62859. * Disables the updraft.
  62860. */
  62861. disable(): void;
  62862. /**
  62863. * Disposes the cylinder.
  62864. * @param force Specifies if the updraft should be disposed by force
  62865. */
  62866. dispose(force?: boolean): void;
  62867. private getImpostorHitData;
  62868. private _tick;
  62869. /*** Helpers ***/
  62870. private _prepareCylinder;
  62871. private _intersectsWithCylinder;
  62872. }
  62873. /**
  62874. * Represents a physics vortex event
  62875. */
  62876. class PhysicsVortexEvent {
  62877. private _scene;
  62878. private _origin;
  62879. private _options;
  62880. private _physicsEngine;
  62881. private _originTop;
  62882. private _tickCallback;
  62883. private _cylinder;
  62884. private _cylinderPosition;
  62885. private _dataFetched;
  62886. /**
  62887. * Initializes the physics vortex event
  62888. * @param _scene The BabylonJS scene
  62889. * @param _origin The origin position of the vortex
  62890. * @param _options The options for the vortex event
  62891. */
  62892. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62893. /**
  62894. * Returns the data related to the vortex event (cylinder).
  62895. * @returns The physics vortex event data
  62896. */
  62897. getData(): PhysicsVortexEventData;
  62898. /**
  62899. * Enables the vortex.
  62900. */
  62901. enable(): void;
  62902. /**
  62903. * Disables the cortex.
  62904. */
  62905. disable(): void;
  62906. /**
  62907. * Disposes the sphere.
  62908. * @param force
  62909. */
  62910. dispose(force?: boolean): void;
  62911. private getImpostorHitData;
  62912. private _tick;
  62913. /*** Helpers ***/
  62914. private _prepareCylinder;
  62915. private _intersectsWithCylinder;
  62916. }
  62917. /**
  62918. * Options fot the radial explosion event
  62919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62920. */
  62921. export class PhysicsRadialExplosionEventOptions {
  62922. /**
  62923. * The radius of the sphere for the radial explosion.
  62924. */
  62925. radius: number;
  62926. /**
  62927. * The strenth of the explosion.
  62928. */
  62929. strength: number;
  62930. /**
  62931. * The strenght of the force in correspondence to the distance of the affected object
  62932. */
  62933. falloff: PhysicsRadialImpulseFalloff;
  62934. /**
  62935. * Sphere options for the radial explosion.
  62936. */
  62937. sphere: {
  62938. segments: number;
  62939. diameter: number;
  62940. };
  62941. /**
  62942. * Sphere options for the radial explosion.
  62943. */
  62944. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62945. }
  62946. /**
  62947. * Options fot the updraft event
  62948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62949. */
  62950. export class PhysicsUpdraftEventOptions {
  62951. /**
  62952. * The radius of the cylinder for the vortex
  62953. */
  62954. radius: number;
  62955. /**
  62956. * The strenth of the updraft.
  62957. */
  62958. strength: number;
  62959. /**
  62960. * The height of the cylinder for the updraft.
  62961. */
  62962. height: number;
  62963. /**
  62964. * The mode for the the updraft.
  62965. */
  62966. updraftMode: PhysicsUpdraftMode;
  62967. }
  62968. /**
  62969. * Options fot the vortex event
  62970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62971. */
  62972. export class PhysicsVortexEventOptions {
  62973. /**
  62974. * The radius of the cylinder for the vortex
  62975. */
  62976. radius: number;
  62977. /**
  62978. * The strenth of the vortex.
  62979. */
  62980. strength: number;
  62981. /**
  62982. * The height of the cylinder for the vortex.
  62983. */
  62984. height: number;
  62985. /**
  62986. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62987. */
  62988. centripetalForceThreshold: number;
  62989. /**
  62990. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62991. */
  62992. centripetalForceMultiplier: number;
  62993. /**
  62994. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62995. */
  62996. centrifugalForceMultiplier: number;
  62997. /**
  62998. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62999. */
  63000. updraftForceMultiplier: number;
  63001. }
  63002. /**
  63003. * The strenght of the force in correspondence to the distance of the affected object
  63004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63005. */
  63006. export enum PhysicsRadialImpulseFalloff {
  63007. /** Defines that impulse is constant in strength across it's whole radius */
  63008. Constant = 0,
  63009. /** Defines that impulse gets weaker if it's further from the origin */
  63010. Linear = 1
  63011. }
  63012. /**
  63013. * The strength of the force in correspondence to the distance of the affected object
  63014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63015. */
  63016. export enum PhysicsUpdraftMode {
  63017. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63018. Center = 0,
  63019. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63020. Perpendicular = 1
  63021. }
  63022. /**
  63023. * Interface for a physics hit data
  63024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63025. */
  63026. export interface PhysicsHitData {
  63027. /**
  63028. * The force applied at the contact point
  63029. */
  63030. force: Vector3;
  63031. /**
  63032. * The contact point
  63033. */
  63034. contactPoint: Vector3;
  63035. /**
  63036. * The distance from the origin to the contact point
  63037. */
  63038. distanceFromOrigin: number;
  63039. }
  63040. /**
  63041. * Interface for radial explosion event data
  63042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63043. */
  63044. export interface PhysicsRadialExplosionEventData {
  63045. /**
  63046. * A sphere used for the radial explosion event
  63047. */
  63048. sphere: Mesh;
  63049. }
  63050. /**
  63051. * Interface for gravitational field event data
  63052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63053. */
  63054. export interface PhysicsGravitationalFieldEventData {
  63055. /**
  63056. * A sphere mesh used for the gravitational field event
  63057. */
  63058. sphere: Mesh;
  63059. }
  63060. /**
  63061. * Interface for updraft event data
  63062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63063. */
  63064. export interface PhysicsUpdraftEventData {
  63065. /**
  63066. * A cylinder used for the updraft event
  63067. */
  63068. cylinder: Mesh;
  63069. }
  63070. /**
  63071. * Interface for vortex event data
  63072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63073. */
  63074. export interface PhysicsVortexEventData {
  63075. /**
  63076. * A cylinder used for the vortex event
  63077. */
  63078. cylinder: Mesh;
  63079. }
  63080. /**
  63081. * Interface for an affected physics impostor
  63082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63083. */
  63084. export interface PhysicsAffectedImpostorWithData {
  63085. /**
  63086. * The impostor affected by the effect
  63087. */
  63088. impostor: PhysicsImpostor;
  63089. /**
  63090. * The data about the hit/horce from the explosion
  63091. */
  63092. hitData: PhysicsHitData;
  63093. }
  63094. }
  63095. declare module "babylonjs/Physics/Plugins/index" {
  63096. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63097. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63098. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63099. }
  63100. declare module "babylonjs/Physics/index" {
  63101. export * from "babylonjs/Physics/IPhysicsEngine";
  63102. export * from "babylonjs/Physics/physicsEngine";
  63103. export * from "babylonjs/Physics/physicsEngineComponent";
  63104. export * from "babylonjs/Physics/physicsHelper";
  63105. export * from "babylonjs/Physics/physicsImpostor";
  63106. export * from "babylonjs/Physics/physicsJoint";
  63107. export * from "babylonjs/Physics/Plugins/index";
  63108. }
  63109. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63110. /** @hidden */
  63111. export var blackAndWhitePixelShader: {
  63112. name: string;
  63113. shader: string;
  63114. };
  63115. }
  63116. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63118. import { Camera } from "babylonjs/Cameras/camera";
  63119. import { Engine } from "babylonjs/Engines/engine";
  63120. import "babylonjs/Shaders/blackAndWhite.fragment";
  63121. /**
  63122. * Post process used to render in black and white
  63123. */
  63124. export class BlackAndWhitePostProcess extends PostProcess {
  63125. /**
  63126. * Linear about to convert he result to black and white (default: 1)
  63127. */
  63128. degree: number;
  63129. /**
  63130. * Creates a black and white post process
  63131. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63132. * @param name The name of the effect.
  63133. * @param options The required width/height ratio to downsize to before computing the render pass.
  63134. * @param camera The camera to apply the render pass to.
  63135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63136. * @param engine The engine which the post process will be applied. (default: current engine)
  63137. * @param reusable If the post process can be reused on the same frame. (default: false)
  63138. */
  63139. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63140. }
  63141. }
  63142. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63143. import { Nullable } from "babylonjs/types";
  63144. import { Camera } from "babylonjs/Cameras/camera";
  63145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63146. import { Engine } from "babylonjs/Engines/engine";
  63147. /**
  63148. * This represents a set of one or more post processes in Babylon.
  63149. * A post process can be used to apply a shader to a texture after it is rendered.
  63150. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63151. */
  63152. export class PostProcessRenderEffect {
  63153. private _postProcesses;
  63154. private _getPostProcesses;
  63155. private _singleInstance;
  63156. private _cameras;
  63157. private _indicesForCamera;
  63158. /**
  63159. * Name of the effect
  63160. * @hidden
  63161. */
  63162. _name: string;
  63163. /**
  63164. * Instantiates a post process render effect.
  63165. * A post process can be used to apply a shader to a texture after it is rendered.
  63166. * @param engine The engine the effect is tied to
  63167. * @param name The name of the effect
  63168. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63169. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63170. */
  63171. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63172. /**
  63173. * Checks if all the post processes in the effect are supported.
  63174. */
  63175. readonly isSupported: boolean;
  63176. /**
  63177. * Updates the current state of the effect
  63178. * @hidden
  63179. */
  63180. _update(): void;
  63181. /**
  63182. * Attaches the effect on cameras
  63183. * @param cameras The camera to attach to.
  63184. * @hidden
  63185. */
  63186. _attachCameras(cameras: Camera): void;
  63187. /**
  63188. * Attaches the effect on cameras
  63189. * @param cameras The camera to attach to.
  63190. * @hidden
  63191. */
  63192. _attachCameras(cameras: Camera[]): void;
  63193. /**
  63194. * Detaches the effect on cameras
  63195. * @param cameras The camera to detatch from.
  63196. * @hidden
  63197. */
  63198. _detachCameras(cameras: Camera): void;
  63199. /**
  63200. * Detatches the effect on cameras
  63201. * @param cameras The camera to detatch from.
  63202. * @hidden
  63203. */
  63204. _detachCameras(cameras: Camera[]): void;
  63205. /**
  63206. * Enables the effect on given cameras
  63207. * @param cameras The camera to enable.
  63208. * @hidden
  63209. */
  63210. _enable(cameras: Camera): void;
  63211. /**
  63212. * Enables the effect on given cameras
  63213. * @param cameras The camera to enable.
  63214. * @hidden
  63215. */
  63216. _enable(cameras: Nullable<Camera[]>): void;
  63217. /**
  63218. * Disables the effect on the given cameras
  63219. * @param cameras The camera to disable.
  63220. * @hidden
  63221. */
  63222. _disable(cameras: Camera): void;
  63223. /**
  63224. * Disables the effect on the given cameras
  63225. * @param cameras The camera to disable.
  63226. * @hidden
  63227. */
  63228. _disable(cameras: Nullable<Camera[]>): void;
  63229. /**
  63230. * Gets a list of the post processes contained in the effect.
  63231. * @param camera The camera to get the post processes on.
  63232. * @returns The list of the post processes in the effect.
  63233. */
  63234. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63235. }
  63236. }
  63237. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63238. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63239. /** @hidden */
  63240. export var extractHighlightsPixelShader: {
  63241. name: string;
  63242. shader: string;
  63243. };
  63244. }
  63245. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63246. import { Nullable } from "babylonjs/types";
  63247. import { Camera } from "babylonjs/Cameras/camera";
  63248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63249. import { Engine } from "babylonjs/Engines/engine";
  63250. import "babylonjs/Shaders/extractHighlights.fragment";
  63251. /**
  63252. * 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.
  63253. */
  63254. export class ExtractHighlightsPostProcess extends PostProcess {
  63255. /**
  63256. * The luminance threshold, pixels below this value will be set to black.
  63257. */
  63258. threshold: number;
  63259. /** @hidden */
  63260. _exposure: number;
  63261. /**
  63262. * Post process which has the input texture to be used when performing highlight extraction
  63263. * @hidden
  63264. */
  63265. _inputPostProcess: Nullable<PostProcess>;
  63266. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63267. }
  63268. }
  63269. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63270. /** @hidden */
  63271. export var bloomMergePixelShader: {
  63272. name: string;
  63273. shader: string;
  63274. };
  63275. }
  63276. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63277. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63278. import { Nullable } from "babylonjs/types";
  63279. import { Engine } from "babylonjs/Engines/engine";
  63280. import { Camera } from "babylonjs/Cameras/camera";
  63281. import "babylonjs/Shaders/bloomMerge.fragment";
  63282. /**
  63283. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63284. */
  63285. export class BloomMergePostProcess extends PostProcess {
  63286. /** Weight of the bloom to be added to the original input. */
  63287. weight: number;
  63288. /**
  63289. * Creates a new instance of @see BloomMergePostProcess
  63290. * @param name The name of the effect.
  63291. * @param originalFromInput Post process which's input will be used for the merge.
  63292. * @param blurred Blurred highlights post process which's output will be used.
  63293. * @param weight Weight of the bloom to be added to the original input.
  63294. * @param options The required width/height ratio to downsize to before computing the render pass.
  63295. * @param camera The camera to apply the render pass to.
  63296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63297. * @param engine The engine which the post process will be applied. (default: current engine)
  63298. * @param reusable If the post process can be reused on the same frame. (default: false)
  63299. * @param textureType Type of textures used when performing the post process. (default: 0)
  63300. * @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)
  63301. */
  63302. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63303. /** Weight of the bloom to be added to the original input. */
  63304. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63305. }
  63306. }
  63307. declare module "babylonjs/PostProcesses/bloomEffect" {
  63308. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63310. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63311. import { Camera } from "babylonjs/Cameras/camera";
  63312. import { Scene } from "babylonjs/scene";
  63313. /**
  63314. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63315. */
  63316. export class BloomEffect extends PostProcessRenderEffect {
  63317. private bloomScale;
  63318. /**
  63319. * @hidden Internal
  63320. */
  63321. _effects: Array<PostProcess>;
  63322. /**
  63323. * @hidden Internal
  63324. */
  63325. _downscale: ExtractHighlightsPostProcess;
  63326. private _blurX;
  63327. private _blurY;
  63328. private _merge;
  63329. /**
  63330. * The luminance threshold to find bright areas of the image to bloom.
  63331. */
  63332. threshold: number;
  63333. /**
  63334. * The strength of the bloom.
  63335. */
  63336. weight: number;
  63337. /**
  63338. * Specifies the size of the bloom blur kernel, relative to the final output size
  63339. */
  63340. kernel: number;
  63341. /**
  63342. * Creates a new instance of @see BloomEffect
  63343. * @param scene The scene the effect belongs to.
  63344. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63345. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63346. * @param bloomWeight The the strength of bloom.
  63347. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63348. * @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)
  63349. */
  63350. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63351. /**
  63352. * Disposes each of the internal effects for a given camera.
  63353. * @param camera The camera to dispose the effect on.
  63354. */
  63355. disposeEffects(camera: Camera): void;
  63356. /**
  63357. * @hidden Internal
  63358. */
  63359. _updateEffects(): void;
  63360. /**
  63361. * Internal
  63362. * @returns if all the contained post processes are ready.
  63363. * @hidden
  63364. */
  63365. _isReady(): boolean;
  63366. }
  63367. }
  63368. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63369. /** @hidden */
  63370. export var chromaticAberrationPixelShader: {
  63371. name: string;
  63372. shader: string;
  63373. };
  63374. }
  63375. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63376. import { Vector2 } from "babylonjs/Maths/math.vector";
  63377. import { Nullable } from "babylonjs/types";
  63378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63379. import { Camera } from "babylonjs/Cameras/camera";
  63380. import { Engine } from "babylonjs/Engines/engine";
  63381. import "babylonjs/Shaders/chromaticAberration.fragment";
  63382. /**
  63383. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63384. */
  63385. export class ChromaticAberrationPostProcess extends PostProcess {
  63386. /**
  63387. * The amount of seperation of rgb channels (default: 30)
  63388. */
  63389. aberrationAmount: number;
  63390. /**
  63391. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63392. */
  63393. radialIntensity: number;
  63394. /**
  63395. * 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))
  63396. */
  63397. direction: Vector2;
  63398. /**
  63399. * 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))
  63400. */
  63401. centerPosition: Vector2;
  63402. /**
  63403. * Creates a new instance ChromaticAberrationPostProcess
  63404. * @param name The name of the effect.
  63405. * @param screenWidth The width of the screen to apply the effect on.
  63406. * @param screenHeight The height of the screen to apply the effect on.
  63407. * @param options The required width/height ratio to downsize to before computing the render pass.
  63408. * @param camera The camera to apply the render pass to.
  63409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63410. * @param engine The engine which the post process will be applied. (default: current engine)
  63411. * @param reusable If the post process can be reused on the same frame. (default: false)
  63412. * @param textureType Type of textures used when performing the post process. (default: 0)
  63413. * @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)
  63414. */
  63415. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63416. }
  63417. }
  63418. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63419. /** @hidden */
  63420. export var circleOfConfusionPixelShader: {
  63421. name: string;
  63422. shader: string;
  63423. };
  63424. }
  63425. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63426. import { Nullable } from "babylonjs/types";
  63427. import { Engine } from "babylonjs/Engines/engine";
  63428. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63430. import { Camera } from "babylonjs/Cameras/camera";
  63431. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63432. /**
  63433. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63434. */
  63435. export class CircleOfConfusionPostProcess extends PostProcess {
  63436. /**
  63437. * 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.
  63438. */
  63439. lensSize: number;
  63440. /**
  63441. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63442. */
  63443. fStop: number;
  63444. /**
  63445. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63446. */
  63447. focusDistance: number;
  63448. /**
  63449. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63450. */
  63451. focalLength: number;
  63452. private _depthTexture;
  63453. /**
  63454. * Creates a new instance CircleOfConfusionPostProcess
  63455. * @param name The name of the effect.
  63456. * @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.
  63457. * @param options The required width/height ratio to downsize to before computing the render pass.
  63458. * @param camera The camera to apply the render pass to.
  63459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63460. * @param engine The engine which the post process will be applied. (default: current engine)
  63461. * @param reusable If the post process can be reused on the same frame. (default: false)
  63462. * @param textureType Type of textures used when performing the post process. (default: 0)
  63463. * @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)
  63464. */
  63465. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63466. /**
  63467. * 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.
  63468. */
  63469. depthTexture: RenderTargetTexture;
  63470. }
  63471. }
  63472. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63473. /** @hidden */
  63474. export var colorCorrectionPixelShader: {
  63475. name: string;
  63476. shader: string;
  63477. };
  63478. }
  63479. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63481. import { Engine } from "babylonjs/Engines/engine";
  63482. import { Camera } from "babylonjs/Cameras/camera";
  63483. import "babylonjs/Shaders/colorCorrection.fragment";
  63484. /**
  63485. *
  63486. * This post-process allows the modification of rendered colors by using
  63487. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63488. *
  63489. * The object needs to be provided an url to a texture containing the color
  63490. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63491. * Use an image editing software to tweak the LUT to match your needs.
  63492. *
  63493. * For an example of a color LUT, see here:
  63494. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63495. * For explanations on color grading, see here:
  63496. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63497. *
  63498. */
  63499. export class ColorCorrectionPostProcess extends PostProcess {
  63500. private _colorTableTexture;
  63501. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63502. }
  63503. }
  63504. declare module "babylonjs/Shaders/convolution.fragment" {
  63505. /** @hidden */
  63506. export var convolutionPixelShader: {
  63507. name: string;
  63508. shader: string;
  63509. };
  63510. }
  63511. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63512. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63513. import { Nullable } from "babylonjs/types";
  63514. import { Camera } from "babylonjs/Cameras/camera";
  63515. import { Engine } from "babylonjs/Engines/engine";
  63516. import "babylonjs/Shaders/convolution.fragment";
  63517. /**
  63518. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63519. * input texture to perform effects such as edge detection or sharpening
  63520. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63521. */
  63522. export class ConvolutionPostProcess extends PostProcess {
  63523. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63524. kernel: number[];
  63525. /**
  63526. * Creates a new instance ConvolutionPostProcess
  63527. * @param name The name of the effect.
  63528. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63529. * @param options The required width/height ratio to downsize to before computing the render pass.
  63530. * @param camera The camera to apply the render pass to.
  63531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63532. * @param engine The engine which the post process will be applied. (default: current engine)
  63533. * @param reusable If the post process can be reused on the same frame. (default: false)
  63534. * @param textureType Type of textures used when performing the post process. (default: 0)
  63535. */
  63536. constructor(name: string,
  63537. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63538. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63539. /**
  63540. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63541. */
  63542. static EdgeDetect0Kernel: number[];
  63543. /**
  63544. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63545. */
  63546. static EdgeDetect1Kernel: number[];
  63547. /**
  63548. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63549. */
  63550. static EdgeDetect2Kernel: number[];
  63551. /**
  63552. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63553. */
  63554. static SharpenKernel: number[];
  63555. /**
  63556. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63557. */
  63558. static EmbossKernel: number[];
  63559. /**
  63560. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63561. */
  63562. static GaussianKernel: number[];
  63563. }
  63564. }
  63565. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63566. import { Nullable } from "babylonjs/types";
  63567. import { Vector2 } from "babylonjs/Maths/math.vector";
  63568. import { Camera } from "babylonjs/Cameras/camera";
  63569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63570. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63571. import { Engine } from "babylonjs/Engines/engine";
  63572. import { Scene } from "babylonjs/scene";
  63573. /**
  63574. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63575. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63576. * based on samples that have a large difference in distance than the center pixel.
  63577. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63578. */
  63579. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63580. direction: Vector2;
  63581. /**
  63582. * Creates a new instance CircleOfConfusionPostProcess
  63583. * @param name The name of the effect.
  63584. * @param scene The scene the effect belongs to.
  63585. * @param direction The direction the blur should be applied.
  63586. * @param kernel The size of the kernel used to blur.
  63587. * @param options The required width/height ratio to downsize to before computing the render pass.
  63588. * @param camera The camera to apply the render pass to.
  63589. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63590. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63592. * @param engine The engine which the post process will be applied. (default: current engine)
  63593. * @param reusable If the post process can be reused on the same frame. (default: false)
  63594. * @param textureType Type of textures used when performing the post process. (default: 0)
  63595. * @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)
  63596. */
  63597. 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);
  63598. }
  63599. }
  63600. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63601. /** @hidden */
  63602. export var depthOfFieldMergePixelShader: {
  63603. name: string;
  63604. shader: string;
  63605. };
  63606. }
  63607. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63608. import { Nullable } from "babylonjs/types";
  63609. import { Camera } from "babylonjs/Cameras/camera";
  63610. import { Effect } from "babylonjs/Materials/effect";
  63611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63612. import { Engine } from "babylonjs/Engines/engine";
  63613. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63614. /**
  63615. * Options to be set when merging outputs from the default pipeline.
  63616. */
  63617. export class DepthOfFieldMergePostProcessOptions {
  63618. /**
  63619. * The original image to merge on top of
  63620. */
  63621. originalFromInput: PostProcess;
  63622. /**
  63623. * Parameters to perform the merge of the depth of field effect
  63624. */
  63625. depthOfField?: {
  63626. circleOfConfusion: PostProcess;
  63627. blurSteps: Array<PostProcess>;
  63628. };
  63629. /**
  63630. * Parameters to perform the merge of bloom effect
  63631. */
  63632. bloom?: {
  63633. blurred: PostProcess;
  63634. weight: number;
  63635. };
  63636. }
  63637. /**
  63638. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63639. */
  63640. export class DepthOfFieldMergePostProcess extends PostProcess {
  63641. private blurSteps;
  63642. /**
  63643. * Creates a new instance of DepthOfFieldMergePostProcess
  63644. * @param name The name of the effect.
  63645. * @param originalFromInput Post process which's input will be used for the merge.
  63646. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63647. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63648. * @param options The required width/height ratio to downsize to before computing the render pass.
  63649. * @param camera The camera to apply the render pass to.
  63650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63651. * @param engine The engine which the post process will be applied. (default: current engine)
  63652. * @param reusable If the post process can be reused on the same frame. (default: false)
  63653. * @param textureType Type of textures used when performing the post process. (default: 0)
  63654. * @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)
  63655. */
  63656. 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);
  63657. /**
  63658. * Updates the effect with the current post process compile time values and recompiles the shader.
  63659. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63660. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63661. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63662. * @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
  63663. * @param onCompiled Called when the shader has been compiled.
  63664. * @param onError Called if there is an error when compiling a shader.
  63665. */
  63666. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63667. }
  63668. }
  63669. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63670. import { Nullable } from "babylonjs/types";
  63671. import { Camera } from "babylonjs/Cameras/camera";
  63672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63673. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63674. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63675. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63676. import { Scene } from "babylonjs/scene";
  63677. /**
  63678. * Specifies the level of max blur that should be applied when using the depth of field effect
  63679. */
  63680. export enum DepthOfFieldEffectBlurLevel {
  63681. /**
  63682. * Subtle blur
  63683. */
  63684. Low = 0,
  63685. /**
  63686. * Medium blur
  63687. */
  63688. Medium = 1,
  63689. /**
  63690. * Large blur
  63691. */
  63692. High = 2
  63693. }
  63694. /**
  63695. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63696. */
  63697. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63698. private _circleOfConfusion;
  63699. /**
  63700. * @hidden Internal, blurs from high to low
  63701. */
  63702. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63703. private _depthOfFieldBlurY;
  63704. private _dofMerge;
  63705. /**
  63706. * @hidden Internal post processes in depth of field effect
  63707. */
  63708. _effects: Array<PostProcess>;
  63709. /**
  63710. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63711. */
  63712. focalLength: number;
  63713. /**
  63714. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63715. */
  63716. fStop: number;
  63717. /**
  63718. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63719. */
  63720. focusDistance: number;
  63721. /**
  63722. * 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.
  63723. */
  63724. lensSize: number;
  63725. /**
  63726. * Creates a new instance DepthOfFieldEffect
  63727. * @param scene The scene the effect belongs to.
  63728. * @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.
  63729. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63730. * @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)
  63731. */
  63732. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63733. /**
  63734. * Get the current class name of the current effet
  63735. * @returns "DepthOfFieldEffect"
  63736. */
  63737. getClassName(): string;
  63738. /**
  63739. * 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.
  63740. */
  63741. depthTexture: RenderTargetTexture;
  63742. /**
  63743. * Disposes each of the internal effects for a given camera.
  63744. * @param camera The camera to dispose the effect on.
  63745. */
  63746. disposeEffects(camera: Camera): void;
  63747. /**
  63748. * @hidden Internal
  63749. */
  63750. _updateEffects(): void;
  63751. /**
  63752. * Internal
  63753. * @returns if all the contained post processes are ready.
  63754. * @hidden
  63755. */
  63756. _isReady(): boolean;
  63757. }
  63758. }
  63759. declare module "babylonjs/Shaders/displayPass.fragment" {
  63760. /** @hidden */
  63761. export var displayPassPixelShader: {
  63762. name: string;
  63763. shader: string;
  63764. };
  63765. }
  63766. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63767. import { Nullable } from "babylonjs/types";
  63768. import { Camera } from "babylonjs/Cameras/camera";
  63769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63770. import { Engine } from "babylonjs/Engines/engine";
  63771. import "babylonjs/Shaders/displayPass.fragment";
  63772. /**
  63773. * DisplayPassPostProcess which produces an output the same as it's input
  63774. */
  63775. export class DisplayPassPostProcess extends PostProcess {
  63776. /**
  63777. * Creates the DisplayPassPostProcess
  63778. * @param name The name of the effect.
  63779. * @param options The required width/height ratio to downsize to before computing the render pass.
  63780. * @param camera The camera to apply the render pass to.
  63781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63782. * @param engine The engine which the post process will be applied. (default: current engine)
  63783. * @param reusable If the post process can be reused on the same frame. (default: false)
  63784. */
  63785. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63786. }
  63787. }
  63788. declare module "babylonjs/Shaders/filter.fragment" {
  63789. /** @hidden */
  63790. export var filterPixelShader: {
  63791. name: string;
  63792. shader: string;
  63793. };
  63794. }
  63795. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63796. import { Nullable } from "babylonjs/types";
  63797. import { Matrix } from "babylonjs/Maths/math.vector";
  63798. import { Camera } from "babylonjs/Cameras/camera";
  63799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63800. import { Engine } from "babylonjs/Engines/engine";
  63801. import "babylonjs/Shaders/filter.fragment";
  63802. /**
  63803. * Applies a kernel filter to the image
  63804. */
  63805. export class FilterPostProcess extends PostProcess {
  63806. /** The matrix to be applied to the image */
  63807. kernelMatrix: Matrix;
  63808. /**
  63809. *
  63810. * @param name The name of the effect.
  63811. * @param kernelMatrix The matrix to be applied to the image
  63812. * @param options The required width/height ratio to downsize to before computing the render pass.
  63813. * @param camera The camera to apply the render pass to.
  63814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63815. * @param engine The engine which the post process will be applied. (default: current engine)
  63816. * @param reusable If the post process can be reused on the same frame. (default: false)
  63817. */
  63818. constructor(name: string,
  63819. /** The matrix to be applied to the image */
  63820. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63821. }
  63822. }
  63823. declare module "babylonjs/Shaders/fxaa.fragment" {
  63824. /** @hidden */
  63825. export var fxaaPixelShader: {
  63826. name: string;
  63827. shader: string;
  63828. };
  63829. }
  63830. declare module "babylonjs/Shaders/fxaa.vertex" {
  63831. /** @hidden */
  63832. export var fxaaVertexShader: {
  63833. name: string;
  63834. shader: string;
  63835. };
  63836. }
  63837. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63838. import { Nullable } from "babylonjs/types";
  63839. import { Camera } from "babylonjs/Cameras/camera";
  63840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63841. import { Engine } from "babylonjs/Engines/engine";
  63842. import "babylonjs/Shaders/fxaa.fragment";
  63843. import "babylonjs/Shaders/fxaa.vertex";
  63844. /**
  63845. * Fxaa post process
  63846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63847. */
  63848. export class FxaaPostProcess extends PostProcess {
  63849. /** @hidden */
  63850. texelWidth: number;
  63851. /** @hidden */
  63852. texelHeight: number;
  63853. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63854. private _getDefines;
  63855. }
  63856. }
  63857. declare module "babylonjs/Shaders/grain.fragment" {
  63858. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63859. /** @hidden */
  63860. export var grainPixelShader: {
  63861. name: string;
  63862. shader: string;
  63863. };
  63864. }
  63865. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63866. import { Nullable } from "babylonjs/types";
  63867. import { Camera } from "babylonjs/Cameras/camera";
  63868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63869. import { Engine } from "babylonjs/Engines/engine";
  63870. import "babylonjs/Shaders/grain.fragment";
  63871. /**
  63872. * The GrainPostProcess adds noise to the image at mid luminance levels
  63873. */
  63874. export class GrainPostProcess extends PostProcess {
  63875. /**
  63876. * The intensity of the grain added (default: 30)
  63877. */
  63878. intensity: number;
  63879. /**
  63880. * If the grain should be randomized on every frame
  63881. */
  63882. animated: boolean;
  63883. /**
  63884. * Creates a new instance of @see GrainPostProcess
  63885. * @param name The name of the effect.
  63886. * @param options The required width/height ratio to downsize to before computing the render pass.
  63887. * @param camera The camera to apply the render pass to.
  63888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63889. * @param engine The engine which the post process will be applied. (default: current engine)
  63890. * @param reusable If the post process can be reused on the same frame. (default: false)
  63891. * @param textureType Type of textures used when performing the post process. (default: 0)
  63892. * @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)
  63893. */
  63894. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63895. }
  63896. }
  63897. declare module "babylonjs/Shaders/highlights.fragment" {
  63898. /** @hidden */
  63899. export var highlightsPixelShader: {
  63900. name: string;
  63901. shader: string;
  63902. };
  63903. }
  63904. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63905. import { Nullable } from "babylonjs/types";
  63906. import { Camera } from "babylonjs/Cameras/camera";
  63907. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63908. import { Engine } from "babylonjs/Engines/engine";
  63909. import "babylonjs/Shaders/highlights.fragment";
  63910. /**
  63911. * Extracts highlights from the image
  63912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63913. */
  63914. export class HighlightsPostProcess extends PostProcess {
  63915. /**
  63916. * Extracts highlights from the image
  63917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63918. * @param name The name of the effect.
  63919. * @param options The required width/height ratio to downsize to before computing the render pass.
  63920. * @param camera The camera to apply the render pass to.
  63921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63922. * @param engine The engine which the post process will be applied. (default: current engine)
  63923. * @param reusable If the post process can be reused on the same frame. (default: false)
  63924. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63925. */
  63926. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63927. }
  63928. }
  63929. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63930. /** @hidden */
  63931. export var mrtFragmentDeclaration: {
  63932. name: string;
  63933. shader: string;
  63934. };
  63935. }
  63936. declare module "babylonjs/Shaders/geometry.fragment" {
  63937. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63938. /** @hidden */
  63939. export var geometryPixelShader: {
  63940. name: string;
  63941. shader: string;
  63942. };
  63943. }
  63944. declare module "babylonjs/Shaders/geometry.vertex" {
  63945. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63946. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63948. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63949. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63950. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63951. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63952. /** @hidden */
  63953. export var geometryVertexShader: {
  63954. name: string;
  63955. shader: string;
  63956. };
  63957. }
  63958. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63959. import { Matrix } from "babylonjs/Maths/math.vector";
  63960. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63961. import { Mesh } from "babylonjs/Meshes/mesh";
  63962. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63963. import { Effect } from "babylonjs/Materials/effect";
  63964. import { Scene } from "babylonjs/scene";
  63965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63966. import "babylonjs/Shaders/geometry.fragment";
  63967. import "babylonjs/Shaders/geometry.vertex";
  63968. /** @hidden */
  63969. interface ISavedTransformationMatrix {
  63970. world: Matrix;
  63971. viewProjection: Matrix;
  63972. }
  63973. /**
  63974. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63975. */
  63976. export class GeometryBufferRenderer {
  63977. /**
  63978. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63979. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63980. */
  63981. static readonly POSITION_TEXTURE_TYPE: number;
  63982. /**
  63983. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63984. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63985. */
  63986. static readonly VELOCITY_TEXTURE_TYPE: number;
  63987. /**
  63988. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63989. * in order to compute objects velocities when enableVelocity is set to "true"
  63990. * @hidden
  63991. */
  63992. _previousTransformationMatrices: {
  63993. [index: number]: ISavedTransformationMatrix;
  63994. };
  63995. /**
  63996. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63997. * in order to compute objects velocities when enableVelocity is set to "true"
  63998. * @hidden
  63999. */
  64000. _previousBonesTransformationMatrices: {
  64001. [index: number]: Float32Array;
  64002. };
  64003. /**
  64004. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64005. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64006. */
  64007. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64008. private _scene;
  64009. private _multiRenderTarget;
  64010. private _ratio;
  64011. private _enablePosition;
  64012. private _enableVelocity;
  64013. private _positionIndex;
  64014. private _velocityIndex;
  64015. protected _effect: Effect;
  64016. protected _cachedDefines: string;
  64017. /**
  64018. * Set the render list (meshes to be rendered) used in the G buffer.
  64019. */
  64020. renderList: Mesh[];
  64021. /**
  64022. * Gets wether or not G buffer are supported by the running hardware.
  64023. * This requires draw buffer supports
  64024. */
  64025. readonly isSupported: boolean;
  64026. /**
  64027. * Returns the index of the given texture type in the G-Buffer textures array
  64028. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64029. * @returns the index of the given texture type in the G-Buffer textures array
  64030. */
  64031. getTextureIndex(textureType: number): number;
  64032. /**
  64033. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64034. */
  64035. /**
  64036. * Sets whether or not objects positions are enabled for the G buffer.
  64037. */
  64038. enablePosition: boolean;
  64039. /**
  64040. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64041. */
  64042. /**
  64043. * Sets wether or not objects velocities are enabled for the G buffer.
  64044. */
  64045. enableVelocity: boolean;
  64046. /**
  64047. * Gets the scene associated with the buffer.
  64048. */
  64049. readonly scene: Scene;
  64050. /**
  64051. * Gets the ratio used by the buffer during its creation.
  64052. * How big is the buffer related to the main canvas.
  64053. */
  64054. readonly ratio: number;
  64055. /** @hidden */
  64056. static _SceneComponentInitialization: (scene: Scene) => void;
  64057. /**
  64058. * Creates a new G Buffer for the scene
  64059. * @param scene The scene the buffer belongs to
  64060. * @param ratio How big is the buffer related to the main canvas.
  64061. */
  64062. constructor(scene: Scene, ratio?: number);
  64063. /**
  64064. * Checks wether everything is ready to render a submesh to the G buffer.
  64065. * @param subMesh the submesh to check readiness for
  64066. * @param useInstances is the mesh drawn using instance or not
  64067. * @returns true if ready otherwise false
  64068. */
  64069. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64070. /**
  64071. * Gets the current underlying G Buffer.
  64072. * @returns the buffer
  64073. */
  64074. getGBuffer(): MultiRenderTarget;
  64075. /**
  64076. * Gets the number of samples used to render the buffer (anti aliasing).
  64077. */
  64078. /**
  64079. * Sets the number of samples used to render the buffer (anti aliasing).
  64080. */
  64081. samples: number;
  64082. /**
  64083. * Disposes the renderer and frees up associated resources.
  64084. */
  64085. dispose(): void;
  64086. protected _createRenderTargets(): void;
  64087. private _copyBonesTransformationMatrices;
  64088. }
  64089. }
  64090. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64091. import { Nullable } from "babylonjs/types";
  64092. import { Scene } from "babylonjs/scene";
  64093. import { ISceneComponent } from "babylonjs/sceneComponent";
  64094. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64095. module "babylonjs/scene" {
  64096. interface Scene {
  64097. /** @hidden (Backing field) */
  64098. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64099. /**
  64100. * Gets or Sets the current geometry buffer associated to the scene.
  64101. */
  64102. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64103. /**
  64104. * Enables a GeometryBufferRender and associates it with the scene
  64105. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64106. * @returns the GeometryBufferRenderer
  64107. */
  64108. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64109. /**
  64110. * Disables the GeometryBufferRender associated with the scene
  64111. */
  64112. disableGeometryBufferRenderer(): void;
  64113. }
  64114. }
  64115. /**
  64116. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64117. * in several rendering techniques.
  64118. */
  64119. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64120. /**
  64121. * The component name helpful to identify the component in the list of scene components.
  64122. */
  64123. readonly name: string;
  64124. /**
  64125. * The scene the component belongs to.
  64126. */
  64127. scene: Scene;
  64128. /**
  64129. * Creates a new instance of the component for the given scene
  64130. * @param scene Defines the scene to register the component in
  64131. */
  64132. constructor(scene: Scene);
  64133. /**
  64134. * Registers the component in a given scene
  64135. */
  64136. register(): void;
  64137. /**
  64138. * Rebuilds the elements related to this component in case of
  64139. * context lost for instance.
  64140. */
  64141. rebuild(): void;
  64142. /**
  64143. * Disposes the component and the associated ressources
  64144. */
  64145. dispose(): void;
  64146. private _gatherRenderTargets;
  64147. }
  64148. }
  64149. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64150. /** @hidden */
  64151. export var motionBlurPixelShader: {
  64152. name: string;
  64153. shader: string;
  64154. };
  64155. }
  64156. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64157. import { Nullable } from "babylonjs/types";
  64158. import { Camera } from "babylonjs/Cameras/camera";
  64159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64160. import { Scene } from "babylonjs/scene";
  64161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64162. import "babylonjs/Animations/animatable";
  64163. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64164. import "babylonjs/Shaders/motionBlur.fragment";
  64165. import { Engine } from "babylonjs/Engines/engine";
  64166. /**
  64167. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64168. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64169. * As an example, all you have to do is to create the post-process:
  64170. * var mb = new BABYLON.MotionBlurPostProcess(
  64171. * 'mb', // The name of the effect.
  64172. * scene, // The scene containing the objects to blur according to their velocity.
  64173. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64174. * camera // The camera to apply the render pass to.
  64175. * );
  64176. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64177. */
  64178. export class MotionBlurPostProcess extends PostProcess {
  64179. /**
  64180. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64181. */
  64182. motionStrength: number;
  64183. /**
  64184. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64185. */
  64186. /**
  64187. * Sets the number of iterations to be used for motion blur quality
  64188. */
  64189. motionBlurSamples: number;
  64190. private _motionBlurSamples;
  64191. private _geometryBufferRenderer;
  64192. /**
  64193. * Creates a new instance MotionBlurPostProcess
  64194. * @param name The name of the effect.
  64195. * @param scene The scene containing the objects to blur according to their velocity.
  64196. * @param options The required width/height ratio to downsize to before computing the render pass.
  64197. * @param camera The camera to apply the render pass to.
  64198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64199. * @param engine The engine which the post process will be applied. (default: current engine)
  64200. * @param reusable If the post process can be reused on the same frame. (default: false)
  64201. * @param textureType Type of textures used when performing the post process. (default: 0)
  64202. * @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)
  64203. */
  64204. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64205. /**
  64206. * Excludes the given skinned mesh from computing bones velocities.
  64207. * 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.
  64208. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64209. */
  64210. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64211. /**
  64212. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64213. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64214. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64215. */
  64216. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64217. /**
  64218. * Disposes the post process.
  64219. * @param camera The camera to dispose the post process on.
  64220. */
  64221. dispose(camera?: Camera): void;
  64222. }
  64223. }
  64224. declare module "babylonjs/Shaders/refraction.fragment" {
  64225. /** @hidden */
  64226. export var refractionPixelShader: {
  64227. name: string;
  64228. shader: string;
  64229. };
  64230. }
  64231. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64232. import { Color3 } from "babylonjs/Maths/math.color";
  64233. import { Camera } from "babylonjs/Cameras/camera";
  64234. import { Texture } from "babylonjs/Materials/Textures/texture";
  64235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64236. import { Engine } from "babylonjs/Engines/engine";
  64237. import "babylonjs/Shaders/refraction.fragment";
  64238. /**
  64239. * Post process which applies a refractin texture
  64240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64241. */
  64242. export class RefractionPostProcess extends PostProcess {
  64243. /** the base color of the refraction (used to taint the rendering) */
  64244. color: Color3;
  64245. /** simulated refraction depth */
  64246. depth: number;
  64247. /** the coefficient of the base color (0 to remove base color tainting) */
  64248. colorLevel: number;
  64249. private _refTexture;
  64250. private _ownRefractionTexture;
  64251. /**
  64252. * Gets or sets the refraction texture
  64253. * Please note that you are responsible for disposing the texture if you set it manually
  64254. */
  64255. refractionTexture: Texture;
  64256. /**
  64257. * Initializes the RefractionPostProcess
  64258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64259. * @param name The name of the effect.
  64260. * @param refractionTextureUrl Url of the refraction texture to use
  64261. * @param color the base color of the refraction (used to taint the rendering)
  64262. * @param depth simulated refraction depth
  64263. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64264. * @param camera The camera to apply the render pass to.
  64265. * @param options The required width/height ratio to downsize to before computing the render pass.
  64266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64267. * @param engine The engine which the post process will be applied. (default: current engine)
  64268. * @param reusable If the post process can be reused on the same frame. (default: false)
  64269. */
  64270. constructor(name: string, refractionTextureUrl: string,
  64271. /** the base color of the refraction (used to taint the rendering) */
  64272. color: Color3,
  64273. /** simulated refraction depth */
  64274. depth: number,
  64275. /** the coefficient of the base color (0 to remove base color tainting) */
  64276. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64277. /**
  64278. * Disposes of the post process
  64279. * @param camera Camera to dispose post process on
  64280. */
  64281. dispose(camera: Camera): void;
  64282. }
  64283. }
  64284. declare module "babylonjs/Shaders/sharpen.fragment" {
  64285. /** @hidden */
  64286. export var sharpenPixelShader: {
  64287. name: string;
  64288. shader: string;
  64289. };
  64290. }
  64291. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64292. import { Nullable } from "babylonjs/types";
  64293. import { Camera } from "babylonjs/Cameras/camera";
  64294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64295. import "babylonjs/Shaders/sharpen.fragment";
  64296. import { Engine } from "babylonjs/Engines/engine";
  64297. /**
  64298. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64299. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64300. */
  64301. export class SharpenPostProcess extends PostProcess {
  64302. /**
  64303. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64304. */
  64305. colorAmount: number;
  64306. /**
  64307. * How much sharpness should be applied (default: 0.3)
  64308. */
  64309. edgeAmount: number;
  64310. /**
  64311. * Creates a new instance ConvolutionPostProcess
  64312. * @param name The name of the effect.
  64313. * @param options The required width/height ratio to downsize to before computing the render pass.
  64314. * @param camera The camera to apply the render pass to.
  64315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64316. * @param engine The engine which the post process will be applied. (default: current engine)
  64317. * @param reusable If the post process can be reused on the same frame. (default: false)
  64318. * @param textureType Type of textures used when performing the post process. (default: 0)
  64319. * @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)
  64320. */
  64321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64322. }
  64323. }
  64324. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64325. import { Nullable } from "babylonjs/types";
  64326. import { Camera } from "babylonjs/Cameras/camera";
  64327. import { Engine } from "babylonjs/Engines/engine";
  64328. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64329. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64330. /**
  64331. * PostProcessRenderPipeline
  64332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64333. */
  64334. export class PostProcessRenderPipeline {
  64335. private engine;
  64336. private _renderEffects;
  64337. private _renderEffectsForIsolatedPass;
  64338. /**
  64339. * List of inspectable custom properties (used by the Inspector)
  64340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64341. */
  64342. inspectableCustomProperties: IInspectable[];
  64343. /**
  64344. * @hidden
  64345. */
  64346. protected _cameras: Camera[];
  64347. /** @hidden */
  64348. _name: string;
  64349. /**
  64350. * Gets pipeline name
  64351. */
  64352. readonly name: string;
  64353. /** Gets the list of attached cameras */
  64354. readonly cameras: Camera[];
  64355. /**
  64356. * Initializes a PostProcessRenderPipeline
  64357. * @param engine engine to add the pipeline to
  64358. * @param name name of the pipeline
  64359. */
  64360. constructor(engine: Engine, name: string);
  64361. /**
  64362. * Gets the class name
  64363. * @returns "PostProcessRenderPipeline"
  64364. */
  64365. getClassName(): string;
  64366. /**
  64367. * If all the render effects in the pipeline are supported
  64368. */
  64369. readonly isSupported: boolean;
  64370. /**
  64371. * Adds an effect to the pipeline
  64372. * @param renderEffect the effect to add
  64373. */
  64374. addEffect(renderEffect: PostProcessRenderEffect): void;
  64375. /** @hidden */
  64376. _rebuild(): void;
  64377. /** @hidden */
  64378. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64379. /** @hidden */
  64380. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64381. /** @hidden */
  64382. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64383. /** @hidden */
  64384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64385. /** @hidden */
  64386. _attachCameras(cameras: Camera, unique: boolean): void;
  64387. /** @hidden */
  64388. _attachCameras(cameras: Camera[], unique: boolean): void;
  64389. /** @hidden */
  64390. _detachCameras(cameras: Camera): void;
  64391. /** @hidden */
  64392. _detachCameras(cameras: Nullable<Camera[]>): void;
  64393. /** @hidden */
  64394. _update(): void;
  64395. /** @hidden */
  64396. _reset(): void;
  64397. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64398. /**
  64399. * Disposes of the pipeline
  64400. */
  64401. dispose(): void;
  64402. }
  64403. }
  64404. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64405. import { Camera } from "babylonjs/Cameras/camera";
  64406. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64407. /**
  64408. * PostProcessRenderPipelineManager class
  64409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64410. */
  64411. export class PostProcessRenderPipelineManager {
  64412. private _renderPipelines;
  64413. /**
  64414. * Initializes a PostProcessRenderPipelineManager
  64415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64416. */
  64417. constructor();
  64418. /**
  64419. * Gets the list of supported render pipelines
  64420. */
  64421. readonly supportedPipelines: PostProcessRenderPipeline[];
  64422. /**
  64423. * Adds a pipeline to the manager
  64424. * @param renderPipeline The pipeline to add
  64425. */
  64426. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64427. /**
  64428. * Attaches a camera to the pipeline
  64429. * @param renderPipelineName The name of the pipeline to attach to
  64430. * @param cameras the camera to attach
  64431. * @param unique if the camera can be attached multiple times to the pipeline
  64432. */
  64433. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64434. /**
  64435. * Detaches a camera from the pipeline
  64436. * @param renderPipelineName The name of the pipeline to detach from
  64437. * @param cameras the camera to detach
  64438. */
  64439. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64440. /**
  64441. * Enables an effect by name on a pipeline
  64442. * @param renderPipelineName the name of the pipeline to enable the effect in
  64443. * @param renderEffectName the name of the effect to enable
  64444. * @param cameras the cameras that the effect should be enabled on
  64445. */
  64446. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64447. /**
  64448. * Disables an effect by name on a pipeline
  64449. * @param renderPipelineName the name of the pipeline to disable the effect in
  64450. * @param renderEffectName the name of the effect to disable
  64451. * @param cameras the cameras that the effect should be disabled on
  64452. */
  64453. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64454. /**
  64455. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64456. */
  64457. update(): void;
  64458. /** @hidden */
  64459. _rebuild(): void;
  64460. /**
  64461. * Disposes of the manager and pipelines
  64462. */
  64463. dispose(): void;
  64464. }
  64465. }
  64466. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64467. import { ISceneComponent } from "babylonjs/sceneComponent";
  64468. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64469. import { Scene } from "babylonjs/scene";
  64470. module "babylonjs/scene" {
  64471. interface Scene {
  64472. /** @hidden (Backing field) */
  64473. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64474. /**
  64475. * Gets the postprocess render pipeline manager
  64476. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64477. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64478. */
  64479. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64480. }
  64481. }
  64482. /**
  64483. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64484. */
  64485. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64486. /**
  64487. * The component name helpfull to identify the component in the list of scene components.
  64488. */
  64489. readonly name: string;
  64490. /**
  64491. * The scene the component belongs to.
  64492. */
  64493. scene: Scene;
  64494. /**
  64495. * Creates a new instance of the component for the given scene
  64496. * @param scene Defines the scene to register the component in
  64497. */
  64498. constructor(scene: Scene);
  64499. /**
  64500. * Registers the component in a given scene
  64501. */
  64502. register(): void;
  64503. /**
  64504. * Rebuilds the elements related to this component in case of
  64505. * context lost for instance.
  64506. */
  64507. rebuild(): void;
  64508. /**
  64509. * Disposes the component and the associated ressources
  64510. */
  64511. dispose(): void;
  64512. private _gatherRenderTargets;
  64513. }
  64514. }
  64515. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64516. import { Nullable } from "babylonjs/types";
  64517. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64518. import { Camera } from "babylonjs/Cameras/camera";
  64519. import { IDisposable } from "babylonjs/scene";
  64520. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64521. import { Scene } from "babylonjs/scene";
  64522. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64523. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64524. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64525. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64526. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64528. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64529. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64530. import { Animation } from "babylonjs/Animations/animation";
  64531. /**
  64532. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64533. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64534. */
  64535. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64536. private _scene;
  64537. private _camerasToBeAttached;
  64538. /**
  64539. * ID of the sharpen post process,
  64540. */
  64541. private readonly SharpenPostProcessId;
  64542. /**
  64543. * @ignore
  64544. * ID of the image processing post process;
  64545. */
  64546. readonly ImageProcessingPostProcessId: string;
  64547. /**
  64548. * @ignore
  64549. * ID of the Fast Approximate Anti-Aliasing post process;
  64550. */
  64551. readonly FxaaPostProcessId: string;
  64552. /**
  64553. * ID of the chromatic aberration post process,
  64554. */
  64555. private readonly ChromaticAberrationPostProcessId;
  64556. /**
  64557. * ID of the grain post process
  64558. */
  64559. private readonly GrainPostProcessId;
  64560. /**
  64561. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64562. */
  64563. sharpen: SharpenPostProcess;
  64564. private _sharpenEffect;
  64565. private bloom;
  64566. /**
  64567. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64568. */
  64569. depthOfField: DepthOfFieldEffect;
  64570. /**
  64571. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64572. */
  64573. fxaa: FxaaPostProcess;
  64574. /**
  64575. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64576. */
  64577. imageProcessing: ImageProcessingPostProcess;
  64578. /**
  64579. * Chromatic aberration post process which will shift rgb colors in the image
  64580. */
  64581. chromaticAberration: ChromaticAberrationPostProcess;
  64582. private _chromaticAberrationEffect;
  64583. /**
  64584. * Grain post process which add noise to the image
  64585. */
  64586. grain: GrainPostProcess;
  64587. private _grainEffect;
  64588. /**
  64589. * Glow post process which adds a glow to emissive areas of the image
  64590. */
  64591. private _glowLayer;
  64592. /**
  64593. * Animations which can be used to tweak settings over a period of time
  64594. */
  64595. animations: Animation[];
  64596. private _imageProcessingConfigurationObserver;
  64597. private _sharpenEnabled;
  64598. private _bloomEnabled;
  64599. private _depthOfFieldEnabled;
  64600. private _depthOfFieldBlurLevel;
  64601. private _fxaaEnabled;
  64602. private _imageProcessingEnabled;
  64603. private _defaultPipelineTextureType;
  64604. private _bloomScale;
  64605. private _chromaticAberrationEnabled;
  64606. private _grainEnabled;
  64607. private _buildAllowed;
  64608. /**
  64609. * Gets active scene
  64610. */
  64611. readonly scene: Scene;
  64612. /**
  64613. * Enable or disable the sharpen process from the pipeline
  64614. */
  64615. sharpenEnabled: boolean;
  64616. private _resizeObserver;
  64617. private _hardwareScaleLevel;
  64618. private _bloomKernel;
  64619. /**
  64620. * Specifies the size of the bloom blur kernel, relative to the final output size
  64621. */
  64622. bloomKernel: number;
  64623. /**
  64624. * Specifies the weight of the bloom in the final rendering
  64625. */
  64626. private _bloomWeight;
  64627. /**
  64628. * Specifies the luma threshold for the area that will be blurred by the bloom
  64629. */
  64630. private _bloomThreshold;
  64631. private _hdr;
  64632. /**
  64633. * The strength of the bloom.
  64634. */
  64635. bloomWeight: number;
  64636. /**
  64637. * The strength of the bloom.
  64638. */
  64639. bloomThreshold: number;
  64640. /**
  64641. * The scale of the bloom, lower value will provide better performance.
  64642. */
  64643. bloomScale: number;
  64644. /**
  64645. * Enable or disable the bloom from the pipeline
  64646. */
  64647. bloomEnabled: boolean;
  64648. private _rebuildBloom;
  64649. /**
  64650. * If the depth of field is enabled.
  64651. */
  64652. depthOfFieldEnabled: boolean;
  64653. /**
  64654. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64655. */
  64656. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64657. /**
  64658. * If the anti aliasing is enabled.
  64659. */
  64660. fxaaEnabled: boolean;
  64661. private _samples;
  64662. /**
  64663. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64664. */
  64665. samples: number;
  64666. /**
  64667. * If image processing is enabled.
  64668. */
  64669. imageProcessingEnabled: boolean;
  64670. /**
  64671. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64672. */
  64673. glowLayerEnabled: boolean;
  64674. /**
  64675. * Gets the glow layer (or null if not defined)
  64676. */
  64677. readonly glowLayer: Nullable<GlowLayer>;
  64678. /**
  64679. * Enable or disable the chromaticAberration process from the pipeline
  64680. */
  64681. chromaticAberrationEnabled: boolean;
  64682. /**
  64683. * Enable or disable the grain process from the pipeline
  64684. */
  64685. grainEnabled: boolean;
  64686. /**
  64687. * @constructor
  64688. * @param name - The rendering pipeline name (default: "")
  64689. * @param hdr - If high dynamic range textures should be used (default: true)
  64690. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64691. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64692. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64693. */
  64694. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64695. /**
  64696. * Get the class name
  64697. * @returns "DefaultRenderingPipeline"
  64698. */
  64699. getClassName(): string;
  64700. /**
  64701. * Force the compilation of the entire pipeline.
  64702. */
  64703. prepare(): void;
  64704. private _hasCleared;
  64705. private _prevPostProcess;
  64706. private _prevPrevPostProcess;
  64707. private _setAutoClearAndTextureSharing;
  64708. private _depthOfFieldSceneObserver;
  64709. private _buildPipeline;
  64710. private _disposePostProcesses;
  64711. /**
  64712. * Adds a camera to the pipeline
  64713. * @param camera the camera to be added
  64714. */
  64715. addCamera(camera: Camera): void;
  64716. /**
  64717. * Removes a camera from the pipeline
  64718. * @param camera the camera to remove
  64719. */
  64720. removeCamera(camera: Camera): void;
  64721. /**
  64722. * Dispose of the pipeline and stop all post processes
  64723. */
  64724. dispose(): void;
  64725. /**
  64726. * Serialize the rendering pipeline (Used when exporting)
  64727. * @returns the serialized object
  64728. */
  64729. serialize(): any;
  64730. /**
  64731. * Parse the serialized pipeline
  64732. * @param source Source pipeline.
  64733. * @param scene The scene to load the pipeline to.
  64734. * @param rootUrl The URL of the serialized pipeline.
  64735. * @returns An instantiated pipeline from the serialized object.
  64736. */
  64737. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64738. }
  64739. }
  64740. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64741. /** @hidden */
  64742. export var lensHighlightsPixelShader: {
  64743. name: string;
  64744. shader: string;
  64745. };
  64746. }
  64747. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64748. /** @hidden */
  64749. export var depthOfFieldPixelShader: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64755. import { Camera } from "babylonjs/Cameras/camera";
  64756. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64757. import { Scene } from "babylonjs/scene";
  64758. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64759. import "babylonjs/Shaders/chromaticAberration.fragment";
  64760. import "babylonjs/Shaders/lensHighlights.fragment";
  64761. import "babylonjs/Shaders/depthOfField.fragment";
  64762. /**
  64763. * BABYLON.JS Chromatic Aberration GLSL Shader
  64764. * Author: Olivier Guyot
  64765. * Separates very slightly R, G and B colors on the edges of the screen
  64766. * Inspired by Francois Tarlier & Martins Upitis
  64767. */
  64768. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64769. /**
  64770. * @ignore
  64771. * The chromatic aberration PostProcess id in the pipeline
  64772. */
  64773. LensChromaticAberrationEffect: string;
  64774. /**
  64775. * @ignore
  64776. * The highlights enhancing PostProcess id in the pipeline
  64777. */
  64778. HighlightsEnhancingEffect: string;
  64779. /**
  64780. * @ignore
  64781. * The depth-of-field PostProcess id in the pipeline
  64782. */
  64783. LensDepthOfFieldEffect: string;
  64784. private _scene;
  64785. private _depthTexture;
  64786. private _grainTexture;
  64787. private _chromaticAberrationPostProcess;
  64788. private _highlightsPostProcess;
  64789. private _depthOfFieldPostProcess;
  64790. private _edgeBlur;
  64791. private _grainAmount;
  64792. private _chromaticAberration;
  64793. private _distortion;
  64794. private _highlightsGain;
  64795. private _highlightsThreshold;
  64796. private _dofDistance;
  64797. private _dofAperture;
  64798. private _dofDarken;
  64799. private _dofPentagon;
  64800. private _blurNoise;
  64801. /**
  64802. * @constructor
  64803. *
  64804. * Effect parameters are as follow:
  64805. * {
  64806. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64807. * edge_blur: number; // from 0 to x (1 for realism)
  64808. * distortion: number; // from 0 to x (1 for realism)
  64809. * grain_amount: number; // from 0 to 1
  64810. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64811. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64812. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64813. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64814. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64815. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64816. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64817. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64818. * }
  64819. * Note: if an effect parameter is unset, effect is disabled
  64820. *
  64821. * @param name The rendering pipeline name
  64822. * @param parameters - An object containing all parameters (see above)
  64823. * @param scene The scene linked to this pipeline
  64824. * @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)
  64825. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64826. */
  64827. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64828. /**
  64829. * Get the class name
  64830. * @returns "LensRenderingPipeline"
  64831. */
  64832. getClassName(): string;
  64833. /**
  64834. * Gets associated scene
  64835. */
  64836. readonly scene: Scene;
  64837. /**
  64838. * Gets or sets the edge blur
  64839. */
  64840. edgeBlur: number;
  64841. /**
  64842. * Gets or sets the grain amount
  64843. */
  64844. grainAmount: number;
  64845. /**
  64846. * Gets or sets the chromatic aberration amount
  64847. */
  64848. chromaticAberration: number;
  64849. /**
  64850. * Gets or sets the depth of field aperture
  64851. */
  64852. dofAperture: number;
  64853. /**
  64854. * Gets or sets the edge distortion
  64855. */
  64856. edgeDistortion: number;
  64857. /**
  64858. * Gets or sets the depth of field distortion
  64859. */
  64860. dofDistortion: number;
  64861. /**
  64862. * Gets or sets the darken out of focus amount
  64863. */
  64864. darkenOutOfFocus: number;
  64865. /**
  64866. * Gets or sets a boolean indicating if blur noise is enabled
  64867. */
  64868. blurNoise: boolean;
  64869. /**
  64870. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64871. */
  64872. pentagonBokeh: boolean;
  64873. /**
  64874. * Gets or sets the highlight grain amount
  64875. */
  64876. highlightsGain: number;
  64877. /**
  64878. * Gets or sets the highlight threshold
  64879. */
  64880. highlightsThreshold: number;
  64881. /**
  64882. * Sets the amount of blur at the edges
  64883. * @param amount blur amount
  64884. */
  64885. setEdgeBlur(amount: number): void;
  64886. /**
  64887. * Sets edge blur to 0
  64888. */
  64889. disableEdgeBlur(): void;
  64890. /**
  64891. * Sets the amout of grain
  64892. * @param amount Amount of grain
  64893. */
  64894. setGrainAmount(amount: number): void;
  64895. /**
  64896. * Set grain amount to 0
  64897. */
  64898. disableGrain(): void;
  64899. /**
  64900. * Sets the chromatic aberration amount
  64901. * @param amount amount of chromatic aberration
  64902. */
  64903. setChromaticAberration(amount: number): void;
  64904. /**
  64905. * Sets chromatic aberration amount to 0
  64906. */
  64907. disableChromaticAberration(): void;
  64908. /**
  64909. * Sets the EdgeDistortion amount
  64910. * @param amount amount of EdgeDistortion
  64911. */
  64912. setEdgeDistortion(amount: number): void;
  64913. /**
  64914. * Sets edge distortion to 0
  64915. */
  64916. disableEdgeDistortion(): void;
  64917. /**
  64918. * Sets the FocusDistance amount
  64919. * @param amount amount of FocusDistance
  64920. */
  64921. setFocusDistance(amount: number): void;
  64922. /**
  64923. * Disables depth of field
  64924. */
  64925. disableDepthOfField(): void;
  64926. /**
  64927. * Sets the Aperture amount
  64928. * @param amount amount of Aperture
  64929. */
  64930. setAperture(amount: number): void;
  64931. /**
  64932. * Sets the DarkenOutOfFocus amount
  64933. * @param amount amount of DarkenOutOfFocus
  64934. */
  64935. setDarkenOutOfFocus(amount: number): void;
  64936. private _pentagonBokehIsEnabled;
  64937. /**
  64938. * Creates a pentagon bokeh effect
  64939. */
  64940. enablePentagonBokeh(): void;
  64941. /**
  64942. * Disables the pentagon bokeh effect
  64943. */
  64944. disablePentagonBokeh(): void;
  64945. /**
  64946. * Enables noise blur
  64947. */
  64948. enableNoiseBlur(): void;
  64949. /**
  64950. * Disables noise blur
  64951. */
  64952. disableNoiseBlur(): void;
  64953. /**
  64954. * Sets the HighlightsGain amount
  64955. * @param amount amount of HighlightsGain
  64956. */
  64957. setHighlightsGain(amount: number): void;
  64958. /**
  64959. * Sets the HighlightsThreshold amount
  64960. * @param amount amount of HighlightsThreshold
  64961. */
  64962. setHighlightsThreshold(amount: number): void;
  64963. /**
  64964. * Disables highlights
  64965. */
  64966. disableHighlights(): void;
  64967. /**
  64968. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64969. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64970. */
  64971. dispose(disableDepthRender?: boolean): void;
  64972. private _createChromaticAberrationPostProcess;
  64973. private _createHighlightsPostProcess;
  64974. private _createDepthOfFieldPostProcess;
  64975. private _createGrainTexture;
  64976. }
  64977. }
  64978. declare module "babylonjs/Shaders/ssao2.fragment" {
  64979. /** @hidden */
  64980. export var ssao2PixelShader: {
  64981. name: string;
  64982. shader: string;
  64983. };
  64984. }
  64985. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64986. /** @hidden */
  64987. export var ssaoCombinePixelShader: {
  64988. name: string;
  64989. shader: string;
  64990. };
  64991. }
  64992. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64993. import { Camera } from "babylonjs/Cameras/camera";
  64994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64995. import { Scene } from "babylonjs/scene";
  64996. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64997. import "babylonjs/Shaders/ssao2.fragment";
  64998. import "babylonjs/Shaders/ssaoCombine.fragment";
  64999. /**
  65000. * Render pipeline to produce ssao effect
  65001. */
  65002. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65003. /**
  65004. * @ignore
  65005. * The PassPostProcess id in the pipeline that contains the original scene color
  65006. */
  65007. SSAOOriginalSceneColorEffect: string;
  65008. /**
  65009. * @ignore
  65010. * The SSAO PostProcess id in the pipeline
  65011. */
  65012. SSAORenderEffect: string;
  65013. /**
  65014. * @ignore
  65015. * The horizontal blur PostProcess id in the pipeline
  65016. */
  65017. SSAOBlurHRenderEffect: string;
  65018. /**
  65019. * @ignore
  65020. * The vertical blur PostProcess id in the pipeline
  65021. */
  65022. SSAOBlurVRenderEffect: string;
  65023. /**
  65024. * @ignore
  65025. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65026. */
  65027. SSAOCombineRenderEffect: string;
  65028. /**
  65029. * The output strength of the SSAO post-process. Default value is 1.0.
  65030. */
  65031. totalStrength: number;
  65032. /**
  65033. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65034. */
  65035. maxZ: number;
  65036. /**
  65037. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65038. */
  65039. minZAspect: number;
  65040. private _samples;
  65041. /**
  65042. * Number of samples used for the SSAO calculations. Default value is 8
  65043. */
  65044. samples: number;
  65045. private _textureSamples;
  65046. /**
  65047. * Number of samples to use for antialiasing
  65048. */
  65049. textureSamples: number;
  65050. /**
  65051. * Ratio object used for SSAO ratio and blur ratio
  65052. */
  65053. private _ratio;
  65054. /**
  65055. * Dynamically generated sphere sampler.
  65056. */
  65057. private _sampleSphere;
  65058. /**
  65059. * Blur filter offsets
  65060. */
  65061. private _samplerOffsets;
  65062. private _expensiveBlur;
  65063. /**
  65064. * If bilateral blur should be used
  65065. */
  65066. expensiveBlur: boolean;
  65067. /**
  65068. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65069. */
  65070. radius: number;
  65071. /**
  65072. * The base color of the SSAO post-process
  65073. * The final result is "base + ssao" between [0, 1]
  65074. */
  65075. base: number;
  65076. /**
  65077. * Support test.
  65078. */
  65079. static readonly IsSupported: boolean;
  65080. private _scene;
  65081. private _depthTexture;
  65082. private _normalTexture;
  65083. private _randomTexture;
  65084. private _originalColorPostProcess;
  65085. private _ssaoPostProcess;
  65086. private _blurHPostProcess;
  65087. private _blurVPostProcess;
  65088. private _ssaoCombinePostProcess;
  65089. /**
  65090. * Gets active scene
  65091. */
  65092. readonly scene: Scene;
  65093. /**
  65094. * @constructor
  65095. * @param name The rendering pipeline name
  65096. * @param scene The scene linked to this pipeline
  65097. * @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 }
  65098. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65099. */
  65100. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65101. /**
  65102. * Get the class name
  65103. * @returns "SSAO2RenderingPipeline"
  65104. */
  65105. getClassName(): string;
  65106. /**
  65107. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65108. */
  65109. dispose(disableGeometryBufferRenderer?: boolean): void;
  65110. private _createBlurPostProcess;
  65111. /** @hidden */
  65112. _rebuild(): void;
  65113. private _bits;
  65114. private _radicalInverse_VdC;
  65115. private _hammersley;
  65116. private _hemisphereSample_uniform;
  65117. private _generateHemisphere;
  65118. private _createSSAOPostProcess;
  65119. private _createSSAOCombinePostProcess;
  65120. private _createRandomTexture;
  65121. /**
  65122. * Serialize the rendering pipeline (Used when exporting)
  65123. * @returns the serialized object
  65124. */
  65125. serialize(): any;
  65126. /**
  65127. * Parse the serialized pipeline
  65128. * @param source Source pipeline.
  65129. * @param scene The scene to load the pipeline to.
  65130. * @param rootUrl The URL of the serialized pipeline.
  65131. * @returns An instantiated pipeline from the serialized object.
  65132. */
  65133. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65134. }
  65135. }
  65136. declare module "babylonjs/Shaders/ssao.fragment" {
  65137. /** @hidden */
  65138. export var ssaoPixelShader: {
  65139. name: string;
  65140. shader: string;
  65141. };
  65142. }
  65143. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65144. import { Camera } from "babylonjs/Cameras/camera";
  65145. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65146. import { Scene } from "babylonjs/scene";
  65147. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65148. import "babylonjs/Shaders/ssao.fragment";
  65149. import "babylonjs/Shaders/ssaoCombine.fragment";
  65150. /**
  65151. * Render pipeline to produce ssao effect
  65152. */
  65153. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65154. /**
  65155. * @ignore
  65156. * The PassPostProcess id in the pipeline that contains the original scene color
  65157. */
  65158. SSAOOriginalSceneColorEffect: string;
  65159. /**
  65160. * @ignore
  65161. * The SSAO PostProcess id in the pipeline
  65162. */
  65163. SSAORenderEffect: string;
  65164. /**
  65165. * @ignore
  65166. * The horizontal blur PostProcess id in the pipeline
  65167. */
  65168. SSAOBlurHRenderEffect: string;
  65169. /**
  65170. * @ignore
  65171. * The vertical blur PostProcess id in the pipeline
  65172. */
  65173. SSAOBlurVRenderEffect: string;
  65174. /**
  65175. * @ignore
  65176. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65177. */
  65178. SSAOCombineRenderEffect: string;
  65179. /**
  65180. * The output strength of the SSAO post-process. Default value is 1.0.
  65181. */
  65182. totalStrength: number;
  65183. /**
  65184. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65185. */
  65186. radius: number;
  65187. /**
  65188. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65189. * Must not be equal to fallOff and superior to fallOff.
  65190. * Default value is 0.0075
  65191. */
  65192. area: number;
  65193. /**
  65194. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65195. * Must not be equal to area and inferior to area.
  65196. * Default value is 0.000001
  65197. */
  65198. fallOff: number;
  65199. /**
  65200. * The base color of the SSAO post-process
  65201. * The final result is "base + ssao" between [0, 1]
  65202. */
  65203. base: number;
  65204. private _scene;
  65205. private _depthTexture;
  65206. private _randomTexture;
  65207. private _originalColorPostProcess;
  65208. private _ssaoPostProcess;
  65209. private _blurHPostProcess;
  65210. private _blurVPostProcess;
  65211. private _ssaoCombinePostProcess;
  65212. private _firstUpdate;
  65213. /**
  65214. * Gets active scene
  65215. */
  65216. readonly scene: Scene;
  65217. /**
  65218. * @constructor
  65219. * @param name - The rendering pipeline name
  65220. * @param scene - The scene linked to this pipeline
  65221. * @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 }
  65222. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65223. */
  65224. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65225. /**
  65226. * Get the class name
  65227. * @returns "SSAORenderingPipeline"
  65228. */
  65229. getClassName(): string;
  65230. /**
  65231. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65232. */
  65233. dispose(disableDepthRender?: boolean): void;
  65234. private _createBlurPostProcess;
  65235. /** @hidden */
  65236. _rebuild(): void;
  65237. private _createSSAOPostProcess;
  65238. private _createSSAOCombinePostProcess;
  65239. private _createRandomTexture;
  65240. }
  65241. }
  65242. declare module "babylonjs/Shaders/standard.fragment" {
  65243. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65244. /** @hidden */
  65245. export var standardPixelShader: {
  65246. name: string;
  65247. shader: string;
  65248. };
  65249. }
  65250. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65251. import { Nullable } from "babylonjs/types";
  65252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65253. import { Camera } from "babylonjs/Cameras/camera";
  65254. import { Texture } from "babylonjs/Materials/Textures/texture";
  65255. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65256. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65257. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65258. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65259. import { IDisposable } from "babylonjs/scene";
  65260. import { SpotLight } from "babylonjs/Lights/spotLight";
  65261. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65262. import { Scene } from "babylonjs/scene";
  65263. import { Animation } from "babylonjs/Animations/animation";
  65264. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65265. import "babylonjs/Shaders/standard.fragment";
  65266. /**
  65267. * Standard rendering pipeline
  65268. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65269. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65270. */
  65271. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65272. /**
  65273. * Public members
  65274. */
  65275. /**
  65276. * Post-process which contains the original scene color before the pipeline applies all the effects
  65277. */
  65278. originalPostProcess: Nullable<PostProcess>;
  65279. /**
  65280. * Post-process used to down scale an image x4
  65281. */
  65282. downSampleX4PostProcess: Nullable<PostProcess>;
  65283. /**
  65284. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65285. */
  65286. brightPassPostProcess: Nullable<PostProcess>;
  65287. /**
  65288. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65289. */
  65290. blurHPostProcesses: PostProcess[];
  65291. /**
  65292. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65293. */
  65294. blurVPostProcesses: PostProcess[];
  65295. /**
  65296. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65297. */
  65298. textureAdderPostProcess: Nullable<PostProcess>;
  65299. /**
  65300. * Post-process used to create volumetric lighting effect
  65301. */
  65302. volumetricLightPostProcess: Nullable<PostProcess>;
  65303. /**
  65304. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65305. */
  65306. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65307. /**
  65308. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65309. */
  65310. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65311. /**
  65312. * Post-process used to merge the volumetric light effect and the real scene color
  65313. */
  65314. volumetricLightMergePostProces: Nullable<PostProcess>;
  65315. /**
  65316. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65317. */
  65318. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65319. /**
  65320. * Base post-process used to calculate the average luminance of the final image for HDR
  65321. */
  65322. luminancePostProcess: Nullable<PostProcess>;
  65323. /**
  65324. * Post-processes used to create down sample post-processes in order to get
  65325. * the average luminance of the final image for HDR
  65326. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65327. */
  65328. luminanceDownSamplePostProcesses: PostProcess[];
  65329. /**
  65330. * Post-process used to create a HDR effect (light adaptation)
  65331. */
  65332. hdrPostProcess: Nullable<PostProcess>;
  65333. /**
  65334. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65335. */
  65336. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65337. /**
  65338. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65339. */
  65340. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65341. /**
  65342. * Post-process used to merge the final HDR post-process and the real scene color
  65343. */
  65344. hdrFinalPostProcess: Nullable<PostProcess>;
  65345. /**
  65346. * Post-process used to create a lens flare effect
  65347. */
  65348. lensFlarePostProcess: Nullable<PostProcess>;
  65349. /**
  65350. * Post-process that merges the result of the lens flare post-process and the real scene color
  65351. */
  65352. lensFlareComposePostProcess: Nullable<PostProcess>;
  65353. /**
  65354. * Post-process used to create a motion blur effect
  65355. */
  65356. motionBlurPostProcess: Nullable<PostProcess>;
  65357. /**
  65358. * Post-process used to create a depth of field effect
  65359. */
  65360. depthOfFieldPostProcess: Nullable<PostProcess>;
  65361. /**
  65362. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65363. */
  65364. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65365. /**
  65366. * Represents the brightness threshold in order to configure the illuminated surfaces
  65367. */
  65368. brightThreshold: number;
  65369. /**
  65370. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65371. */
  65372. blurWidth: number;
  65373. /**
  65374. * Sets if the blur for highlighted surfaces must be only horizontal
  65375. */
  65376. horizontalBlur: boolean;
  65377. /**
  65378. * Gets the overall exposure used by the pipeline
  65379. */
  65380. /**
  65381. * Sets the overall exposure used by the pipeline
  65382. */
  65383. exposure: number;
  65384. /**
  65385. * Texture used typically to simulate "dirty" on camera lens
  65386. */
  65387. lensTexture: Nullable<Texture>;
  65388. /**
  65389. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65390. */
  65391. volumetricLightCoefficient: number;
  65392. /**
  65393. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65394. */
  65395. volumetricLightPower: number;
  65396. /**
  65397. * Used the set the blur intensity to smooth the volumetric lights
  65398. */
  65399. volumetricLightBlurScale: number;
  65400. /**
  65401. * Light (spot or directional) used to generate the volumetric lights rays
  65402. * The source light must have a shadow generate so the pipeline can get its
  65403. * depth map
  65404. */
  65405. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65406. /**
  65407. * For eye adaptation, represents the minimum luminance the eye can see
  65408. */
  65409. hdrMinimumLuminance: number;
  65410. /**
  65411. * For eye adaptation, represents the decrease luminance speed
  65412. */
  65413. hdrDecreaseRate: number;
  65414. /**
  65415. * For eye adaptation, represents the increase luminance speed
  65416. */
  65417. hdrIncreaseRate: number;
  65418. /**
  65419. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65420. */
  65421. /**
  65422. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65423. */
  65424. hdrAutoExposure: boolean;
  65425. /**
  65426. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65427. */
  65428. lensColorTexture: Nullable<Texture>;
  65429. /**
  65430. * The overall strengh for the lens flare effect
  65431. */
  65432. lensFlareStrength: number;
  65433. /**
  65434. * Dispersion coefficient for lens flare ghosts
  65435. */
  65436. lensFlareGhostDispersal: number;
  65437. /**
  65438. * Main lens flare halo width
  65439. */
  65440. lensFlareHaloWidth: number;
  65441. /**
  65442. * Based on the lens distortion effect, defines how much the lens flare result
  65443. * is distorted
  65444. */
  65445. lensFlareDistortionStrength: number;
  65446. /**
  65447. * Configures the blur intensity used for for lens flare (halo)
  65448. */
  65449. lensFlareBlurWidth: number;
  65450. /**
  65451. * Lens star texture must be used to simulate rays on the flares and is available
  65452. * in the documentation
  65453. */
  65454. lensStarTexture: Nullable<Texture>;
  65455. /**
  65456. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65457. * flare effect by taking account of the dirt texture
  65458. */
  65459. lensFlareDirtTexture: Nullable<Texture>;
  65460. /**
  65461. * Represents the focal length for the depth of field effect
  65462. */
  65463. depthOfFieldDistance: number;
  65464. /**
  65465. * Represents the blur intensity for the blurred part of the depth of field effect
  65466. */
  65467. depthOfFieldBlurWidth: number;
  65468. /**
  65469. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65470. */
  65471. /**
  65472. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65473. */
  65474. motionStrength: number;
  65475. /**
  65476. * Gets wether or not the motion blur post-process is object based or screen based.
  65477. */
  65478. /**
  65479. * Sets wether or not the motion blur post-process should be object based or screen based
  65480. */
  65481. objectBasedMotionBlur: boolean;
  65482. /**
  65483. * List of animations for the pipeline (IAnimatable implementation)
  65484. */
  65485. animations: Animation[];
  65486. /**
  65487. * Private members
  65488. */
  65489. private _scene;
  65490. private _currentDepthOfFieldSource;
  65491. private _basePostProcess;
  65492. private _fixedExposure;
  65493. private _currentExposure;
  65494. private _hdrAutoExposure;
  65495. private _hdrCurrentLuminance;
  65496. private _motionStrength;
  65497. private _isObjectBasedMotionBlur;
  65498. private _floatTextureType;
  65499. private _camerasToBeAttached;
  65500. private _ratio;
  65501. private _bloomEnabled;
  65502. private _depthOfFieldEnabled;
  65503. private _vlsEnabled;
  65504. private _lensFlareEnabled;
  65505. private _hdrEnabled;
  65506. private _motionBlurEnabled;
  65507. private _fxaaEnabled;
  65508. private _motionBlurSamples;
  65509. private _volumetricLightStepsCount;
  65510. private _samples;
  65511. /**
  65512. * @ignore
  65513. * Specifies if the bloom pipeline is enabled
  65514. */
  65515. BloomEnabled: boolean;
  65516. /**
  65517. * @ignore
  65518. * Specifies if the depth of field pipeline is enabed
  65519. */
  65520. DepthOfFieldEnabled: boolean;
  65521. /**
  65522. * @ignore
  65523. * Specifies if the lens flare pipeline is enabed
  65524. */
  65525. LensFlareEnabled: boolean;
  65526. /**
  65527. * @ignore
  65528. * Specifies if the HDR pipeline is enabled
  65529. */
  65530. HDREnabled: boolean;
  65531. /**
  65532. * @ignore
  65533. * Specifies if the volumetric lights scattering effect is enabled
  65534. */
  65535. VLSEnabled: boolean;
  65536. /**
  65537. * @ignore
  65538. * Specifies if the motion blur effect is enabled
  65539. */
  65540. MotionBlurEnabled: boolean;
  65541. /**
  65542. * Specifies if anti-aliasing is enabled
  65543. */
  65544. fxaaEnabled: boolean;
  65545. /**
  65546. * Specifies the number of steps used to calculate the volumetric lights
  65547. * Typically in interval [50, 200]
  65548. */
  65549. volumetricLightStepsCount: number;
  65550. /**
  65551. * Specifies the number of samples used for the motion blur effect
  65552. * Typically in interval [16, 64]
  65553. */
  65554. motionBlurSamples: number;
  65555. /**
  65556. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65557. */
  65558. samples: number;
  65559. /**
  65560. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65561. * @constructor
  65562. * @param name The rendering pipeline name
  65563. * @param scene The scene linked to this pipeline
  65564. * @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)
  65565. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65566. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65567. */
  65568. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65569. private _buildPipeline;
  65570. private _createDownSampleX4PostProcess;
  65571. private _createBrightPassPostProcess;
  65572. private _createBlurPostProcesses;
  65573. private _createTextureAdderPostProcess;
  65574. private _createVolumetricLightPostProcess;
  65575. private _createLuminancePostProcesses;
  65576. private _createHdrPostProcess;
  65577. private _createLensFlarePostProcess;
  65578. private _createDepthOfFieldPostProcess;
  65579. private _createMotionBlurPostProcess;
  65580. private _getDepthTexture;
  65581. private _disposePostProcesses;
  65582. /**
  65583. * Dispose of the pipeline and stop all post processes
  65584. */
  65585. dispose(): void;
  65586. /**
  65587. * Serialize the rendering pipeline (Used when exporting)
  65588. * @returns the serialized object
  65589. */
  65590. serialize(): any;
  65591. /**
  65592. * Parse the serialized pipeline
  65593. * @param source Source pipeline.
  65594. * @param scene The scene to load the pipeline to.
  65595. * @param rootUrl The URL of the serialized pipeline.
  65596. * @returns An instantiated pipeline from the serialized object.
  65597. */
  65598. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65599. /**
  65600. * Luminance steps
  65601. */
  65602. static LuminanceSteps: number;
  65603. }
  65604. }
  65605. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65606. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65607. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65608. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65609. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65610. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65611. }
  65612. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65613. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65614. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65615. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65616. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65617. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65618. }
  65619. declare module "babylonjs/Shaders/tonemap.fragment" {
  65620. /** @hidden */
  65621. export var tonemapPixelShader: {
  65622. name: string;
  65623. shader: string;
  65624. };
  65625. }
  65626. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65627. import { Camera } from "babylonjs/Cameras/camera";
  65628. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65629. import "babylonjs/Shaders/tonemap.fragment";
  65630. import { Engine } from "babylonjs/Engines/engine";
  65631. /** Defines operator used for tonemapping */
  65632. export enum TonemappingOperator {
  65633. /** Hable */
  65634. Hable = 0,
  65635. /** Reinhard */
  65636. Reinhard = 1,
  65637. /** HejiDawson */
  65638. HejiDawson = 2,
  65639. /** Photographic */
  65640. Photographic = 3
  65641. }
  65642. /**
  65643. * Defines a post process to apply tone mapping
  65644. */
  65645. export class TonemapPostProcess extends PostProcess {
  65646. private _operator;
  65647. /** Defines the required exposure adjustement */
  65648. exposureAdjustment: number;
  65649. /**
  65650. * Creates a new TonemapPostProcess
  65651. * @param name defines the name of the postprocess
  65652. * @param _operator defines the operator to use
  65653. * @param exposureAdjustment defines the required exposure adjustement
  65654. * @param camera defines the camera to use (can be null)
  65655. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65656. * @param engine defines the hosting engine (can be ignore if camera is set)
  65657. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65658. */
  65659. constructor(name: string, _operator: TonemappingOperator,
  65660. /** Defines the required exposure adjustement */
  65661. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65662. }
  65663. }
  65664. declare module "babylonjs/Shaders/depth.vertex" {
  65665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65666. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65667. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65668. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65669. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65670. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65671. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65672. /** @hidden */
  65673. export var depthVertexShader: {
  65674. name: string;
  65675. shader: string;
  65676. };
  65677. }
  65678. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65679. /** @hidden */
  65680. export var volumetricLightScatteringPixelShader: {
  65681. name: string;
  65682. shader: string;
  65683. };
  65684. }
  65685. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65686. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65687. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65690. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65691. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65692. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65693. /** @hidden */
  65694. export var volumetricLightScatteringPassVertexShader: {
  65695. name: string;
  65696. shader: string;
  65697. };
  65698. }
  65699. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65700. /** @hidden */
  65701. export var volumetricLightScatteringPassPixelShader: {
  65702. name: string;
  65703. shader: string;
  65704. };
  65705. }
  65706. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65707. import { Vector3 } from "babylonjs/Maths/math.vector";
  65708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65709. import { Mesh } from "babylonjs/Meshes/mesh";
  65710. import { Camera } from "babylonjs/Cameras/camera";
  65711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65712. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65713. import { Scene } from "babylonjs/scene";
  65714. import "babylonjs/Meshes/Builders/planeBuilder";
  65715. import "babylonjs/Shaders/depth.vertex";
  65716. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65717. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65718. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65719. import { Engine } from "babylonjs/Engines/engine";
  65720. /**
  65721. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65722. */
  65723. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65724. private _volumetricLightScatteringPass;
  65725. private _volumetricLightScatteringRTT;
  65726. private _viewPort;
  65727. private _screenCoordinates;
  65728. private _cachedDefines;
  65729. /**
  65730. * If not undefined, the mesh position is computed from the attached node position
  65731. */
  65732. attachedNode: {
  65733. position: Vector3;
  65734. };
  65735. /**
  65736. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65737. */
  65738. customMeshPosition: Vector3;
  65739. /**
  65740. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65741. */
  65742. useCustomMeshPosition: boolean;
  65743. /**
  65744. * If the post-process should inverse the light scattering direction
  65745. */
  65746. invert: boolean;
  65747. /**
  65748. * The internal mesh used by the post-process
  65749. */
  65750. mesh: Mesh;
  65751. /**
  65752. * @hidden
  65753. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65754. */
  65755. useDiffuseColor: boolean;
  65756. /**
  65757. * Array containing the excluded meshes not rendered in the internal pass
  65758. */
  65759. excludedMeshes: AbstractMesh[];
  65760. /**
  65761. * Controls the overall intensity of the post-process
  65762. */
  65763. exposure: number;
  65764. /**
  65765. * Dissipates each sample's contribution in range [0, 1]
  65766. */
  65767. decay: number;
  65768. /**
  65769. * Controls the overall intensity of each sample
  65770. */
  65771. weight: number;
  65772. /**
  65773. * Controls the density of each sample
  65774. */
  65775. density: number;
  65776. /**
  65777. * @constructor
  65778. * @param name The post-process name
  65779. * @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)
  65780. * @param camera The camera that the post-process will be attached to
  65781. * @param mesh The mesh used to create the light scattering
  65782. * @param samples The post-process quality, default 100
  65783. * @param samplingModeThe post-process filtering mode
  65784. * @param engine The babylon engine
  65785. * @param reusable If the post-process is reusable
  65786. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65787. */
  65788. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65789. /**
  65790. * Returns the string "VolumetricLightScatteringPostProcess"
  65791. * @returns "VolumetricLightScatteringPostProcess"
  65792. */
  65793. getClassName(): string;
  65794. private _isReady;
  65795. /**
  65796. * Sets the new light position for light scattering effect
  65797. * @param position The new custom light position
  65798. */
  65799. setCustomMeshPosition(position: Vector3): void;
  65800. /**
  65801. * Returns the light position for light scattering effect
  65802. * @return Vector3 The custom light position
  65803. */
  65804. getCustomMeshPosition(): Vector3;
  65805. /**
  65806. * Disposes the internal assets and detaches the post-process from the camera
  65807. */
  65808. dispose(camera: Camera): void;
  65809. /**
  65810. * Returns the render target texture used by the post-process
  65811. * @return the render target texture used by the post-process
  65812. */
  65813. getPass(): RenderTargetTexture;
  65814. private _meshExcluded;
  65815. private _createPass;
  65816. private _updateMeshScreenCoordinates;
  65817. /**
  65818. * Creates a default mesh for the Volumeric Light Scattering post-process
  65819. * @param name The mesh name
  65820. * @param scene The scene where to create the mesh
  65821. * @return the default mesh
  65822. */
  65823. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65824. }
  65825. }
  65826. declare module "babylonjs/PostProcesses/index" {
  65827. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65828. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65829. export * from "babylonjs/PostProcesses/bloomEffect";
  65830. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65831. export * from "babylonjs/PostProcesses/blurPostProcess";
  65832. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65833. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65834. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65835. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65836. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65837. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65838. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65839. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65840. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65841. export * from "babylonjs/PostProcesses/filterPostProcess";
  65842. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65843. export * from "babylonjs/PostProcesses/grainPostProcess";
  65844. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65845. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65846. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65847. export * from "babylonjs/PostProcesses/passPostProcess";
  65848. export * from "babylonjs/PostProcesses/postProcess";
  65849. export * from "babylonjs/PostProcesses/postProcessManager";
  65850. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65851. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65852. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65853. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65854. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65855. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65856. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65857. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65858. }
  65859. declare module "babylonjs/Probes/index" {
  65860. export * from "babylonjs/Probes/reflectionProbe";
  65861. }
  65862. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65863. import { Scene } from "babylonjs/scene";
  65864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65865. import { SmartArray } from "babylonjs/Misc/smartArray";
  65866. import { ISceneComponent } from "babylonjs/sceneComponent";
  65867. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65868. import "babylonjs/Meshes/Builders/boxBuilder";
  65869. import "babylonjs/Shaders/color.fragment";
  65870. import "babylonjs/Shaders/color.vertex";
  65871. import { Color3 } from "babylonjs/Maths/math.color";
  65872. module "babylonjs/scene" {
  65873. interface Scene {
  65874. /** @hidden (Backing field) */
  65875. _boundingBoxRenderer: BoundingBoxRenderer;
  65876. /** @hidden (Backing field) */
  65877. _forceShowBoundingBoxes: boolean;
  65878. /**
  65879. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65880. */
  65881. forceShowBoundingBoxes: boolean;
  65882. /**
  65883. * Gets the bounding box renderer associated with the scene
  65884. * @returns a BoundingBoxRenderer
  65885. */
  65886. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65887. }
  65888. }
  65889. module "babylonjs/Meshes/abstractMesh" {
  65890. interface AbstractMesh {
  65891. /** @hidden (Backing field) */
  65892. _showBoundingBox: boolean;
  65893. /**
  65894. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65895. */
  65896. showBoundingBox: boolean;
  65897. }
  65898. }
  65899. /**
  65900. * Component responsible of rendering the bounding box of the meshes in a scene.
  65901. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65902. */
  65903. export class BoundingBoxRenderer implements ISceneComponent {
  65904. /**
  65905. * The component name helpfull to identify the component in the list of scene components.
  65906. */
  65907. readonly name: string;
  65908. /**
  65909. * The scene the component belongs to.
  65910. */
  65911. scene: Scene;
  65912. /**
  65913. * Color of the bounding box lines placed in front of an object
  65914. */
  65915. frontColor: Color3;
  65916. /**
  65917. * Color of the bounding box lines placed behind an object
  65918. */
  65919. backColor: Color3;
  65920. /**
  65921. * Defines if the renderer should show the back lines or not
  65922. */
  65923. showBackLines: boolean;
  65924. /**
  65925. * @hidden
  65926. */
  65927. renderList: SmartArray<BoundingBox>;
  65928. private _colorShader;
  65929. private _vertexBuffers;
  65930. private _indexBuffer;
  65931. private _fillIndexBuffer;
  65932. private _fillIndexData;
  65933. /**
  65934. * Instantiates a new bounding box renderer in a scene.
  65935. * @param scene the scene the renderer renders in
  65936. */
  65937. constructor(scene: Scene);
  65938. /**
  65939. * Registers the component in a given scene
  65940. */
  65941. register(): void;
  65942. private _evaluateSubMesh;
  65943. private _activeMesh;
  65944. private _prepareRessources;
  65945. private _createIndexBuffer;
  65946. /**
  65947. * Rebuilds the elements related to this component in case of
  65948. * context lost for instance.
  65949. */
  65950. rebuild(): void;
  65951. /**
  65952. * @hidden
  65953. */
  65954. reset(): void;
  65955. /**
  65956. * Render the bounding boxes of a specific rendering group
  65957. * @param renderingGroupId defines the rendering group to render
  65958. */
  65959. render(renderingGroupId: number): void;
  65960. /**
  65961. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65962. * @param mesh Define the mesh to render the occlusion bounding box for
  65963. */
  65964. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65965. /**
  65966. * Dispose and release the resources attached to this renderer.
  65967. */
  65968. dispose(): void;
  65969. }
  65970. }
  65971. declare module "babylonjs/Shaders/depth.fragment" {
  65972. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65973. /** @hidden */
  65974. export var depthPixelShader: {
  65975. name: string;
  65976. shader: string;
  65977. };
  65978. }
  65979. declare module "babylonjs/Rendering/depthRenderer" {
  65980. import { Nullable } from "babylonjs/types";
  65981. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65982. import { Scene } from "babylonjs/scene";
  65983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65984. import { Camera } from "babylonjs/Cameras/camera";
  65985. import "babylonjs/Shaders/depth.fragment";
  65986. import "babylonjs/Shaders/depth.vertex";
  65987. /**
  65988. * This represents a depth renderer in Babylon.
  65989. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65990. */
  65991. export class DepthRenderer {
  65992. private _scene;
  65993. private _depthMap;
  65994. private _effect;
  65995. private readonly _storeNonLinearDepth;
  65996. private readonly _clearColor;
  65997. /** Get if the depth renderer is using packed depth or not */
  65998. readonly isPacked: boolean;
  65999. private _cachedDefines;
  66000. private _camera;
  66001. /**
  66002. * Specifiess that the depth renderer will only be used within
  66003. * the camera it is created for.
  66004. * This can help forcing its rendering during the camera processing.
  66005. */
  66006. useOnlyInActiveCamera: boolean;
  66007. /** @hidden */
  66008. static _SceneComponentInitialization: (scene: Scene) => void;
  66009. /**
  66010. * Instantiates a depth renderer
  66011. * @param scene The scene the renderer belongs to
  66012. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66013. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66014. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66015. */
  66016. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66017. /**
  66018. * Creates the depth rendering effect and checks if the effect is ready.
  66019. * @param subMesh The submesh to be used to render the depth map of
  66020. * @param useInstances If multiple world instances should be used
  66021. * @returns if the depth renderer is ready to render the depth map
  66022. */
  66023. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66024. /**
  66025. * Gets the texture which the depth map will be written to.
  66026. * @returns The depth map texture
  66027. */
  66028. getDepthMap(): RenderTargetTexture;
  66029. /**
  66030. * Disposes of the depth renderer.
  66031. */
  66032. dispose(): void;
  66033. }
  66034. }
  66035. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66036. import { Nullable } from "babylonjs/types";
  66037. import { Scene } from "babylonjs/scene";
  66038. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66039. import { Camera } from "babylonjs/Cameras/camera";
  66040. import { ISceneComponent } from "babylonjs/sceneComponent";
  66041. module "babylonjs/scene" {
  66042. interface Scene {
  66043. /** @hidden (Backing field) */
  66044. _depthRenderer: {
  66045. [id: string]: DepthRenderer;
  66046. };
  66047. /**
  66048. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66049. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66050. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66051. * @returns the created depth renderer
  66052. */
  66053. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66054. /**
  66055. * Disables a depth renderer for a given camera
  66056. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66057. */
  66058. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66059. }
  66060. }
  66061. /**
  66062. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66063. * in several rendering techniques.
  66064. */
  66065. export class DepthRendererSceneComponent implements ISceneComponent {
  66066. /**
  66067. * The component name helpfull to identify the component in the list of scene components.
  66068. */
  66069. readonly name: string;
  66070. /**
  66071. * The scene the component belongs to.
  66072. */
  66073. scene: Scene;
  66074. /**
  66075. * Creates a new instance of the component for the given scene
  66076. * @param scene Defines the scene to register the component in
  66077. */
  66078. constructor(scene: Scene);
  66079. /**
  66080. * Registers the component in a given scene
  66081. */
  66082. register(): void;
  66083. /**
  66084. * Rebuilds the elements related to this component in case of
  66085. * context lost for instance.
  66086. */
  66087. rebuild(): void;
  66088. /**
  66089. * Disposes the component and the associated ressources
  66090. */
  66091. dispose(): void;
  66092. private _gatherRenderTargets;
  66093. private _gatherActiveCameraRenderTargets;
  66094. }
  66095. }
  66096. declare module "babylonjs/Shaders/outline.fragment" {
  66097. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66098. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66099. /** @hidden */
  66100. export var outlinePixelShader: {
  66101. name: string;
  66102. shader: string;
  66103. };
  66104. }
  66105. declare module "babylonjs/Shaders/outline.vertex" {
  66106. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66107. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66108. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66109. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66110. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66111. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66112. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66113. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66114. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66115. /** @hidden */
  66116. export var outlineVertexShader: {
  66117. name: string;
  66118. shader: string;
  66119. };
  66120. }
  66121. declare module "babylonjs/Rendering/outlineRenderer" {
  66122. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66123. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66124. import { Scene } from "babylonjs/scene";
  66125. import { ISceneComponent } from "babylonjs/sceneComponent";
  66126. import "babylonjs/Shaders/outline.fragment";
  66127. import "babylonjs/Shaders/outline.vertex";
  66128. module "babylonjs/scene" {
  66129. interface Scene {
  66130. /** @hidden */
  66131. _outlineRenderer: OutlineRenderer;
  66132. /**
  66133. * Gets the outline renderer associated with the scene
  66134. * @returns a OutlineRenderer
  66135. */
  66136. getOutlineRenderer(): OutlineRenderer;
  66137. }
  66138. }
  66139. module "babylonjs/Meshes/abstractMesh" {
  66140. interface AbstractMesh {
  66141. /** @hidden (Backing field) */
  66142. _renderOutline: boolean;
  66143. /**
  66144. * Gets or sets a boolean indicating if the outline must be rendered as well
  66145. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66146. */
  66147. renderOutline: boolean;
  66148. /** @hidden (Backing field) */
  66149. _renderOverlay: boolean;
  66150. /**
  66151. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66152. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66153. */
  66154. renderOverlay: boolean;
  66155. }
  66156. }
  66157. /**
  66158. * This class is responsible to draw bothe outline/overlay of meshes.
  66159. * It should not be used directly but through the available method on mesh.
  66160. */
  66161. export class OutlineRenderer implements ISceneComponent {
  66162. /**
  66163. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66164. */
  66165. private static _StencilReference;
  66166. /**
  66167. * The name of the component. Each component must have a unique name.
  66168. */
  66169. name: string;
  66170. /**
  66171. * The scene the component belongs to.
  66172. */
  66173. scene: Scene;
  66174. /**
  66175. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66176. */
  66177. zOffset: number;
  66178. private _engine;
  66179. private _effect;
  66180. private _cachedDefines;
  66181. private _savedDepthWrite;
  66182. /**
  66183. * Instantiates a new outline renderer. (There could be only one per scene).
  66184. * @param scene Defines the scene it belongs to
  66185. */
  66186. constructor(scene: Scene);
  66187. /**
  66188. * Register the component to one instance of a scene.
  66189. */
  66190. register(): void;
  66191. /**
  66192. * Rebuilds the elements related to this component in case of
  66193. * context lost for instance.
  66194. */
  66195. rebuild(): void;
  66196. /**
  66197. * Disposes the component and the associated ressources.
  66198. */
  66199. dispose(): void;
  66200. /**
  66201. * Renders the outline in the canvas.
  66202. * @param subMesh Defines the sumesh to render
  66203. * @param batch Defines the batch of meshes in case of instances
  66204. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66205. */
  66206. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66207. /**
  66208. * Returns whether or not the outline renderer is ready for a given submesh.
  66209. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66210. * @param subMesh Defines the submesh to check readyness for
  66211. * @param useInstances Defines wheter wee are trying to render instances or not
  66212. * @returns true if ready otherwise false
  66213. */
  66214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66215. private _beforeRenderingMesh;
  66216. private _afterRenderingMesh;
  66217. }
  66218. }
  66219. declare module "babylonjs/Rendering/index" {
  66220. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66221. export * from "babylonjs/Rendering/depthRenderer";
  66222. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66223. export * from "babylonjs/Rendering/edgesRenderer";
  66224. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66225. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66226. export * from "babylonjs/Rendering/outlineRenderer";
  66227. export * from "babylonjs/Rendering/renderingGroup";
  66228. export * from "babylonjs/Rendering/renderingManager";
  66229. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66230. }
  66231. declare module "babylonjs/Sprites/spritePackedManager" {
  66232. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66233. import { Scene } from "babylonjs/scene";
  66234. /**
  66235. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66236. * @see http://doc.babylonjs.com/babylon101/sprites
  66237. */
  66238. export class SpritePackedManager extends SpriteManager {
  66239. /** defines the packed manager's name */
  66240. name: string;
  66241. /**
  66242. * Creates a new sprite manager from a packed sprite sheet
  66243. * @param name defines the manager's name
  66244. * @param imgUrl defines the sprite sheet url
  66245. * @param capacity defines the maximum allowed number of sprites
  66246. * @param scene defines the hosting scene
  66247. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66248. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66249. * @param samplingMode defines the smapling mode to use with spritesheet
  66250. * @param fromPacked set to true; do not alter
  66251. */
  66252. constructor(
  66253. /** defines the packed manager's name */
  66254. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66255. }
  66256. }
  66257. declare module "babylonjs/Sprites/index" {
  66258. export * from "babylonjs/Sprites/sprite";
  66259. export * from "babylonjs/Sprites/spriteManager";
  66260. export * from "babylonjs/Sprites/spritePackedManager";
  66261. export * from "babylonjs/Sprites/spriteSceneComponent";
  66262. }
  66263. declare module "babylonjs/States/index" {
  66264. export * from "babylonjs/States/alphaCullingState";
  66265. export * from "babylonjs/States/depthCullingState";
  66266. export * from "babylonjs/States/stencilState";
  66267. }
  66268. declare module "babylonjs/Misc/assetsManager" {
  66269. import { Scene } from "babylonjs/scene";
  66270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66271. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66272. import { Skeleton } from "babylonjs/Bones/skeleton";
  66273. import { Observable } from "babylonjs/Misc/observable";
  66274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66275. import { Texture } from "babylonjs/Materials/Textures/texture";
  66276. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66277. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66278. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66279. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66280. /**
  66281. * Defines the list of states available for a task inside a AssetsManager
  66282. */
  66283. export enum AssetTaskState {
  66284. /**
  66285. * Initialization
  66286. */
  66287. INIT = 0,
  66288. /**
  66289. * Running
  66290. */
  66291. RUNNING = 1,
  66292. /**
  66293. * Done
  66294. */
  66295. DONE = 2,
  66296. /**
  66297. * Error
  66298. */
  66299. ERROR = 3
  66300. }
  66301. /**
  66302. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66303. */
  66304. export abstract class AbstractAssetTask {
  66305. /**
  66306. * Task name
  66307. */ name: string;
  66308. /**
  66309. * Callback called when the task is successful
  66310. */
  66311. onSuccess: (task: any) => void;
  66312. /**
  66313. * Callback called when the task is not successful
  66314. */
  66315. onError: (task: any, message?: string, exception?: any) => void;
  66316. /**
  66317. * Creates a new AssetsManager
  66318. * @param name defines the name of the task
  66319. */
  66320. constructor(
  66321. /**
  66322. * Task name
  66323. */ name: string);
  66324. private _isCompleted;
  66325. private _taskState;
  66326. private _errorObject;
  66327. /**
  66328. * Get if the task is completed
  66329. */
  66330. readonly isCompleted: boolean;
  66331. /**
  66332. * Gets the current state of the task
  66333. */
  66334. readonly taskState: AssetTaskState;
  66335. /**
  66336. * Gets the current error object (if task is in error)
  66337. */
  66338. readonly errorObject: {
  66339. message?: string;
  66340. exception?: any;
  66341. };
  66342. /**
  66343. * Internal only
  66344. * @hidden
  66345. */
  66346. _setErrorObject(message?: string, exception?: any): void;
  66347. /**
  66348. * Execute the current task
  66349. * @param scene defines the scene where you want your assets to be loaded
  66350. * @param onSuccess is a callback called when the task is successfully executed
  66351. * @param onError is a callback called if an error occurs
  66352. */
  66353. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66354. /**
  66355. * Execute the current task
  66356. * @param scene defines the scene where you want your assets to be loaded
  66357. * @param onSuccess is a callback called when the task is successfully executed
  66358. * @param onError is a callback called if an error occurs
  66359. */
  66360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66361. /**
  66362. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66363. * This can be used with failed tasks that have the reason for failure fixed.
  66364. */
  66365. reset(): void;
  66366. private onErrorCallback;
  66367. private onDoneCallback;
  66368. }
  66369. /**
  66370. * Define the interface used by progress events raised during assets loading
  66371. */
  66372. export interface IAssetsProgressEvent {
  66373. /**
  66374. * Defines the number of remaining tasks to process
  66375. */
  66376. remainingCount: number;
  66377. /**
  66378. * Defines the total number of tasks
  66379. */
  66380. totalCount: number;
  66381. /**
  66382. * Defines the task that was just processed
  66383. */
  66384. task: AbstractAssetTask;
  66385. }
  66386. /**
  66387. * Class used to share progress information about assets loading
  66388. */
  66389. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66390. /**
  66391. * Defines the number of remaining tasks to process
  66392. */
  66393. remainingCount: number;
  66394. /**
  66395. * Defines the total number of tasks
  66396. */
  66397. totalCount: number;
  66398. /**
  66399. * Defines the task that was just processed
  66400. */
  66401. task: AbstractAssetTask;
  66402. /**
  66403. * Creates a AssetsProgressEvent
  66404. * @param remainingCount defines the number of remaining tasks to process
  66405. * @param totalCount defines the total number of tasks
  66406. * @param task defines the task that was just processed
  66407. */
  66408. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66409. }
  66410. /**
  66411. * Define a task used by AssetsManager to load meshes
  66412. */
  66413. export class MeshAssetTask extends AbstractAssetTask {
  66414. /**
  66415. * Defines the name of the task
  66416. */
  66417. name: string;
  66418. /**
  66419. * Defines the list of mesh's names you want to load
  66420. */
  66421. meshesNames: any;
  66422. /**
  66423. * Defines the root url to use as a base to load your meshes and associated resources
  66424. */
  66425. rootUrl: string;
  66426. /**
  66427. * Defines the filename of the scene to load from
  66428. */
  66429. sceneFilename: string;
  66430. /**
  66431. * Gets the list of loaded meshes
  66432. */
  66433. loadedMeshes: Array<AbstractMesh>;
  66434. /**
  66435. * Gets the list of loaded particle systems
  66436. */
  66437. loadedParticleSystems: Array<IParticleSystem>;
  66438. /**
  66439. * Gets the list of loaded skeletons
  66440. */
  66441. loadedSkeletons: Array<Skeleton>;
  66442. /**
  66443. * Gets the list of loaded animation groups
  66444. */
  66445. loadedAnimationGroups: Array<AnimationGroup>;
  66446. /**
  66447. * Callback called when the task is successful
  66448. */
  66449. onSuccess: (task: MeshAssetTask) => void;
  66450. /**
  66451. * Callback called when the task is successful
  66452. */
  66453. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66454. /**
  66455. * Creates a new MeshAssetTask
  66456. * @param name defines the name of the task
  66457. * @param meshesNames defines the list of mesh's names you want to load
  66458. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66459. * @param sceneFilename defines the filename of the scene to load from
  66460. */
  66461. constructor(
  66462. /**
  66463. * Defines the name of the task
  66464. */
  66465. name: string,
  66466. /**
  66467. * Defines the list of mesh's names you want to load
  66468. */
  66469. meshesNames: any,
  66470. /**
  66471. * Defines the root url to use as a base to load your meshes and associated resources
  66472. */
  66473. rootUrl: string,
  66474. /**
  66475. * Defines the filename of the scene to load from
  66476. */
  66477. sceneFilename: string);
  66478. /**
  66479. * Execute the current task
  66480. * @param scene defines the scene where you want your assets to be loaded
  66481. * @param onSuccess is a callback called when the task is successfully executed
  66482. * @param onError is a callback called if an error occurs
  66483. */
  66484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66485. }
  66486. /**
  66487. * Define a task used by AssetsManager to load text content
  66488. */
  66489. export class TextFileAssetTask extends AbstractAssetTask {
  66490. /**
  66491. * Defines the name of the task
  66492. */
  66493. name: string;
  66494. /**
  66495. * Defines the location of the file to load
  66496. */
  66497. url: string;
  66498. /**
  66499. * Gets the loaded text string
  66500. */
  66501. text: string;
  66502. /**
  66503. * Callback called when the task is successful
  66504. */
  66505. onSuccess: (task: TextFileAssetTask) => void;
  66506. /**
  66507. * Callback called when the task is successful
  66508. */
  66509. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66510. /**
  66511. * Creates a new TextFileAssetTask object
  66512. * @param name defines the name of the task
  66513. * @param url defines the location of the file to load
  66514. */
  66515. constructor(
  66516. /**
  66517. * Defines the name of the task
  66518. */
  66519. name: string,
  66520. /**
  66521. * Defines the location of the file to load
  66522. */
  66523. url: string);
  66524. /**
  66525. * Execute the current task
  66526. * @param scene defines the scene where you want your assets to be loaded
  66527. * @param onSuccess is a callback called when the task is successfully executed
  66528. * @param onError is a callback called if an error occurs
  66529. */
  66530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66531. }
  66532. /**
  66533. * Define a task used by AssetsManager to load binary data
  66534. */
  66535. export class BinaryFileAssetTask extends AbstractAssetTask {
  66536. /**
  66537. * Defines the name of the task
  66538. */
  66539. name: string;
  66540. /**
  66541. * Defines the location of the file to load
  66542. */
  66543. url: string;
  66544. /**
  66545. * Gets the lodaded data (as an array buffer)
  66546. */
  66547. data: ArrayBuffer;
  66548. /**
  66549. * Callback called when the task is successful
  66550. */
  66551. onSuccess: (task: BinaryFileAssetTask) => void;
  66552. /**
  66553. * Callback called when the task is successful
  66554. */
  66555. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66556. /**
  66557. * Creates a new BinaryFileAssetTask object
  66558. * @param name defines the name of the new task
  66559. * @param url defines the location of the file to load
  66560. */
  66561. constructor(
  66562. /**
  66563. * Defines the name of the task
  66564. */
  66565. name: string,
  66566. /**
  66567. * Defines the location of the file to load
  66568. */
  66569. url: string);
  66570. /**
  66571. * Execute the current task
  66572. * @param scene defines the scene where you want your assets to be loaded
  66573. * @param onSuccess is a callback called when the task is successfully executed
  66574. * @param onError is a callback called if an error occurs
  66575. */
  66576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66577. }
  66578. /**
  66579. * Define a task used by AssetsManager to load images
  66580. */
  66581. export class ImageAssetTask extends AbstractAssetTask {
  66582. /**
  66583. * Defines the name of the task
  66584. */
  66585. name: string;
  66586. /**
  66587. * Defines the location of the image to load
  66588. */
  66589. url: string;
  66590. /**
  66591. * Gets the loaded images
  66592. */
  66593. image: HTMLImageElement;
  66594. /**
  66595. * Callback called when the task is successful
  66596. */
  66597. onSuccess: (task: ImageAssetTask) => void;
  66598. /**
  66599. * Callback called when the task is successful
  66600. */
  66601. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66602. /**
  66603. * Creates a new ImageAssetTask
  66604. * @param name defines the name of the task
  66605. * @param url defines the location of the image to load
  66606. */
  66607. constructor(
  66608. /**
  66609. * Defines the name of the task
  66610. */
  66611. name: string,
  66612. /**
  66613. * Defines the location of the image to load
  66614. */
  66615. url: string);
  66616. /**
  66617. * Execute the current task
  66618. * @param scene defines the scene where you want your assets to be loaded
  66619. * @param onSuccess is a callback called when the task is successfully executed
  66620. * @param onError is a callback called if an error occurs
  66621. */
  66622. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66623. }
  66624. /**
  66625. * Defines the interface used by texture loading tasks
  66626. */
  66627. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66628. /**
  66629. * Gets the loaded texture
  66630. */
  66631. texture: TEX;
  66632. }
  66633. /**
  66634. * Define a task used by AssetsManager to load 2D textures
  66635. */
  66636. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66637. /**
  66638. * Defines the name of the task
  66639. */
  66640. name: string;
  66641. /**
  66642. * Defines the location of the file to load
  66643. */
  66644. url: string;
  66645. /**
  66646. * Defines if mipmap should not be generated (default is false)
  66647. */
  66648. noMipmap?: boolean | undefined;
  66649. /**
  66650. * Defines if texture must be inverted on Y axis (default is false)
  66651. */
  66652. invertY?: boolean | undefined;
  66653. /**
  66654. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66655. */
  66656. samplingMode: number;
  66657. /**
  66658. * Gets the loaded texture
  66659. */
  66660. texture: Texture;
  66661. /**
  66662. * Callback called when the task is successful
  66663. */
  66664. onSuccess: (task: TextureAssetTask) => void;
  66665. /**
  66666. * Callback called when the task is successful
  66667. */
  66668. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66669. /**
  66670. * Creates a new TextureAssetTask object
  66671. * @param name defines the name of the task
  66672. * @param url defines the location of the file to load
  66673. * @param noMipmap defines if mipmap should not be generated (default is false)
  66674. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66675. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66676. */
  66677. constructor(
  66678. /**
  66679. * Defines the name of the task
  66680. */
  66681. name: string,
  66682. /**
  66683. * Defines the location of the file to load
  66684. */
  66685. url: string,
  66686. /**
  66687. * Defines if mipmap should not be generated (default is false)
  66688. */
  66689. noMipmap?: boolean | undefined,
  66690. /**
  66691. * Defines if texture must be inverted on Y axis (default is false)
  66692. */
  66693. invertY?: boolean | undefined,
  66694. /**
  66695. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66696. */
  66697. samplingMode?: number);
  66698. /**
  66699. * Execute the current task
  66700. * @param scene defines the scene where you want your assets to be loaded
  66701. * @param onSuccess is a callback called when the task is successfully executed
  66702. * @param onError is a callback called if an error occurs
  66703. */
  66704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66705. }
  66706. /**
  66707. * Define a task used by AssetsManager to load cube textures
  66708. */
  66709. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66710. /**
  66711. * Defines the name of the task
  66712. */
  66713. name: string;
  66714. /**
  66715. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66716. */
  66717. url: string;
  66718. /**
  66719. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66720. */
  66721. extensions?: string[] | undefined;
  66722. /**
  66723. * Defines if mipmaps should not be generated (default is false)
  66724. */
  66725. noMipmap?: boolean | undefined;
  66726. /**
  66727. * Defines the explicit list of files (undefined by default)
  66728. */
  66729. files?: string[] | undefined;
  66730. /**
  66731. * Gets the loaded texture
  66732. */
  66733. texture: CubeTexture;
  66734. /**
  66735. * Callback called when the task is successful
  66736. */
  66737. onSuccess: (task: CubeTextureAssetTask) => void;
  66738. /**
  66739. * Callback called when the task is successful
  66740. */
  66741. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66742. /**
  66743. * Creates a new CubeTextureAssetTask
  66744. * @param name defines the name of the task
  66745. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66746. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66747. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66748. * @param files defines the explicit list of files (undefined by default)
  66749. */
  66750. constructor(
  66751. /**
  66752. * Defines the name of the task
  66753. */
  66754. name: string,
  66755. /**
  66756. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66757. */
  66758. url: string,
  66759. /**
  66760. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66761. */
  66762. extensions?: string[] | undefined,
  66763. /**
  66764. * Defines if mipmaps should not be generated (default is false)
  66765. */
  66766. noMipmap?: boolean | undefined,
  66767. /**
  66768. * Defines the explicit list of files (undefined by default)
  66769. */
  66770. files?: string[] | undefined);
  66771. /**
  66772. * Execute the current task
  66773. * @param scene defines the scene where you want your assets to be loaded
  66774. * @param onSuccess is a callback called when the task is successfully executed
  66775. * @param onError is a callback called if an error occurs
  66776. */
  66777. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66778. }
  66779. /**
  66780. * Define a task used by AssetsManager to load HDR cube textures
  66781. */
  66782. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66783. /**
  66784. * Defines the name of the task
  66785. */
  66786. name: string;
  66787. /**
  66788. * Defines the location of the file to load
  66789. */
  66790. url: string;
  66791. /**
  66792. * Defines the desired size (the more it increases the longer the generation will be)
  66793. */
  66794. size: number;
  66795. /**
  66796. * Defines if mipmaps should not be generated (default is false)
  66797. */
  66798. noMipmap: boolean;
  66799. /**
  66800. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66801. */
  66802. generateHarmonics: boolean;
  66803. /**
  66804. * 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)
  66805. */
  66806. gammaSpace: boolean;
  66807. /**
  66808. * Internal Use Only
  66809. */
  66810. reserved: boolean;
  66811. /**
  66812. * Gets the loaded texture
  66813. */
  66814. texture: HDRCubeTexture;
  66815. /**
  66816. * Callback called when the task is successful
  66817. */
  66818. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66819. /**
  66820. * Callback called when the task is successful
  66821. */
  66822. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66823. /**
  66824. * Creates a new HDRCubeTextureAssetTask object
  66825. * @param name defines the name of the task
  66826. * @param url defines the location of the file to load
  66827. * @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.
  66828. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66829. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66830. * @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)
  66831. * @param reserved Internal use only
  66832. */
  66833. constructor(
  66834. /**
  66835. * Defines the name of the task
  66836. */
  66837. name: string,
  66838. /**
  66839. * Defines the location of the file to load
  66840. */
  66841. url: string,
  66842. /**
  66843. * Defines the desired size (the more it increases the longer the generation will be)
  66844. */
  66845. size: number,
  66846. /**
  66847. * Defines if mipmaps should not be generated (default is false)
  66848. */
  66849. noMipmap?: boolean,
  66850. /**
  66851. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66852. */
  66853. generateHarmonics?: boolean,
  66854. /**
  66855. * 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)
  66856. */
  66857. gammaSpace?: boolean,
  66858. /**
  66859. * Internal Use Only
  66860. */
  66861. reserved?: boolean);
  66862. /**
  66863. * Execute the current task
  66864. * @param scene defines the scene where you want your assets to be loaded
  66865. * @param onSuccess is a callback called when the task is successfully executed
  66866. * @param onError is a callback called if an error occurs
  66867. */
  66868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66869. }
  66870. /**
  66871. * Define a task used by AssetsManager to load Equirectangular cube textures
  66872. */
  66873. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66874. /**
  66875. * Defines the name of the task
  66876. */
  66877. name: string;
  66878. /**
  66879. * Defines the location of the file to load
  66880. */
  66881. url: string;
  66882. /**
  66883. * Defines the desired size (the more it increases the longer the generation will be)
  66884. */
  66885. size: number;
  66886. /**
  66887. * Defines if mipmaps should not be generated (default is false)
  66888. */
  66889. noMipmap: boolean;
  66890. /**
  66891. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66892. * but the standard material would require them in Gamma space) (default is true)
  66893. */
  66894. gammaSpace: boolean;
  66895. /**
  66896. * Gets the loaded texture
  66897. */
  66898. texture: EquiRectangularCubeTexture;
  66899. /**
  66900. * Callback called when the task is successful
  66901. */
  66902. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66903. /**
  66904. * Callback called when the task is successful
  66905. */
  66906. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66907. /**
  66908. * Creates a new EquiRectangularCubeTextureAssetTask object
  66909. * @param name defines the name of the task
  66910. * @param url defines the location of the file to load
  66911. * @param size defines the desired size (the more it increases the longer the generation will be)
  66912. * If the size is omitted this implies you are using a preprocessed cubemap.
  66913. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66914. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66915. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66916. * (default is true)
  66917. */
  66918. constructor(
  66919. /**
  66920. * Defines the name of the task
  66921. */
  66922. name: string,
  66923. /**
  66924. * Defines the location of the file to load
  66925. */
  66926. url: string,
  66927. /**
  66928. * Defines the desired size (the more it increases the longer the generation will be)
  66929. */
  66930. size: number,
  66931. /**
  66932. * Defines if mipmaps should not be generated (default is false)
  66933. */
  66934. noMipmap?: boolean,
  66935. /**
  66936. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66937. * but the standard material would require them in Gamma space) (default is true)
  66938. */
  66939. gammaSpace?: boolean);
  66940. /**
  66941. * Execute the current task
  66942. * @param scene defines the scene where you want your assets to be loaded
  66943. * @param onSuccess is a callback called when the task is successfully executed
  66944. * @param onError is a callback called if an error occurs
  66945. */
  66946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66947. }
  66948. /**
  66949. * This class can be used to easily import assets into a scene
  66950. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66951. */
  66952. export class AssetsManager {
  66953. private _scene;
  66954. private _isLoading;
  66955. protected _tasks: AbstractAssetTask[];
  66956. protected _waitingTasksCount: number;
  66957. protected _totalTasksCount: number;
  66958. /**
  66959. * Callback called when all tasks are processed
  66960. */
  66961. onFinish: (tasks: AbstractAssetTask[]) => void;
  66962. /**
  66963. * Callback called when a task is successful
  66964. */
  66965. onTaskSuccess: (task: AbstractAssetTask) => void;
  66966. /**
  66967. * Callback called when a task had an error
  66968. */
  66969. onTaskError: (task: AbstractAssetTask) => void;
  66970. /**
  66971. * Callback called when a task is done (whatever the result is)
  66972. */
  66973. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66974. /**
  66975. * Observable called when all tasks are processed
  66976. */
  66977. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66978. /**
  66979. * Observable called when a task had an error
  66980. */
  66981. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66982. /**
  66983. * Observable called when all tasks were executed
  66984. */
  66985. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66986. /**
  66987. * Observable called when a task is done (whatever the result is)
  66988. */
  66989. onProgressObservable: Observable<IAssetsProgressEvent>;
  66990. /**
  66991. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66993. */
  66994. useDefaultLoadingScreen: boolean;
  66995. /**
  66996. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66997. * when all assets have been downloaded.
  66998. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66999. */
  67000. autoHideLoadingUI: boolean;
  67001. /**
  67002. * Creates a new AssetsManager
  67003. * @param scene defines the scene to work on
  67004. */
  67005. constructor(scene: Scene);
  67006. /**
  67007. * Add a MeshAssetTask to the list of active tasks
  67008. * @param taskName defines the name of the new task
  67009. * @param meshesNames defines the name of meshes to load
  67010. * @param rootUrl defines the root url to use to locate files
  67011. * @param sceneFilename defines the filename of the scene file
  67012. * @returns a new MeshAssetTask object
  67013. */
  67014. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67015. /**
  67016. * Add a TextFileAssetTask to the list of active tasks
  67017. * @param taskName defines the name of the new task
  67018. * @param url defines the url of the file to load
  67019. * @returns a new TextFileAssetTask object
  67020. */
  67021. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67022. /**
  67023. * Add a BinaryFileAssetTask to the list of active tasks
  67024. * @param taskName defines the name of the new task
  67025. * @param url defines the url of the file to load
  67026. * @returns a new BinaryFileAssetTask object
  67027. */
  67028. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67029. /**
  67030. * Add a ImageAssetTask to the list of active tasks
  67031. * @param taskName defines the name of the new task
  67032. * @param url defines the url of the file to load
  67033. * @returns a new ImageAssetTask object
  67034. */
  67035. addImageTask(taskName: string, url: string): ImageAssetTask;
  67036. /**
  67037. * Add a TextureAssetTask to the list of active tasks
  67038. * @param taskName defines the name of the new task
  67039. * @param url defines the url of the file to load
  67040. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67041. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67042. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67043. * @returns a new TextureAssetTask object
  67044. */
  67045. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67046. /**
  67047. * Add a CubeTextureAssetTask to the list of active tasks
  67048. * @param taskName defines the name of the new task
  67049. * @param url defines the url of the file to load
  67050. * @param extensions defines the extension to use to load the cube map (can be null)
  67051. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67052. * @param files defines the list of files to load (can be null)
  67053. * @returns a new CubeTextureAssetTask object
  67054. */
  67055. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67056. /**
  67057. *
  67058. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67059. * @param taskName defines the name of the new task
  67060. * @param url defines the url of the file to load
  67061. * @param size defines the size you want for the cubemap (can be null)
  67062. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67063. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67064. * @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)
  67065. * @param reserved Internal use only
  67066. * @returns a new HDRCubeTextureAssetTask object
  67067. */
  67068. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67069. /**
  67070. *
  67071. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67072. * @param taskName defines the name of the new task
  67073. * @param url defines the url of the file to load
  67074. * @param size defines the size you want for the cubemap (can be null)
  67075. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67076. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67077. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67078. * @returns a new EquiRectangularCubeTextureAssetTask object
  67079. */
  67080. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67081. /**
  67082. * Remove a task from the assets manager.
  67083. * @param task the task to remove
  67084. */
  67085. removeTask(task: AbstractAssetTask): void;
  67086. private _decreaseWaitingTasksCount;
  67087. private _runTask;
  67088. /**
  67089. * Reset the AssetsManager and remove all tasks
  67090. * @return the current instance of the AssetsManager
  67091. */
  67092. reset(): AssetsManager;
  67093. /**
  67094. * Start the loading process
  67095. * @return the current instance of the AssetsManager
  67096. */
  67097. load(): AssetsManager;
  67098. /**
  67099. * Start the loading process as an async operation
  67100. * @return a promise returning the list of failed tasks
  67101. */
  67102. loadAsync(): Promise<void>;
  67103. }
  67104. }
  67105. declare module "babylonjs/Misc/deferred" {
  67106. /**
  67107. * Wrapper class for promise with external resolve and reject.
  67108. */
  67109. export class Deferred<T> {
  67110. /**
  67111. * The promise associated with this deferred object.
  67112. */
  67113. readonly promise: Promise<T>;
  67114. private _resolve;
  67115. private _reject;
  67116. /**
  67117. * The resolve method of the promise associated with this deferred object.
  67118. */
  67119. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67120. /**
  67121. * The reject method of the promise associated with this deferred object.
  67122. */
  67123. readonly reject: (reason?: any) => void;
  67124. /**
  67125. * Constructor for this deferred object.
  67126. */
  67127. constructor();
  67128. }
  67129. }
  67130. declare module "babylonjs/Misc/meshExploder" {
  67131. import { Mesh } from "babylonjs/Meshes/mesh";
  67132. /**
  67133. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67134. */
  67135. export class MeshExploder {
  67136. private _centerMesh;
  67137. private _meshes;
  67138. private _meshesOrigins;
  67139. private _toCenterVectors;
  67140. private _scaledDirection;
  67141. private _newPosition;
  67142. private _centerPosition;
  67143. /**
  67144. * Explodes meshes from a center mesh.
  67145. * @param meshes The meshes to explode.
  67146. * @param centerMesh The mesh to be center of explosion.
  67147. */
  67148. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67149. private _setCenterMesh;
  67150. /**
  67151. * Get class name
  67152. * @returns "MeshExploder"
  67153. */
  67154. getClassName(): string;
  67155. /**
  67156. * "Exploded meshes"
  67157. * @returns Array of meshes with the centerMesh at index 0.
  67158. */
  67159. getMeshes(): Array<Mesh>;
  67160. /**
  67161. * Explodes meshes giving a specific direction
  67162. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67163. */
  67164. explode(direction?: number): void;
  67165. }
  67166. }
  67167. declare module "babylonjs/Misc/filesInput" {
  67168. import { Engine } from "babylonjs/Engines/engine";
  67169. import { Scene } from "babylonjs/scene";
  67170. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67171. /**
  67172. * Class used to help managing file picking and drag'n'drop
  67173. */
  67174. export class FilesInput {
  67175. /**
  67176. * List of files ready to be loaded
  67177. */
  67178. static readonly FilesToLoad: {
  67179. [key: string]: File;
  67180. };
  67181. /**
  67182. * Callback called when a file is processed
  67183. */
  67184. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67185. private _engine;
  67186. private _currentScene;
  67187. private _sceneLoadedCallback;
  67188. private _progressCallback;
  67189. private _additionalRenderLoopLogicCallback;
  67190. private _textureLoadingCallback;
  67191. private _startingProcessingFilesCallback;
  67192. private _onReloadCallback;
  67193. private _errorCallback;
  67194. private _elementToMonitor;
  67195. private _sceneFileToLoad;
  67196. private _filesToLoad;
  67197. /**
  67198. * Creates a new FilesInput
  67199. * @param engine defines the rendering engine
  67200. * @param scene defines the hosting scene
  67201. * @param sceneLoadedCallback callback called when scene is loaded
  67202. * @param progressCallback callback called to track progress
  67203. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67204. * @param textureLoadingCallback callback called when a texture is loading
  67205. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67206. * @param onReloadCallback callback called when a reload is requested
  67207. * @param errorCallback callback call if an error occurs
  67208. */
  67209. 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);
  67210. private _dragEnterHandler;
  67211. private _dragOverHandler;
  67212. private _dropHandler;
  67213. /**
  67214. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67215. * @param elementToMonitor defines the DOM element to track
  67216. */
  67217. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67218. /**
  67219. * Release all associated resources
  67220. */
  67221. dispose(): void;
  67222. private renderFunction;
  67223. private drag;
  67224. private drop;
  67225. private _traverseFolder;
  67226. private _processFiles;
  67227. /**
  67228. * Load files from a drop event
  67229. * @param event defines the drop event to use as source
  67230. */
  67231. loadFiles(event: any): void;
  67232. private _processReload;
  67233. /**
  67234. * Reload the current scene from the loaded files
  67235. */
  67236. reload(): void;
  67237. }
  67238. }
  67239. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67240. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67241. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67242. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67243. }
  67244. declare module "babylonjs/Misc/sceneOptimizer" {
  67245. import { Scene, IDisposable } from "babylonjs/scene";
  67246. import { Observable } from "babylonjs/Misc/observable";
  67247. /**
  67248. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67249. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67250. */
  67251. export class SceneOptimization {
  67252. /**
  67253. * Defines the priority of this optimization (0 by default which means first in the list)
  67254. */
  67255. priority: number;
  67256. /**
  67257. * Gets a string describing the action executed by the current optimization
  67258. * @returns description string
  67259. */
  67260. getDescription(): string;
  67261. /**
  67262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67263. * @param scene defines the current scene where to apply this optimization
  67264. * @param optimizer defines the current optimizer
  67265. * @returns true if everything that can be done was applied
  67266. */
  67267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67268. /**
  67269. * Creates the SceneOptimization object
  67270. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67271. * @param desc defines the description associated with the optimization
  67272. */
  67273. constructor(
  67274. /**
  67275. * Defines the priority of this optimization (0 by default which means first in the list)
  67276. */
  67277. priority?: number);
  67278. }
  67279. /**
  67280. * Defines an optimization used to reduce the size of render target textures
  67281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67282. */
  67283. export class TextureOptimization extends SceneOptimization {
  67284. /**
  67285. * Defines the priority of this optimization (0 by default which means first in the list)
  67286. */
  67287. priority: number;
  67288. /**
  67289. * 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
  67290. */
  67291. maximumSize: number;
  67292. /**
  67293. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67294. */
  67295. step: number;
  67296. /**
  67297. * Gets a string describing the action executed by the current optimization
  67298. * @returns description string
  67299. */
  67300. getDescription(): string;
  67301. /**
  67302. * Creates the TextureOptimization object
  67303. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67304. * @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
  67305. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67306. */
  67307. constructor(
  67308. /**
  67309. * Defines the priority of this optimization (0 by default which means first in the list)
  67310. */
  67311. priority?: number,
  67312. /**
  67313. * 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
  67314. */
  67315. maximumSize?: number,
  67316. /**
  67317. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67318. */
  67319. step?: number);
  67320. /**
  67321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67322. * @param scene defines the current scene where to apply this optimization
  67323. * @param optimizer defines the current optimizer
  67324. * @returns true if everything that can be done was applied
  67325. */
  67326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67327. }
  67328. /**
  67329. * Defines an optimization used to increase or decrease the rendering resolution
  67330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67331. */
  67332. export class HardwareScalingOptimization extends SceneOptimization {
  67333. /**
  67334. * Defines the priority of this optimization (0 by default which means first in the list)
  67335. */
  67336. priority: number;
  67337. /**
  67338. * Defines the maximum scale to use (2 by default)
  67339. */
  67340. maximumScale: number;
  67341. /**
  67342. * Defines the step to use between two passes (0.5 by default)
  67343. */
  67344. step: number;
  67345. private _currentScale;
  67346. private _directionOffset;
  67347. /**
  67348. * Gets a string describing the action executed by the current optimization
  67349. * @return description string
  67350. */
  67351. getDescription(): string;
  67352. /**
  67353. * Creates the HardwareScalingOptimization object
  67354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67355. * @param maximumScale defines the maximum scale to use (2 by default)
  67356. * @param step defines the step to use between two passes (0.5 by default)
  67357. */
  67358. constructor(
  67359. /**
  67360. * Defines the priority of this optimization (0 by default which means first in the list)
  67361. */
  67362. priority?: number,
  67363. /**
  67364. * Defines the maximum scale to use (2 by default)
  67365. */
  67366. maximumScale?: number,
  67367. /**
  67368. * Defines the step to use between two passes (0.5 by default)
  67369. */
  67370. step?: number);
  67371. /**
  67372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67373. * @param scene defines the current scene where to apply this optimization
  67374. * @param optimizer defines the current optimizer
  67375. * @returns true if everything that can be done was applied
  67376. */
  67377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67378. }
  67379. /**
  67380. * Defines an optimization used to remove shadows
  67381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67382. */
  67383. export class ShadowsOptimization extends SceneOptimization {
  67384. /**
  67385. * Gets a string describing the action executed by the current optimization
  67386. * @return description string
  67387. */
  67388. getDescription(): string;
  67389. /**
  67390. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67391. * @param scene defines the current scene where to apply this optimization
  67392. * @param optimizer defines the current optimizer
  67393. * @returns true if everything that can be done was applied
  67394. */
  67395. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67396. }
  67397. /**
  67398. * Defines an optimization used to turn post-processes off
  67399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67400. */
  67401. export class PostProcessesOptimization extends SceneOptimization {
  67402. /**
  67403. * Gets a string describing the action executed by the current optimization
  67404. * @return description string
  67405. */
  67406. getDescription(): string;
  67407. /**
  67408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67409. * @param scene defines the current scene where to apply this optimization
  67410. * @param optimizer defines the current optimizer
  67411. * @returns true if everything that can be done was applied
  67412. */
  67413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67414. }
  67415. /**
  67416. * Defines an optimization used to turn lens flares off
  67417. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67418. */
  67419. export class LensFlaresOptimization extends SceneOptimization {
  67420. /**
  67421. * Gets a string describing the action executed by the current optimization
  67422. * @return description string
  67423. */
  67424. getDescription(): string;
  67425. /**
  67426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67427. * @param scene defines the current scene where to apply this optimization
  67428. * @param optimizer defines the current optimizer
  67429. * @returns true if everything that can be done was applied
  67430. */
  67431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67432. }
  67433. /**
  67434. * Defines an optimization based on user defined callback.
  67435. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67436. */
  67437. export class CustomOptimization extends SceneOptimization {
  67438. /**
  67439. * Callback called to apply the custom optimization.
  67440. */
  67441. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67442. /**
  67443. * Callback called to get custom description
  67444. */
  67445. onGetDescription: () => string;
  67446. /**
  67447. * Gets a string describing the action executed by the current optimization
  67448. * @returns description string
  67449. */
  67450. getDescription(): string;
  67451. /**
  67452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67453. * @param scene defines the current scene where to apply this optimization
  67454. * @param optimizer defines the current optimizer
  67455. * @returns true if everything that can be done was applied
  67456. */
  67457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67458. }
  67459. /**
  67460. * Defines an optimization used to turn particles off
  67461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67462. */
  67463. export class ParticlesOptimization extends SceneOptimization {
  67464. /**
  67465. * Gets a string describing the action executed by the current optimization
  67466. * @return description string
  67467. */
  67468. getDescription(): string;
  67469. /**
  67470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67471. * @param scene defines the current scene where to apply this optimization
  67472. * @param optimizer defines the current optimizer
  67473. * @returns true if everything that can be done was applied
  67474. */
  67475. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67476. }
  67477. /**
  67478. * Defines an optimization used to turn render targets off
  67479. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67480. */
  67481. export class RenderTargetsOptimization extends SceneOptimization {
  67482. /**
  67483. * Gets a string describing the action executed by the current optimization
  67484. * @return description string
  67485. */
  67486. getDescription(): string;
  67487. /**
  67488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67489. * @param scene defines the current scene where to apply this optimization
  67490. * @param optimizer defines the current optimizer
  67491. * @returns true if everything that can be done was applied
  67492. */
  67493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67494. }
  67495. /**
  67496. * Defines an optimization used to merge meshes with compatible materials
  67497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67498. */
  67499. export class MergeMeshesOptimization extends SceneOptimization {
  67500. private static _UpdateSelectionTree;
  67501. /**
  67502. * Gets or sets a boolean which defines if optimization octree has to be updated
  67503. */
  67504. /**
  67505. * Gets or sets a boolean which defines if optimization octree has to be updated
  67506. */
  67507. static UpdateSelectionTree: boolean;
  67508. /**
  67509. * Gets a string describing the action executed by the current optimization
  67510. * @return description string
  67511. */
  67512. getDescription(): string;
  67513. private _canBeMerged;
  67514. /**
  67515. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67516. * @param scene defines the current scene where to apply this optimization
  67517. * @param optimizer defines the current optimizer
  67518. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67519. * @returns true if everything that can be done was applied
  67520. */
  67521. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67522. }
  67523. /**
  67524. * Defines a list of options used by SceneOptimizer
  67525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67526. */
  67527. export class SceneOptimizerOptions {
  67528. /**
  67529. * Defines the target frame rate to reach (60 by default)
  67530. */
  67531. targetFrameRate: number;
  67532. /**
  67533. * Defines the interval between two checkes (2000ms by default)
  67534. */
  67535. trackerDuration: number;
  67536. /**
  67537. * Gets the list of optimizations to apply
  67538. */
  67539. optimizations: SceneOptimization[];
  67540. /**
  67541. * Creates a new list of options used by SceneOptimizer
  67542. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67543. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67544. */
  67545. constructor(
  67546. /**
  67547. * Defines the target frame rate to reach (60 by default)
  67548. */
  67549. targetFrameRate?: number,
  67550. /**
  67551. * Defines the interval between two checkes (2000ms by default)
  67552. */
  67553. trackerDuration?: number);
  67554. /**
  67555. * Add a new optimization
  67556. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67557. * @returns the current SceneOptimizerOptions
  67558. */
  67559. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67560. /**
  67561. * Add a new custom optimization
  67562. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67563. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67564. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67565. * @returns the current SceneOptimizerOptions
  67566. */
  67567. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67568. /**
  67569. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67570. * @param targetFrameRate defines the target frame rate (60 by default)
  67571. * @returns a SceneOptimizerOptions object
  67572. */
  67573. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67574. /**
  67575. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67576. * @param targetFrameRate defines the target frame rate (60 by default)
  67577. * @returns a SceneOptimizerOptions object
  67578. */
  67579. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67580. /**
  67581. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67582. * @param targetFrameRate defines the target frame rate (60 by default)
  67583. * @returns a SceneOptimizerOptions object
  67584. */
  67585. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67586. }
  67587. /**
  67588. * Class used to run optimizations in order to reach a target frame rate
  67589. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67590. */
  67591. export class SceneOptimizer implements IDisposable {
  67592. private _isRunning;
  67593. private _options;
  67594. private _scene;
  67595. private _currentPriorityLevel;
  67596. private _targetFrameRate;
  67597. private _trackerDuration;
  67598. private _currentFrameRate;
  67599. private _sceneDisposeObserver;
  67600. private _improvementMode;
  67601. /**
  67602. * Defines an observable called when the optimizer reaches the target frame rate
  67603. */
  67604. onSuccessObservable: Observable<SceneOptimizer>;
  67605. /**
  67606. * Defines an observable called when the optimizer enables an optimization
  67607. */
  67608. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67609. /**
  67610. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67611. */
  67612. onFailureObservable: Observable<SceneOptimizer>;
  67613. /**
  67614. * Gets a boolean indicating if the optimizer is in improvement mode
  67615. */
  67616. readonly isInImprovementMode: boolean;
  67617. /**
  67618. * Gets the current priority level (0 at start)
  67619. */
  67620. readonly currentPriorityLevel: number;
  67621. /**
  67622. * Gets the current frame rate checked by the SceneOptimizer
  67623. */
  67624. readonly currentFrameRate: number;
  67625. /**
  67626. * Gets or sets the current target frame rate (60 by default)
  67627. */
  67628. /**
  67629. * Gets or sets the current target frame rate (60 by default)
  67630. */
  67631. targetFrameRate: number;
  67632. /**
  67633. * Gets or sets the current interval between two checks (every 2000ms by default)
  67634. */
  67635. /**
  67636. * Gets or sets the current interval between two checks (every 2000ms by default)
  67637. */
  67638. trackerDuration: number;
  67639. /**
  67640. * Gets the list of active optimizations
  67641. */
  67642. readonly optimizations: SceneOptimization[];
  67643. /**
  67644. * Creates a new SceneOptimizer
  67645. * @param scene defines the scene to work on
  67646. * @param options defines the options to use with the SceneOptimizer
  67647. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67648. * @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)
  67649. */
  67650. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67651. /**
  67652. * Stops the current optimizer
  67653. */
  67654. stop(): void;
  67655. /**
  67656. * Reset the optimizer to initial step (current priority level = 0)
  67657. */
  67658. reset(): void;
  67659. /**
  67660. * Start the optimizer. By default it will try to reach a specific framerate
  67661. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67662. */
  67663. start(): void;
  67664. private _checkCurrentState;
  67665. /**
  67666. * Release all resources
  67667. */
  67668. dispose(): void;
  67669. /**
  67670. * Helper function to create a SceneOptimizer with one single line of code
  67671. * @param scene defines the scene to work on
  67672. * @param options defines the options to use with the SceneOptimizer
  67673. * @param onSuccess defines a callback to call on success
  67674. * @param onFailure defines a callback to call on failure
  67675. * @returns the new SceneOptimizer object
  67676. */
  67677. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67678. }
  67679. }
  67680. declare module "babylonjs/Misc/sceneSerializer" {
  67681. import { Scene } from "babylonjs/scene";
  67682. /**
  67683. * Class used to serialize a scene into a string
  67684. */
  67685. export class SceneSerializer {
  67686. /**
  67687. * Clear cache used by a previous serialization
  67688. */
  67689. static ClearCache(): void;
  67690. /**
  67691. * Serialize a scene into a JSON compatible object
  67692. * @param scene defines the scene to serialize
  67693. * @returns a JSON compatible object
  67694. */
  67695. static Serialize(scene: Scene): any;
  67696. /**
  67697. * Serialize a mesh into a JSON compatible object
  67698. * @param toSerialize defines the mesh to serialize
  67699. * @param withParents defines if parents must be serialized as well
  67700. * @param withChildren defines if children must be serialized as well
  67701. * @returns a JSON compatible object
  67702. */
  67703. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67704. }
  67705. }
  67706. declare module "babylonjs/Misc/textureTools" {
  67707. import { Texture } from "babylonjs/Materials/Textures/texture";
  67708. /**
  67709. * Class used to host texture specific utilities
  67710. */
  67711. export class TextureTools {
  67712. /**
  67713. * Uses the GPU to create a copy texture rescaled at a given size
  67714. * @param texture Texture to copy from
  67715. * @param width defines the desired width
  67716. * @param height defines the desired height
  67717. * @param useBilinearMode defines if bilinear mode has to be used
  67718. * @return the generated texture
  67719. */
  67720. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67721. }
  67722. }
  67723. declare module "babylonjs/Misc/videoRecorder" {
  67724. import { Nullable } from "babylonjs/types";
  67725. import { Engine } from "babylonjs/Engines/engine";
  67726. /**
  67727. * This represents the different options available for the video capture.
  67728. */
  67729. export interface VideoRecorderOptions {
  67730. /** Defines the mime type of the video. */
  67731. mimeType: string;
  67732. /** Defines the FPS the video should be recorded at. */
  67733. fps: number;
  67734. /** Defines the chunk size for the recording data. */
  67735. recordChunckSize: number;
  67736. /** The audio tracks to attach to the recording. */
  67737. audioTracks?: MediaStreamTrack[];
  67738. }
  67739. /**
  67740. * This can help with recording videos from BabylonJS.
  67741. * This is based on the available WebRTC functionalities of the browser.
  67742. *
  67743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67744. */
  67745. export class VideoRecorder {
  67746. private static readonly _defaultOptions;
  67747. /**
  67748. * Returns whether or not the VideoRecorder is available in your browser.
  67749. * @param engine Defines the Babylon Engine.
  67750. * @returns true if supported otherwise false.
  67751. */
  67752. static IsSupported(engine: Engine): boolean;
  67753. private readonly _options;
  67754. private _canvas;
  67755. private _mediaRecorder;
  67756. private _recordedChunks;
  67757. private _fileName;
  67758. private _resolve;
  67759. private _reject;
  67760. /**
  67761. * True when a recording is already in progress.
  67762. */
  67763. readonly isRecording: boolean;
  67764. /**
  67765. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67766. * @param engine Defines the BabylonJS Engine you wish to record.
  67767. * @param options Defines options that can be used to customize the capture.
  67768. */
  67769. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67770. /**
  67771. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67772. */
  67773. stopRecording(): void;
  67774. /**
  67775. * Starts recording the canvas for a max duration specified in parameters.
  67776. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67777. * If null no automatic download will start and you can rely on the promise to get the data back.
  67778. * @param maxDuration Defines the maximum recording time in seconds.
  67779. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67780. * @return A promise callback at the end of the recording with the video data in Blob.
  67781. */
  67782. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67783. /**
  67784. * Releases internal resources used during the recording.
  67785. */
  67786. dispose(): void;
  67787. private _handleDataAvailable;
  67788. private _handleError;
  67789. private _handleStop;
  67790. }
  67791. }
  67792. declare module "babylonjs/Misc/screenshotTools" {
  67793. import { Camera } from "babylonjs/Cameras/camera";
  67794. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67795. import { Engine } from "babylonjs/Engines/engine";
  67796. /**
  67797. * Class containing a set of static utilities functions for screenshots
  67798. */
  67799. export class ScreenshotTools {
  67800. /**
  67801. * Captures a screenshot of the current rendering
  67802. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67803. * @param engine defines the rendering engine
  67804. * @param camera defines the source camera
  67805. * @param size This parameter can be set to a single number or to an object with the
  67806. * following (optional) properties: precision, width, height. If a single number is passed,
  67807. * it will be used for both width and height. If an object is passed, the screenshot size
  67808. * will be derived from the parameters. The precision property is a multiplier allowing
  67809. * rendering at a higher or lower resolution
  67810. * @param successCallback defines the callback receives a single parameter which contains the
  67811. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67812. * src parameter of an <img> to display it
  67813. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67814. * Check your browser for supported MIME types
  67815. */
  67816. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67817. /**
  67818. * Captures a screenshot of the current rendering
  67819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67820. * @param engine defines the rendering engine
  67821. * @param camera defines the source camera
  67822. * @param size This parameter can be set to a single number or to an object with the
  67823. * following (optional) properties: precision, width, height. If a single number is passed,
  67824. * it will be used for both width and height. If an object is passed, the screenshot size
  67825. * will be derived from the parameters. The precision property is a multiplier allowing
  67826. * rendering at a higher or lower resolution
  67827. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67828. * Check your browser for supported MIME types
  67829. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67830. * to the src parameter of an <img> to display it
  67831. */
  67832. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67833. /**
  67834. * Generates an image screenshot from the specified camera.
  67835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67836. * @param engine The engine to use for rendering
  67837. * @param camera The camera to use for rendering
  67838. * @param size This parameter can be set to a single number or to an object with the
  67839. * following (optional) properties: precision, width, height. If a single number is passed,
  67840. * it will be used for both width and height. If an object is passed, the screenshot size
  67841. * will be derived from the parameters. The precision property is a multiplier allowing
  67842. * rendering at a higher or lower resolution
  67843. * @param successCallback The callback receives a single parameter which contains the
  67844. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67845. * src parameter of an <img> to display it
  67846. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67847. * Check your browser for supported MIME types
  67848. * @param samples Texture samples (default: 1)
  67849. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67850. * @param fileName A name for for the downloaded file.
  67851. */
  67852. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67853. /**
  67854. * Generates an image screenshot from the specified camera.
  67855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67856. * @param engine The engine to use for rendering
  67857. * @param camera The camera to use for rendering
  67858. * @param size This parameter can be set to a single number or to an object with the
  67859. * following (optional) properties: precision, width, height. If a single number is passed,
  67860. * it will be used for both width and height. If an object is passed, the screenshot size
  67861. * will be derived from the parameters. The precision property is a multiplier allowing
  67862. * rendering at a higher or lower resolution
  67863. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67864. * Check your browser for supported MIME types
  67865. * @param samples Texture samples (default: 1)
  67866. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67867. * @param fileName A name for for the downloaded file.
  67868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67869. * to the src parameter of an <img> to display it
  67870. */
  67871. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67872. /**
  67873. * Gets height and width for screenshot size
  67874. * @private
  67875. */
  67876. private static _getScreenshotSize;
  67877. }
  67878. }
  67879. declare module "babylonjs/Misc/dataReader" {
  67880. /**
  67881. * Interface for a data buffer
  67882. */
  67883. export interface IDataBuffer {
  67884. /**
  67885. * Reads bytes from the data buffer.
  67886. * @param byteOffset The byte offset to read
  67887. * @param byteLength The byte length to read
  67888. * @returns A promise that resolves when the bytes are read
  67889. */
  67890. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67891. /**
  67892. * The byte length of the buffer.
  67893. */
  67894. readonly byteLength: number;
  67895. }
  67896. /**
  67897. * Utility class for reading from a data buffer
  67898. */
  67899. export class DataReader {
  67900. /**
  67901. * The data buffer associated with this data reader.
  67902. */
  67903. readonly buffer: IDataBuffer;
  67904. /**
  67905. * The current byte offset from the beginning of the data buffer.
  67906. */
  67907. byteOffset: number;
  67908. private _dataView;
  67909. private _dataByteOffset;
  67910. /**
  67911. * Constructor
  67912. * @param buffer The buffer to read
  67913. */
  67914. constructor(buffer: IDataBuffer);
  67915. /**
  67916. * Loads the given byte length.
  67917. * @param byteLength The byte length to load
  67918. * @returns A promise that resolves when the load is complete
  67919. */
  67920. loadAsync(byteLength: number): Promise<void>;
  67921. /**
  67922. * Read a unsigned 32-bit integer from the currently loaded data range.
  67923. * @returns The 32-bit integer read
  67924. */
  67925. readUint32(): number;
  67926. /**
  67927. * Read a byte array from the currently loaded data range.
  67928. * @param byteLength The byte length to read
  67929. * @returns The byte array read
  67930. */
  67931. readUint8Array(byteLength: number): Uint8Array;
  67932. /**
  67933. * Read a string from the currently loaded data range.
  67934. * @param byteLength The byte length to read
  67935. * @returns The string read
  67936. */
  67937. readString(byteLength: number): string;
  67938. /**
  67939. * Skips the given byte length the currently loaded data range.
  67940. * @param byteLength The byte length to skip
  67941. */
  67942. skipBytes(byteLength: number): void;
  67943. }
  67944. }
  67945. declare module "babylonjs/Misc/index" {
  67946. export * from "babylonjs/Misc/andOrNotEvaluator";
  67947. export * from "babylonjs/Misc/assetsManager";
  67948. export * from "babylonjs/Misc/dds";
  67949. export * from "babylonjs/Misc/decorators";
  67950. export * from "babylonjs/Misc/deferred";
  67951. export * from "babylonjs/Misc/environmentTextureTools";
  67952. export * from "babylonjs/Misc/meshExploder";
  67953. export * from "babylonjs/Misc/filesInput";
  67954. export * from "babylonjs/Misc/HighDynamicRange/index";
  67955. export * from "babylonjs/Misc/khronosTextureContainer";
  67956. export * from "babylonjs/Misc/observable";
  67957. export * from "babylonjs/Misc/performanceMonitor";
  67958. export * from "babylonjs/Misc/promise";
  67959. export * from "babylonjs/Misc/sceneOptimizer";
  67960. export * from "babylonjs/Misc/sceneSerializer";
  67961. export * from "babylonjs/Misc/smartArray";
  67962. export * from "babylonjs/Misc/stringDictionary";
  67963. export * from "babylonjs/Misc/tags";
  67964. export * from "babylonjs/Misc/textureTools";
  67965. export * from "babylonjs/Misc/tga";
  67966. export * from "babylonjs/Misc/tools";
  67967. export * from "babylonjs/Misc/videoRecorder";
  67968. export * from "babylonjs/Misc/virtualJoystick";
  67969. export * from "babylonjs/Misc/workerPool";
  67970. export * from "babylonjs/Misc/logger";
  67971. export * from "babylonjs/Misc/typeStore";
  67972. export * from "babylonjs/Misc/filesInputStore";
  67973. export * from "babylonjs/Misc/deepCopier";
  67974. export * from "babylonjs/Misc/pivotTools";
  67975. export * from "babylonjs/Misc/precisionDate";
  67976. export * from "babylonjs/Misc/screenshotTools";
  67977. export * from "babylonjs/Misc/typeStore";
  67978. export * from "babylonjs/Misc/webRequest";
  67979. export * from "babylonjs/Misc/iInspectable";
  67980. export * from "babylonjs/Misc/brdfTextureTools";
  67981. export * from "babylonjs/Misc/rgbdTextureTools";
  67982. export * from "babylonjs/Misc/gradients";
  67983. export * from "babylonjs/Misc/perfCounter";
  67984. export * from "babylonjs/Misc/fileRequest";
  67985. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67986. export * from "babylonjs/Misc/retryStrategy";
  67987. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67988. export * from "babylonjs/Misc/canvasGenerator";
  67989. export * from "babylonjs/Misc/fileTools";
  67990. export * from "babylonjs/Misc/stringTools";
  67991. export * from "babylonjs/Misc/dataReader";
  67992. }
  67993. declare module "babylonjs/index" {
  67994. export * from "babylonjs/abstractScene";
  67995. export * from "babylonjs/Actions/index";
  67996. export * from "babylonjs/Animations/index";
  67997. export * from "babylonjs/assetContainer";
  67998. export * from "babylonjs/Audio/index";
  67999. export * from "babylonjs/Behaviors/index";
  68000. export * from "babylonjs/Bones/index";
  68001. export * from "babylonjs/Cameras/index";
  68002. export * from "babylonjs/Collisions/index";
  68003. export * from "babylonjs/Culling/index";
  68004. export * from "babylonjs/Debug/index";
  68005. export * from "babylonjs/Engines/index";
  68006. export * from "babylonjs/Events/index";
  68007. export * from "babylonjs/Gamepads/index";
  68008. export * from "babylonjs/Gizmos/index";
  68009. export * from "babylonjs/Helpers/index";
  68010. export * from "babylonjs/Instrumentation/index";
  68011. export * from "babylonjs/Layers/index";
  68012. export * from "babylonjs/LensFlares/index";
  68013. export * from "babylonjs/Lights/index";
  68014. export * from "babylonjs/Loading/index";
  68015. export * from "babylonjs/Materials/index";
  68016. export * from "babylonjs/Maths/index";
  68017. export * from "babylonjs/Meshes/index";
  68018. export * from "babylonjs/Morph/index";
  68019. export * from "babylonjs/Navigation/index";
  68020. export * from "babylonjs/node";
  68021. export * from "babylonjs/Offline/index";
  68022. export * from "babylonjs/Particles/index";
  68023. export * from "babylonjs/Physics/index";
  68024. export * from "babylonjs/PostProcesses/index";
  68025. export * from "babylonjs/Probes/index";
  68026. export * from "babylonjs/Rendering/index";
  68027. export * from "babylonjs/scene";
  68028. export * from "babylonjs/sceneComponent";
  68029. export * from "babylonjs/Sprites/index";
  68030. export * from "babylonjs/States/index";
  68031. export * from "babylonjs/Misc/index";
  68032. export * from "babylonjs/types";
  68033. }
  68034. declare module "babylonjs/Animations/pathCursor" {
  68035. import { Vector3 } from "babylonjs/Maths/math.vector";
  68036. import { Path2 } from "babylonjs/Maths/math.path";
  68037. /**
  68038. * A cursor which tracks a point on a path
  68039. */
  68040. export class PathCursor {
  68041. private path;
  68042. /**
  68043. * Stores path cursor callbacks for when an onchange event is triggered
  68044. */
  68045. private _onchange;
  68046. /**
  68047. * The value of the path cursor
  68048. */
  68049. value: number;
  68050. /**
  68051. * The animation array of the path cursor
  68052. */
  68053. animations: Animation[];
  68054. /**
  68055. * Initializes the path cursor
  68056. * @param path The path to track
  68057. */
  68058. constructor(path: Path2);
  68059. /**
  68060. * Gets the cursor point on the path
  68061. * @returns A point on the path cursor at the cursor location
  68062. */
  68063. getPoint(): Vector3;
  68064. /**
  68065. * Moves the cursor ahead by the step amount
  68066. * @param step The amount to move the cursor forward
  68067. * @returns This path cursor
  68068. */
  68069. moveAhead(step?: number): PathCursor;
  68070. /**
  68071. * Moves the cursor behind by the step amount
  68072. * @param step The amount to move the cursor back
  68073. * @returns This path cursor
  68074. */
  68075. moveBack(step?: number): PathCursor;
  68076. /**
  68077. * Moves the cursor by the step amount
  68078. * If the step amount is greater than one, an exception is thrown
  68079. * @param step The amount to move the cursor
  68080. * @returns This path cursor
  68081. */
  68082. move(step: number): PathCursor;
  68083. /**
  68084. * Ensures that the value is limited between zero and one
  68085. * @returns This path cursor
  68086. */
  68087. private ensureLimits;
  68088. /**
  68089. * Runs onchange callbacks on change (used by the animation engine)
  68090. * @returns This path cursor
  68091. */
  68092. private raiseOnChange;
  68093. /**
  68094. * Executes a function on change
  68095. * @param f A path cursor onchange callback
  68096. * @returns This path cursor
  68097. */
  68098. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68099. }
  68100. }
  68101. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68102. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68103. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68104. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68105. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68106. }
  68107. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68108. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68109. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68110. }
  68111. declare module "babylonjs/Engines/Processors/index" {
  68112. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68113. export * from "babylonjs/Engines/Processors/Expressions/index";
  68114. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68115. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68116. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68117. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68118. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68119. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68120. }
  68121. declare module "babylonjs/Legacy/legacy" {
  68122. import * as Babylon from "babylonjs/index";
  68123. export * from "babylonjs/index";
  68124. }
  68125. declare module "babylonjs/Shaders/blur.fragment" {
  68126. /** @hidden */
  68127. export var blurPixelShader: {
  68128. name: string;
  68129. shader: string;
  68130. };
  68131. }
  68132. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68133. /** @hidden */
  68134. export var pointCloudVertexDeclaration: {
  68135. name: string;
  68136. shader: string;
  68137. };
  68138. }
  68139. declare module "babylonjs" {
  68140. export * from "babylonjs/Legacy/legacy";
  68141. }
  68142. declare module BABYLON {
  68143. /** Alias type for value that can be null */
  68144. export type Nullable<T> = T | null;
  68145. /**
  68146. * Alias type for number that are floats
  68147. * @ignorenaming
  68148. */
  68149. export type float = number;
  68150. /**
  68151. * Alias type for number that are doubles.
  68152. * @ignorenaming
  68153. */
  68154. export type double = number;
  68155. /**
  68156. * Alias type for number that are integer
  68157. * @ignorenaming
  68158. */
  68159. export type int = number;
  68160. /** Alias type for number array or Float32Array */
  68161. export type FloatArray = number[] | Float32Array;
  68162. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68163. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68164. /**
  68165. * Alias for types that can be used by a Buffer or VertexBuffer.
  68166. */
  68167. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68168. /**
  68169. * Alias type for primitive types
  68170. * @ignorenaming
  68171. */
  68172. type Primitive = undefined | null | boolean | string | number | Function;
  68173. /**
  68174. * Type modifier to make all the properties of an object Readonly
  68175. */
  68176. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68177. /**
  68178. * Type modifier to make all the properties of an object Readonly recursively
  68179. */
  68180. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68181. /**
  68182. * Type modifier to make object properties readonly.
  68183. */
  68184. export type DeepImmutableObject<T> = {
  68185. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68186. };
  68187. /** @hidden */
  68188. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * A class serves as a medium between the observable and its observers
  68194. */
  68195. export class EventState {
  68196. /**
  68197. * Create a new EventState
  68198. * @param mask defines the mask associated with this state
  68199. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68200. * @param target defines the original target of the state
  68201. * @param currentTarget defines the current target of the state
  68202. */
  68203. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68204. /**
  68205. * Initialize the current event state
  68206. * @param mask defines the mask associated with this state
  68207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68208. * @param target defines the original target of the state
  68209. * @param currentTarget defines the current target of the state
  68210. * @returns the current event state
  68211. */
  68212. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68213. /**
  68214. * An Observer can set this property to true to prevent subsequent observers of being notified
  68215. */
  68216. skipNextObservers: boolean;
  68217. /**
  68218. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68219. */
  68220. mask: number;
  68221. /**
  68222. * The object that originally notified the event
  68223. */
  68224. target?: any;
  68225. /**
  68226. * The current object in the bubbling phase
  68227. */
  68228. currentTarget?: any;
  68229. /**
  68230. * This will be populated with the return value of the last function that was executed.
  68231. * If it is the first function in the callback chain it will be the event data.
  68232. */
  68233. lastReturnValue?: any;
  68234. }
  68235. /**
  68236. * Represent an Observer registered to a given Observable object.
  68237. */
  68238. export class Observer<T> {
  68239. /**
  68240. * Defines the callback to call when the observer is notified
  68241. */
  68242. callback: (eventData: T, eventState: EventState) => void;
  68243. /**
  68244. * Defines the mask of the observer (used to filter notifications)
  68245. */
  68246. mask: number;
  68247. /**
  68248. * Defines the current scope used to restore the JS context
  68249. */
  68250. scope: any;
  68251. /** @hidden */
  68252. _willBeUnregistered: boolean;
  68253. /**
  68254. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68255. */
  68256. unregisterOnNextCall: boolean;
  68257. /**
  68258. * Creates a new observer
  68259. * @param callback defines the callback to call when the observer is notified
  68260. * @param mask defines the mask of the observer (used to filter notifications)
  68261. * @param scope defines the current scope used to restore the JS context
  68262. */
  68263. constructor(
  68264. /**
  68265. * Defines the callback to call when the observer is notified
  68266. */
  68267. callback: (eventData: T, eventState: EventState) => void,
  68268. /**
  68269. * Defines the mask of the observer (used to filter notifications)
  68270. */
  68271. mask: number,
  68272. /**
  68273. * Defines the current scope used to restore the JS context
  68274. */
  68275. scope?: any);
  68276. }
  68277. /**
  68278. * Represent a list of observers registered to multiple Observables object.
  68279. */
  68280. export class MultiObserver<T> {
  68281. private _observers;
  68282. private _observables;
  68283. /**
  68284. * Release associated resources
  68285. */
  68286. dispose(): void;
  68287. /**
  68288. * Raise a callback when one of the observable will notify
  68289. * @param observables defines a list of observables to watch
  68290. * @param callback defines the callback to call on notification
  68291. * @param mask defines the mask used to filter notifications
  68292. * @param scope defines the current scope used to restore the JS context
  68293. * @returns the new MultiObserver
  68294. */
  68295. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68296. }
  68297. /**
  68298. * The Observable class is a simple implementation of the Observable pattern.
  68299. *
  68300. * 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.
  68301. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68302. * 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).
  68303. * 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.
  68304. */
  68305. export class Observable<T> {
  68306. private _observers;
  68307. private _eventState;
  68308. private _onObserverAdded;
  68309. /**
  68310. * Gets the list of observers
  68311. */
  68312. readonly observers: Array<Observer<T>>;
  68313. /**
  68314. * Creates a new observable
  68315. * @param onObserverAdded defines a callback to call when a new observer is added
  68316. */
  68317. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68318. /**
  68319. * Create a new Observer with the specified callback
  68320. * @param callback the callback that will be executed for that Observer
  68321. * @param mask the mask used to filter observers
  68322. * @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.
  68323. * @param scope optional scope for the callback to be called from
  68324. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68325. * @returns the new observer created for the callback
  68326. */
  68327. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68328. /**
  68329. * Create a new Observer with the specified callback and unregisters after the next notification
  68330. * @param callback the callback that will be executed for that Observer
  68331. * @returns the new observer created for the callback
  68332. */
  68333. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68334. /**
  68335. * Remove an Observer from the Observable object
  68336. * @param observer the instance of the Observer to remove
  68337. * @returns false if it doesn't belong to this Observable
  68338. */
  68339. remove(observer: Nullable<Observer<T>>): boolean;
  68340. /**
  68341. * Remove a callback from the Observable object
  68342. * @param callback the callback to remove
  68343. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68344. * @returns false if it doesn't belong to this Observable
  68345. */
  68346. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68347. private _deferUnregister;
  68348. private _remove;
  68349. /**
  68350. * Moves the observable to the top of the observer list making it get called first when notified
  68351. * @param observer the observer to move
  68352. */
  68353. makeObserverTopPriority(observer: Observer<T>): void;
  68354. /**
  68355. * Moves the observable to the bottom of the observer list making it get called last when notified
  68356. * @param observer the observer to move
  68357. */
  68358. makeObserverBottomPriority(observer: Observer<T>): void;
  68359. /**
  68360. * Notify all Observers by calling their respective callback with the given data
  68361. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68362. * @param eventData defines the data to send to all observers
  68363. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68364. * @param target defines the original target of the state
  68365. * @param currentTarget defines the current target of the state
  68366. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68367. */
  68368. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68369. /**
  68370. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68371. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68372. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68373. * and it is crucial that all callbacks will be executed.
  68374. * The order of the callbacks is kept, callbacks are not executed parallel.
  68375. *
  68376. * @param eventData The data to be sent to each callback
  68377. * @param mask is used to filter observers defaults to -1
  68378. * @param target defines the callback target (see EventState)
  68379. * @param currentTarget defines he current object in the bubbling phase
  68380. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68381. */
  68382. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68383. /**
  68384. * Notify a specific observer
  68385. * @param observer defines the observer to notify
  68386. * @param eventData defines the data to be sent to each callback
  68387. * @param mask is used to filter observers defaults to -1
  68388. */
  68389. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68390. /**
  68391. * Gets a boolean indicating if the observable has at least one observer
  68392. * @returns true is the Observable has at least one Observer registered
  68393. */
  68394. hasObservers(): boolean;
  68395. /**
  68396. * Clear the list of observers
  68397. */
  68398. clear(): void;
  68399. /**
  68400. * Clone the current observable
  68401. * @returns a new observable
  68402. */
  68403. clone(): Observable<T>;
  68404. /**
  68405. * Does this observable handles observer registered with a given mask
  68406. * @param mask defines the mask to be tested
  68407. * @return whether or not one observer registered with the given mask is handeled
  68408. **/
  68409. hasSpecificMask(mask?: number): boolean;
  68410. }
  68411. }
  68412. declare module BABYLON {
  68413. /**
  68414. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68415. * Babylon.js
  68416. */
  68417. export class DomManagement {
  68418. /**
  68419. * Checks if the window object exists
  68420. * @returns true if the window object exists
  68421. */
  68422. static IsWindowObjectExist(): boolean;
  68423. /**
  68424. * Checks if the navigator object exists
  68425. * @returns true if the navigator object exists
  68426. */
  68427. static IsNavigatorAvailable(): boolean;
  68428. /**
  68429. * Extracts text content from a DOM element hierarchy
  68430. * @param element defines the root element
  68431. * @returns a string
  68432. */
  68433. static GetDOMTextContent(element: HTMLElement): string;
  68434. }
  68435. }
  68436. declare module BABYLON {
  68437. /**
  68438. * Logger used througouht the application to allow configuration of
  68439. * the log level required for the messages.
  68440. */
  68441. export class Logger {
  68442. /**
  68443. * No log
  68444. */
  68445. static readonly NoneLogLevel: number;
  68446. /**
  68447. * Only message logs
  68448. */
  68449. static readonly MessageLogLevel: number;
  68450. /**
  68451. * Only warning logs
  68452. */
  68453. static readonly WarningLogLevel: number;
  68454. /**
  68455. * Only error logs
  68456. */
  68457. static readonly ErrorLogLevel: number;
  68458. /**
  68459. * All logs
  68460. */
  68461. static readonly AllLogLevel: number;
  68462. private static _LogCache;
  68463. /**
  68464. * Gets a value indicating the number of loading errors
  68465. * @ignorenaming
  68466. */
  68467. static errorsCount: number;
  68468. /**
  68469. * Callback called when a new log is added
  68470. */
  68471. static OnNewCacheEntry: (entry: string) => void;
  68472. private static _AddLogEntry;
  68473. private static _FormatMessage;
  68474. private static _LogDisabled;
  68475. private static _LogEnabled;
  68476. private static _WarnDisabled;
  68477. private static _WarnEnabled;
  68478. private static _ErrorDisabled;
  68479. private static _ErrorEnabled;
  68480. /**
  68481. * Log a message to the console
  68482. */
  68483. static Log: (message: string) => void;
  68484. /**
  68485. * Write a warning message to the console
  68486. */
  68487. static Warn: (message: string) => void;
  68488. /**
  68489. * Write an error message to the console
  68490. */
  68491. static Error: (message: string) => void;
  68492. /**
  68493. * Gets current log cache (list of logs)
  68494. */
  68495. static readonly LogCache: string;
  68496. /**
  68497. * Clears the log cache
  68498. */
  68499. static ClearLogCache(): void;
  68500. /**
  68501. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68502. */
  68503. static LogLevels: number;
  68504. }
  68505. }
  68506. declare module BABYLON {
  68507. /** @hidden */
  68508. export class _TypeStore {
  68509. /** @hidden */
  68510. static RegisteredTypes: {
  68511. [key: string]: Object;
  68512. };
  68513. /** @hidden */
  68514. static GetClass(fqdn: string): any;
  68515. }
  68516. }
  68517. declare module BABYLON {
  68518. /**
  68519. * Helper to manipulate strings
  68520. */
  68521. export class StringTools {
  68522. /**
  68523. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68524. * @param str Source string
  68525. * @param suffix Suffix to search for in the source string
  68526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68527. */
  68528. static EndsWith(str: string, suffix: string): boolean;
  68529. /**
  68530. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68531. * @param str Source string
  68532. * @param suffix Suffix to search for in the source string
  68533. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68534. */
  68535. static StartsWith(str: string, suffix: string): boolean;
  68536. /**
  68537. * Decodes a buffer into a string
  68538. * @param buffer The buffer to decode
  68539. * @returns The decoded string
  68540. */
  68541. static Decode(buffer: Uint8Array | Uint16Array): string;
  68542. /**
  68543. * Encode a buffer to a base64 string
  68544. * @param buffer defines the buffer to encode
  68545. * @returns the encoded string
  68546. */
  68547. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68548. }
  68549. }
  68550. declare module BABYLON {
  68551. /**
  68552. * Class containing a set of static utilities functions for deep copy.
  68553. */
  68554. export class DeepCopier {
  68555. /**
  68556. * Tries to copy an object by duplicating every property
  68557. * @param source defines the source object
  68558. * @param destination defines the target object
  68559. * @param doNotCopyList defines a list of properties to avoid
  68560. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68561. */
  68562. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68563. }
  68564. }
  68565. declare module BABYLON {
  68566. /**
  68567. * Class containing a set of static utilities functions for precision date
  68568. */
  68569. export class PrecisionDate {
  68570. /**
  68571. * Gets either window.performance.now() if supported or Date.now() else
  68572. */
  68573. static readonly Now: number;
  68574. }
  68575. }
  68576. declare module BABYLON {
  68577. /** @hidden */
  68578. export class _DevTools {
  68579. static WarnImport(name: string): string;
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /**
  68584. * Interface used to define the mechanism to get data from the network
  68585. */
  68586. export interface IWebRequest {
  68587. /**
  68588. * Returns client's response url
  68589. */
  68590. responseURL: string;
  68591. /**
  68592. * Returns client's status
  68593. */
  68594. status: number;
  68595. /**
  68596. * Returns client's status as a text
  68597. */
  68598. statusText: string;
  68599. }
  68600. }
  68601. declare module BABYLON {
  68602. /**
  68603. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68604. */
  68605. export class WebRequest implements IWebRequest {
  68606. private _xhr;
  68607. /**
  68608. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68609. * i.e. when loading files, where the server/service expects an Authorization header
  68610. */
  68611. static CustomRequestHeaders: {
  68612. [key: string]: string;
  68613. };
  68614. /**
  68615. * Add callback functions in this array to update all the requests before they get sent to the network
  68616. */
  68617. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68618. private _injectCustomRequestHeaders;
  68619. /**
  68620. * Gets or sets a function to be called when loading progress changes
  68621. */
  68622. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68623. /**
  68624. * Returns client's state
  68625. */
  68626. readonly readyState: number;
  68627. /**
  68628. * Returns client's status
  68629. */
  68630. readonly status: number;
  68631. /**
  68632. * Returns client's status as a text
  68633. */
  68634. readonly statusText: string;
  68635. /**
  68636. * Returns client's response
  68637. */
  68638. readonly response: any;
  68639. /**
  68640. * Returns client's response url
  68641. */
  68642. readonly responseURL: string;
  68643. /**
  68644. * Returns client's response as text
  68645. */
  68646. readonly responseText: string;
  68647. /**
  68648. * Gets or sets the expected response type
  68649. */
  68650. responseType: XMLHttpRequestResponseType;
  68651. /** @hidden */
  68652. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68653. /** @hidden */
  68654. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68655. /**
  68656. * Cancels any network activity
  68657. */
  68658. abort(): void;
  68659. /**
  68660. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68661. * @param body defines an optional request body
  68662. */
  68663. send(body?: Document | BodyInit | null): void;
  68664. /**
  68665. * Sets the request method, request URL
  68666. * @param method defines the method to use (GET, POST, etc..)
  68667. * @param url defines the url to connect with
  68668. */
  68669. open(method: string, url: string): void;
  68670. /**
  68671. * Sets the value of a request header.
  68672. * @param name The name of the header whose value is to be set
  68673. * @param value The value to set as the body of the header
  68674. */
  68675. setRequestHeader(name: string, value: string): void;
  68676. /**
  68677. * Get the string containing the text of a particular header's value.
  68678. * @param name The name of the header
  68679. * @returns The string containing the text of the given header name
  68680. */
  68681. getResponseHeader(name: string): Nullable<string>;
  68682. }
  68683. }
  68684. declare module BABYLON {
  68685. /**
  68686. * File request interface
  68687. */
  68688. export interface IFileRequest {
  68689. /**
  68690. * Raised when the request is complete (success or error).
  68691. */
  68692. onCompleteObservable: Observable<IFileRequest>;
  68693. /**
  68694. * Aborts the request for a file.
  68695. */
  68696. abort: () => void;
  68697. }
  68698. }
  68699. declare module BABYLON {
  68700. /**
  68701. * Define options used to create a render target texture
  68702. */
  68703. export class RenderTargetCreationOptions {
  68704. /**
  68705. * Specifies is mipmaps must be generated
  68706. */
  68707. generateMipMaps?: boolean;
  68708. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68709. generateDepthBuffer?: boolean;
  68710. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68711. generateStencilBuffer?: boolean;
  68712. /** Defines texture type (int by default) */
  68713. type?: number;
  68714. /** Defines sampling mode (trilinear by default) */
  68715. samplingMode?: number;
  68716. /** Defines format (RGBA by default) */
  68717. format?: number;
  68718. }
  68719. }
  68720. declare module BABYLON {
  68721. /**
  68722. * @hidden
  68723. **/
  68724. export class _TimeToken {
  68725. _startTimeQuery: Nullable<WebGLQuery>;
  68726. _endTimeQuery: Nullable<WebGLQuery>;
  68727. _timeElapsedQuery: Nullable<WebGLQuery>;
  68728. _timeElapsedQueryEnded: boolean;
  68729. }
  68730. }
  68731. declare module BABYLON {
  68732. /** Defines the cross module used constants to avoid circular dependncies */
  68733. export class Constants {
  68734. /** Defines that alpha blending is disabled */
  68735. static readonly ALPHA_DISABLE: number;
  68736. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68737. static readonly ALPHA_ADD: number;
  68738. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68739. static readonly ALPHA_COMBINE: number;
  68740. /** Defines that alpha blending to DEST - SRC * DEST */
  68741. static readonly ALPHA_SUBTRACT: number;
  68742. /** Defines that alpha blending to SRC * DEST */
  68743. static readonly ALPHA_MULTIPLY: number;
  68744. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68745. static readonly ALPHA_MAXIMIZED: number;
  68746. /** Defines that alpha blending to SRC + DEST */
  68747. static readonly ALPHA_ONEONE: number;
  68748. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68749. static readonly ALPHA_PREMULTIPLIED: number;
  68750. /**
  68751. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68752. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68753. */
  68754. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68755. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68756. static readonly ALPHA_INTERPOLATE: number;
  68757. /**
  68758. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68759. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68760. */
  68761. static readonly ALPHA_SCREENMODE: number;
  68762. /**
  68763. * Defines that alpha blending to SRC + DST
  68764. * Alpha will be set to SRC ALPHA + DST ALPHA
  68765. */
  68766. static readonly ALPHA_ONEONE_ONEONE: number;
  68767. /**
  68768. * Defines that alpha blending to SRC * DST ALPHA + DST
  68769. * Alpha will be set to 0
  68770. */
  68771. static readonly ALPHA_ALPHATOCOLOR: number;
  68772. /**
  68773. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68774. */
  68775. static readonly ALPHA_REVERSEONEMINUS: number;
  68776. /**
  68777. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68778. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68779. */
  68780. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68781. /**
  68782. * Defines that alpha blending to SRC + DST
  68783. * Alpha will be set to SRC ALPHA
  68784. */
  68785. static readonly ALPHA_ONEONE_ONEZERO: number;
  68786. /** Defines that alpha blending equation a SUM */
  68787. static readonly ALPHA_EQUATION_ADD: number;
  68788. /** Defines that alpha blending equation a SUBSTRACTION */
  68789. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68790. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68791. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68792. /** Defines that alpha blending equation a MAX operation */
  68793. static readonly ALPHA_EQUATION_MAX: number;
  68794. /** Defines that alpha blending equation a MIN operation */
  68795. static readonly ALPHA_EQUATION_MIN: number;
  68796. /**
  68797. * Defines that alpha blending equation a DARKEN operation:
  68798. * It takes the min of the src and sums the alpha channels.
  68799. */
  68800. static readonly ALPHA_EQUATION_DARKEN: number;
  68801. /** Defines that the ressource is not delayed*/
  68802. static readonly DELAYLOADSTATE_NONE: number;
  68803. /** Defines that the ressource was successfully delay loaded */
  68804. static readonly DELAYLOADSTATE_LOADED: number;
  68805. /** Defines that the ressource is currently delay loading */
  68806. static readonly DELAYLOADSTATE_LOADING: number;
  68807. /** Defines that the ressource is delayed and has not started loading */
  68808. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68809. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68810. static readonly NEVER: number;
  68811. /** 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 */
  68812. static readonly ALWAYS: number;
  68813. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68814. static readonly LESS: number;
  68815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68816. static readonly EQUAL: number;
  68817. /** 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 */
  68818. static readonly LEQUAL: number;
  68819. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68820. static readonly GREATER: number;
  68821. /** 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 */
  68822. static readonly GEQUAL: number;
  68823. /** 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 */
  68824. static readonly NOTEQUAL: number;
  68825. /** Passed to stencilOperation to specify that stencil value must be kept */
  68826. static readonly KEEP: number;
  68827. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68828. static readonly REPLACE: number;
  68829. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68830. static readonly INCR: number;
  68831. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68832. static readonly DECR: number;
  68833. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68834. static readonly INVERT: number;
  68835. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68836. static readonly INCR_WRAP: number;
  68837. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68838. static readonly DECR_WRAP: number;
  68839. /** Texture is not repeating outside of 0..1 UVs */
  68840. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68841. /** Texture is repeating outside of 0..1 UVs */
  68842. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68843. /** Texture is repeating and mirrored */
  68844. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68845. /** ALPHA */
  68846. static readonly TEXTUREFORMAT_ALPHA: number;
  68847. /** LUMINANCE */
  68848. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68849. /** LUMINANCE_ALPHA */
  68850. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68851. /** RGB */
  68852. static readonly TEXTUREFORMAT_RGB: number;
  68853. /** RGBA */
  68854. static readonly TEXTUREFORMAT_RGBA: number;
  68855. /** RED */
  68856. static readonly TEXTUREFORMAT_RED: number;
  68857. /** RED (2nd reference) */
  68858. static readonly TEXTUREFORMAT_R: number;
  68859. /** RG */
  68860. static readonly TEXTUREFORMAT_RG: number;
  68861. /** RED_INTEGER */
  68862. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68863. /** RED_INTEGER (2nd reference) */
  68864. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68865. /** RG_INTEGER */
  68866. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68867. /** RGB_INTEGER */
  68868. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68869. /** RGBA_INTEGER */
  68870. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68871. /** UNSIGNED_BYTE */
  68872. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68873. /** UNSIGNED_BYTE (2nd reference) */
  68874. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68875. /** FLOAT */
  68876. static readonly TEXTURETYPE_FLOAT: number;
  68877. /** HALF_FLOAT */
  68878. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68879. /** BYTE */
  68880. static readonly TEXTURETYPE_BYTE: number;
  68881. /** SHORT */
  68882. static readonly TEXTURETYPE_SHORT: number;
  68883. /** UNSIGNED_SHORT */
  68884. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68885. /** INT */
  68886. static readonly TEXTURETYPE_INT: number;
  68887. /** UNSIGNED_INT */
  68888. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68889. /** UNSIGNED_SHORT_4_4_4_4 */
  68890. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68891. /** UNSIGNED_SHORT_5_5_5_1 */
  68892. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68893. /** UNSIGNED_SHORT_5_6_5 */
  68894. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68895. /** UNSIGNED_INT_2_10_10_10_REV */
  68896. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68897. /** UNSIGNED_INT_24_8 */
  68898. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68899. /** UNSIGNED_INT_10F_11F_11F_REV */
  68900. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68901. /** UNSIGNED_INT_5_9_9_9_REV */
  68902. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68903. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68904. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68905. /** nearest is mag = nearest and min = nearest and mip = linear */
  68906. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68907. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68908. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68909. /** Trilinear is mag = linear and min = linear and mip = linear */
  68910. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68911. /** nearest is mag = nearest and min = nearest and mip = linear */
  68912. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68914. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68915. /** Trilinear is mag = linear and min = linear and mip = linear */
  68916. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68917. /** mag = nearest and min = nearest and mip = nearest */
  68918. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68919. /** mag = nearest and min = linear and mip = nearest */
  68920. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68921. /** mag = nearest and min = linear and mip = linear */
  68922. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68923. /** mag = nearest and min = linear and mip = none */
  68924. static readonly TEXTURE_NEAREST_LINEAR: number;
  68925. /** mag = nearest and min = nearest and mip = none */
  68926. static readonly TEXTURE_NEAREST_NEAREST: number;
  68927. /** mag = linear and min = nearest and mip = nearest */
  68928. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68929. /** mag = linear and min = nearest and mip = linear */
  68930. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68931. /** mag = linear and min = linear and mip = none */
  68932. static readonly TEXTURE_LINEAR_LINEAR: number;
  68933. /** mag = linear and min = nearest and mip = none */
  68934. static readonly TEXTURE_LINEAR_NEAREST: number;
  68935. /** Explicit coordinates mode */
  68936. static readonly TEXTURE_EXPLICIT_MODE: number;
  68937. /** Spherical coordinates mode */
  68938. static readonly TEXTURE_SPHERICAL_MODE: number;
  68939. /** Planar coordinates mode */
  68940. static readonly TEXTURE_PLANAR_MODE: number;
  68941. /** Cubic coordinates mode */
  68942. static readonly TEXTURE_CUBIC_MODE: number;
  68943. /** Projection coordinates mode */
  68944. static readonly TEXTURE_PROJECTION_MODE: number;
  68945. /** Skybox coordinates mode */
  68946. static readonly TEXTURE_SKYBOX_MODE: number;
  68947. /** Inverse Cubic coordinates mode */
  68948. static readonly TEXTURE_INVCUBIC_MODE: number;
  68949. /** Equirectangular coordinates mode */
  68950. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68951. /** Equirectangular Fixed coordinates mode */
  68952. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68953. /** Equirectangular Fixed Mirrored coordinates mode */
  68954. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68955. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68956. static readonly SCALEMODE_FLOOR: number;
  68957. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68958. static readonly SCALEMODE_NEAREST: number;
  68959. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68960. static readonly SCALEMODE_CEILING: number;
  68961. /**
  68962. * The dirty texture flag value
  68963. */
  68964. static readonly MATERIAL_TextureDirtyFlag: number;
  68965. /**
  68966. * The dirty light flag value
  68967. */
  68968. static readonly MATERIAL_LightDirtyFlag: number;
  68969. /**
  68970. * The dirty fresnel flag value
  68971. */
  68972. static readonly MATERIAL_FresnelDirtyFlag: number;
  68973. /**
  68974. * The dirty attribute flag value
  68975. */
  68976. static readonly MATERIAL_AttributesDirtyFlag: number;
  68977. /**
  68978. * The dirty misc flag value
  68979. */
  68980. static readonly MATERIAL_MiscDirtyFlag: number;
  68981. /**
  68982. * The all dirty flag value
  68983. */
  68984. static readonly MATERIAL_AllDirtyFlag: number;
  68985. /**
  68986. * Returns the triangle fill mode
  68987. */
  68988. static readonly MATERIAL_TriangleFillMode: number;
  68989. /**
  68990. * Returns the wireframe mode
  68991. */
  68992. static readonly MATERIAL_WireFrameFillMode: number;
  68993. /**
  68994. * Returns the point fill mode
  68995. */
  68996. static readonly MATERIAL_PointFillMode: number;
  68997. /**
  68998. * Returns the point list draw mode
  68999. */
  69000. static readonly MATERIAL_PointListDrawMode: number;
  69001. /**
  69002. * Returns the line list draw mode
  69003. */
  69004. static readonly MATERIAL_LineListDrawMode: number;
  69005. /**
  69006. * Returns the line loop draw mode
  69007. */
  69008. static readonly MATERIAL_LineLoopDrawMode: number;
  69009. /**
  69010. * Returns the line strip draw mode
  69011. */
  69012. static readonly MATERIAL_LineStripDrawMode: number;
  69013. /**
  69014. * Returns the triangle strip draw mode
  69015. */
  69016. static readonly MATERIAL_TriangleStripDrawMode: number;
  69017. /**
  69018. * Returns the triangle fan draw mode
  69019. */
  69020. static readonly MATERIAL_TriangleFanDrawMode: number;
  69021. /**
  69022. * Stores the clock-wise side orientation
  69023. */
  69024. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69025. /**
  69026. * Stores the counter clock-wise side orientation
  69027. */
  69028. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69029. /**
  69030. * Nothing
  69031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69032. */
  69033. static readonly ACTION_NothingTrigger: number;
  69034. /**
  69035. * On pick
  69036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69037. */
  69038. static readonly ACTION_OnPickTrigger: number;
  69039. /**
  69040. * On left pick
  69041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69042. */
  69043. static readonly ACTION_OnLeftPickTrigger: number;
  69044. /**
  69045. * On right pick
  69046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69047. */
  69048. static readonly ACTION_OnRightPickTrigger: number;
  69049. /**
  69050. * On center pick
  69051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69052. */
  69053. static readonly ACTION_OnCenterPickTrigger: number;
  69054. /**
  69055. * On pick down
  69056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69057. */
  69058. static readonly ACTION_OnPickDownTrigger: number;
  69059. /**
  69060. * On double pick
  69061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69062. */
  69063. static readonly ACTION_OnDoublePickTrigger: number;
  69064. /**
  69065. * On pick up
  69066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69067. */
  69068. static readonly ACTION_OnPickUpTrigger: number;
  69069. /**
  69070. * On pick out.
  69071. * This trigger will only be raised if you also declared a OnPickDown
  69072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69073. */
  69074. static readonly ACTION_OnPickOutTrigger: number;
  69075. /**
  69076. * On long press
  69077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69078. */
  69079. static readonly ACTION_OnLongPressTrigger: number;
  69080. /**
  69081. * On pointer over
  69082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69083. */
  69084. static readonly ACTION_OnPointerOverTrigger: number;
  69085. /**
  69086. * On pointer out
  69087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69088. */
  69089. static readonly ACTION_OnPointerOutTrigger: number;
  69090. /**
  69091. * On every frame
  69092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69093. */
  69094. static readonly ACTION_OnEveryFrameTrigger: number;
  69095. /**
  69096. * On intersection enter
  69097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69098. */
  69099. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69100. /**
  69101. * On intersection exit
  69102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69103. */
  69104. static readonly ACTION_OnIntersectionExitTrigger: number;
  69105. /**
  69106. * On key down
  69107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69108. */
  69109. static readonly ACTION_OnKeyDownTrigger: number;
  69110. /**
  69111. * On key up
  69112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69113. */
  69114. static readonly ACTION_OnKeyUpTrigger: number;
  69115. /**
  69116. * Billboard mode will only apply to Y axis
  69117. */
  69118. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69119. /**
  69120. * Billboard mode will apply to all axes
  69121. */
  69122. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69123. /**
  69124. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69125. */
  69126. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69127. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69128. * Test order :
  69129. * Is the bounding sphere outside the frustum ?
  69130. * If not, are the bounding box vertices outside the frustum ?
  69131. * It not, then the cullable object is in the frustum.
  69132. */
  69133. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69134. /** Culling strategy : Bounding Sphere Only.
  69135. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69136. * It's also less accurate than the standard because some not visible objects can still be selected.
  69137. * Test : is the bounding sphere outside the frustum ?
  69138. * If not, then the cullable object is in the frustum.
  69139. */
  69140. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69141. /** Culling strategy : Optimistic Inclusion.
  69142. * This in an inclusion test first, then the standard exclusion test.
  69143. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69144. * 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.
  69145. * Anyway, it's as accurate as the standard strategy.
  69146. * Test :
  69147. * Is the cullable object bounding sphere center in the frustum ?
  69148. * If not, apply the default culling strategy.
  69149. */
  69150. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69151. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69152. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69153. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69154. * 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.
  69155. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69156. * Test :
  69157. * Is the cullable object bounding sphere center in the frustum ?
  69158. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69159. */
  69160. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69161. /**
  69162. * No logging while loading
  69163. */
  69164. static readonly SCENELOADER_NO_LOGGING: number;
  69165. /**
  69166. * Minimal logging while loading
  69167. */
  69168. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69169. /**
  69170. * Summary logging while loading
  69171. */
  69172. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69173. /**
  69174. * Detailled logging while loading
  69175. */
  69176. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69177. }
  69178. }
  69179. declare module BABYLON {
  69180. /**
  69181. * This represents the required contract to create a new type of texture loader.
  69182. */
  69183. export interface IInternalTextureLoader {
  69184. /**
  69185. * Defines wether the loader supports cascade loading the different faces.
  69186. */
  69187. supportCascades: boolean;
  69188. /**
  69189. * This returns if the loader support the current file information.
  69190. * @param extension defines the file extension of the file being loaded
  69191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69192. * @param fallback defines the fallback internal texture if any
  69193. * @param isBase64 defines whether the texture is encoded as a base64
  69194. * @param isBuffer defines whether the texture data are stored as a buffer
  69195. * @returns true if the loader can load the specified file
  69196. */
  69197. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69198. /**
  69199. * Transform the url before loading if required.
  69200. * @param rootUrl the url of the texture
  69201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69202. * @returns the transformed texture
  69203. */
  69204. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69205. /**
  69206. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69207. * @param rootUrl the url of the texture
  69208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69209. * @returns the fallback texture
  69210. */
  69211. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69212. /**
  69213. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69214. * @param data contains the texture data
  69215. * @param texture defines the BabylonJS internal texture
  69216. * @param createPolynomials will be true if polynomials have been requested
  69217. * @param onLoad defines the callback to trigger once the texture is ready
  69218. * @param onError defines the callback to trigger in case of error
  69219. */
  69220. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69221. /**
  69222. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69223. * @param data contains the texture data
  69224. * @param texture defines the BabylonJS internal texture
  69225. * @param callback defines the method to call once ready to upload
  69226. */
  69227. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69228. }
  69229. }
  69230. declare module BABYLON {
  69231. /**
  69232. * Class used to store and describe the pipeline context associated with an effect
  69233. */
  69234. export interface IPipelineContext {
  69235. /**
  69236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69237. */
  69238. isAsync: boolean;
  69239. /**
  69240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69241. */
  69242. isReady: boolean;
  69243. /** @hidden */
  69244. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69245. }
  69246. }
  69247. declare module BABYLON {
  69248. /**
  69249. * Class used to store gfx data (like WebGLBuffer)
  69250. */
  69251. export class DataBuffer {
  69252. /**
  69253. * Gets or sets the number of objects referencing this buffer
  69254. */
  69255. references: number;
  69256. /** Gets or sets the size of the underlying buffer */
  69257. capacity: number;
  69258. /**
  69259. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69260. */
  69261. is32Bits: boolean;
  69262. /**
  69263. * Gets the underlying buffer
  69264. */
  69265. readonly underlyingResource: any;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /** @hidden */
  69270. export interface IShaderProcessor {
  69271. attributeProcessor?: (attribute: string) => string;
  69272. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69273. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69274. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69275. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69276. lineProcessor?: (line: string, isFragment: boolean) => string;
  69277. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69278. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69279. }
  69280. }
  69281. declare module BABYLON {
  69282. /** @hidden */
  69283. export interface ProcessingOptions {
  69284. defines: string[];
  69285. indexParameters: any;
  69286. isFragment: boolean;
  69287. shouldUseHighPrecisionShader: boolean;
  69288. supportsUniformBuffers: boolean;
  69289. shadersRepository: string;
  69290. includesShadersStore: {
  69291. [key: string]: string;
  69292. };
  69293. processor?: IShaderProcessor;
  69294. version: string;
  69295. platformName: string;
  69296. lookForClosingBracketForUniformBuffer?: boolean;
  69297. }
  69298. }
  69299. declare module BABYLON {
  69300. /** @hidden */
  69301. export class ShaderCodeNode {
  69302. line: string;
  69303. children: ShaderCodeNode[];
  69304. additionalDefineKey?: string;
  69305. additionalDefineValue?: string;
  69306. isValid(preprocessors: {
  69307. [key: string]: string;
  69308. }): boolean;
  69309. process(preprocessors: {
  69310. [key: string]: string;
  69311. }, options: ProcessingOptions): string;
  69312. }
  69313. }
  69314. declare module BABYLON {
  69315. /** @hidden */
  69316. export class ShaderCodeCursor {
  69317. private _lines;
  69318. lineIndex: number;
  69319. readonly currentLine: string;
  69320. readonly canRead: boolean;
  69321. lines: string[];
  69322. }
  69323. }
  69324. declare module BABYLON {
  69325. /** @hidden */
  69326. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69327. process(preprocessors: {
  69328. [key: string]: string;
  69329. }, options: ProcessingOptions): string;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /** @hidden */
  69334. export class ShaderDefineExpression {
  69335. isTrue(preprocessors: {
  69336. [key: string]: string;
  69337. }): boolean;
  69338. }
  69339. }
  69340. declare module BABYLON {
  69341. /** @hidden */
  69342. export class ShaderCodeTestNode extends ShaderCodeNode {
  69343. testExpression: ShaderDefineExpression;
  69344. isValid(preprocessors: {
  69345. [key: string]: string;
  69346. }): boolean;
  69347. }
  69348. }
  69349. declare module BABYLON {
  69350. /** @hidden */
  69351. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69352. define: string;
  69353. not: boolean;
  69354. constructor(define: string, not?: boolean);
  69355. isTrue(preprocessors: {
  69356. [key: string]: string;
  69357. }): boolean;
  69358. }
  69359. }
  69360. declare module BABYLON {
  69361. /** @hidden */
  69362. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69363. leftOperand: ShaderDefineExpression;
  69364. rightOperand: ShaderDefineExpression;
  69365. isTrue(preprocessors: {
  69366. [key: string]: string;
  69367. }): boolean;
  69368. }
  69369. }
  69370. declare module BABYLON {
  69371. /** @hidden */
  69372. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69373. leftOperand: ShaderDefineExpression;
  69374. rightOperand: ShaderDefineExpression;
  69375. isTrue(preprocessors: {
  69376. [key: string]: string;
  69377. }): boolean;
  69378. }
  69379. }
  69380. declare module BABYLON {
  69381. /** @hidden */
  69382. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69383. define: string;
  69384. operand: string;
  69385. testValue: string;
  69386. constructor(define: string, operand: string, testValue: string);
  69387. isTrue(preprocessors: {
  69388. [key: string]: string;
  69389. }): boolean;
  69390. }
  69391. }
  69392. declare module BABYLON {
  69393. /**
  69394. * Class used to enable access to offline support
  69395. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69396. */
  69397. export interface IOfflineProvider {
  69398. /**
  69399. * Gets a boolean indicating if scene must be saved in the database
  69400. */
  69401. enableSceneOffline: boolean;
  69402. /**
  69403. * Gets a boolean indicating if textures must be saved in the database
  69404. */
  69405. enableTexturesOffline: boolean;
  69406. /**
  69407. * Open the offline support and make it available
  69408. * @param successCallback defines the callback to call on success
  69409. * @param errorCallback defines the callback to call on error
  69410. */
  69411. open(successCallback: () => void, errorCallback: () => void): void;
  69412. /**
  69413. * Loads an image from the offline support
  69414. * @param url defines the url to load from
  69415. * @param image defines the target DOM image
  69416. */
  69417. loadImage(url: string, image: HTMLImageElement): void;
  69418. /**
  69419. * Loads a file from offline support
  69420. * @param url defines the URL to load from
  69421. * @param sceneLoaded defines a callback to call on success
  69422. * @param progressCallBack defines a callback to call when progress changed
  69423. * @param errorCallback defines a callback to call on error
  69424. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69425. */
  69426. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69427. }
  69428. }
  69429. declare module BABYLON {
  69430. /**
  69431. * Class used to help managing file picking and drag'n'drop
  69432. * File Storage
  69433. */
  69434. export class FilesInputStore {
  69435. /**
  69436. * List of files ready to be loaded
  69437. */
  69438. static FilesToLoad: {
  69439. [key: string]: File;
  69440. };
  69441. }
  69442. }
  69443. declare module BABYLON {
  69444. /**
  69445. * Class used to define a retry strategy when error happens while loading assets
  69446. */
  69447. export class RetryStrategy {
  69448. /**
  69449. * Function used to defines an exponential back off strategy
  69450. * @param maxRetries defines the maximum number of retries (3 by default)
  69451. * @param baseInterval defines the interval between retries
  69452. * @returns the strategy function to use
  69453. */
  69454. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69455. }
  69456. }
  69457. declare module BABYLON {
  69458. /**
  69459. * @ignore
  69460. * Application error to support additional information when loading a file
  69461. */
  69462. export abstract class BaseError extends Error {
  69463. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /** @ignore */
  69468. export class LoadFileError extends BaseError {
  69469. request?: WebRequest;
  69470. file?: File;
  69471. /**
  69472. * Creates a new LoadFileError
  69473. * @param message defines the message of the error
  69474. * @param request defines the optional web request
  69475. * @param file defines the optional file
  69476. */
  69477. constructor(message: string, object?: WebRequest | File);
  69478. }
  69479. /** @ignore */
  69480. export class RequestFileError extends BaseError {
  69481. request: WebRequest;
  69482. /**
  69483. * Creates a new LoadFileError
  69484. * @param message defines the message of the error
  69485. * @param request defines the optional web request
  69486. */
  69487. constructor(message: string, request: WebRequest);
  69488. }
  69489. /** @ignore */
  69490. export class ReadFileError extends BaseError {
  69491. file: File;
  69492. /**
  69493. * Creates a new ReadFileError
  69494. * @param message defines the message of the error
  69495. * @param file defines the optional file
  69496. */
  69497. constructor(message: string, file: File);
  69498. }
  69499. /**
  69500. * @hidden
  69501. */
  69502. export class FileTools {
  69503. /**
  69504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69505. */
  69506. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69507. /**
  69508. * Gets or sets the base URL to use to load assets
  69509. */
  69510. static BaseUrl: string;
  69511. /**
  69512. * Default behaviour for cors in the application.
  69513. * It can be a string if the expected behavior is identical in the entire app.
  69514. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69515. */
  69516. static CorsBehavior: string | ((url: string | string[]) => string);
  69517. /**
  69518. * Gets or sets a function used to pre-process url before using them to load assets
  69519. */
  69520. static PreprocessUrl: (url: string) => string;
  69521. /**
  69522. * Removes unwanted characters from an url
  69523. * @param url defines the url to clean
  69524. * @returns the cleaned url
  69525. */
  69526. private static _CleanUrl;
  69527. /**
  69528. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69529. * @param url define the url we are trying
  69530. * @param element define the dom element where to configure the cors policy
  69531. */
  69532. static SetCorsBehavior(url: string | string[], element: {
  69533. crossOrigin: string | null;
  69534. }): void;
  69535. /**
  69536. * Loads an image as an HTMLImageElement.
  69537. * @param input url string, ArrayBuffer, or Blob to load
  69538. * @param onLoad callback called when the image successfully loads
  69539. * @param onError callback called when the image fails to load
  69540. * @param offlineProvider offline provider for caching
  69541. * @param mimeType optional mime type
  69542. * @returns the HTMLImageElement of the loaded image
  69543. */
  69544. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  69545. /**
  69546. * Reads a file from a File object
  69547. * @param file defines the file to load
  69548. * @param onSuccess defines the callback to call when data is loaded
  69549. * @param onProgress defines the callback to call during loading process
  69550. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69551. * @param onError defines the callback to call when an error occurs
  69552. * @returns a file request object
  69553. */
  69554. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69555. /**
  69556. * Loads a file from a url
  69557. * @param url url to load
  69558. * @param onSuccess callback called when the file successfully loads
  69559. * @param onProgress callback called while file is loading (if the server supports this mode)
  69560. * @param offlineProvider defines the offline provider for caching
  69561. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69562. * @param onError callback called when the file fails to load
  69563. * @returns a file request object
  69564. */
  69565. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  69566. /**
  69567. * Loads a file
  69568. * @param url url to load
  69569. * @param onSuccess callback called when the file successfully loads
  69570. * @param onProgress callback called while file is loading (if the server supports this mode)
  69571. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69572. * @param onError callback called when the file fails to load
  69573. * @param onOpened callback called when the web request is opened
  69574. * @returns a file request object
  69575. */
  69576. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  69577. /**
  69578. * Checks if the loaded document was accessed via `file:`-Protocol.
  69579. * @returns boolean
  69580. */
  69581. static IsFileURL(): boolean;
  69582. }
  69583. }
  69584. declare module BABYLON {
  69585. /** @hidden */
  69586. export class ShaderProcessor {
  69587. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69588. private static _ProcessPrecision;
  69589. private static _ExtractOperation;
  69590. private static _BuildSubExpression;
  69591. private static _BuildExpression;
  69592. private static _MoveCursorWithinIf;
  69593. private static _MoveCursor;
  69594. private static _EvaluatePreProcessors;
  69595. private static _PreparePreProcessors;
  69596. private static _ProcessShaderConversion;
  69597. private static _ProcessIncludes;
  69598. }
  69599. }
  69600. declare module BABYLON {
  69601. /**
  69602. * @hidden
  69603. */
  69604. export interface IColor4Like {
  69605. r: float;
  69606. g: float;
  69607. b: float;
  69608. a: float;
  69609. }
  69610. /**
  69611. * @hidden
  69612. */
  69613. export interface IColor3Like {
  69614. r: float;
  69615. g: float;
  69616. b: float;
  69617. }
  69618. /**
  69619. * @hidden
  69620. */
  69621. export interface IVector4Like {
  69622. x: float;
  69623. y: float;
  69624. z: float;
  69625. w: float;
  69626. }
  69627. /**
  69628. * @hidden
  69629. */
  69630. export interface IVector3Like {
  69631. x: float;
  69632. y: float;
  69633. z: float;
  69634. }
  69635. /**
  69636. * @hidden
  69637. */
  69638. export interface IVector2Like {
  69639. x: float;
  69640. y: float;
  69641. }
  69642. /**
  69643. * @hidden
  69644. */
  69645. export interface IMatrixLike {
  69646. toArray(): DeepImmutable<Float32Array>;
  69647. updateFlag: int;
  69648. }
  69649. /**
  69650. * @hidden
  69651. */
  69652. export interface IViewportLike {
  69653. x: float;
  69654. y: float;
  69655. width: float;
  69656. height: float;
  69657. }
  69658. /**
  69659. * @hidden
  69660. */
  69661. export interface IPlaneLike {
  69662. normal: IVector3Like;
  69663. d: float;
  69664. normalize(): void;
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /**
  69669. * Interface used to define common properties for effect fallbacks
  69670. */
  69671. export interface IEffectFallbacks {
  69672. /**
  69673. * Removes the defines that should be removed when falling back.
  69674. * @param currentDefines defines the current define statements for the shader.
  69675. * @param effect defines the current effect we try to compile
  69676. * @returns The resulting defines with defines of the current rank removed.
  69677. */
  69678. reduce(currentDefines: string, effect: Effect): string;
  69679. /**
  69680. * Removes the fallback from the bound mesh.
  69681. */
  69682. unBindMesh(): void;
  69683. /**
  69684. * Checks to see if more fallbacks are still availible.
  69685. */
  69686. hasMoreFallbacks: boolean;
  69687. }
  69688. }
  69689. declare module BABYLON {
  69690. /**
  69691. * Class used to evalaute queries containing `and` and `or` operators
  69692. */
  69693. export class AndOrNotEvaluator {
  69694. /**
  69695. * Evaluate a query
  69696. * @param query defines the query to evaluate
  69697. * @param evaluateCallback defines the callback used to filter result
  69698. * @returns true if the query matches
  69699. */
  69700. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69701. private static _HandleParenthesisContent;
  69702. private static _SimplifyNegation;
  69703. }
  69704. }
  69705. declare module BABYLON {
  69706. /**
  69707. * Class used to store custom tags
  69708. */
  69709. export class Tags {
  69710. /**
  69711. * Adds support for tags on the given object
  69712. * @param obj defines the object to use
  69713. */
  69714. static EnableFor(obj: any): void;
  69715. /**
  69716. * Removes tags support
  69717. * @param obj defines the object to use
  69718. */
  69719. static DisableFor(obj: any): void;
  69720. /**
  69721. * Gets a boolean indicating if the given object has tags
  69722. * @param obj defines the object to use
  69723. * @returns a boolean
  69724. */
  69725. static HasTags(obj: any): boolean;
  69726. /**
  69727. * Gets the tags available on a given object
  69728. * @param obj defines the object to use
  69729. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69730. * @returns the tags
  69731. */
  69732. static GetTags(obj: any, asString?: boolean): any;
  69733. /**
  69734. * Adds tags to an object
  69735. * @param obj defines the object to use
  69736. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69737. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69738. */
  69739. static AddTagsTo(obj: any, tagsString: string): void;
  69740. /**
  69741. * @hidden
  69742. */
  69743. static _AddTagTo(obj: any, tag: string): void;
  69744. /**
  69745. * Removes specific tags from a specific object
  69746. * @param obj defines the object to use
  69747. * @param tagsString defines the tags to remove
  69748. */
  69749. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69750. /**
  69751. * @hidden
  69752. */
  69753. static _RemoveTagFrom(obj: any, tag: string): void;
  69754. /**
  69755. * Defines if tags hosted on an object match a given query
  69756. * @param obj defines the object to use
  69757. * @param tagsQuery defines the tag query
  69758. * @returns a boolean
  69759. */
  69760. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69761. }
  69762. }
  69763. declare module BABYLON {
  69764. /**
  69765. * Scalar computation library
  69766. */
  69767. export class Scalar {
  69768. /**
  69769. * Two pi constants convenient for computation.
  69770. */
  69771. static TwoPi: number;
  69772. /**
  69773. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69774. * @param a number
  69775. * @param b number
  69776. * @param epsilon (default = 1.401298E-45)
  69777. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69778. */
  69779. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69780. /**
  69781. * Returns a string : the upper case translation of the number i to hexadecimal.
  69782. * @param i number
  69783. * @returns the upper case translation of the number i to hexadecimal.
  69784. */
  69785. static ToHex(i: number): string;
  69786. /**
  69787. * Returns -1 if value is negative and +1 is value is positive.
  69788. * @param value the value
  69789. * @returns the value itself if it's equal to zero.
  69790. */
  69791. static Sign(value: number): number;
  69792. /**
  69793. * Returns the value itself if it's between min and max.
  69794. * Returns min if the value is lower than min.
  69795. * Returns max if the value is greater than max.
  69796. * @param value the value to clmap
  69797. * @param min the min value to clamp to (default: 0)
  69798. * @param max the max value to clamp to (default: 1)
  69799. * @returns the clamped value
  69800. */
  69801. static Clamp(value: number, min?: number, max?: number): number;
  69802. /**
  69803. * the log2 of value.
  69804. * @param value the value to compute log2 of
  69805. * @returns the log2 of value.
  69806. */
  69807. static Log2(value: number): number;
  69808. /**
  69809. * Loops the value, so that it is never larger than length and never smaller than 0.
  69810. *
  69811. * This is similar to the modulo operator but it works with floating point numbers.
  69812. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69813. * With t = 5 and length = 2.5, the result would be 0.0.
  69814. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69815. * @param value the value
  69816. * @param length the length
  69817. * @returns the looped value
  69818. */
  69819. static Repeat(value: number, length: number): number;
  69820. /**
  69821. * Normalize the value between 0.0 and 1.0 using min and max values
  69822. * @param value value to normalize
  69823. * @param min max to normalize between
  69824. * @param max min to normalize between
  69825. * @returns the normalized value
  69826. */
  69827. static Normalize(value: number, min: number, max: number): number;
  69828. /**
  69829. * Denormalize the value from 0.0 and 1.0 using min and max values
  69830. * @param normalized value to denormalize
  69831. * @param min max to denormalize between
  69832. * @param max min to denormalize between
  69833. * @returns the denormalized value
  69834. */
  69835. static Denormalize(normalized: number, min: number, max: number): number;
  69836. /**
  69837. * Calculates the shortest difference between two given angles given in degrees.
  69838. * @param current current angle in degrees
  69839. * @param target target angle in degrees
  69840. * @returns the delta
  69841. */
  69842. static DeltaAngle(current: number, target: number): number;
  69843. /**
  69844. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69845. * @param tx value
  69846. * @param length length
  69847. * @returns The returned value will move back and forth between 0 and length
  69848. */
  69849. static PingPong(tx: number, length: number): number;
  69850. /**
  69851. * Interpolates between min and max with smoothing at the limits.
  69852. *
  69853. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69854. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69855. * @param from from
  69856. * @param to to
  69857. * @param tx value
  69858. * @returns the smooth stepped value
  69859. */
  69860. static SmoothStep(from: number, to: number, tx: number): number;
  69861. /**
  69862. * Moves a value current towards target.
  69863. *
  69864. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69865. * Negative values of maxDelta pushes the value away from target.
  69866. * @param current current value
  69867. * @param target target value
  69868. * @param maxDelta max distance to move
  69869. * @returns resulting value
  69870. */
  69871. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69872. /**
  69873. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69874. *
  69875. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69876. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69877. * @param current current value
  69878. * @param target target value
  69879. * @param maxDelta max distance to move
  69880. * @returns resulting angle
  69881. */
  69882. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69883. /**
  69884. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69885. * @param start start value
  69886. * @param end target value
  69887. * @param amount amount to lerp between
  69888. * @returns the lerped value
  69889. */
  69890. static Lerp(start: number, end: number, amount: number): number;
  69891. /**
  69892. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69893. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69894. * @param start start value
  69895. * @param end target value
  69896. * @param amount amount to lerp between
  69897. * @returns the lerped value
  69898. */
  69899. static LerpAngle(start: number, end: number, amount: number): number;
  69900. /**
  69901. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69902. * @param a start value
  69903. * @param b target value
  69904. * @param value value between a and b
  69905. * @returns the inverseLerp value
  69906. */
  69907. static InverseLerp(a: number, b: number, value: number): number;
  69908. /**
  69909. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69910. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69911. * @param value1 spline value
  69912. * @param tangent1 spline value
  69913. * @param value2 spline value
  69914. * @param tangent2 spline value
  69915. * @param amount input value
  69916. * @returns hermite result
  69917. */
  69918. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69919. /**
  69920. * Returns a random float number between and min and max values
  69921. * @param min min value of random
  69922. * @param max max value of random
  69923. * @returns random value
  69924. */
  69925. static RandomRange(min: number, max: number): number;
  69926. /**
  69927. * This function returns percentage of a number in a given range.
  69928. *
  69929. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69930. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69931. * @param number to convert to percentage
  69932. * @param min min range
  69933. * @param max max range
  69934. * @returns the percentage
  69935. */
  69936. static RangeToPercent(number: number, min: number, max: number): number;
  69937. /**
  69938. * This function returns number that corresponds to the percentage in a given range.
  69939. *
  69940. * PercentToRange(0.34,0,100) will return 34.
  69941. * @param percent to convert to number
  69942. * @param min min range
  69943. * @param max max range
  69944. * @returns the number
  69945. */
  69946. static PercentToRange(percent: number, min: number, max: number): number;
  69947. /**
  69948. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69949. * @param angle The angle to normalize in radian.
  69950. * @return The converted angle.
  69951. */
  69952. static NormalizeRadians(angle: number): number;
  69953. }
  69954. }
  69955. declare module BABYLON {
  69956. /**
  69957. * Constant used to convert a value to gamma space
  69958. * @ignorenaming
  69959. */
  69960. export const ToGammaSpace: number;
  69961. /**
  69962. * Constant used to convert a value to linear space
  69963. * @ignorenaming
  69964. */
  69965. export const ToLinearSpace = 2.2;
  69966. /**
  69967. * Constant used to define the minimal number value in Babylon.js
  69968. * @ignorenaming
  69969. */
  69970. let Epsilon: number;
  69971. }
  69972. declare module BABYLON {
  69973. /**
  69974. * Class used to represent a viewport on screen
  69975. */
  69976. export class Viewport {
  69977. /** viewport left coordinate */
  69978. x: number;
  69979. /** viewport top coordinate */
  69980. y: number;
  69981. /**viewport width */
  69982. width: number;
  69983. /** viewport height */
  69984. height: number;
  69985. /**
  69986. * Creates a Viewport object located at (x, y) and sized (width, height)
  69987. * @param x defines viewport left coordinate
  69988. * @param y defines viewport top coordinate
  69989. * @param width defines the viewport width
  69990. * @param height defines the viewport height
  69991. */
  69992. constructor(
  69993. /** viewport left coordinate */
  69994. x: number,
  69995. /** viewport top coordinate */
  69996. y: number,
  69997. /**viewport width */
  69998. width: number,
  69999. /** viewport height */
  70000. height: number);
  70001. /**
  70002. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70003. * @param renderWidth defines the rendering width
  70004. * @param renderHeight defines the rendering height
  70005. * @returns a new Viewport
  70006. */
  70007. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70008. /**
  70009. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70010. * @param renderWidth defines the rendering width
  70011. * @param renderHeight defines the rendering height
  70012. * @param ref defines the target viewport
  70013. * @returns the current viewport
  70014. */
  70015. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70016. /**
  70017. * Returns a new Viewport copied from the current one
  70018. * @returns a new Viewport
  70019. */
  70020. clone(): Viewport;
  70021. }
  70022. }
  70023. declare module BABYLON {
  70024. /**
  70025. * Class containing a set of static utilities functions for arrays.
  70026. */
  70027. export class ArrayTools {
  70028. /**
  70029. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70030. * @param size the number of element to construct and put in the array
  70031. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70032. * @returns a new array filled with new objects
  70033. */
  70034. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70035. }
  70036. }
  70037. declare module BABYLON {
  70038. /**
  70039. * Class representing a vector containing 2 coordinates
  70040. */
  70041. export class Vector2 {
  70042. /** defines the first coordinate */
  70043. x: number;
  70044. /** defines the second coordinate */
  70045. y: number;
  70046. /**
  70047. * Creates a new Vector2 from the given x and y coordinates
  70048. * @param x defines the first coordinate
  70049. * @param y defines the second coordinate
  70050. */
  70051. constructor(
  70052. /** defines the first coordinate */
  70053. x?: number,
  70054. /** defines the second coordinate */
  70055. y?: number);
  70056. /**
  70057. * Gets a string with the Vector2 coordinates
  70058. * @returns a string with the Vector2 coordinates
  70059. */
  70060. toString(): string;
  70061. /**
  70062. * Gets class name
  70063. * @returns the string "Vector2"
  70064. */
  70065. getClassName(): string;
  70066. /**
  70067. * Gets current vector hash code
  70068. * @returns the Vector2 hash code as a number
  70069. */
  70070. getHashCode(): number;
  70071. /**
  70072. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70073. * @param array defines the source array
  70074. * @param index defines the offset in source array
  70075. * @returns the current Vector2
  70076. */
  70077. toArray(array: FloatArray, index?: number): Vector2;
  70078. /**
  70079. * Copy the current vector to an array
  70080. * @returns a new array with 2 elements: the Vector2 coordinates.
  70081. */
  70082. asArray(): number[];
  70083. /**
  70084. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70085. * @param source defines the source Vector2
  70086. * @returns the current updated Vector2
  70087. */
  70088. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70089. /**
  70090. * Sets the Vector2 coordinates with the given floats
  70091. * @param x defines the first coordinate
  70092. * @param y defines the second coordinate
  70093. * @returns the current updated Vector2
  70094. */
  70095. copyFromFloats(x: number, y: number): Vector2;
  70096. /**
  70097. * Sets the Vector2 coordinates with the given floats
  70098. * @param x defines the first coordinate
  70099. * @param y defines the second coordinate
  70100. * @returns the current updated Vector2
  70101. */
  70102. set(x: number, y: number): Vector2;
  70103. /**
  70104. * Add another vector with the current one
  70105. * @param otherVector defines the other vector
  70106. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70107. */
  70108. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70109. /**
  70110. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70111. * @param otherVector defines the other vector
  70112. * @param result defines the target vector
  70113. * @returns the unmodified current Vector2
  70114. */
  70115. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70116. /**
  70117. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70118. * @param otherVector defines the other vector
  70119. * @returns the current updated Vector2
  70120. */
  70121. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70122. /**
  70123. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70124. * @param otherVector defines the other vector
  70125. * @returns a new Vector2
  70126. */
  70127. addVector3(otherVector: Vector3): Vector2;
  70128. /**
  70129. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70130. * @param otherVector defines the other vector
  70131. * @returns a new Vector2
  70132. */
  70133. subtract(otherVector: Vector2): Vector2;
  70134. /**
  70135. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70136. * @param otherVector defines the other vector
  70137. * @param result defines the target vector
  70138. * @returns the unmodified current Vector2
  70139. */
  70140. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70141. /**
  70142. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70143. * @param otherVector defines the other vector
  70144. * @returns the current updated Vector2
  70145. */
  70146. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70147. /**
  70148. * Multiplies in place the current Vector2 coordinates by the given ones
  70149. * @param otherVector defines the other vector
  70150. * @returns the current updated Vector2
  70151. */
  70152. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70153. /**
  70154. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70155. * @param otherVector defines the other vector
  70156. * @returns a new Vector2
  70157. */
  70158. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70159. /**
  70160. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70161. * @param otherVector defines the other vector
  70162. * @param result defines the target vector
  70163. * @returns the unmodified current Vector2
  70164. */
  70165. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70166. /**
  70167. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70168. * @param x defines the first coordinate
  70169. * @param y defines the second coordinate
  70170. * @returns a new Vector2
  70171. */
  70172. multiplyByFloats(x: number, y: number): Vector2;
  70173. /**
  70174. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70175. * @param otherVector defines the other vector
  70176. * @returns a new Vector2
  70177. */
  70178. divide(otherVector: Vector2): Vector2;
  70179. /**
  70180. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70181. * @param otherVector defines the other vector
  70182. * @param result defines the target vector
  70183. * @returns the unmodified current Vector2
  70184. */
  70185. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70186. /**
  70187. * Divides the current Vector2 coordinates by the given ones
  70188. * @param otherVector defines the other vector
  70189. * @returns the current updated Vector2
  70190. */
  70191. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70192. /**
  70193. * Gets a new Vector2 with current Vector2 negated coordinates
  70194. * @returns a new Vector2
  70195. */
  70196. negate(): Vector2;
  70197. /**
  70198. * Multiply the Vector2 coordinates by scale
  70199. * @param scale defines the scaling factor
  70200. * @returns the current updated Vector2
  70201. */
  70202. scaleInPlace(scale: number): Vector2;
  70203. /**
  70204. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70205. * @param scale defines the scaling factor
  70206. * @returns a new Vector2
  70207. */
  70208. scale(scale: number): Vector2;
  70209. /**
  70210. * Scale the current Vector2 values by a factor to a given Vector2
  70211. * @param scale defines the scale factor
  70212. * @param result defines the Vector2 object where to store the result
  70213. * @returns the unmodified current Vector2
  70214. */
  70215. scaleToRef(scale: number, result: Vector2): Vector2;
  70216. /**
  70217. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70218. * @param scale defines the scale factor
  70219. * @param result defines the Vector2 object where to store the result
  70220. * @returns the unmodified current Vector2
  70221. */
  70222. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70223. /**
  70224. * Gets a boolean if two vectors are equals
  70225. * @param otherVector defines the other vector
  70226. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70227. */
  70228. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70229. /**
  70230. * Gets a boolean if two vectors are equals (using an epsilon value)
  70231. * @param otherVector defines the other vector
  70232. * @param epsilon defines the minimal distance to consider equality
  70233. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70234. */
  70235. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70236. /**
  70237. * Gets a new Vector2 from current Vector2 floored values
  70238. * @returns a new Vector2
  70239. */
  70240. floor(): Vector2;
  70241. /**
  70242. * Gets a new Vector2 from current Vector2 floored values
  70243. * @returns a new Vector2
  70244. */
  70245. fract(): Vector2;
  70246. /**
  70247. * Gets the length of the vector
  70248. * @returns the vector length (float)
  70249. */
  70250. length(): number;
  70251. /**
  70252. * Gets the vector squared length
  70253. * @returns the vector squared length (float)
  70254. */
  70255. lengthSquared(): number;
  70256. /**
  70257. * Normalize the vector
  70258. * @returns the current updated Vector2
  70259. */
  70260. normalize(): Vector2;
  70261. /**
  70262. * Gets a new Vector2 copied from the Vector2
  70263. * @returns a new Vector2
  70264. */
  70265. clone(): Vector2;
  70266. /**
  70267. * Gets a new Vector2(0, 0)
  70268. * @returns a new Vector2
  70269. */
  70270. static Zero(): Vector2;
  70271. /**
  70272. * Gets a new Vector2(1, 1)
  70273. * @returns a new Vector2
  70274. */
  70275. static One(): Vector2;
  70276. /**
  70277. * Gets a new Vector2 set from the given index element of the given array
  70278. * @param array defines the data source
  70279. * @param offset defines the offset in the data source
  70280. * @returns a new Vector2
  70281. */
  70282. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70283. /**
  70284. * Sets "result" from the given index element of the given array
  70285. * @param array defines the data source
  70286. * @param offset defines the offset in the data source
  70287. * @param result defines the target vector
  70288. */
  70289. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70290. /**
  70291. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70292. * @param value1 defines 1st point of control
  70293. * @param value2 defines 2nd point of control
  70294. * @param value3 defines 3rd point of control
  70295. * @param value4 defines 4th point of control
  70296. * @param amount defines the interpolation factor
  70297. * @returns a new Vector2
  70298. */
  70299. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70300. /**
  70301. * 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".
  70302. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70303. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70304. * @param value defines the value to clamp
  70305. * @param min defines the lower limit
  70306. * @param max defines the upper limit
  70307. * @returns a new Vector2
  70308. */
  70309. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70310. /**
  70311. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70312. * @param value1 defines the 1st control point
  70313. * @param tangent1 defines the outgoing tangent
  70314. * @param value2 defines the 2nd control point
  70315. * @param tangent2 defines the incoming tangent
  70316. * @param amount defines the interpolation factor
  70317. * @returns a new Vector2
  70318. */
  70319. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70320. /**
  70321. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70322. * @param start defines the start vector
  70323. * @param end defines the end vector
  70324. * @param amount defines the interpolation factor
  70325. * @returns a new Vector2
  70326. */
  70327. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70328. /**
  70329. * Gets the dot product of the vector "left" and the vector "right"
  70330. * @param left defines first vector
  70331. * @param right defines second vector
  70332. * @returns the dot product (float)
  70333. */
  70334. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70335. /**
  70336. * Returns a new Vector2 equal to the normalized given vector
  70337. * @param vector defines the vector to normalize
  70338. * @returns a new Vector2
  70339. */
  70340. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70341. /**
  70342. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70343. * @param left defines 1st vector
  70344. * @param right defines 2nd vector
  70345. * @returns a new Vector2
  70346. */
  70347. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70348. /**
  70349. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70350. * @param left defines 1st vector
  70351. * @param right defines 2nd vector
  70352. * @returns a new Vector2
  70353. */
  70354. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70355. /**
  70356. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70357. * @param vector defines the vector to transform
  70358. * @param transformation defines the matrix to apply
  70359. * @returns a new Vector2
  70360. */
  70361. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70362. /**
  70363. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70364. * @param vector defines the vector to transform
  70365. * @param transformation defines the matrix to apply
  70366. * @param result defines the target vector
  70367. */
  70368. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70369. /**
  70370. * Determines if a given vector is included in a triangle
  70371. * @param p defines the vector to test
  70372. * @param p0 defines 1st triangle point
  70373. * @param p1 defines 2nd triangle point
  70374. * @param p2 defines 3rd triangle point
  70375. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70376. */
  70377. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70378. /**
  70379. * Gets the distance between the vectors "value1" and "value2"
  70380. * @param value1 defines first vector
  70381. * @param value2 defines second vector
  70382. * @returns the distance between vectors
  70383. */
  70384. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70385. /**
  70386. * Returns the squared distance between the vectors "value1" and "value2"
  70387. * @param value1 defines first vector
  70388. * @param value2 defines second vector
  70389. * @returns the squared distance between vectors
  70390. */
  70391. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70392. /**
  70393. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70394. * @param value1 defines first vector
  70395. * @param value2 defines second vector
  70396. * @returns a new Vector2
  70397. */
  70398. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70399. /**
  70400. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70401. * @param p defines the middle point
  70402. * @param segA defines one point of the segment
  70403. * @param segB defines the other point of the segment
  70404. * @returns the shortest distance
  70405. */
  70406. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70407. }
  70408. /**
  70409. * Classed used to store (x,y,z) vector representation
  70410. * A Vector3 is the main object used in 3D geometry
  70411. * It can represent etiher the coordinates of a point the space, either a direction
  70412. * Reminder: js uses a left handed forward facing system
  70413. */
  70414. export class Vector3 {
  70415. /**
  70416. * Defines the first coordinates (on X axis)
  70417. */
  70418. x: number;
  70419. /**
  70420. * Defines the second coordinates (on Y axis)
  70421. */
  70422. y: number;
  70423. /**
  70424. * Defines the third coordinates (on Z axis)
  70425. */
  70426. z: number;
  70427. private static _UpReadOnly;
  70428. private static _ZeroReadOnly;
  70429. /**
  70430. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70431. * @param x defines the first coordinates (on X axis)
  70432. * @param y defines the second coordinates (on Y axis)
  70433. * @param z defines the third coordinates (on Z axis)
  70434. */
  70435. constructor(
  70436. /**
  70437. * Defines the first coordinates (on X axis)
  70438. */
  70439. x?: number,
  70440. /**
  70441. * Defines the second coordinates (on Y axis)
  70442. */
  70443. y?: number,
  70444. /**
  70445. * Defines the third coordinates (on Z axis)
  70446. */
  70447. z?: number);
  70448. /**
  70449. * Creates a string representation of the Vector3
  70450. * @returns a string with the Vector3 coordinates.
  70451. */
  70452. toString(): string;
  70453. /**
  70454. * Gets the class name
  70455. * @returns the string "Vector3"
  70456. */
  70457. getClassName(): string;
  70458. /**
  70459. * Creates the Vector3 hash code
  70460. * @returns a number which tends to be unique between Vector3 instances
  70461. */
  70462. getHashCode(): number;
  70463. /**
  70464. * Creates an array containing three elements : the coordinates of the Vector3
  70465. * @returns a new array of numbers
  70466. */
  70467. asArray(): number[];
  70468. /**
  70469. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70470. * @param array defines the destination array
  70471. * @param index defines the offset in the destination array
  70472. * @returns the current Vector3
  70473. */
  70474. toArray(array: FloatArray, index?: number): Vector3;
  70475. /**
  70476. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70477. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70478. */
  70479. toQuaternion(): Quaternion;
  70480. /**
  70481. * Adds the given vector to the current Vector3
  70482. * @param otherVector defines the second operand
  70483. * @returns the current updated Vector3
  70484. */
  70485. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70486. /**
  70487. * Adds the given coordinates to the current Vector3
  70488. * @param x defines the x coordinate of the operand
  70489. * @param y defines the y coordinate of the operand
  70490. * @param z defines the z coordinate of the operand
  70491. * @returns the current updated Vector3
  70492. */
  70493. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70494. /**
  70495. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70496. * @param otherVector defines the second operand
  70497. * @returns the resulting Vector3
  70498. */
  70499. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70500. /**
  70501. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70502. * @param otherVector defines the second operand
  70503. * @param result defines the Vector3 object where to store the result
  70504. * @returns the current Vector3
  70505. */
  70506. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70507. /**
  70508. * Subtract the given vector from the current Vector3
  70509. * @param otherVector defines the second operand
  70510. * @returns the current updated Vector3
  70511. */
  70512. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70513. /**
  70514. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70515. * @param otherVector defines the second operand
  70516. * @returns the resulting Vector3
  70517. */
  70518. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70519. /**
  70520. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70521. * @param otherVector defines the second operand
  70522. * @param result defines the Vector3 object where to store the result
  70523. * @returns the current Vector3
  70524. */
  70525. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70526. /**
  70527. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70528. * @param x defines the x coordinate of the operand
  70529. * @param y defines the y coordinate of the operand
  70530. * @param z defines the z coordinate of the operand
  70531. * @returns the resulting Vector3
  70532. */
  70533. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70534. /**
  70535. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70536. * @param x defines the x coordinate of the operand
  70537. * @param y defines the y coordinate of the operand
  70538. * @param z defines the z coordinate of the operand
  70539. * @param result defines the Vector3 object where to store the result
  70540. * @returns the current Vector3
  70541. */
  70542. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70543. /**
  70544. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70545. * @returns a new Vector3
  70546. */
  70547. negate(): Vector3;
  70548. /**
  70549. * Multiplies the Vector3 coordinates by the float "scale"
  70550. * @param scale defines the multiplier factor
  70551. * @returns the current updated Vector3
  70552. */
  70553. scaleInPlace(scale: number): Vector3;
  70554. /**
  70555. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70556. * @param scale defines the multiplier factor
  70557. * @returns a new Vector3
  70558. */
  70559. scale(scale: number): Vector3;
  70560. /**
  70561. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70562. * @param scale defines the multiplier factor
  70563. * @param result defines the Vector3 object where to store the result
  70564. * @returns the current Vector3
  70565. */
  70566. scaleToRef(scale: number, result: Vector3): Vector3;
  70567. /**
  70568. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70569. * @param scale defines the scale factor
  70570. * @param result defines the Vector3 object where to store the result
  70571. * @returns the unmodified current Vector3
  70572. */
  70573. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70574. /**
  70575. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70576. * @param otherVector defines the second operand
  70577. * @returns true if both vectors are equals
  70578. */
  70579. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70580. /**
  70581. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70582. * @param otherVector defines the second operand
  70583. * @param epsilon defines the minimal distance to define values as equals
  70584. * @returns true if both vectors are distant less than epsilon
  70585. */
  70586. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70587. /**
  70588. * Returns true if the current Vector3 coordinates equals the given floats
  70589. * @param x defines the x coordinate of the operand
  70590. * @param y defines the y coordinate of the operand
  70591. * @param z defines the z coordinate of the operand
  70592. * @returns true if both vectors are equals
  70593. */
  70594. equalsToFloats(x: number, y: number, z: number): boolean;
  70595. /**
  70596. * Multiplies the current Vector3 coordinates by the given ones
  70597. * @param otherVector defines the second operand
  70598. * @returns the current updated Vector3
  70599. */
  70600. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70601. /**
  70602. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70603. * @param otherVector defines the second operand
  70604. * @returns the new Vector3
  70605. */
  70606. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70607. /**
  70608. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70609. * @param otherVector defines the second operand
  70610. * @param result defines the Vector3 object where to store the result
  70611. * @returns the current Vector3
  70612. */
  70613. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70614. /**
  70615. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70616. * @param x defines the x coordinate of the operand
  70617. * @param y defines the y coordinate of the operand
  70618. * @param z defines the z coordinate of the operand
  70619. * @returns the new Vector3
  70620. */
  70621. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70622. /**
  70623. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70624. * @param otherVector defines the second operand
  70625. * @returns the new Vector3
  70626. */
  70627. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70628. /**
  70629. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70630. * @param otherVector defines the second operand
  70631. * @param result defines the Vector3 object where to store the result
  70632. * @returns the current Vector3
  70633. */
  70634. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70635. /**
  70636. * Divides the current Vector3 coordinates by the given ones.
  70637. * @param otherVector defines the second operand
  70638. * @returns the current updated Vector3
  70639. */
  70640. divideInPlace(otherVector: Vector3): Vector3;
  70641. /**
  70642. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70643. * @param other defines the second operand
  70644. * @returns the current updated Vector3
  70645. */
  70646. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70647. /**
  70648. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70649. * @param other defines the second operand
  70650. * @returns the current updated Vector3
  70651. */
  70652. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70653. /**
  70654. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70655. * @param x defines the x coordinate of the operand
  70656. * @param y defines the y coordinate of the operand
  70657. * @param z defines the z coordinate of the operand
  70658. * @returns the current updated Vector3
  70659. */
  70660. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70661. /**
  70662. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70663. * @param x defines the x coordinate of the operand
  70664. * @param y defines the y coordinate of the operand
  70665. * @param z defines the z coordinate of the operand
  70666. * @returns the current updated Vector3
  70667. */
  70668. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70669. /**
  70670. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70671. * Check if is non uniform within a certain amount of decimal places to account for this
  70672. * @param epsilon the amount the values can differ
  70673. * @returns if the the vector is non uniform to a certain number of decimal places
  70674. */
  70675. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70676. /**
  70677. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70678. */
  70679. readonly isNonUniform: boolean;
  70680. /**
  70681. * Gets a new Vector3 from current Vector3 floored values
  70682. * @returns a new Vector3
  70683. */
  70684. floor(): Vector3;
  70685. /**
  70686. * Gets a new Vector3 from current Vector3 floored values
  70687. * @returns a new Vector3
  70688. */
  70689. fract(): Vector3;
  70690. /**
  70691. * Gets the length of the Vector3
  70692. * @returns the length of the Vector3
  70693. */
  70694. length(): number;
  70695. /**
  70696. * Gets the squared length of the Vector3
  70697. * @returns squared length of the Vector3
  70698. */
  70699. lengthSquared(): number;
  70700. /**
  70701. * Normalize the current Vector3.
  70702. * Please note that this is an in place operation.
  70703. * @returns the current updated Vector3
  70704. */
  70705. normalize(): Vector3;
  70706. /**
  70707. * Reorders the x y z properties of the vector in place
  70708. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70709. * @returns the current updated vector
  70710. */
  70711. reorderInPlace(order: string): this;
  70712. /**
  70713. * Rotates the vector around 0,0,0 by a quaternion
  70714. * @param quaternion the rotation quaternion
  70715. * @param result vector to store the result
  70716. * @returns the resulting vector
  70717. */
  70718. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70719. /**
  70720. * Rotates a vector around a given point
  70721. * @param quaternion the rotation quaternion
  70722. * @param point the point to rotate around
  70723. * @param result vector to store the result
  70724. * @returns the resulting vector
  70725. */
  70726. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70727. /**
  70728. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70729. * The cross product is then orthogonal to both current and "other"
  70730. * @param other defines the right operand
  70731. * @returns the cross product
  70732. */
  70733. cross(other: Vector3): Vector3;
  70734. /**
  70735. * Normalize the current Vector3 with the given input length.
  70736. * Please note that this is an in place operation.
  70737. * @param len the length of the vector
  70738. * @returns the current updated Vector3
  70739. */
  70740. normalizeFromLength(len: number): Vector3;
  70741. /**
  70742. * Normalize the current Vector3 to a new vector
  70743. * @returns the new Vector3
  70744. */
  70745. normalizeToNew(): Vector3;
  70746. /**
  70747. * Normalize the current Vector3 to the reference
  70748. * @param reference define the Vector3 to update
  70749. * @returns the updated Vector3
  70750. */
  70751. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70752. /**
  70753. * Creates a new Vector3 copied from the current Vector3
  70754. * @returns the new Vector3
  70755. */
  70756. clone(): Vector3;
  70757. /**
  70758. * Copies the given vector coordinates to the current Vector3 ones
  70759. * @param source defines the source Vector3
  70760. * @returns the current updated Vector3
  70761. */
  70762. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70763. /**
  70764. * Copies the given floats to the current Vector3 coordinates
  70765. * @param x defines the x coordinate of the operand
  70766. * @param y defines the y coordinate of the operand
  70767. * @param z defines the z coordinate of the operand
  70768. * @returns the current updated Vector3
  70769. */
  70770. copyFromFloats(x: number, y: number, z: number): Vector3;
  70771. /**
  70772. * Copies the given floats to the current Vector3 coordinates
  70773. * @param x defines the x coordinate of the operand
  70774. * @param y defines the y coordinate of the operand
  70775. * @param z defines the z coordinate of the operand
  70776. * @returns the current updated Vector3
  70777. */
  70778. set(x: number, y: number, z: number): Vector3;
  70779. /**
  70780. * Copies the given float to the current Vector3 coordinates
  70781. * @param v defines the x, y and z coordinates of the operand
  70782. * @returns the current updated Vector3
  70783. */
  70784. setAll(v: number): Vector3;
  70785. /**
  70786. * Get the clip factor between two vectors
  70787. * @param vector0 defines the first operand
  70788. * @param vector1 defines the second operand
  70789. * @param axis defines the axis to use
  70790. * @param size defines the size along the axis
  70791. * @returns the clip factor
  70792. */
  70793. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70794. /**
  70795. * Get angle between two vectors
  70796. * @param vector0 angle between vector0 and vector1
  70797. * @param vector1 angle between vector0 and vector1
  70798. * @param normal direction of the normal
  70799. * @return the angle between vector0 and vector1
  70800. */
  70801. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70802. /**
  70803. * Returns a new Vector3 set from the index "offset" of the given array
  70804. * @param array defines the source array
  70805. * @param offset defines the offset in the source array
  70806. * @returns the new Vector3
  70807. */
  70808. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70809. /**
  70810. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70811. * This function is deprecated. Use FromArray instead
  70812. * @param array defines the source array
  70813. * @param offset defines the offset in the source array
  70814. * @returns the new Vector3
  70815. */
  70816. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70817. /**
  70818. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70819. * @param array defines the source array
  70820. * @param offset defines the offset in the source array
  70821. * @param result defines the Vector3 where to store the result
  70822. */
  70823. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70824. /**
  70825. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70826. * This function is deprecated. Use FromArrayToRef instead.
  70827. * @param array defines the source array
  70828. * @param offset defines the offset in the source array
  70829. * @param result defines the Vector3 where to store the result
  70830. */
  70831. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70832. /**
  70833. * Sets the given vector "result" with the given floats.
  70834. * @param x defines the x coordinate of the source
  70835. * @param y defines the y coordinate of the source
  70836. * @param z defines the z coordinate of the source
  70837. * @param result defines the Vector3 where to store the result
  70838. */
  70839. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70840. /**
  70841. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70842. * @returns a new empty Vector3
  70843. */
  70844. static Zero(): Vector3;
  70845. /**
  70846. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70847. * @returns a new unit Vector3
  70848. */
  70849. static One(): Vector3;
  70850. /**
  70851. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70852. * @returns a new up Vector3
  70853. */
  70854. static Up(): Vector3;
  70855. /**
  70856. * Gets a up Vector3 that must not be updated
  70857. */
  70858. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70859. /**
  70860. * Gets a zero Vector3 that must not be updated
  70861. */
  70862. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70863. /**
  70864. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70865. * @returns a new down Vector3
  70866. */
  70867. static Down(): Vector3;
  70868. /**
  70869. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70870. * @returns a new forward Vector3
  70871. */
  70872. static Forward(): Vector3;
  70873. /**
  70874. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70875. * @returns a new forward Vector3
  70876. */
  70877. static Backward(): Vector3;
  70878. /**
  70879. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70880. * @returns a new right Vector3
  70881. */
  70882. static Right(): Vector3;
  70883. /**
  70884. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70885. * @returns a new left Vector3
  70886. */
  70887. static Left(): Vector3;
  70888. /**
  70889. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70890. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70891. * @param vector defines the Vector3 to transform
  70892. * @param transformation defines the transformation matrix
  70893. * @returns the transformed Vector3
  70894. */
  70895. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70896. /**
  70897. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70898. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70899. * @param vector defines the Vector3 to transform
  70900. * @param transformation defines the transformation matrix
  70901. * @param result defines the Vector3 where to store the result
  70902. */
  70903. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70904. /**
  70905. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70906. * This method computes tranformed coordinates only, not transformed direction vectors
  70907. * @param x define the x coordinate of the source vector
  70908. * @param y define the y coordinate of the source vector
  70909. * @param z define the z coordinate of the source vector
  70910. * @param transformation defines the transformation matrix
  70911. * @param result defines the Vector3 where to store the result
  70912. */
  70913. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70914. /**
  70915. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70916. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70917. * @param vector defines the Vector3 to transform
  70918. * @param transformation defines the transformation matrix
  70919. * @returns the new Vector3
  70920. */
  70921. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70922. /**
  70923. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70924. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70925. * @param vector defines the Vector3 to transform
  70926. * @param transformation defines the transformation matrix
  70927. * @param result defines the Vector3 where to store the result
  70928. */
  70929. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70930. /**
  70931. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70932. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70933. * @param x define the x coordinate of the source vector
  70934. * @param y define the y coordinate of the source vector
  70935. * @param z define the z coordinate of the source vector
  70936. * @param transformation defines the transformation matrix
  70937. * @param result defines the Vector3 where to store the result
  70938. */
  70939. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70940. /**
  70941. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70942. * @param value1 defines the first control point
  70943. * @param value2 defines the second control point
  70944. * @param value3 defines the third control point
  70945. * @param value4 defines the fourth control point
  70946. * @param amount defines the amount on the spline to use
  70947. * @returns the new Vector3
  70948. */
  70949. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70950. /**
  70951. * 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"
  70952. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70953. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70954. * @param value defines the current value
  70955. * @param min defines the lower range value
  70956. * @param max defines the upper range value
  70957. * @returns the new Vector3
  70958. */
  70959. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70960. /**
  70961. * 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"
  70962. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70963. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70964. * @param value defines the current value
  70965. * @param min defines the lower range value
  70966. * @param max defines the upper range value
  70967. * @param result defines the Vector3 where to store the result
  70968. */
  70969. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70970. /**
  70971. * Checks if a given vector is inside a specific range
  70972. * @param v defines the vector to test
  70973. * @param min defines the minimum range
  70974. * @param max defines the maximum range
  70975. */
  70976. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70977. /**
  70978. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70979. * @param value1 defines the first control point
  70980. * @param tangent1 defines the first tangent vector
  70981. * @param value2 defines the second control point
  70982. * @param tangent2 defines the second tangent vector
  70983. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70984. * @returns the new Vector3
  70985. */
  70986. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70987. /**
  70988. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70989. * @param start defines the start value
  70990. * @param end defines the end value
  70991. * @param amount max defines amount between both (between 0 and 1)
  70992. * @returns the new Vector3
  70993. */
  70994. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70995. /**
  70996. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70997. * @param start defines the start value
  70998. * @param end defines the end value
  70999. * @param amount max defines amount between both (between 0 and 1)
  71000. * @param result defines the Vector3 where to store the result
  71001. */
  71002. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71003. /**
  71004. * Returns the dot product (float) between the vectors "left" and "right"
  71005. * @param left defines the left operand
  71006. * @param right defines the right operand
  71007. * @returns the dot product
  71008. */
  71009. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71010. /**
  71011. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71012. * The cross product is then orthogonal to both "left" and "right"
  71013. * @param left defines the left operand
  71014. * @param right defines the right operand
  71015. * @returns the cross product
  71016. */
  71017. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71018. /**
  71019. * Sets the given vector "result" with the cross product of "left" and "right"
  71020. * The cross product is then orthogonal to both "left" and "right"
  71021. * @param left defines the left operand
  71022. * @param right defines the right operand
  71023. * @param result defines the Vector3 where to store the result
  71024. */
  71025. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71026. /**
  71027. * Returns a new Vector3 as the normalization of the given vector
  71028. * @param vector defines the Vector3 to normalize
  71029. * @returns the new Vector3
  71030. */
  71031. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71032. /**
  71033. * Sets the given vector "result" with the normalization of the given first vector
  71034. * @param vector defines the Vector3 to normalize
  71035. * @param result defines the Vector3 where to store the result
  71036. */
  71037. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71038. /**
  71039. * Project a Vector3 onto screen space
  71040. * @param vector defines the Vector3 to project
  71041. * @param world defines the world matrix to use
  71042. * @param transform defines the transform (view x projection) matrix to use
  71043. * @param viewport defines the screen viewport to use
  71044. * @returns the new Vector3
  71045. */
  71046. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71047. /** @hidden */
  71048. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71049. /**
  71050. * Unproject from screen space to object space
  71051. * @param source defines the screen space Vector3 to use
  71052. * @param viewportWidth defines the current width of the viewport
  71053. * @param viewportHeight defines the current height of the viewport
  71054. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71055. * @param transform defines the transform (view x projection) matrix to use
  71056. * @returns the new Vector3
  71057. */
  71058. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71059. /**
  71060. * Unproject from screen space to object space
  71061. * @param source defines the screen space Vector3 to use
  71062. * @param viewportWidth defines the current width of the viewport
  71063. * @param viewportHeight defines the current height of the viewport
  71064. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71065. * @param view defines the view matrix to use
  71066. * @param projection defines the projection matrix to use
  71067. * @returns the new Vector3
  71068. */
  71069. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71070. /**
  71071. * Unproject from screen space to object space
  71072. * @param source defines the screen space Vector3 to use
  71073. * @param viewportWidth defines the current width of the viewport
  71074. * @param viewportHeight defines the current height of the viewport
  71075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71076. * @param view defines the view matrix to use
  71077. * @param projection defines the projection matrix to use
  71078. * @param result defines the Vector3 where to store the result
  71079. */
  71080. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71081. /**
  71082. * Unproject from screen space to object space
  71083. * @param sourceX defines the screen space x coordinate to use
  71084. * @param sourceY defines the screen space y coordinate to use
  71085. * @param sourceZ defines the screen space z coordinate to use
  71086. * @param viewportWidth defines the current width of the viewport
  71087. * @param viewportHeight defines the current height of the viewport
  71088. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71089. * @param view defines the view matrix to use
  71090. * @param projection defines the projection matrix to use
  71091. * @param result defines the Vector3 where to store the result
  71092. */
  71093. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71094. /**
  71095. * Gets the minimal coordinate values between two Vector3
  71096. * @param left defines the first operand
  71097. * @param right defines the second operand
  71098. * @returns the new Vector3
  71099. */
  71100. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71101. /**
  71102. * Gets the maximal coordinate values between two Vector3
  71103. * @param left defines the first operand
  71104. * @param right defines the second operand
  71105. * @returns the new Vector3
  71106. */
  71107. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71108. /**
  71109. * Returns the distance between the vectors "value1" and "value2"
  71110. * @param value1 defines the first operand
  71111. * @param value2 defines the second operand
  71112. * @returns the distance
  71113. */
  71114. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71115. /**
  71116. * Returns the squared distance between the vectors "value1" and "value2"
  71117. * @param value1 defines the first operand
  71118. * @param value2 defines the second operand
  71119. * @returns the squared distance
  71120. */
  71121. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71122. /**
  71123. * Returns a new Vector3 located at the center between "value1" and "value2"
  71124. * @param value1 defines the first operand
  71125. * @param value2 defines the second operand
  71126. * @returns the new Vector3
  71127. */
  71128. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71129. /**
  71130. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71131. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71132. * to something in order to rotate it from its local system to the given target system
  71133. * Note: axis1, axis2 and axis3 are normalized during this operation
  71134. * @param axis1 defines the first axis
  71135. * @param axis2 defines the second axis
  71136. * @param axis3 defines the third axis
  71137. * @returns a new Vector3
  71138. */
  71139. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71140. /**
  71141. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71142. * @param axis1 defines the first axis
  71143. * @param axis2 defines the second axis
  71144. * @param axis3 defines the third axis
  71145. * @param ref defines the Vector3 where to store the result
  71146. */
  71147. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71148. }
  71149. /**
  71150. * Vector4 class created for EulerAngle class conversion to Quaternion
  71151. */
  71152. export class Vector4 {
  71153. /** x value of the vector */
  71154. x: number;
  71155. /** y value of the vector */
  71156. y: number;
  71157. /** z value of the vector */
  71158. z: number;
  71159. /** w value of the vector */
  71160. w: number;
  71161. /**
  71162. * Creates a Vector4 object from the given floats.
  71163. * @param x x value of the vector
  71164. * @param y y value of the vector
  71165. * @param z z value of the vector
  71166. * @param w w value of the vector
  71167. */
  71168. constructor(
  71169. /** x value of the vector */
  71170. x: number,
  71171. /** y value of the vector */
  71172. y: number,
  71173. /** z value of the vector */
  71174. z: number,
  71175. /** w value of the vector */
  71176. w: number);
  71177. /**
  71178. * Returns the string with the Vector4 coordinates.
  71179. * @returns a string containing all the vector values
  71180. */
  71181. toString(): string;
  71182. /**
  71183. * Returns the string "Vector4".
  71184. * @returns "Vector4"
  71185. */
  71186. getClassName(): string;
  71187. /**
  71188. * Returns the Vector4 hash code.
  71189. * @returns a unique hash code
  71190. */
  71191. getHashCode(): number;
  71192. /**
  71193. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71194. * @returns the resulting array
  71195. */
  71196. asArray(): number[];
  71197. /**
  71198. * Populates the given array from the given index with the Vector4 coordinates.
  71199. * @param array array to populate
  71200. * @param index index of the array to start at (default: 0)
  71201. * @returns the Vector4.
  71202. */
  71203. toArray(array: FloatArray, index?: number): Vector4;
  71204. /**
  71205. * Adds the given vector to the current Vector4.
  71206. * @param otherVector the vector to add
  71207. * @returns the updated Vector4.
  71208. */
  71209. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71210. /**
  71211. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71212. * @param otherVector the vector to add
  71213. * @returns the resulting vector
  71214. */
  71215. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71216. /**
  71217. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71218. * @param otherVector the vector to add
  71219. * @param result the vector to store the result
  71220. * @returns the current Vector4.
  71221. */
  71222. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71223. /**
  71224. * Subtract in place the given vector from the current Vector4.
  71225. * @param otherVector the vector to subtract
  71226. * @returns the updated Vector4.
  71227. */
  71228. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71229. /**
  71230. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71231. * @param otherVector the vector to add
  71232. * @returns the new vector with the result
  71233. */
  71234. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71235. /**
  71236. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71237. * @param otherVector the vector to subtract
  71238. * @param result the vector to store the result
  71239. * @returns the current Vector4.
  71240. */
  71241. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71242. /**
  71243. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71244. */
  71245. /**
  71246. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71247. * @param x value to subtract
  71248. * @param y value to subtract
  71249. * @param z value to subtract
  71250. * @param w value to subtract
  71251. * @returns new vector containing the result
  71252. */
  71253. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71254. /**
  71255. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71256. * @param x value to subtract
  71257. * @param y value to subtract
  71258. * @param z value to subtract
  71259. * @param w value to subtract
  71260. * @param result the vector to store the result in
  71261. * @returns the current Vector4.
  71262. */
  71263. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71264. /**
  71265. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71266. * @returns a new vector with the negated values
  71267. */
  71268. negate(): Vector4;
  71269. /**
  71270. * Multiplies the current Vector4 coordinates by scale (float).
  71271. * @param scale the number to scale with
  71272. * @returns the updated Vector4.
  71273. */
  71274. scaleInPlace(scale: number): Vector4;
  71275. /**
  71276. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71277. * @param scale the number to scale with
  71278. * @returns a new vector with the result
  71279. */
  71280. scale(scale: number): Vector4;
  71281. /**
  71282. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71283. * @param scale the number to scale with
  71284. * @param result a vector to store the result in
  71285. * @returns the current Vector4.
  71286. */
  71287. scaleToRef(scale: number, result: Vector4): Vector4;
  71288. /**
  71289. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71290. * @param scale defines the scale factor
  71291. * @param result defines the Vector4 object where to store the result
  71292. * @returns the unmodified current Vector4
  71293. */
  71294. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71295. /**
  71296. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71297. * @param otherVector the vector to compare against
  71298. * @returns true if they are equal
  71299. */
  71300. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71301. /**
  71302. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71303. * @param otherVector vector to compare against
  71304. * @param epsilon (Default: very small number)
  71305. * @returns true if they are equal
  71306. */
  71307. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71308. /**
  71309. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71310. * @param x x value to compare against
  71311. * @param y y value to compare against
  71312. * @param z z value to compare against
  71313. * @param w w value to compare against
  71314. * @returns true if equal
  71315. */
  71316. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71317. /**
  71318. * Multiplies in place the current Vector4 by the given one.
  71319. * @param otherVector vector to multiple with
  71320. * @returns the updated Vector4.
  71321. */
  71322. multiplyInPlace(otherVector: Vector4): Vector4;
  71323. /**
  71324. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71325. * @param otherVector vector to multiple with
  71326. * @returns resulting new vector
  71327. */
  71328. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71329. /**
  71330. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71331. * @param otherVector vector to multiple with
  71332. * @param result vector to store the result
  71333. * @returns the current Vector4.
  71334. */
  71335. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71336. /**
  71337. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71338. * @param x x value multiply with
  71339. * @param y y value multiply with
  71340. * @param z z value multiply with
  71341. * @param w w value multiply with
  71342. * @returns resulting new vector
  71343. */
  71344. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71345. /**
  71346. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71347. * @param otherVector vector to devide with
  71348. * @returns resulting new vector
  71349. */
  71350. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71351. /**
  71352. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71353. * @param otherVector vector to devide with
  71354. * @param result vector to store the result
  71355. * @returns the current Vector4.
  71356. */
  71357. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71358. /**
  71359. * Divides the current Vector3 coordinates by the given ones.
  71360. * @param otherVector vector to devide with
  71361. * @returns the updated Vector3.
  71362. */
  71363. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71364. /**
  71365. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71366. * @param other defines the second operand
  71367. * @returns the current updated Vector4
  71368. */
  71369. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71370. /**
  71371. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71372. * @param other defines the second operand
  71373. * @returns the current updated Vector4
  71374. */
  71375. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71376. /**
  71377. * Gets a new Vector4 from current Vector4 floored values
  71378. * @returns a new Vector4
  71379. */
  71380. floor(): Vector4;
  71381. /**
  71382. * Gets a new Vector4 from current Vector3 floored values
  71383. * @returns a new Vector4
  71384. */
  71385. fract(): Vector4;
  71386. /**
  71387. * Returns the Vector4 length (float).
  71388. * @returns the length
  71389. */
  71390. length(): number;
  71391. /**
  71392. * Returns the Vector4 squared length (float).
  71393. * @returns the length squared
  71394. */
  71395. lengthSquared(): number;
  71396. /**
  71397. * Normalizes in place the Vector4.
  71398. * @returns the updated Vector4.
  71399. */
  71400. normalize(): Vector4;
  71401. /**
  71402. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71403. * @returns this converted to a new vector3
  71404. */
  71405. toVector3(): Vector3;
  71406. /**
  71407. * Returns a new Vector4 copied from the current one.
  71408. * @returns the new cloned vector
  71409. */
  71410. clone(): Vector4;
  71411. /**
  71412. * Updates the current Vector4 with the given one coordinates.
  71413. * @param source the source vector to copy from
  71414. * @returns the updated Vector4.
  71415. */
  71416. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71417. /**
  71418. * Updates the current Vector4 coordinates with the given floats.
  71419. * @param x float to copy from
  71420. * @param y float to copy from
  71421. * @param z float to copy from
  71422. * @param w float to copy from
  71423. * @returns the updated Vector4.
  71424. */
  71425. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71426. /**
  71427. * Updates the current Vector4 coordinates with the given floats.
  71428. * @param x float to set from
  71429. * @param y float to set from
  71430. * @param z float to set from
  71431. * @param w float to set from
  71432. * @returns the updated Vector4.
  71433. */
  71434. set(x: number, y: number, z: number, w: number): Vector4;
  71435. /**
  71436. * Copies the given float to the current Vector3 coordinates
  71437. * @param v defines the x, y, z and w coordinates of the operand
  71438. * @returns the current updated Vector3
  71439. */
  71440. setAll(v: number): Vector4;
  71441. /**
  71442. * Returns a new Vector4 set from the starting index of the given array.
  71443. * @param array the array to pull values from
  71444. * @param offset the offset into the array to start at
  71445. * @returns the new vector
  71446. */
  71447. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71448. /**
  71449. * Updates the given vector "result" from the starting index of the given array.
  71450. * @param array the array to pull values from
  71451. * @param offset the offset into the array to start at
  71452. * @param result the vector to store the result in
  71453. */
  71454. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71455. /**
  71456. * Updates the given vector "result" from the starting index of the given Float32Array.
  71457. * @param array the array to pull values from
  71458. * @param offset the offset into the array to start at
  71459. * @param result the vector to store the result in
  71460. */
  71461. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71462. /**
  71463. * Updates the given vector "result" coordinates from the given floats.
  71464. * @param x float to set from
  71465. * @param y float to set from
  71466. * @param z float to set from
  71467. * @param w float to set from
  71468. * @param result the vector to the floats in
  71469. */
  71470. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71471. /**
  71472. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71473. * @returns the new vector
  71474. */
  71475. static Zero(): Vector4;
  71476. /**
  71477. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71478. * @returns the new vector
  71479. */
  71480. static One(): Vector4;
  71481. /**
  71482. * Returns a new normalized Vector4 from the given one.
  71483. * @param vector the vector to normalize
  71484. * @returns the vector
  71485. */
  71486. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71487. /**
  71488. * Updates the given vector "result" from the normalization of the given one.
  71489. * @param vector the vector to normalize
  71490. * @param result the vector to store the result in
  71491. */
  71492. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71493. /**
  71494. * Returns a vector with the minimum values from the left and right vectors
  71495. * @param left left vector to minimize
  71496. * @param right right vector to minimize
  71497. * @returns a new vector with the minimum of the left and right vector values
  71498. */
  71499. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71500. /**
  71501. * Returns a vector with the maximum values from the left and right vectors
  71502. * @param left left vector to maximize
  71503. * @param right right vector to maximize
  71504. * @returns a new vector with the maximum of the left and right vector values
  71505. */
  71506. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71507. /**
  71508. * Returns the distance (float) between the vectors "value1" and "value2".
  71509. * @param value1 value to calulate the distance between
  71510. * @param value2 value to calulate the distance between
  71511. * @return the distance between the two vectors
  71512. */
  71513. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71514. /**
  71515. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71516. * @param value1 value to calulate the distance between
  71517. * @param value2 value to calulate the distance between
  71518. * @return the distance between the two vectors squared
  71519. */
  71520. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71521. /**
  71522. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71523. * @param value1 value to calulate the center between
  71524. * @param value2 value to calulate the center between
  71525. * @return the center between the two vectors
  71526. */
  71527. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71528. /**
  71529. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71530. * This methods computes transformed normalized direction vectors only.
  71531. * @param vector the vector to transform
  71532. * @param transformation the transformation matrix to apply
  71533. * @returns the new vector
  71534. */
  71535. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71536. /**
  71537. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71538. * This methods computes transformed normalized direction vectors only.
  71539. * @param vector the vector to transform
  71540. * @param transformation the transformation matrix to apply
  71541. * @param result the vector to store the result in
  71542. */
  71543. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71544. /**
  71545. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71546. * This methods computes transformed normalized direction vectors only.
  71547. * @param x value to transform
  71548. * @param y value to transform
  71549. * @param z value to transform
  71550. * @param w value to transform
  71551. * @param transformation the transformation matrix to apply
  71552. * @param result the vector to store the results in
  71553. */
  71554. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71555. /**
  71556. * Creates a new Vector4 from a Vector3
  71557. * @param source defines the source data
  71558. * @param w defines the 4th component (default is 0)
  71559. * @returns a new Vector4
  71560. */
  71561. static FromVector3(source: Vector3, w?: number): Vector4;
  71562. }
  71563. /**
  71564. * Class used to store quaternion data
  71565. * @see https://en.wikipedia.org/wiki/Quaternion
  71566. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71567. */
  71568. export class Quaternion {
  71569. /** defines the first component (0 by default) */
  71570. x: number;
  71571. /** defines the second component (0 by default) */
  71572. y: number;
  71573. /** defines the third component (0 by default) */
  71574. z: number;
  71575. /** defines the fourth component (1.0 by default) */
  71576. w: number;
  71577. /**
  71578. * Creates a new Quaternion from the given floats
  71579. * @param x defines the first component (0 by default)
  71580. * @param y defines the second component (0 by default)
  71581. * @param z defines the third component (0 by default)
  71582. * @param w defines the fourth component (1.0 by default)
  71583. */
  71584. constructor(
  71585. /** defines the first component (0 by default) */
  71586. x?: number,
  71587. /** defines the second component (0 by default) */
  71588. y?: number,
  71589. /** defines the third component (0 by default) */
  71590. z?: number,
  71591. /** defines the fourth component (1.0 by default) */
  71592. w?: number);
  71593. /**
  71594. * Gets a string representation for the current quaternion
  71595. * @returns a string with the Quaternion coordinates
  71596. */
  71597. toString(): string;
  71598. /**
  71599. * Gets the class name of the quaternion
  71600. * @returns the string "Quaternion"
  71601. */
  71602. getClassName(): string;
  71603. /**
  71604. * Gets a hash code for this quaternion
  71605. * @returns the quaternion hash code
  71606. */
  71607. getHashCode(): number;
  71608. /**
  71609. * Copy the quaternion to an array
  71610. * @returns a new array populated with 4 elements from the quaternion coordinates
  71611. */
  71612. asArray(): number[];
  71613. /**
  71614. * Check if two quaternions are equals
  71615. * @param otherQuaternion defines the second operand
  71616. * @return true if the current quaternion and the given one coordinates are strictly equals
  71617. */
  71618. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71619. /**
  71620. * Clone the current quaternion
  71621. * @returns a new quaternion copied from the current one
  71622. */
  71623. clone(): Quaternion;
  71624. /**
  71625. * Copy a quaternion to the current one
  71626. * @param other defines the other quaternion
  71627. * @returns the updated current quaternion
  71628. */
  71629. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71630. /**
  71631. * Updates the current quaternion with the given float coordinates
  71632. * @param x defines the x coordinate
  71633. * @param y defines the y coordinate
  71634. * @param z defines the z coordinate
  71635. * @param w defines the w coordinate
  71636. * @returns the updated current quaternion
  71637. */
  71638. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71639. /**
  71640. * Updates the current quaternion from the given float coordinates
  71641. * @param x defines the x coordinate
  71642. * @param y defines the y coordinate
  71643. * @param z defines the z coordinate
  71644. * @param w defines the w coordinate
  71645. * @returns the updated current quaternion
  71646. */
  71647. set(x: number, y: number, z: number, w: number): Quaternion;
  71648. /**
  71649. * Adds two quaternions
  71650. * @param other defines the second operand
  71651. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71652. */
  71653. add(other: DeepImmutable<Quaternion>): Quaternion;
  71654. /**
  71655. * Add a quaternion to the current one
  71656. * @param other defines the quaternion to add
  71657. * @returns the current quaternion
  71658. */
  71659. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71660. /**
  71661. * Subtract two quaternions
  71662. * @param other defines the second operand
  71663. * @returns a new quaternion as the subtraction result of the given one from the current one
  71664. */
  71665. subtract(other: Quaternion): Quaternion;
  71666. /**
  71667. * Multiplies the current quaternion by a scale factor
  71668. * @param value defines the scale factor
  71669. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71670. */
  71671. scale(value: number): Quaternion;
  71672. /**
  71673. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71674. * @param scale defines the scale factor
  71675. * @param result defines the Quaternion object where to store the result
  71676. * @returns the unmodified current quaternion
  71677. */
  71678. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71679. /**
  71680. * Multiplies in place the current quaternion by a scale factor
  71681. * @param value defines the scale factor
  71682. * @returns the current modified quaternion
  71683. */
  71684. scaleInPlace(value: number): Quaternion;
  71685. /**
  71686. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71687. * @param scale defines the scale factor
  71688. * @param result defines the Quaternion object where to store the result
  71689. * @returns the unmodified current quaternion
  71690. */
  71691. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71692. /**
  71693. * Multiplies two quaternions
  71694. * @param q1 defines the second operand
  71695. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71696. */
  71697. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71698. /**
  71699. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71700. * @param q1 defines the second operand
  71701. * @param result defines the target quaternion
  71702. * @returns the current quaternion
  71703. */
  71704. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71705. /**
  71706. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71707. * @param q1 defines the second operand
  71708. * @returns the currentupdated quaternion
  71709. */
  71710. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71711. /**
  71712. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71713. * @param ref defines the target quaternion
  71714. * @returns the current quaternion
  71715. */
  71716. conjugateToRef(ref: Quaternion): Quaternion;
  71717. /**
  71718. * Conjugates in place (1-q) the current quaternion
  71719. * @returns the current updated quaternion
  71720. */
  71721. conjugateInPlace(): Quaternion;
  71722. /**
  71723. * Conjugates in place (1-q) the current quaternion
  71724. * @returns a new quaternion
  71725. */
  71726. conjugate(): Quaternion;
  71727. /**
  71728. * Gets length of current quaternion
  71729. * @returns the quaternion length (float)
  71730. */
  71731. length(): number;
  71732. /**
  71733. * Normalize in place the current quaternion
  71734. * @returns the current updated quaternion
  71735. */
  71736. normalize(): Quaternion;
  71737. /**
  71738. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71739. * @param order is a reserved parameter and is ignore for now
  71740. * @returns a new Vector3 containing the Euler angles
  71741. */
  71742. toEulerAngles(order?: string): Vector3;
  71743. /**
  71744. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71745. * @param result defines the vector which will be filled with the Euler angles
  71746. * @param order is a reserved parameter and is ignore for now
  71747. * @returns the current unchanged quaternion
  71748. */
  71749. toEulerAnglesToRef(result: Vector3): Quaternion;
  71750. /**
  71751. * Updates the given rotation matrix with the current quaternion values
  71752. * @param result defines the target matrix
  71753. * @returns the current unchanged quaternion
  71754. */
  71755. toRotationMatrix(result: Matrix): Quaternion;
  71756. /**
  71757. * Updates the current quaternion from the given rotation matrix values
  71758. * @param matrix defines the source matrix
  71759. * @returns the current updated quaternion
  71760. */
  71761. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71762. /**
  71763. * Creates a new quaternion from a rotation matrix
  71764. * @param matrix defines the source matrix
  71765. * @returns a new quaternion created from the given rotation matrix values
  71766. */
  71767. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71768. /**
  71769. * Updates the given quaternion with the given rotation matrix values
  71770. * @param matrix defines the source matrix
  71771. * @param result defines the target quaternion
  71772. */
  71773. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71774. /**
  71775. * Returns the dot product (float) between the quaternions "left" and "right"
  71776. * @param left defines the left operand
  71777. * @param right defines the right operand
  71778. * @returns the dot product
  71779. */
  71780. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71781. /**
  71782. * Checks if the two quaternions are close to each other
  71783. * @param quat0 defines the first quaternion to check
  71784. * @param quat1 defines the second quaternion to check
  71785. * @returns true if the two quaternions are close to each other
  71786. */
  71787. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71788. /**
  71789. * Creates an empty quaternion
  71790. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71791. */
  71792. static Zero(): Quaternion;
  71793. /**
  71794. * Inverse a given quaternion
  71795. * @param q defines the source quaternion
  71796. * @returns a new quaternion as the inverted current quaternion
  71797. */
  71798. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71799. /**
  71800. * Inverse a given quaternion
  71801. * @param q defines the source quaternion
  71802. * @param result the quaternion the result will be stored in
  71803. * @returns the result quaternion
  71804. */
  71805. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71806. /**
  71807. * Creates an identity quaternion
  71808. * @returns the identity quaternion
  71809. */
  71810. static Identity(): Quaternion;
  71811. /**
  71812. * Gets a boolean indicating if the given quaternion is identity
  71813. * @param quaternion defines the quaternion to check
  71814. * @returns true if the quaternion is identity
  71815. */
  71816. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71817. /**
  71818. * Creates a quaternion from a rotation around an axis
  71819. * @param axis defines the axis to use
  71820. * @param angle defines the angle to use
  71821. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71822. */
  71823. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71824. /**
  71825. * Creates a rotation around an axis and stores it into the given quaternion
  71826. * @param axis defines the axis to use
  71827. * @param angle defines the angle to use
  71828. * @param result defines the target quaternion
  71829. * @returns the target quaternion
  71830. */
  71831. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71832. /**
  71833. * Creates a new quaternion from data stored into an array
  71834. * @param array defines the data source
  71835. * @param offset defines the offset in the source array where the data starts
  71836. * @returns a new quaternion
  71837. */
  71838. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71839. /**
  71840. * Create a quaternion from Euler rotation angles
  71841. * @param x Pitch
  71842. * @param y Yaw
  71843. * @param z Roll
  71844. * @returns the new Quaternion
  71845. */
  71846. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71847. /**
  71848. * Updates a quaternion from Euler rotation angles
  71849. * @param x Pitch
  71850. * @param y Yaw
  71851. * @param z Roll
  71852. * @param result the quaternion to store the result
  71853. * @returns the updated quaternion
  71854. */
  71855. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71856. /**
  71857. * Create a quaternion from Euler rotation vector
  71858. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71859. * @returns the new Quaternion
  71860. */
  71861. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71862. /**
  71863. * Updates a quaternion from Euler rotation vector
  71864. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71865. * @param result the quaternion to store the result
  71866. * @returns the updated quaternion
  71867. */
  71868. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71869. /**
  71870. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71871. * @param yaw defines the rotation around Y axis
  71872. * @param pitch defines the rotation around X axis
  71873. * @param roll defines the rotation around Z axis
  71874. * @returns the new quaternion
  71875. */
  71876. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71877. /**
  71878. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71879. * @param yaw defines the rotation around Y axis
  71880. * @param pitch defines the rotation around X axis
  71881. * @param roll defines the rotation around Z axis
  71882. * @param result defines the target quaternion
  71883. */
  71884. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71885. /**
  71886. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71887. * @param alpha defines the rotation around first axis
  71888. * @param beta defines the rotation around second axis
  71889. * @param gamma defines the rotation around third axis
  71890. * @returns the new quaternion
  71891. */
  71892. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71893. /**
  71894. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71895. * @param alpha defines the rotation around first axis
  71896. * @param beta defines the rotation around second axis
  71897. * @param gamma defines the rotation around third axis
  71898. * @param result defines the target quaternion
  71899. */
  71900. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71901. /**
  71902. * 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)
  71903. * @param axis1 defines the first axis
  71904. * @param axis2 defines the second axis
  71905. * @param axis3 defines the third axis
  71906. * @returns the new quaternion
  71907. */
  71908. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71909. /**
  71910. * 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
  71911. * @param axis1 defines the first axis
  71912. * @param axis2 defines the second axis
  71913. * @param axis3 defines the third axis
  71914. * @param ref defines the target quaternion
  71915. */
  71916. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71917. /**
  71918. * Interpolates between two quaternions
  71919. * @param left defines first quaternion
  71920. * @param right defines second quaternion
  71921. * @param amount defines the gradient to use
  71922. * @returns the new interpolated quaternion
  71923. */
  71924. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71925. /**
  71926. * Interpolates between two quaternions and stores it into a target quaternion
  71927. * @param left defines first quaternion
  71928. * @param right defines second quaternion
  71929. * @param amount defines the gradient to use
  71930. * @param result defines the target quaternion
  71931. */
  71932. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71933. /**
  71934. * Interpolate between two quaternions using Hermite interpolation
  71935. * @param value1 defines first quaternion
  71936. * @param tangent1 defines the incoming tangent
  71937. * @param value2 defines second quaternion
  71938. * @param tangent2 defines the outgoing tangent
  71939. * @param amount defines the target quaternion
  71940. * @returns the new interpolated quaternion
  71941. */
  71942. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71943. }
  71944. /**
  71945. * Class used to store matrix data (4x4)
  71946. */
  71947. export class Matrix {
  71948. private static _updateFlagSeed;
  71949. private static _identityReadOnly;
  71950. private _isIdentity;
  71951. private _isIdentityDirty;
  71952. private _isIdentity3x2;
  71953. private _isIdentity3x2Dirty;
  71954. /**
  71955. * Gets the update flag of the matrix which is an unique number for the matrix.
  71956. * It will be incremented every time the matrix data change.
  71957. * You can use it to speed the comparison between two versions of the same matrix.
  71958. */
  71959. updateFlag: number;
  71960. private readonly _m;
  71961. /**
  71962. * Gets the internal data of the matrix
  71963. */
  71964. readonly m: DeepImmutable<Float32Array>;
  71965. /** @hidden */
  71966. _markAsUpdated(): void;
  71967. /** @hidden */
  71968. private _updateIdentityStatus;
  71969. /**
  71970. * Creates an empty matrix (filled with zeros)
  71971. */
  71972. constructor();
  71973. /**
  71974. * Check if the current matrix is identity
  71975. * @returns true is the matrix is the identity matrix
  71976. */
  71977. isIdentity(): boolean;
  71978. /**
  71979. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71980. * @returns true is the matrix is the identity matrix
  71981. */
  71982. isIdentityAs3x2(): boolean;
  71983. /**
  71984. * Gets the determinant of the matrix
  71985. * @returns the matrix determinant
  71986. */
  71987. determinant(): number;
  71988. /**
  71989. * Returns the matrix as a Float32Array
  71990. * @returns the matrix underlying array
  71991. */
  71992. toArray(): DeepImmutable<Float32Array>;
  71993. /**
  71994. * Returns the matrix as a Float32Array
  71995. * @returns the matrix underlying array.
  71996. */
  71997. asArray(): DeepImmutable<Float32Array>;
  71998. /**
  71999. * Inverts the current matrix in place
  72000. * @returns the current inverted matrix
  72001. */
  72002. invert(): Matrix;
  72003. /**
  72004. * Sets all the matrix elements to zero
  72005. * @returns the current matrix
  72006. */
  72007. reset(): Matrix;
  72008. /**
  72009. * Adds the current matrix with a second one
  72010. * @param other defines the matrix to add
  72011. * @returns a new matrix as the addition of the current matrix and the given one
  72012. */
  72013. add(other: DeepImmutable<Matrix>): Matrix;
  72014. /**
  72015. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72016. * @param other defines the matrix to add
  72017. * @param result defines the target matrix
  72018. * @returns the current matrix
  72019. */
  72020. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72021. /**
  72022. * Adds in place the given matrix to the current matrix
  72023. * @param other defines the second operand
  72024. * @returns the current updated matrix
  72025. */
  72026. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72027. /**
  72028. * Sets the given matrix to the current inverted Matrix
  72029. * @param other defines the target matrix
  72030. * @returns the unmodified current matrix
  72031. */
  72032. invertToRef(other: Matrix): Matrix;
  72033. /**
  72034. * add a value at the specified position in the current Matrix
  72035. * @param index the index of the value within the matrix. between 0 and 15.
  72036. * @param value the value to be added
  72037. * @returns the current updated matrix
  72038. */
  72039. addAtIndex(index: number, value: number): Matrix;
  72040. /**
  72041. * mutiply the specified position in the current Matrix by a value
  72042. * @param index the index of the value within the matrix. between 0 and 15.
  72043. * @param value the value to be added
  72044. * @returns the current updated matrix
  72045. */
  72046. multiplyAtIndex(index: number, value: number): Matrix;
  72047. /**
  72048. * Inserts the translation vector (using 3 floats) in the current matrix
  72049. * @param x defines the 1st component of the translation
  72050. * @param y defines the 2nd component of the translation
  72051. * @param z defines the 3rd component of the translation
  72052. * @returns the current updated matrix
  72053. */
  72054. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72055. /**
  72056. * Adds the translation vector (using 3 floats) in the current matrix
  72057. * @param x defines the 1st component of the translation
  72058. * @param y defines the 2nd component of the translation
  72059. * @param z defines the 3rd component of the translation
  72060. * @returns the current updated matrix
  72061. */
  72062. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72063. /**
  72064. * Inserts the translation vector in the current matrix
  72065. * @param vector3 defines the translation to insert
  72066. * @returns the current updated matrix
  72067. */
  72068. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72069. /**
  72070. * Gets the translation value of the current matrix
  72071. * @returns a new Vector3 as the extracted translation from the matrix
  72072. */
  72073. getTranslation(): Vector3;
  72074. /**
  72075. * Fill a Vector3 with the extracted translation from the matrix
  72076. * @param result defines the Vector3 where to store the translation
  72077. * @returns the current matrix
  72078. */
  72079. getTranslationToRef(result: Vector3): Matrix;
  72080. /**
  72081. * Remove rotation and scaling part from the matrix
  72082. * @returns the updated matrix
  72083. */
  72084. removeRotationAndScaling(): Matrix;
  72085. /**
  72086. * Multiply two matrices
  72087. * @param other defines the second operand
  72088. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72089. */
  72090. multiply(other: DeepImmutable<Matrix>): Matrix;
  72091. /**
  72092. * Copy the current matrix from the given one
  72093. * @param other defines the source matrix
  72094. * @returns the current updated matrix
  72095. */
  72096. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72097. /**
  72098. * Populates the given array from the starting index with the current matrix values
  72099. * @param array defines the target array
  72100. * @param offset defines the offset in the target array where to start storing values
  72101. * @returns the current matrix
  72102. */
  72103. copyToArray(array: Float32Array, offset?: number): Matrix;
  72104. /**
  72105. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72106. * @param other defines the second operand
  72107. * @param result defines the matrix where to store the multiplication
  72108. * @returns the current matrix
  72109. */
  72110. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72111. /**
  72112. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72113. * @param other defines the second operand
  72114. * @param result defines the array where to store the multiplication
  72115. * @param offset defines the offset in the target array where to start storing values
  72116. * @returns the current matrix
  72117. */
  72118. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72119. /**
  72120. * Check equality between this matrix and a second one
  72121. * @param value defines the second matrix to compare
  72122. * @returns true is the current matrix and the given one values are strictly equal
  72123. */
  72124. equals(value: DeepImmutable<Matrix>): boolean;
  72125. /**
  72126. * Clone the current matrix
  72127. * @returns a new matrix from the current matrix
  72128. */
  72129. clone(): Matrix;
  72130. /**
  72131. * Returns the name of the current matrix class
  72132. * @returns the string "Matrix"
  72133. */
  72134. getClassName(): string;
  72135. /**
  72136. * Gets the hash code of the current matrix
  72137. * @returns the hash code
  72138. */
  72139. getHashCode(): number;
  72140. /**
  72141. * Decomposes the current Matrix into a translation, rotation and scaling components
  72142. * @param scale defines the scale vector3 given as a reference to update
  72143. * @param rotation defines the rotation quaternion given as a reference to update
  72144. * @param translation defines the translation vector3 given as a reference to update
  72145. * @returns true if operation was successful
  72146. */
  72147. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72148. /**
  72149. * Gets specific row of the matrix
  72150. * @param index defines the number of the row to get
  72151. * @returns the index-th row of the current matrix as a new Vector4
  72152. */
  72153. getRow(index: number): Nullable<Vector4>;
  72154. /**
  72155. * Sets the index-th row of the current matrix to the vector4 values
  72156. * @param index defines the number of the row to set
  72157. * @param row defines the target vector4
  72158. * @returns the updated current matrix
  72159. */
  72160. setRow(index: number, row: Vector4): Matrix;
  72161. /**
  72162. * Compute the transpose of the matrix
  72163. * @returns the new transposed matrix
  72164. */
  72165. transpose(): Matrix;
  72166. /**
  72167. * Compute the transpose of the matrix and store it in a given matrix
  72168. * @param result defines the target matrix
  72169. * @returns the current matrix
  72170. */
  72171. transposeToRef(result: Matrix): Matrix;
  72172. /**
  72173. * Sets the index-th row of the current matrix with the given 4 x float values
  72174. * @param index defines the row index
  72175. * @param x defines the x component to set
  72176. * @param y defines the y component to set
  72177. * @param z defines the z component to set
  72178. * @param w defines the w component to set
  72179. * @returns the updated current matrix
  72180. */
  72181. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72182. /**
  72183. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72184. * @param scale defines the scale factor
  72185. * @returns a new matrix
  72186. */
  72187. scale(scale: number): Matrix;
  72188. /**
  72189. * Scale the current matrix values by a factor to a given result matrix
  72190. * @param scale defines the scale factor
  72191. * @param result defines the matrix to store the result
  72192. * @returns the current matrix
  72193. */
  72194. scaleToRef(scale: number, result: Matrix): Matrix;
  72195. /**
  72196. * Scale the current matrix values by a factor and add the result to a given matrix
  72197. * @param scale defines the scale factor
  72198. * @param result defines the Matrix to store the result
  72199. * @returns the current matrix
  72200. */
  72201. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72202. /**
  72203. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72204. * @param ref matrix to store the result
  72205. */
  72206. toNormalMatrix(ref: Matrix): void;
  72207. /**
  72208. * Gets only rotation part of the current matrix
  72209. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72210. */
  72211. getRotationMatrix(): Matrix;
  72212. /**
  72213. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72214. * @param result defines the target matrix to store data to
  72215. * @returns the current matrix
  72216. */
  72217. getRotationMatrixToRef(result: Matrix): Matrix;
  72218. /**
  72219. * Toggles model matrix from being right handed to left handed in place and vice versa
  72220. */
  72221. toggleModelMatrixHandInPlace(): void;
  72222. /**
  72223. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72224. */
  72225. toggleProjectionMatrixHandInPlace(): void;
  72226. /**
  72227. * Creates a matrix from an array
  72228. * @param array defines the source array
  72229. * @param offset defines an offset in the source array
  72230. * @returns a new Matrix set from the starting index of the given array
  72231. */
  72232. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72233. /**
  72234. * Copy the content of an array into a given matrix
  72235. * @param array defines the source array
  72236. * @param offset defines an offset in the source array
  72237. * @param result defines the target matrix
  72238. */
  72239. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72240. /**
  72241. * Stores an array into a matrix after having multiplied each component by a given factor
  72242. * @param array defines the source array
  72243. * @param offset defines the offset in the source array
  72244. * @param scale defines the scaling factor
  72245. * @param result defines the target matrix
  72246. */
  72247. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72248. /**
  72249. * Gets an identity matrix that must not be updated
  72250. */
  72251. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72252. /**
  72253. * Stores a list of values (16) inside a given matrix
  72254. * @param initialM11 defines 1st value of 1st row
  72255. * @param initialM12 defines 2nd value of 1st row
  72256. * @param initialM13 defines 3rd value of 1st row
  72257. * @param initialM14 defines 4th value of 1st row
  72258. * @param initialM21 defines 1st value of 2nd row
  72259. * @param initialM22 defines 2nd value of 2nd row
  72260. * @param initialM23 defines 3rd value of 2nd row
  72261. * @param initialM24 defines 4th value of 2nd row
  72262. * @param initialM31 defines 1st value of 3rd row
  72263. * @param initialM32 defines 2nd value of 3rd row
  72264. * @param initialM33 defines 3rd value of 3rd row
  72265. * @param initialM34 defines 4th value of 3rd row
  72266. * @param initialM41 defines 1st value of 4th row
  72267. * @param initialM42 defines 2nd value of 4th row
  72268. * @param initialM43 defines 3rd value of 4th row
  72269. * @param initialM44 defines 4th value of 4th row
  72270. * @param result defines the target matrix
  72271. */
  72272. 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;
  72273. /**
  72274. * Creates new matrix from a list of values (16)
  72275. * @param initialM11 defines 1st value of 1st row
  72276. * @param initialM12 defines 2nd value of 1st row
  72277. * @param initialM13 defines 3rd value of 1st row
  72278. * @param initialM14 defines 4th value of 1st row
  72279. * @param initialM21 defines 1st value of 2nd row
  72280. * @param initialM22 defines 2nd value of 2nd row
  72281. * @param initialM23 defines 3rd value of 2nd row
  72282. * @param initialM24 defines 4th value of 2nd row
  72283. * @param initialM31 defines 1st value of 3rd row
  72284. * @param initialM32 defines 2nd value of 3rd row
  72285. * @param initialM33 defines 3rd value of 3rd row
  72286. * @param initialM34 defines 4th value of 3rd row
  72287. * @param initialM41 defines 1st value of 4th row
  72288. * @param initialM42 defines 2nd value of 4th row
  72289. * @param initialM43 defines 3rd value of 4th row
  72290. * @param initialM44 defines 4th value of 4th row
  72291. * @returns the new matrix
  72292. */
  72293. 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;
  72294. /**
  72295. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72296. * @param scale defines the scale vector3
  72297. * @param rotation defines the rotation quaternion
  72298. * @param translation defines the translation vector3
  72299. * @returns a new matrix
  72300. */
  72301. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72302. /**
  72303. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72304. * @param scale defines the scale vector3
  72305. * @param rotation defines the rotation quaternion
  72306. * @param translation defines the translation vector3
  72307. * @param result defines the target matrix
  72308. */
  72309. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72310. /**
  72311. * Creates a new identity matrix
  72312. * @returns a new identity matrix
  72313. */
  72314. static Identity(): Matrix;
  72315. /**
  72316. * Creates a new identity matrix and stores the result in a given matrix
  72317. * @param result defines the target matrix
  72318. */
  72319. static IdentityToRef(result: Matrix): void;
  72320. /**
  72321. * Creates a new zero matrix
  72322. * @returns a new zero matrix
  72323. */
  72324. static Zero(): Matrix;
  72325. /**
  72326. * Creates a new rotation matrix for "angle" radians around the X axis
  72327. * @param angle defines the angle (in radians) to use
  72328. * @return the new matrix
  72329. */
  72330. static RotationX(angle: number): Matrix;
  72331. /**
  72332. * Creates a new matrix as the invert of a given matrix
  72333. * @param source defines the source matrix
  72334. * @returns the new matrix
  72335. */
  72336. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72337. /**
  72338. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72339. * @param angle defines the angle (in radians) to use
  72340. * @param result defines the target matrix
  72341. */
  72342. static RotationXToRef(angle: number, result: Matrix): void;
  72343. /**
  72344. * Creates a new rotation matrix for "angle" radians around the Y axis
  72345. * @param angle defines the angle (in radians) to use
  72346. * @return the new matrix
  72347. */
  72348. static RotationY(angle: number): Matrix;
  72349. /**
  72350. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72351. * @param angle defines the angle (in radians) to use
  72352. * @param result defines the target matrix
  72353. */
  72354. static RotationYToRef(angle: number, result: Matrix): void;
  72355. /**
  72356. * Creates a new rotation matrix for "angle" radians around the Z axis
  72357. * @param angle defines the angle (in radians) to use
  72358. * @return the new matrix
  72359. */
  72360. static RotationZ(angle: number): Matrix;
  72361. /**
  72362. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72363. * @param angle defines the angle (in radians) to use
  72364. * @param result defines the target matrix
  72365. */
  72366. static RotationZToRef(angle: number, result: Matrix): void;
  72367. /**
  72368. * Creates a new rotation matrix for "angle" radians around the given axis
  72369. * @param axis defines the axis to use
  72370. * @param angle defines the angle (in radians) to use
  72371. * @return the new matrix
  72372. */
  72373. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72374. /**
  72375. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72376. * @param axis defines the axis to use
  72377. * @param angle defines the angle (in radians) to use
  72378. * @param result defines the target matrix
  72379. */
  72380. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72381. /**
  72382. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72383. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72384. * @param from defines the vector to align
  72385. * @param to defines the vector to align to
  72386. * @param result defines the target matrix
  72387. */
  72388. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72389. /**
  72390. * Creates a rotation matrix
  72391. * @param yaw defines the yaw angle in radians (Y axis)
  72392. * @param pitch defines the pitch angle in radians (X axis)
  72393. * @param roll defines the roll angle in radians (X axis)
  72394. * @returns the new rotation matrix
  72395. */
  72396. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72397. /**
  72398. * Creates a rotation matrix and stores it in a given matrix
  72399. * @param yaw defines the yaw angle in radians (Y axis)
  72400. * @param pitch defines the pitch angle in radians (X axis)
  72401. * @param roll defines the roll angle in radians (X axis)
  72402. * @param result defines the target matrix
  72403. */
  72404. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72405. /**
  72406. * Creates a scaling matrix
  72407. * @param x defines the scale factor on X axis
  72408. * @param y defines the scale factor on Y axis
  72409. * @param z defines the scale factor on Z axis
  72410. * @returns the new matrix
  72411. */
  72412. static Scaling(x: number, y: number, z: number): Matrix;
  72413. /**
  72414. * Creates a scaling matrix and stores it in a given matrix
  72415. * @param x defines the scale factor on X axis
  72416. * @param y defines the scale factor on Y axis
  72417. * @param z defines the scale factor on Z axis
  72418. * @param result defines the target matrix
  72419. */
  72420. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72421. /**
  72422. * Creates a translation matrix
  72423. * @param x defines the translation on X axis
  72424. * @param y defines the translation on Y axis
  72425. * @param z defines the translationon Z axis
  72426. * @returns the new matrix
  72427. */
  72428. static Translation(x: number, y: number, z: number): Matrix;
  72429. /**
  72430. * Creates a translation matrix and stores it in a given matrix
  72431. * @param x defines the translation on X axis
  72432. * @param y defines the translation on Y axis
  72433. * @param z defines the translationon Z axis
  72434. * @param result defines the target matrix
  72435. */
  72436. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72437. /**
  72438. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72439. * @param startValue defines the start value
  72440. * @param endValue defines the end value
  72441. * @param gradient defines the gradient factor
  72442. * @returns the new matrix
  72443. */
  72444. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72445. /**
  72446. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72447. * @param startValue defines the start value
  72448. * @param endValue defines the end value
  72449. * @param gradient defines the gradient factor
  72450. * @param result defines the Matrix object where to store data
  72451. */
  72452. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72453. /**
  72454. * Builds a new matrix whose values are computed by:
  72455. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72456. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72457. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72458. * @param startValue defines the first matrix
  72459. * @param endValue defines the second matrix
  72460. * @param gradient defines the gradient between the two matrices
  72461. * @returns the new matrix
  72462. */
  72463. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72464. /**
  72465. * Update a matrix to values which are computed by:
  72466. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72467. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72468. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72469. * @param startValue defines the first matrix
  72470. * @param endValue defines the second matrix
  72471. * @param gradient defines the gradient between the two matrices
  72472. * @param result defines the target matrix
  72473. */
  72474. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72475. /**
  72476. * 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"
  72477. * This function works in left handed mode
  72478. * @param eye defines the final position of the entity
  72479. * @param target defines where the entity should look at
  72480. * @param up defines the up vector for the entity
  72481. * @returns the new matrix
  72482. */
  72483. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72484. /**
  72485. * 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".
  72486. * This function works in left handed mode
  72487. * @param eye defines the final position of the entity
  72488. * @param target defines where the entity should look at
  72489. * @param up defines the up vector for the entity
  72490. * @param result defines the target matrix
  72491. */
  72492. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72493. /**
  72494. * 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"
  72495. * This function works in right handed mode
  72496. * @param eye defines the final position of the entity
  72497. * @param target defines where the entity should look at
  72498. * @param up defines the up vector for the entity
  72499. * @returns the new matrix
  72500. */
  72501. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72502. /**
  72503. * 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".
  72504. * This function works in right handed mode
  72505. * @param eye defines the final position of the entity
  72506. * @param target defines where the entity should look at
  72507. * @param up defines the up vector for the entity
  72508. * @param result defines the target matrix
  72509. */
  72510. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72511. /**
  72512. * Create a left-handed orthographic projection matrix
  72513. * @param width defines the viewport width
  72514. * @param height defines the viewport height
  72515. * @param znear defines the near clip plane
  72516. * @param zfar defines the far clip plane
  72517. * @returns a new matrix as a left-handed orthographic projection matrix
  72518. */
  72519. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72520. /**
  72521. * Store a left-handed orthographic projection to a given matrix
  72522. * @param width defines the viewport width
  72523. * @param height defines the viewport height
  72524. * @param znear defines the near clip plane
  72525. * @param zfar defines the far clip plane
  72526. * @param result defines the target matrix
  72527. */
  72528. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72529. /**
  72530. * Create a left-handed orthographic projection matrix
  72531. * @param left defines the viewport left coordinate
  72532. * @param right defines the viewport right coordinate
  72533. * @param bottom defines the viewport bottom coordinate
  72534. * @param top defines the viewport top coordinate
  72535. * @param znear defines the near clip plane
  72536. * @param zfar defines the far clip plane
  72537. * @returns a new matrix as a left-handed orthographic projection matrix
  72538. */
  72539. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72540. /**
  72541. * Stores a left-handed orthographic projection into a given matrix
  72542. * @param left defines the viewport left coordinate
  72543. * @param right defines the viewport right coordinate
  72544. * @param bottom defines the viewport bottom coordinate
  72545. * @param top defines the viewport top coordinate
  72546. * @param znear defines the near clip plane
  72547. * @param zfar defines the far clip plane
  72548. * @param result defines the target matrix
  72549. */
  72550. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72551. /**
  72552. * Creates a right-handed orthographic projection matrix
  72553. * @param left defines the viewport left coordinate
  72554. * @param right defines the viewport right coordinate
  72555. * @param bottom defines the viewport bottom coordinate
  72556. * @param top defines the viewport top coordinate
  72557. * @param znear defines the near clip plane
  72558. * @param zfar defines the far clip plane
  72559. * @returns a new matrix as a right-handed orthographic projection matrix
  72560. */
  72561. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72562. /**
  72563. * Stores a right-handed orthographic projection into a given matrix
  72564. * @param left defines the viewport left coordinate
  72565. * @param right defines the viewport right coordinate
  72566. * @param bottom defines the viewport bottom coordinate
  72567. * @param top defines the viewport top coordinate
  72568. * @param znear defines the near clip plane
  72569. * @param zfar defines the far clip plane
  72570. * @param result defines the target matrix
  72571. */
  72572. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72573. /**
  72574. * Creates a left-handed perspective projection matrix
  72575. * @param width defines the viewport width
  72576. * @param height defines the viewport height
  72577. * @param znear defines the near clip plane
  72578. * @param zfar defines the far clip plane
  72579. * @returns a new matrix as a left-handed perspective projection matrix
  72580. */
  72581. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72582. /**
  72583. * Creates a left-handed perspective projection matrix
  72584. * @param fov defines the horizontal field of view
  72585. * @param aspect defines the aspect ratio
  72586. * @param znear defines the near clip plane
  72587. * @param zfar defines the far clip plane
  72588. * @returns a new matrix as a left-handed perspective projection matrix
  72589. */
  72590. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72591. /**
  72592. * Stores a left-handed perspective projection into a given matrix
  72593. * @param fov defines the horizontal field of view
  72594. * @param aspect defines the aspect ratio
  72595. * @param znear defines the near clip plane
  72596. * @param zfar defines the far clip plane
  72597. * @param result defines the target matrix
  72598. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72599. */
  72600. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72601. /**
  72602. * Creates a right-handed perspective projection matrix
  72603. * @param fov defines the horizontal field of view
  72604. * @param aspect defines the aspect ratio
  72605. * @param znear defines the near clip plane
  72606. * @param zfar defines the far clip plane
  72607. * @returns a new matrix as a right-handed perspective projection matrix
  72608. */
  72609. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72610. /**
  72611. * Stores a right-handed perspective projection into a given matrix
  72612. * @param fov defines the horizontal field of view
  72613. * @param aspect defines the aspect ratio
  72614. * @param znear defines the near clip plane
  72615. * @param zfar defines the far clip plane
  72616. * @param result defines the target matrix
  72617. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72618. */
  72619. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72620. /**
  72621. * Stores a perspective projection for WebVR info a given matrix
  72622. * @param fov defines the field of view
  72623. * @param znear defines the near clip plane
  72624. * @param zfar defines the far clip plane
  72625. * @param result defines the target matrix
  72626. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72627. */
  72628. static PerspectiveFovWebVRToRef(fov: {
  72629. upDegrees: number;
  72630. downDegrees: number;
  72631. leftDegrees: number;
  72632. rightDegrees: number;
  72633. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72634. /**
  72635. * Computes a complete transformation matrix
  72636. * @param viewport defines the viewport to use
  72637. * @param world defines the world matrix
  72638. * @param view defines the view matrix
  72639. * @param projection defines the projection matrix
  72640. * @param zmin defines the near clip plane
  72641. * @param zmax defines the far clip plane
  72642. * @returns the transformation matrix
  72643. */
  72644. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72645. /**
  72646. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72647. * @param matrix defines the matrix to use
  72648. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72649. */
  72650. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72651. /**
  72652. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72653. * @param matrix defines the matrix to use
  72654. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72655. */
  72656. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72657. /**
  72658. * Compute the transpose of a given matrix
  72659. * @param matrix defines the matrix to transpose
  72660. * @returns the new matrix
  72661. */
  72662. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72663. /**
  72664. * Compute the transpose of a matrix and store it in a target matrix
  72665. * @param matrix defines the matrix to transpose
  72666. * @param result defines the target matrix
  72667. */
  72668. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72669. /**
  72670. * Computes a reflection matrix from a plane
  72671. * @param plane defines the reflection plane
  72672. * @returns a new matrix
  72673. */
  72674. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72675. /**
  72676. * Computes a reflection matrix from a plane
  72677. * @param plane defines the reflection plane
  72678. * @param result defines the target matrix
  72679. */
  72680. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72681. /**
  72682. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72683. * @param xaxis defines the value of the 1st axis
  72684. * @param yaxis defines the value of the 2nd axis
  72685. * @param zaxis defines the value of the 3rd axis
  72686. * @param result defines the target matrix
  72687. */
  72688. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72689. /**
  72690. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72691. * @param quat defines the quaternion to use
  72692. * @param result defines the target matrix
  72693. */
  72694. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72695. }
  72696. /**
  72697. * @hidden
  72698. */
  72699. export class TmpVectors {
  72700. static Vector2: Vector2[];
  72701. static Vector3: Vector3[];
  72702. static Vector4: Vector4[];
  72703. static Quaternion: Quaternion[];
  72704. static Matrix: Matrix[];
  72705. }
  72706. }
  72707. declare module BABYLON {
  72708. /**
  72709. * Defines potential orientation for back face culling
  72710. */
  72711. export enum Orientation {
  72712. /**
  72713. * Clockwise
  72714. */
  72715. CW = 0,
  72716. /** Counter clockwise */
  72717. CCW = 1
  72718. }
  72719. /** Class used to represent a Bezier curve */
  72720. export class BezierCurve {
  72721. /**
  72722. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72723. * @param t defines the time
  72724. * @param x1 defines the left coordinate on X axis
  72725. * @param y1 defines the left coordinate on Y axis
  72726. * @param x2 defines the right coordinate on X axis
  72727. * @param y2 defines the right coordinate on Y axis
  72728. * @returns the interpolated value
  72729. */
  72730. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72731. }
  72732. /**
  72733. * Defines angle representation
  72734. */
  72735. export class Angle {
  72736. private _radians;
  72737. /**
  72738. * Creates an Angle object of "radians" radians (float).
  72739. * @param radians the angle in radians
  72740. */
  72741. constructor(radians: number);
  72742. /**
  72743. * Get value in degrees
  72744. * @returns the Angle value in degrees (float)
  72745. */
  72746. degrees(): number;
  72747. /**
  72748. * Get value in radians
  72749. * @returns the Angle value in radians (float)
  72750. */
  72751. radians(): number;
  72752. /**
  72753. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72754. * @param a defines first vector
  72755. * @param b defines second vector
  72756. * @returns a new Angle
  72757. */
  72758. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72759. /**
  72760. * Gets a new Angle object from the given float in radians
  72761. * @param radians defines the angle value in radians
  72762. * @returns a new Angle
  72763. */
  72764. static FromRadians(radians: number): Angle;
  72765. /**
  72766. * Gets a new Angle object from the given float in degrees
  72767. * @param degrees defines the angle value in degrees
  72768. * @returns a new Angle
  72769. */
  72770. static FromDegrees(degrees: number): Angle;
  72771. }
  72772. /**
  72773. * This represents an arc in a 2d space.
  72774. */
  72775. export class Arc2 {
  72776. /** Defines the start point of the arc */
  72777. startPoint: Vector2;
  72778. /** Defines the mid point of the arc */
  72779. midPoint: Vector2;
  72780. /** Defines the end point of the arc */
  72781. endPoint: Vector2;
  72782. /**
  72783. * Defines the center point of the arc.
  72784. */
  72785. centerPoint: Vector2;
  72786. /**
  72787. * Defines the radius of the arc.
  72788. */
  72789. radius: number;
  72790. /**
  72791. * Defines the angle of the arc (from mid point to end point).
  72792. */
  72793. angle: Angle;
  72794. /**
  72795. * Defines the start angle of the arc (from start point to middle point).
  72796. */
  72797. startAngle: Angle;
  72798. /**
  72799. * Defines the orientation of the arc (clock wise/counter clock wise).
  72800. */
  72801. orientation: Orientation;
  72802. /**
  72803. * Creates an Arc object from the three given points : start, middle and end.
  72804. * @param startPoint Defines the start point of the arc
  72805. * @param midPoint Defines the midlle point of the arc
  72806. * @param endPoint Defines the end point of the arc
  72807. */
  72808. constructor(
  72809. /** Defines the start point of the arc */
  72810. startPoint: Vector2,
  72811. /** Defines the mid point of the arc */
  72812. midPoint: Vector2,
  72813. /** Defines the end point of the arc */
  72814. endPoint: Vector2);
  72815. }
  72816. /**
  72817. * Represents a 2D path made up of multiple 2D points
  72818. */
  72819. export class Path2 {
  72820. private _points;
  72821. private _length;
  72822. /**
  72823. * If the path start and end point are the same
  72824. */
  72825. closed: boolean;
  72826. /**
  72827. * Creates a Path2 object from the starting 2D coordinates x and y.
  72828. * @param x the starting points x value
  72829. * @param y the starting points y value
  72830. */
  72831. constructor(x: number, y: number);
  72832. /**
  72833. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72834. * @param x the added points x value
  72835. * @param y the added points y value
  72836. * @returns the updated Path2.
  72837. */
  72838. addLineTo(x: number, y: number): Path2;
  72839. /**
  72840. * 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.
  72841. * @param midX middle point x value
  72842. * @param midY middle point y value
  72843. * @param endX end point x value
  72844. * @param endY end point y value
  72845. * @param numberOfSegments (default: 36)
  72846. * @returns the updated Path2.
  72847. */
  72848. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72849. /**
  72850. * Closes the Path2.
  72851. * @returns the Path2.
  72852. */
  72853. close(): Path2;
  72854. /**
  72855. * Gets the sum of the distance between each sequential point in the path
  72856. * @returns the Path2 total length (float).
  72857. */
  72858. length(): number;
  72859. /**
  72860. * Gets the points which construct the path
  72861. * @returns the Path2 internal array of points.
  72862. */
  72863. getPoints(): Vector2[];
  72864. /**
  72865. * Retreives the point at the distance aways from the starting point
  72866. * @param normalizedLengthPosition the length along the path to retreive the point from
  72867. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72868. */
  72869. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72870. /**
  72871. * Creates a new path starting from an x and y position
  72872. * @param x starting x value
  72873. * @param y starting y value
  72874. * @returns a new Path2 starting at the coordinates (x, y).
  72875. */
  72876. static StartingAt(x: number, y: number): Path2;
  72877. }
  72878. /**
  72879. * Represents a 3D path made up of multiple 3D points
  72880. */
  72881. export class Path3D {
  72882. /**
  72883. * an array of Vector3, the curve axis of the Path3D
  72884. */
  72885. path: Vector3[];
  72886. private _curve;
  72887. private _distances;
  72888. private _tangents;
  72889. private _normals;
  72890. private _binormals;
  72891. private _raw;
  72892. private _alignTangentsWithPath;
  72893. private readonly _pointAtData;
  72894. /**
  72895. * new Path3D(path, normal, raw)
  72896. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72897. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72898. * @param path an array of Vector3, the curve axis of the Path3D
  72899. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72900. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72901. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  72902. */
  72903. constructor(
  72904. /**
  72905. * an array of Vector3, the curve axis of the Path3D
  72906. */
  72907. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  72908. /**
  72909. * Returns the Path3D array of successive Vector3 designing its curve.
  72910. * @returns the Path3D array of successive Vector3 designing its curve.
  72911. */
  72912. getCurve(): Vector3[];
  72913. /**
  72914. * Returns the Path3D array of successive Vector3 designing its curve.
  72915. * @returns the Path3D array of successive Vector3 designing its curve.
  72916. */
  72917. getPoints(): Vector3[];
  72918. /**
  72919. * @returns the computed length (float) of the path.
  72920. */
  72921. length(): number;
  72922. /**
  72923. * Returns an array populated with tangent vectors on each Path3D curve point.
  72924. * @returns an array populated with tangent vectors on each Path3D curve point.
  72925. */
  72926. getTangents(): Vector3[];
  72927. /**
  72928. * Returns an array populated with normal vectors on each Path3D curve point.
  72929. * @returns an array populated with normal vectors on each Path3D curve point.
  72930. */
  72931. getNormals(): Vector3[];
  72932. /**
  72933. * Returns an array populated with binormal vectors on each Path3D curve point.
  72934. * @returns an array populated with binormal vectors on each Path3D curve point.
  72935. */
  72936. getBinormals(): Vector3[];
  72937. /**
  72938. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72939. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72940. */
  72941. getDistances(): number[];
  72942. /**
  72943. * Returns an interpolated point along this path
  72944. * @param position the position of the point along this path, from 0.0 to 1.0
  72945. * @returns a new Vector3 as the point
  72946. */
  72947. getPointAt(position: number): Vector3;
  72948. /**
  72949. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72950. * @param position the position of the point along this path, from 0.0 to 1.0
  72951. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  72952. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  72953. */
  72954. getTangentAt(position: number, interpolated?: boolean): Vector3;
  72955. /**
  72956. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  72957. * @param position the position of the point along this path, from 0.0 to 1.0
  72958. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  72959. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  72960. */
  72961. getNormalAt(position: number, interpolated?: boolean): Vector3;
  72962. /**
  72963. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  72964. * @param position the position of the point along this path, from 0.0 to 1.0
  72965. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  72966. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  72967. */
  72968. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  72969. /**
  72970. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  72971. * @param position the position of the point along this path, from 0.0 to 1.0
  72972. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  72973. */
  72974. getDistanceAt(position: number): number;
  72975. /**
  72976. * Returns the array index of the previous point of an interpolated point along this path
  72977. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  72978. * @returns the array index
  72979. */
  72980. getPreviousPointIndexAt(position: number): number;
  72981. /**
  72982. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  72983. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  72984. * @returns the sub position
  72985. */
  72986. getSubPositionAt(position: number): number;
  72987. /**
  72988. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  72989. * @param target the vector of which to get the closest position to
  72990. * @returns the position of the closest virtual point on this path to the target vector
  72991. */
  72992. getClosestPositionTo(target: Vector3): number;
  72993. /**
  72994. * Returns a sub path (slice) of this path
  72995. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  72996. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  72997. * @returns a sub path (slice) of this path
  72998. */
  72999. slice(start?: number, end?: number): Path3D;
  73000. /**
  73001. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73002. * @param path path which all values are copied into the curves points
  73003. * @param firstNormal which should be projected onto the curve
  73004. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73005. * @returns the same object updated.
  73006. */
  73007. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73008. private _compute;
  73009. private _getFirstNonNullVector;
  73010. private _getLastNonNullVector;
  73011. private _normalVector;
  73012. /**
  73013. * Updates the point at data for an interpolated point along this curve
  73014. * @param position the position of the point along this curve, from 0.0 to 1.0
  73015. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73016. * @returns the (updated) point at data
  73017. */
  73018. private _updatePointAtData;
  73019. /**
  73020. * Updates the point at data from the specified parameters
  73021. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73022. * @param point the interpolated point
  73023. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73024. */
  73025. private _setPointAtData;
  73026. /**
  73027. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73028. */
  73029. private _updateInterpolationMatrix;
  73030. }
  73031. /**
  73032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73033. * A Curve3 is designed from a series of successive Vector3.
  73034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73035. */
  73036. export class Curve3 {
  73037. private _points;
  73038. private _length;
  73039. /**
  73040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73042. * @param v1 (Vector3) the control point
  73043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73044. * @param nbPoints (integer) the wanted number of points in the curve
  73045. * @returns the created Curve3
  73046. */
  73047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73048. /**
  73049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73051. * @param v1 (Vector3) the first control point
  73052. * @param v2 (Vector3) the second control point
  73053. * @param v3 (Vector3) the end point of the Cubic Bezier
  73054. * @param nbPoints (integer) the wanted number of points in the curve
  73055. * @returns the created Curve3
  73056. */
  73057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73058. /**
  73059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73060. * @param p1 (Vector3) the origin point of the Hermite Spline
  73061. * @param t1 (Vector3) the tangent vector at the origin point
  73062. * @param p2 (Vector3) the end point of the Hermite Spline
  73063. * @param t2 (Vector3) the tangent vector at the end point
  73064. * @param nbPoints (integer) the wanted number of points in the curve
  73065. * @returns the created Curve3
  73066. */
  73067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73068. /**
  73069. * Returns a Curve3 object along a CatmullRom Spline curve :
  73070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73071. * @param nbPoints (integer) the wanted number of points between each curve control points
  73072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73073. * @returns the created Curve3
  73074. */
  73075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73076. /**
  73077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73078. * A Curve3 is designed from a series of successive Vector3.
  73079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73080. * @param points points which make up the curve
  73081. */
  73082. constructor(points: Vector3[]);
  73083. /**
  73084. * @returns the Curve3 stored array of successive Vector3
  73085. */
  73086. getPoints(): Vector3[];
  73087. /**
  73088. * @returns the computed length (float) of the curve.
  73089. */
  73090. length(): number;
  73091. /**
  73092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73094. * curveA and curveB keep unchanged.
  73095. * @param curve the curve to continue from this curve
  73096. * @returns the newly constructed curve
  73097. */
  73098. continue(curve: DeepImmutable<Curve3>): Curve3;
  73099. private _computeLength;
  73100. }
  73101. }
  73102. declare module BABYLON {
  73103. /**
  73104. * This represents the main contract an easing function should follow.
  73105. * Easing functions are used throughout the animation system.
  73106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73107. */
  73108. export interface IEasingFunction {
  73109. /**
  73110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73111. * of the easing function.
  73112. * The link below provides some of the most common examples of easing functions.
  73113. * @see https://easings.net/
  73114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73115. * @returns the corresponding value on the curve defined by the easing function
  73116. */
  73117. ease(gradient: number): number;
  73118. }
  73119. /**
  73120. * Base class used for every default easing function.
  73121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73122. */
  73123. export class EasingFunction implements IEasingFunction {
  73124. /**
  73125. * Interpolation follows the mathematical formula associated with the easing function.
  73126. */
  73127. static readonly EASINGMODE_EASEIN: number;
  73128. /**
  73129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73130. */
  73131. static readonly EASINGMODE_EASEOUT: number;
  73132. /**
  73133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73134. */
  73135. static readonly EASINGMODE_EASEINOUT: number;
  73136. private _easingMode;
  73137. /**
  73138. * Sets the easing mode of the current function.
  73139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73140. */
  73141. setEasingMode(easingMode: number): void;
  73142. /**
  73143. * Gets the current easing mode.
  73144. * @returns the easing mode
  73145. */
  73146. getEasingMode(): number;
  73147. /**
  73148. * @hidden
  73149. */
  73150. easeInCore(gradient: number): number;
  73151. /**
  73152. * Given an input gradient between 0 and 1, this returns the corresponding value
  73153. * of the easing function.
  73154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73155. * @returns the corresponding value on the curve defined by the easing function
  73156. */
  73157. ease(gradient: number): number;
  73158. }
  73159. /**
  73160. * Easing function with a circle shape (see link below).
  73161. * @see https://easings.net/#easeInCirc
  73162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73163. */
  73164. export class CircleEase extends EasingFunction implements IEasingFunction {
  73165. /** @hidden */
  73166. easeInCore(gradient: number): number;
  73167. }
  73168. /**
  73169. * Easing function with a ease back shape (see link below).
  73170. * @see https://easings.net/#easeInBack
  73171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73172. */
  73173. export class BackEase extends EasingFunction implements IEasingFunction {
  73174. /** Defines the amplitude of the function */
  73175. amplitude: number;
  73176. /**
  73177. * Instantiates a back ease easing
  73178. * @see https://easings.net/#easeInBack
  73179. * @param amplitude Defines the amplitude of the function
  73180. */
  73181. constructor(
  73182. /** Defines the amplitude of the function */
  73183. amplitude?: number);
  73184. /** @hidden */
  73185. easeInCore(gradient: number): number;
  73186. }
  73187. /**
  73188. * Easing function with a bouncing shape (see link below).
  73189. * @see https://easings.net/#easeInBounce
  73190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73191. */
  73192. export class BounceEase extends EasingFunction implements IEasingFunction {
  73193. /** Defines the number of bounces */
  73194. bounces: number;
  73195. /** Defines the amplitude of the bounce */
  73196. bounciness: number;
  73197. /**
  73198. * Instantiates a bounce easing
  73199. * @see https://easings.net/#easeInBounce
  73200. * @param bounces Defines the number of bounces
  73201. * @param bounciness Defines the amplitude of the bounce
  73202. */
  73203. constructor(
  73204. /** Defines the number of bounces */
  73205. bounces?: number,
  73206. /** Defines the amplitude of the bounce */
  73207. bounciness?: number);
  73208. /** @hidden */
  73209. easeInCore(gradient: number): number;
  73210. }
  73211. /**
  73212. * Easing function with a power of 3 shape (see link below).
  73213. * @see https://easings.net/#easeInCubic
  73214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73215. */
  73216. export class CubicEase extends EasingFunction implements IEasingFunction {
  73217. /** @hidden */
  73218. easeInCore(gradient: number): number;
  73219. }
  73220. /**
  73221. * Easing function with an elastic shape (see link below).
  73222. * @see https://easings.net/#easeInElastic
  73223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73224. */
  73225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73226. /** Defines the number of oscillations*/
  73227. oscillations: number;
  73228. /** Defines the amplitude of the oscillations*/
  73229. springiness: number;
  73230. /**
  73231. * Instantiates an elastic easing function
  73232. * @see https://easings.net/#easeInElastic
  73233. * @param oscillations Defines the number of oscillations
  73234. * @param springiness Defines the amplitude of the oscillations
  73235. */
  73236. constructor(
  73237. /** Defines the number of oscillations*/
  73238. oscillations?: number,
  73239. /** Defines the amplitude of the oscillations*/
  73240. springiness?: number);
  73241. /** @hidden */
  73242. easeInCore(gradient: number): number;
  73243. }
  73244. /**
  73245. * Easing function with an exponential shape (see link below).
  73246. * @see https://easings.net/#easeInExpo
  73247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73248. */
  73249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73250. /** Defines the exponent of the function */
  73251. exponent: number;
  73252. /**
  73253. * Instantiates an exponential easing function
  73254. * @see https://easings.net/#easeInExpo
  73255. * @param exponent Defines the exponent of the function
  73256. */
  73257. constructor(
  73258. /** Defines the exponent of the function */
  73259. exponent?: number);
  73260. /** @hidden */
  73261. easeInCore(gradient: number): number;
  73262. }
  73263. /**
  73264. * Easing function with a power shape (see link below).
  73265. * @see https://easings.net/#easeInQuad
  73266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73267. */
  73268. export class PowerEase extends EasingFunction implements IEasingFunction {
  73269. /** Defines the power of the function */
  73270. power: number;
  73271. /**
  73272. * Instantiates an power base easing function
  73273. * @see https://easings.net/#easeInQuad
  73274. * @param power Defines the power of the function
  73275. */
  73276. constructor(
  73277. /** Defines the power of the function */
  73278. power?: number);
  73279. /** @hidden */
  73280. easeInCore(gradient: number): number;
  73281. }
  73282. /**
  73283. * Easing function with a power of 2 shape (see link below).
  73284. * @see https://easings.net/#easeInQuad
  73285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73286. */
  73287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73288. /** @hidden */
  73289. easeInCore(gradient: number): number;
  73290. }
  73291. /**
  73292. * Easing function with a power of 4 shape (see link below).
  73293. * @see https://easings.net/#easeInQuart
  73294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73295. */
  73296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73297. /** @hidden */
  73298. easeInCore(gradient: number): number;
  73299. }
  73300. /**
  73301. * Easing function with a power of 5 shape (see link below).
  73302. * @see https://easings.net/#easeInQuint
  73303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73304. */
  73305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73306. /** @hidden */
  73307. easeInCore(gradient: number): number;
  73308. }
  73309. /**
  73310. * Easing function with a sin shape (see link below).
  73311. * @see https://easings.net/#easeInSine
  73312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73313. */
  73314. export class SineEase extends EasingFunction implements IEasingFunction {
  73315. /** @hidden */
  73316. easeInCore(gradient: number): number;
  73317. }
  73318. /**
  73319. * Easing function with a bezier shape (see link below).
  73320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73322. */
  73323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73324. /** Defines the x component of the start tangent in the bezier curve */
  73325. x1: number;
  73326. /** Defines the y component of the start tangent in the bezier curve */
  73327. y1: number;
  73328. /** Defines the x component of the end tangent in the bezier curve */
  73329. x2: number;
  73330. /** Defines the y component of the end tangent in the bezier curve */
  73331. y2: number;
  73332. /**
  73333. * Instantiates a bezier function
  73334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73335. * @param x1 Defines the x component of the start tangent in the bezier curve
  73336. * @param y1 Defines the y component of the start tangent in the bezier curve
  73337. * @param x2 Defines the x component of the end tangent in the bezier curve
  73338. * @param y2 Defines the y component of the end tangent in the bezier curve
  73339. */
  73340. constructor(
  73341. /** Defines the x component of the start tangent in the bezier curve */
  73342. x1?: number,
  73343. /** Defines the y component of the start tangent in the bezier curve */
  73344. y1?: number,
  73345. /** Defines the x component of the end tangent in the bezier curve */
  73346. x2?: number,
  73347. /** Defines the y component of the end tangent in the bezier curve */
  73348. y2?: number);
  73349. /** @hidden */
  73350. easeInCore(gradient: number): number;
  73351. }
  73352. }
  73353. declare module BABYLON {
  73354. /**
  73355. * Class used to hold a RBG color
  73356. */
  73357. export class Color3 {
  73358. /**
  73359. * Defines the red component (between 0 and 1, default is 0)
  73360. */
  73361. r: number;
  73362. /**
  73363. * Defines the green component (between 0 and 1, default is 0)
  73364. */
  73365. g: number;
  73366. /**
  73367. * Defines the blue component (between 0 and 1, default is 0)
  73368. */
  73369. b: number;
  73370. /**
  73371. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73372. * @param r defines the red component (between 0 and 1, default is 0)
  73373. * @param g defines the green component (between 0 and 1, default is 0)
  73374. * @param b defines the blue component (between 0 and 1, default is 0)
  73375. */
  73376. constructor(
  73377. /**
  73378. * Defines the red component (between 0 and 1, default is 0)
  73379. */
  73380. r?: number,
  73381. /**
  73382. * Defines the green component (between 0 and 1, default is 0)
  73383. */
  73384. g?: number,
  73385. /**
  73386. * Defines the blue component (between 0 and 1, default is 0)
  73387. */
  73388. b?: number);
  73389. /**
  73390. * Creates a string with the Color3 current values
  73391. * @returns the string representation of the Color3 object
  73392. */
  73393. toString(): string;
  73394. /**
  73395. * Returns the string "Color3"
  73396. * @returns "Color3"
  73397. */
  73398. getClassName(): string;
  73399. /**
  73400. * Compute the Color3 hash code
  73401. * @returns an unique number that can be used to hash Color3 objects
  73402. */
  73403. getHashCode(): number;
  73404. /**
  73405. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73406. * @param array defines the array where to store the r,g,b components
  73407. * @param index defines an optional index in the target array to define where to start storing values
  73408. * @returns the current Color3 object
  73409. */
  73410. toArray(array: FloatArray, index?: number): Color3;
  73411. /**
  73412. * Returns a new Color4 object from the current Color3 and the given alpha
  73413. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73414. * @returns a new Color4 object
  73415. */
  73416. toColor4(alpha?: number): Color4;
  73417. /**
  73418. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73419. * @returns the new array
  73420. */
  73421. asArray(): number[];
  73422. /**
  73423. * Returns the luminance value
  73424. * @returns a float value
  73425. */
  73426. toLuminance(): number;
  73427. /**
  73428. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73429. * @param otherColor defines the second operand
  73430. * @returns the new Color3 object
  73431. */
  73432. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73433. /**
  73434. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73435. * @param otherColor defines the second operand
  73436. * @param result defines the Color3 object where to store the result
  73437. * @returns the current Color3
  73438. */
  73439. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73440. /**
  73441. * Determines equality between Color3 objects
  73442. * @param otherColor defines the second operand
  73443. * @returns true if the rgb values are equal to the given ones
  73444. */
  73445. equals(otherColor: DeepImmutable<Color3>): boolean;
  73446. /**
  73447. * Determines equality between the current Color3 object and a set of r,b,g values
  73448. * @param r defines the red component to check
  73449. * @param g defines the green component to check
  73450. * @param b defines the blue component to check
  73451. * @returns true if the rgb values are equal to the given ones
  73452. */
  73453. equalsFloats(r: number, g: number, b: number): boolean;
  73454. /**
  73455. * Multiplies in place each rgb value by scale
  73456. * @param scale defines the scaling factor
  73457. * @returns the updated Color3
  73458. */
  73459. scale(scale: number): Color3;
  73460. /**
  73461. * Multiplies the rgb values by scale and stores the result into "result"
  73462. * @param scale defines the scaling factor
  73463. * @param result defines the Color3 object where to store the result
  73464. * @returns the unmodified current Color3
  73465. */
  73466. scaleToRef(scale: number, result: Color3): Color3;
  73467. /**
  73468. * Scale the current Color3 values by a factor and add the result to a given Color3
  73469. * @param scale defines the scale factor
  73470. * @param result defines color to store the result into
  73471. * @returns the unmodified current Color3
  73472. */
  73473. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73474. /**
  73475. * Clamps the rgb values by the min and max values and stores the result into "result"
  73476. * @param min defines minimum clamping value (default is 0)
  73477. * @param max defines maximum clamping value (default is 1)
  73478. * @param result defines color to store the result into
  73479. * @returns the original Color3
  73480. */
  73481. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73482. /**
  73483. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73484. * @param otherColor defines the second operand
  73485. * @returns the new Color3
  73486. */
  73487. add(otherColor: DeepImmutable<Color3>): Color3;
  73488. /**
  73489. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73490. * @param otherColor defines the second operand
  73491. * @param result defines Color3 object to store the result into
  73492. * @returns the unmodified current Color3
  73493. */
  73494. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73495. /**
  73496. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73497. * @param otherColor defines the second operand
  73498. * @returns the new Color3
  73499. */
  73500. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73501. /**
  73502. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73503. * @param otherColor defines the second operand
  73504. * @param result defines Color3 object to store the result into
  73505. * @returns the unmodified current Color3
  73506. */
  73507. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73508. /**
  73509. * Copy the current object
  73510. * @returns a new Color3 copied the current one
  73511. */
  73512. clone(): Color3;
  73513. /**
  73514. * Copies the rgb values from the source in the current Color3
  73515. * @param source defines the source Color3 object
  73516. * @returns the updated Color3 object
  73517. */
  73518. copyFrom(source: DeepImmutable<Color3>): Color3;
  73519. /**
  73520. * Updates the Color3 rgb values from the given floats
  73521. * @param r defines the red component to read from
  73522. * @param g defines the green component to read from
  73523. * @param b defines the blue component to read from
  73524. * @returns the current Color3 object
  73525. */
  73526. copyFromFloats(r: number, g: number, b: number): Color3;
  73527. /**
  73528. * Updates the Color3 rgb values from the given floats
  73529. * @param r defines the red component to read from
  73530. * @param g defines the green component to read from
  73531. * @param b defines the blue component to read from
  73532. * @returns the current Color3 object
  73533. */
  73534. set(r: number, g: number, b: number): Color3;
  73535. /**
  73536. * Compute the Color3 hexadecimal code as a string
  73537. * @returns a string containing the hexadecimal representation of the Color3 object
  73538. */
  73539. toHexString(): string;
  73540. /**
  73541. * Computes a new Color3 converted from the current one to linear space
  73542. * @returns a new Color3 object
  73543. */
  73544. toLinearSpace(): Color3;
  73545. /**
  73546. * Converts current color in rgb space to HSV values
  73547. * @returns a new color3 representing the HSV values
  73548. */
  73549. toHSV(): Color3;
  73550. /**
  73551. * Converts current color in rgb space to HSV values
  73552. * @param result defines the Color3 where to store the HSV values
  73553. */
  73554. toHSVToRef(result: Color3): void;
  73555. /**
  73556. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73557. * @param convertedColor defines the Color3 object where to store the linear space version
  73558. * @returns the unmodified Color3
  73559. */
  73560. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73561. /**
  73562. * Computes a new Color3 converted from the current one to gamma space
  73563. * @returns a new Color3 object
  73564. */
  73565. toGammaSpace(): Color3;
  73566. /**
  73567. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73568. * @param convertedColor defines the Color3 object where to store the gamma space version
  73569. * @returns the unmodified Color3
  73570. */
  73571. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73572. private static _BlackReadOnly;
  73573. /**
  73574. * Convert Hue, saturation and value to a Color3 (RGB)
  73575. * @param hue defines the hue
  73576. * @param saturation defines the saturation
  73577. * @param value defines the value
  73578. * @param result defines the Color3 where to store the RGB values
  73579. */
  73580. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73581. /**
  73582. * Creates a new Color3 from the string containing valid hexadecimal values
  73583. * @param hex defines a string containing valid hexadecimal values
  73584. * @returns a new Color3 object
  73585. */
  73586. static FromHexString(hex: string): Color3;
  73587. /**
  73588. * Creates a new Color3 from the starting index of the given array
  73589. * @param array defines the source array
  73590. * @param offset defines an offset in the source array
  73591. * @returns a new Color3 object
  73592. */
  73593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73594. /**
  73595. * Creates a new Color3 from integer values (< 256)
  73596. * @param r defines the red component to read from (value between 0 and 255)
  73597. * @param g defines the green component to read from (value between 0 and 255)
  73598. * @param b defines the blue component to read from (value between 0 and 255)
  73599. * @returns a new Color3 object
  73600. */
  73601. static FromInts(r: number, g: number, b: number): Color3;
  73602. /**
  73603. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73604. * @param start defines the start Color3 value
  73605. * @param end defines the end Color3 value
  73606. * @param amount defines the gradient value between start and end
  73607. * @returns a new Color3 object
  73608. */
  73609. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73610. /**
  73611. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73612. * @param left defines the start value
  73613. * @param right defines the end value
  73614. * @param amount defines the gradient factor
  73615. * @param result defines the Color3 object where to store the result
  73616. */
  73617. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73618. /**
  73619. * Returns a Color3 value containing a red color
  73620. * @returns a new Color3 object
  73621. */
  73622. static Red(): Color3;
  73623. /**
  73624. * Returns a Color3 value containing a green color
  73625. * @returns a new Color3 object
  73626. */
  73627. static Green(): Color3;
  73628. /**
  73629. * Returns a Color3 value containing a blue color
  73630. * @returns a new Color3 object
  73631. */
  73632. static Blue(): Color3;
  73633. /**
  73634. * Returns a Color3 value containing a black color
  73635. * @returns a new Color3 object
  73636. */
  73637. static Black(): Color3;
  73638. /**
  73639. * Gets a Color3 value containing a black color that must not be updated
  73640. */
  73641. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73642. /**
  73643. * Returns a Color3 value containing a white color
  73644. * @returns a new Color3 object
  73645. */
  73646. static White(): Color3;
  73647. /**
  73648. * Returns a Color3 value containing a purple color
  73649. * @returns a new Color3 object
  73650. */
  73651. static Purple(): Color3;
  73652. /**
  73653. * Returns a Color3 value containing a magenta color
  73654. * @returns a new Color3 object
  73655. */
  73656. static Magenta(): Color3;
  73657. /**
  73658. * Returns a Color3 value containing a yellow color
  73659. * @returns a new Color3 object
  73660. */
  73661. static Yellow(): Color3;
  73662. /**
  73663. * Returns a Color3 value containing a gray color
  73664. * @returns a new Color3 object
  73665. */
  73666. static Gray(): Color3;
  73667. /**
  73668. * Returns a Color3 value containing a teal color
  73669. * @returns a new Color3 object
  73670. */
  73671. static Teal(): Color3;
  73672. /**
  73673. * Returns a Color3 value containing a random color
  73674. * @returns a new Color3 object
  73675. */
  73676. static Random(): Color3;
  73677. }
  73678. /**
  73679. * Class used to hold a RBGA color
  73680. */
  73681. export class Color4 {
  73682. /**
  73683. * Defines the red component (between 0 and 1, default is 0)
  73684. */
  73685. r: number;
  73686. /**
  73687. * Defines the green component (between 0 and 1, default is 0)
  73688. */
  73689. g: number;
  73690. /**
  73691. * Defines the blue component (between 0 and 1, default is 0)
  73692. */
  73693. b: number;
  73694. /**
  73695. * Defines the alpha component (between 0 and 1, default is 1)
  73696. */
  73697. a: number;
  73698. /**
  73699. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73700. * @param r defines the red component (between 0 and 1, default is 0)
  73701. * @param g defines the green component (between 0 and 1, default is 0)
  73702. * @param b defines the blue component (between 0 and 1, default is 0)
  73703. * @param a defines the alpha component (between 0 and 1, default is 1)
  73704. */
  73705. constructor(
  73706. /**
  73707. * Defines the red component (between 0 and 1, default is 0)
  73708. */
  73709. r?: number,
  73710. /**
  73711. * Defines the green component (between 0 and 1, default is 0)
  73712. */
  73713. g?: number,
  73714. /**
  73715. * Defines the blue component (between 0 and 1, default is 0)
  73716. */
  73717. b?: number,
  73718. /**
  73719. * Defines the alpha component (between 0 and 1, default is 1)
  73720. */
  73721. a?: number);
  73722. /**
  73723. * Adds in place the given Color4 values to the current Color4 object
  73724. * @param right defines the second operand
  73725. * @returns the current updated Color4 object
  73726. */
  73727. addInPlace(right: DeepImmutable<Color4>): Color4;
  73728. /**
  73729. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73730. * @returns the new array
  73731. */
  73732. asArray(): number[];
  73733. /**
  73734. * Stores from the starting index in the given array the Color4 successive values
  73735. * @param array defines the array where to store the r,g,b components
  73736. * @param index defines an optional index in the target array to define where to start storing values
  73737. * @returns the current Color4 object
  73738. */
  73739. toArray(array: number[], index?: number): Color4;
  73740. /**
  73741. * Determines equality between Color4 objects
  73742. * @param otherColor defines the second operand
  73743. * @returns true if the rgba values are equal to the given ones
  73744. */
  73745. equals(otherColor: DeepImmutable<Color4>): boolean;
  73746. /**
  73747. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73748. * @param right defines the second operand
  73749. * @returns a new Color4 object
  73750. */
  73751. add(right: DeepImmutable<Color4>): Color4;
  73752. /**
  73753. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73754. * @param right defines the second operand
  73755. * @returns a new Color4 object
  73756. */
  73757. subtract(right: DeepImmutable<Color4>): Color4;
  73758. /**
  73759. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73760. * @param right defines the second operand
  73761. * @param result defines the Color4 object where to store the result
  73762. * @returns the current Color4 object
  73763. */
  73764. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73765. /**
  73766. * Creates a new Color4 with the current Color4 values multiplied by scale
  73767. * @param scale defines the scaling factor to apply
  73768. * @returns a new Color4 object
  73769. */
  73770. scale(scale: number): Color4;
  73771. /**
  73772. * Multiplies the current Color4 values by scale and stores the result in "result"
  73773. * @param scale defines the scaling factor to apply
  73774. * @param result defines the Color4 object where to store the result
  73775. * @returns the current unmodified Color4
  73776. */
  73777. scaleToRef(scale: number, result: Color4): Color4;
  73778. /**
  73779. * Scale the current Color4 values by a factor and add the result to a given Color4
  73780. * @param scale defines the scale factor
  73781. * @param result defines the Color4 object where to store the result
  73782. * @returns the unmodified current Color4
  73783. */
  73784. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73785. /**
  73786. * Clamps the rgb values by the min and max values and stores the result into "result"
  73787. * @param min defines minimum clamping value (default is 0)
  73788. * @param max defines maximum clamping value (default is 1)
  73789. * @param result defines color to store the result into.
  73790. * @returns the cuurent Color4
  73791. */
  73792. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73793. /**
  73794. * Multipy an Color4 value by another and return a new Color4 object
  73795. * @param color defines the Color4 value to multiply by
  73796. * @returns a new Color4 object
  73797. */
  73798. multiply(color: Color4): Color4;
  73799. /**
  73800. * Multipy a Color4 value by another and push the result in a reference value
  73801. * @param color defines the Color4 value to multiply by
  73802. * @param result defines the Color4 to fill the result in
  73803. * @returns the result Color4
  73804. */
  73805. multiplyToRef(color: Color4, result: Color4): Color4;
  73806. /**
  73807. * Creates a string with the Color4 current values
  73808. * @returns the string representation of the Color4 object
  73809. */
  73810. toString(): string;
  73811. /**
  73812. * Returns the string "Color4"
  73813. * @returns "Color4"
  73814. */
  73815. getClassName(): string;
  73816. /**
  73817. * Compute the Color4 hash code
  73818. * @returns an unique number that can be used to hash Color4 objects
  73819. */
  73820. getHashCode(): number;
  73821. /**
  73822. * Creates a new Color4 copied from the current one
  73823. * @returns a new Color4 object
  73824. */
  73825. clone(): Color4;
  73826. /**
  73827. * Copies the given Color4 values into the current one
  73828. * @param source defines the source Color4 object
  73829. * @returns the current updated Color4 object
  73830. */
  73831. copyFrom(source: Color4): Color4;
  73832. /**
  73833. * Copies the given float values into the current one
  73834. * @param r defines the red component to read from
  73835. * @param g defines the green component to read from
  73836. * @param b defines the blue component to read from
  73837. * @param a defines the alpha component to read from
  73838. * @returns the current updated Color4 object
  73839. */
  73840. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73841. /**
  73842. * Copies the given float values into the current one
  73843. * @param r defines the red component to read from
  73844. * @param g defines the green component to read from
  73845. * @param b defines the blue component to read from
  73846. * @param a defines the alpha component to read from
  73847. * @returns the current updated Color4 object
  73848. */
  73849. set(r: number, g: number, b: number, a: number): Color4;
  73850. /**
  73851. * Compute the Color4 hexadecimal code as a string
  73852. * @returns a string containing the hexadecimal representation of the Color4 object
  73853. */
  73854. toHexString(): string;
  73855. /**
  73856. * Computes a new Color4 converted from the current one to linear space
  73857. * @returns a new Color4 object
  73858. */
  73859. toLinearSpace(): Color4;
  73860. /**
  73861. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73862. * @param convertedColor defines the Color4 object where to store the linear space version
  73863. * @returns the unmodified Color4
  73864. */
  73865. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73866. /**
  73867. * Computes a new Color4 converted from the current one to gamma space
  73868. * @returns a new Color4 object
  73869. */
  73870. toGammaSpace(): Color4;
  73871. /**
  73872. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73873. * @param convertedColor defines the Color4 object where to store the gamma space version
  73874. * @returns the unmodified Color4
  73875. */
  73876. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73877. /**
  73878. * Creates a new Color4 from the string containing valid hexadecimal values
  73879. * @param hex defines a string containing valid hexadecimal values
  73880. * @returns a new Color4 object
  73881. */
  73882. static FromHexString(hex: string): Color4;
  73883. /**
  73884. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73885. * @param left defines the start value
  73886. * @param right defines the end value
  73887. * @param amount defines the gradient factor
  73888. * @returns a new Color4 object
  73889. */
  73890. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73891. /**
  73892. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73893. * @param left defines the start value
  73894. * @param right defines the end value
  73895. * @param amount defines the gradient factor
  73896. * @param result defines the Color4 object where to store data
  73897. */
  73898. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73899. /**
  73900. * Creates a new Color4 from a Color3 and an alpha value
  73901. * @param color3 defines the source Color3 to read from
  73902. * @param alpha defines the alpha component (1.0 by default)
  73903. * @returns a new Color4 object
  73904. */
  73905. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73906. /**
  73907. * Creates a new Color4 from the starting index element of the given array
  73908. * @param array defines the source array to read from
  73909. * @param offset defines the offset in the source array
  73910. * @returns a new Color4 object
  73911. */
  73912. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73913. /**
  73914. * Creates a new Color3 from integer values (< 256)
  73915. * @param r defines the red component to read from (value between 0 and 255)
  73916. * @param g defines the green component to read from (value between 0 and 255)
  73917. * @param b defines the blue component to read from (value between 0 and 255)
  73918. * @param a defines the alpha component to read from (value between 0 and 255)
  73919. * @returns a new Color3 object
  73920. */
  73921. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73922. /**
  73923. * Check the content of a given array and convert it to an array containing RGBA data
  73924. * If the original array was already containing count * 4 values then it is returned directly
  73925. * @param colors defines the array to check
  73926. * @param count defines the number of RGBA data to expect
  73927. * @returns an array containing count * 4 values (RGBA)
  73928. */
  73929. static CheckColors4(colors: number[], count: number): number[];
  73930. }
  73931. /**
  73932. * @hidden
  73933. */
  73934. export class TmpColors {
  73935. static Color3: Color3[];
  73936. static Color4: Color4[];
  73937. }
  73938. }
  73939. declare module BABYLON {
  73940. /**
  73941. * Defines an interface which represents an animation key frame
  73942. */
  73943. export interface IAnimationKey {
  73944. /**
  73945. * Frame of the key frame
  73946. */
  73947. frame: number;
  73948. /**
  73949. * Value at the specifies key frame
  73950. */
  73951. value: any;
  73952. /**
  73953. * The input tangent for the cubic hermite spline
  73954. */
  73955. inTangent?: any;
  73956. /**
  73957. * The output tangent for the cubic hermite spline
  73958. */
  73959. outTangent?: any;
  73960. /**
  73961. * The animation interpolation type
  73962. */
  73963. interpolation?: AnimationKeyInterpolation;
  73964. }
  73965. /**
  73966. * Enum for the animation key frame interpolation type
  73967. */
  73968. export enum AnimationKeyInterpolation {
  73969. /**
  73970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73971. */
  73972. STEP = 1
  73973. }
  73974. }
  73975. declare module BABYLON {
  73976. /**
  73977. * Represents the range of an animation
  73978. */
  73979. export class AnimationRange {
  73980. /**The name of the animation range**/
  73981. name: string;
  73982. /**The starting frame of the animation */
  73983. from: number;
  73984. /**The ending frame of the animation*/
  73985. to: number;
  73986. /**
  73987. * Initializes the range of an animation
  73988. * @param name The name of the animation range
  73989. * @param from The starting frame of the animation
  73990. * @param to The ending frame of the animation
  73991. */
  73992. constructor(
  73993. /**The name of the animation range**/
  73994. name: string,
  73995. /**The starting frame of the animation */
  73996. from: number,
  73997. /**The ending frame of the animation*/
  73998. to: number);
  73999. /**
  74000. * Makes a copy of the animation range
  74001. * @returns A copy of the animation range
  74002. */
  74003. clone(): AnimationRange;
  74004. }
  74005. }
  74006. declare module BABYLON {
  74007. /**
  74008. * Composed of a frame, and an action function
  74009. */
  74010. export class AnimationEvent {
  74011. /** The frame for which the event is triggered **/
  74012. frame: number;
  74013. /** The event to perform when triggered **/
  74014. action: (currentFrame: number) => void;
  74015. /** Specifies if the event should be triggered only once**/
  74016. onlyOnce?: boolean | undefined;
  74017. /**
  74018. * Specifies if the animation event is done
  74019. */
  74020. isDone: boolean;
  74021. /**
  74022. * Initializes the animation event
  74023. * @param frame The frame for which the event is triggered
  74024. * @param action The event to perform when triggered
  74025. * @param onlyOnce Specifies if the event should be triggered only once
  74026. */
  74027. constructor(
  74028. /** The frame for which the event is triggered **/
  74029. frame: number,
  74030. /** The event to perform when triggered **/
  74031. action: (currentFrame: number) => void,
  74032. /** Specifies if the event should be triggered only once**/
  74033. onlyOnce?: boolean | undefined);
  74034. /** @hidden */
  74035. _clone(): AnimationEvent;
  74036. }
  74037. }
  74038. declare module BABYLON {
  74039. /**
  74040. * Interface used to define a behavior
  74041. */
  74042. export interface Behavior<T> {
  74043. /** gets or sets behavior's name */
  74044. name: string;
  74045. /**
  74046. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74047. */
  74048. init(): void;
  74049. /**
  74050. * Called when the behavior is attached to a target
  74051. * @param target defines the target where the behavior is attached to
  74052. */
  74053. attach(target: T): void;
  74054. /**
  74055. * Called when the behavior is detached from its target
  74056. */
  74057. detach(): void;
  74058. }
  74059. /**
  74060. * Interface implemented by classes supporting behaviors
  74061. */
  74062. export interface IBehaviorAware<T> {
  74063. /**
  74064. * Attach a behavior
  74065. * @param behavior defines the behavior to attach
  74066. * @returns the current host
  74067. */
  74068. addBehavior(behavior: Behavior<T>): T;
  74069. /**
  74070. * Remove a behavior from the current object
  74071. * @param behavior defines the behavior to detach
  74072. * @returns the current host
  74073. */
  74074. removeBehavior(behavior: Behavior<T>): T;
  74075. /**
  74076. * Gets a behavior using its name to search
  74077. * @param name defines the name to search
  74078. * @returns the behavior or null if not found
  74079. */
  74080. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74081. }
  74082. }
  74083. declare module BABYLON {
  74084. /**
  74085. * Defines an array and its length.
  74086. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74087. */
  74088. export interface ISmartArrayLike<T> {
  74089. /**
  74090. * The data of the array.
  74091. */
  74092. data: Array<T>;
  74093. /**
  74094. * The active length of the array.
  74095. */
  74096. length: number;
  74097. }
  74098. /**
  74099. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74100. */
  74101. export class SmartArray<T> implements ISmartArrayLike<T> {
  74102. /**
  74103. * The full set of data from the array.
  74104. */
  74105. data: Array<T>;
  74106. /**
  74107. * The active length of the array.
  74108. */
  74109. length: number;
  74110. protected _id: number;
  74111. /**
  74112. * Instantiates a Smart Array.
  74113. * @param capacity defines the default capacity of the array.
  74114. */
  74115. constructor(capacity: number);
  74116. /**
  74117. * Pushes a value at the end of the active data.
  74118. * @param value defines the object to push in the array.
  74119. */
  74120. push(value: T): void;
  74121. /**
  74122. * Iterates over the active data and apply the lambda to them.
  74123. * @param func defines the action to apply on each value.
  74124. */
  74125. forEach(func: (content: T) => void): void;
  74126. /**
  74127. * Sorts the full sets of data.
  74128. * @param compareFn defines the comparison function to apply.
  74129. */
  74130. sort(compareFn: (a: T, b: T) => number): void;
  74131. /**
  74132. * Resets the active data to an empty array.
  74133. */
  74134. reset(): void;
  74135. /**
  74136. * Releases all the data from the array as well as the array.
  74137. */
  74138. dispose(): void;
  74139. /**
  74140. * Concats the active data with a given array.
  74141. * @param array defines the data to concatenate with.
  74142. */
  74143. concat(array: any): void;
  74144. /**
  74145. * Returns the position of a value in the active data.
  74146. * @param value defines the value to find the index for
  74147. * @returns the index if found in the active data otherwise -1
  74148. */
  74149. indexOf(value: T): number;
  74150. /**
  74151. * Returns whether an element is part of the active data.
  74152. * @param value defines the value to look for
  74153. * @returns true if found in the active data otherwise false
  74154. */
  74155. contains(value: T): boolean;
  74156. private static _GlobalId;
  74157. }
  74158. /**
  74159. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74160. * The data in this array can only be present once
  74161. */
  74162. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74163. private _duplicateId;
  74164. /**
  74165. * Pushes a value at the end of the active data.
  74166. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74167. * @param value defines the object to push in the array.
  74168. */
  74169. push(value: T): void;
  74170. /**
  74171. * Pushes a value at the end of the active data.
  74172. * If the data is already present, it won t be added again
  74173. * @param value defines the object to push in the array.
  74174. * @returns true if added false if it was already present
  74175. */
  74176. pushNoDuplicate(value: T): boolean;
  74177. /**
  74178. * Resets the active data to an empty array.
  74179. */
  74180. reset(): void;
  74181. /**
  74182. * Concats the active data with a given array.
  74183. * This ensures no dupplicate will be present in the result.
  74184. * @param array defines the data to concatenate with.
  74185. */
  74186. concatWithNoDuplicate(array: any): void;
  74187. }
  74188. }
  74189. declare module BABYLON {
  74190. /**
  74191. * @ignore
  74192. * This is a list of all the different input types that are available in the application.
  74193. * Fo instance: ArcRotateCameraGamepadInput...
  74194. */
  74195. export var CameraInputTypes: {};
  74196. /**
  74197. * This is the contract to implement in order to create a new input class.
  74198. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74199. */
  74200. export interface ICameraInput<TCamera extends Camera> {
  74201. /**
  74202. * Defines the camera the input is attached to.
  74203. */
  74204. camera: Nullable<TCamera>;
  74205. /**
  74206. * Gets the class name of the current intput.
  74207. * @returns the class name
  74208. */
  74209. getClassName(): string;
  74210. /**
  74211. * Get the friendly name associated with the input class.
  74212. * @returns the input friendly name
  74213. */
  74214. getSimpleName(): string;
  74215. /**
  74216. * Attach the input controls to a specific dom element to get the input from.
  74217. * @param element Defines the element the controls should be listened from
  74218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74219. */
  74220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74221. /**
  74222. * Detach the current controls from the specified dom element.
  74223. * @param element Defines the element to stop listening the inputs from
  74224. */
  74225. detachControl(element: Nullable<HTMLElement>): void;
  74226. /**
  74227. * Update the current camera state depending on the inputs that have been used this frame.
  74228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74229. */
  74230. checkInputs?: () => void;
  74231. }
  74232. /**
  74233. * Represents a map of input types to input instance or input index to input instance.
  74234. */
  74235. export interface CameraInputsMap<TCamera extends Camera> {
  74236. /**
  74237. * Accessor to the input by input type.
  74238. */
  74239. [name: string]: ICameraInput<TCamera>;
  74240. /**
  74241. * Accessor to the input by input index.
  74242. */
  74243. [idx: number]: ICameraInput<TCamera>;
  74244. }
  74245. /**
  74246. * This represents the input manager used within a camera.
  74247. * It helps dealing with all the different kind of input attached to a camera.
  74248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74249. */
  74250. export class CameraInputsManager<TCamera extends Camera> {
  74251. /**
  74252. * Defines the list of inputs attahed to the camera.
  74253. */
  74254. attached: CameraInputsMap<TCamera>;
  74255. /**
  74256. * Defines the dom element the camera is collecting inputs from.
  74257. * This is null if the controls have not been attached.
  74258. */
  74259. attachedElement: Nullable<HTMLElement>;
  74260. /**
  74261. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74262. */
  74263. noPreventDefault: boolean;
  74264. /**
  74265. * Defined the camera the input manager belongs to.
  74266. */
  74267. camera: TCamera;
  74268. /**
  74269. * Update the current camera state depending on the inputs that have been used this frame.
  74270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74271. */
  74272. checkInputs: () => void;
  74273. /**
  74274. * Instantiate a new Camera Input Manager.
  74275. * @param camera Defines the camera the input manager blongs to
  74276. */
  74277. constructor(camera: TCamera);
  74278. /**
  74279. * Add an input method to a camera
  74280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74281. * @param input camera input method
  74282. */
  74283. add(input: ICameraInput<TCamera>): void;
  74284. /**
  74285. * Remove a specific input method from a camera
  74286. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74287. * @param inputToRemove camera input method
  74288. */
  74289. remove(inputToRemove: ICameraInput<TCamera>): void;
  74290. /**
  74291. * Remove a specific input type from a camera
  74292. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74293. * @param inputType the type of the input to remove
  74294. */
  74295. removeByType(inputType: string): void;
  74296. private _addCheckInputs;
  74297. /**
  74298. * Attach the input controls to the currently attached dom element to listen the events from.
  74299. * @param input Defines the input to attach
  74300. */
  74301. attachInput(input: ICameraInput<TCamera>): void;
  74302. /**
  74303. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74304. * @param element Defines the dom element to collect the events from
  74305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74306. */
  74307. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74308. /**
  74309. * Detach the current manager inputs controls from a specific dom element.
  74310. * @param element Defines the dom element to collect the events from
  74311. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74312. */
  74313. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74314. /**
  74315. * Rebuild the dynamic inputCheck function from the current list of
  74316. * defined inputs in the manager.
  74317. */
  74318. rebuildInputCheck(): void;
  74319. /**
  74320. * Remove all attached input methods from a camera
  74321. */
  74322. clear(): void;
  74323. /**
  74324. * Serialize the current input manager attached to a camera.
  74325. * This ensures than once parsed,
  74326. * the input associated to the camera will be identical to the current ones
  74327. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74328. */
  74329. serialize(serializedCamera: any): void;
  74330. /**
  74331. * Parses an input manager serialized JSON to restore the previous list of inputs
  74332. * and states associated to a camera.
  74333. * @param parsedCamera Defines the JSON to parse
  74334. */
  74335. parse(parsedCamera: any): void;
  74336. }
  74337. }
  74338. declare module BABYLON {
  74339. /**
  74340. * Class used to store data that will be store in GPU memory
  74341. */
  74342. export class Buffer {
  74343. private _engine;
  74344. private _buffer;
  74345. /** @hidden */
  74346. _data: Nullable<DataArray>;
  74347. private _updatable;
  74348. private _instanced;
  74349. private _divisor;
  74350. /**
  74351. * Gets the byte stride.
  74352. */
  74353. readonly byteStride: number;
  74354. /**
  74355. * Constructor
  74356. * @param engine the engine
  74357. * @param data the data to use for this buffer
  74358. * @param updatable whether the data is updatable
  74359. * @param stride the stride (optional)
  74360. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74361. * @param instanced whether the buffer is instanced (optional)
  74362. * @param useBytes set to true if the stride in in bytes (optional)
  74363. * @param divisor sets an optional divisor for instances (1 by default)
  74364. */
  74365. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74366. /**
  74367. * Create a new VertexBuffer based on the current buffer
  74368. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74369. * @param offset defines offset in the buffer (0 by default)
  74370. * @param size defines the size in floats of attributes (position is 3 for instance)
  74371. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74372. * @param instanced defines if the vertex buffer contains indexed data
  74373. * @param useBytes defines if the offset and stride are in bytes *
  74374. * @param divisor sets an optional divisor for instances (1 by default)
  74375. * @returns the new vertex buffer
  74376. */
  74377. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74378. /**
  74379. * Gets a boolean indicating if the Buffer is updatable?
  74380. * @returns true if the buffer is updatable
  74381. */
  74382. isUpdatable(): boolean;
  74383. /**
  74384. * Gets current buffer's data
  74385. * @returns a DataArray or null
  74386. */
  74387. getData(): Nullable<DataArray>;
  74388. /**
  74389. * Gets underlying native buffer
  74390. * @returns underlying native buffer
  74391. */
  74392. getBuffer(): Nullable<DataBuffer>;
  74393. /**
  74394. * Gets the stride in float32 units (i.e. byte stride / 4).
  74395. * May not be an integer if the byte stride is not divisible by 4.
  74396. * DEPRECATED. Use byteStride instead.
  74397. * @returns the stride in float32 units
  74398. */
  74399. getStrideSize(): number;
  74400. /**
  74401. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74402. * @param data defines the data to store
  74403. */
  74404. create(data?: Nullable<DataArray>): void;
  74405. /** @hidden */
  74406. _rebuild(): void;
  74407. /**
  74408. * Update current buffer data
  74409. * @param data defines the data to store
  74410. */
  74411. update(data: DataArray): void;
  74412. /**
  74413. * Updates the data directly.
  74414. * @param data the new data
  74415. * @param offset the new offset
  74416. * @param vertexCount the vertex count (optional)
  74417. * @param useBytes set to true if the offset is in bytes
  74418. */
  74419. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74420. /**
  74421. * Release all resources
  74422. */
  74423. dispose(): void;
  74424. }
  74425. /**
  74426. * Specialized buffer used to store vertex data
  74427. */
  74428. export class VertexBuffer {
  74429. /** @hidden */
  74430. _buffer: Buffer;
  74431. private _kind;
  74432. private _size;
  74433. private _ownsBuffer;
  74434. private _instanced;
  74435. private _instanceDivisor;
  74436. /**
  74437. * The byte type.
  74438. */
  74439. static readonly BYTE: number;
  74440. /**
  74441. * The unsigned byte type.
  74442. */
  74443. static readonly UNSIGNED_BYTE: number;
  74444. /**
  74445. * The short type.
  74446. */
  74447. static readonly SHORT: number;
  74448. /**
  74449. * The unsigned short type.
  74450. */
  74451. static readonly UNSIGNED_SHORT: number;
  74452. /**
  74453. * The integer type.
  74454. */
  74455. static readonly INT: number;
  74456. /**
  74457. * The unsigned integer type.
  74458. */
  74459. static readonly UNSIGNED_INT: number;
  74460. /**
  74461. * The float type.
  74462. */
  74463. static readonly FLOAT: number;
  74464. /**
  74465. * Gets or sets the instance divisor when in instanced mode
  74466. */
  74467. instanceDivisor: number;
  74468. /**
  74469. * Gets the byte stride.
  74470. */
  74471. readonly byteStride: number;
  74472. /**
  74473. * Gets the byte offset.
  74474. */
  74475. readonly byteOffset: number;
  74476. /**
  74477. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74478. */
  74479. readonly normalized: boolean;
  74480. /**
  74481. * Gets the data type of each component in the array.
  74482. */
  74483. readonly type: number;
  74484. /**
  74485. * Constructor
  74486. * @param engine the engine
  74487. * @param data the data to use for this vertex buffer
  74488. * @param kind the vertex buffer kind
  74489. * @param updatable whether the data is updatable
  74490. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74491. * @param stride the stride (optional)
  74492. * @param instanced whether the buffer is instanced (optional)
  74493. * @param offset the offset of the data (optional)
  74494. * @param size the number of components (optional)
  74495. * @param type the type of the component (optional)
  74496. * @param normalized whether the data contains normalized data (optional)
  74497. * @param useBytes set to true if stride and offset are in bytes (optional)
  74498. * @param divisor defines the instance divisor to use (1 by default)
  74499. */
  74500. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  74501. /** @hidden */
  74502. _rebuild(): void;
  74503. /**
  74504. * Returns the kind of the VertexBuffer (string)
  74505. * @returns a string
  74506. */
  74507. getKind(): string;
  74508. /**
  74509. * Gets a boolean indicating if the VertexBuffer is updatable?
  74510. * @returns true if the buffer is updatable
  74511. */
  74512. isUpdatable(): boolean;
  74513. /**
  74514. * Gets current buffer's data
  74515. * @returns a DataArray or null
  74516. */
  74517. getData(): Nullable<DataArray>;
  74518. /**
  74519. * Gets underlying native buffer
  74520. * @returns underlying native buffer
  74521. */
  74522. getBuffer(): Nullable<DataBuffer>;
  74523. /**
  74524. * Gets the stride in float32 units (i.e. byte stride / 4).
  74525. * May not be an integer if the byte stride is not divisible by 4.
  74526. * DEPRECATED. Use byteStride instead.
  74527. * @returns the stride in float32 units
  74528. */
  74529. getStrideSize(): number;
  74530. /**
  74531. * Returns the offset as a multiple of the type byte length.
  74532. * DEPRECATED. Use byteOffset instead.
  74533. * @returns the offset in bytes
  74534. */
  74535. getOffset(): number;
  74536. /**
  74537. * Returns the number of components per vertex attribute (integer)
  74538. * @returns the size in float
  74539. */
  74540. getSize(): number;
  74541. /**
  74542. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74543. * @returns true if this buffer is instanced
  74544. */
  74545. getIsInstanced(): boolean;
  74546. /**
  74547. * Returns the instancing divisor, zero for non-instanced (integer).
  74548. * @returns a number
  74549. */
  74550. getInstanceDivisor(): number;
  74551. /**
  74552. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74553. * @param data defines the data to store
  74554. */
  74555. create(data?: DataArray): void;
  74556. /**
  74557. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74558. * This function will create a new buffer if the current one is not updatable
  74559. * @param data defines the data to store
  74560. */
  74561. update(data: DataArray): void;
  74562. /**
  74563. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74564. * Returns the directly updated WebGLBuffer.
  74565. * @param data the new data
  74566. * @param offset the new offset
  74567. * @param useBytes set to true if the offset is in bytes
  74568. */
  74569. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74570. /**
  74571. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74572. */
  74573. dispose(): void;
  74574. /**
  74575. * Enumerates each value of this vertex buffer as numbers.
  74576. * @param count the number of values to enumerate
  74577. * @param callback the callback function called for each value
  74578. */
  74579. forEach(count: number, callback: (value: number, index: number) => void): void;
  74580. /**
  74581. * Positions
  74582. */
  74583. static readonly PositionKind: string;
  74584. /**
  74585. * Normals
  74586. */
  74587. static readonly NormalKind: string;
  74588. /**
  74589. * Tangents
  74590. */
  74591. static readonly TangentKind: string;
  74592. /**
  74593. * Texture coordinates
  74594. */
  74595. static readonly UVKind: string;
  74596. /**
  74597. * Texture coordinates 2
  74598. */
  74599. static readonly UV2Kind: string;
  74600. /**
  74601. * Texture coordinates 3
  74602. */
  74603. static readonly UV3Kind: string;
  74604. /**
  74605. * Texture coordinates 4
  74606. */
  74607. static readonly UV4Kind: string;
  74608. /**
  74609. * Texture coordinates 5
  74610. */
  74611. static readonly UV5Kind: string;
  74612. /**
  74613. * Texture coordinates 6
  74614. */
  74615. static readonly UV6Kind: string;
  74616. /**
  74617. * Colors
  74618. */
  74619. static readonly ColorKind: string;
  74620. /**
  74621. * Matrix indices (for bones)
  74622. */
  74623. static readonly MatricesIndicesKind: string;
  74624. /**
  74625. * Matrix weights (for bones)
  74626. */
  74627. static readonly MatricesWeightsKind: string;
  74628. /**
  74629. * Additional matrix indices (for bones)
  74630. */
  74631. static readonly MatricesIndicesExtraKind: string;
  74632. /**
  74633. * Additional matrix weights (for bones)
  74634. */
  74635. static readonly MatricesWeightsExtraKind: string;
  74636. /**
  74637. * Deduces the stride given a kind.
  74638. * @param kind The kind string to deduce
  74639. * @returns The deduced stride
  74640. */
  74641. static DeduceStride(kind: string): number;
  74642. /**
  74643. * Gets the byte length of the given type.
  74644. * @param type the type
  74645. * @returns the number of bytes
  74646. */
  74647. static GetTypeByteLength(type: number): number;
  74648. /**
  74649. * Enumerates each value of the given parameters as numbers.
  74650. * @param data the data to enumerate
  74651. * @param byteOffset the byte offset of the data
  74652. * @param byteStride the byte stride of the data
  74653. * @param componentCount the number of components per element
  74654. * @param componentType the type of the component
  74655. * @param count the number of values to enumerate
  74656. * @param normalized whether the data is normalized
  74657. * @param callback the callback function called for each value
  74658. */
  74659. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74660. private static _GetFloatValue;
  74661. }
  74662. }
  74663. declare module BABYLON {
  74664. /**
  74665. * @hidden
  74666. */
  74667. export class IntersectionInfo {
  74668. bu: Nullable<number>;
  74669. bv: Nullable<number>;
  74670. distance: number;
  74671. faceId: number;
  74672. subMeshId: number;
  74673. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74674. }
  74675. }
  74676. declare module BABYLON {
  74677. /**
  74678. * Represens a plane by the equation ax + by + cz + d = 0
  74679. */
  74680. export class Plane {
  74681. private static _TmpMatrix;
  74682. /**
  74683. * Normal of the plane (a,b,c)
  74684. */
  74685. normal: Vector3;
  74686. /**
  74687. * d component of the plane
  74688. */
  74689. d: number;
  74690. /**
  74691. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74692. * @param a a component of the plane
  74693. * @param b b component of the plane
  74694. * @param c c component of the plane
  74695. * @param d d component of the plane
  74696. */
  74697. constructor(a: number, b: number, c: number, d: number);
  74698. /**
  74699. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74700. */
  74701. asArray(): number[];
  74702. /**
  74703. * @returns a new plane copied from the current Plane.
  74704. */
  74705. clone(): Plane;
  74706. /**
  74707. * @returns the string "Plane".
  74708. */
  74709. getClassName(): string;
  74710. /**
  74711. * @returns the Plane hash code.
  74712. */
  74713. getHashCode(): number;
  74714. /**
  74715. * Normalize the current Plane in place.
  74716. * @returns the updated Plane.
  74717. */
  74718. normalize(): Plane;
  74719. /**
  74720. * Applies a transformation the plane and returns the result
  74721. * @param transformation the transformation matrix to be applied to the plane
  74722. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74723. */
  74724. transform(transformation: DeepImmutable<Matrix>): Plane;
  74725. /**
  74726. * Calcualtte the dot product between the point and the plane normal
  74727. * @param point point to calculate the dot product with
  74728. * @returns the dot product (float) of the point coordinates and the plane normal.
  74729. */
  74730. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74731. /**
  74732. * Updates the current Plane from the plane defined by the three given points.
  74733. * @param point1 one of the points used to contruct the plane
  74734. * @param point2 one of the points used to contruct the plane
  74735. * @param point3 one of the points used to contruct the plane
  74736. * @returns the updated Plane.
  74737. */
  74738. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74739. /**
  74740. * Checks if the plane is facing a given direction
  74741. * @param direction the direction to check if the plane is facing
  74742. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74743. * @returns True is the vector "direction" is the same side than the plane normal.
  74744. */
  74745. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74746. /**
  74747. * Calculates the distance to a point
  74748. * @param point point to calculate distance to
  74749. * @returns the signed distance (float) from the given point to the Plane.
  74750. */
  74751. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74752. /**
  74753. * Creates a plane from an array
  74754. * @param array the array to create a plane from
  74755. * @returns a new Plane from the given array.
  74756. */
  74757. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74758. /**
  74759. * Creates a plane from three points
  74760. * @param point1 point used to create the plane
  74761. * @param point2 point used to create the plane
  74762. * @param point3 point used to create the plane
  74763. * @returns a new Plane defined by the three given points.
  74764. */
  74765. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74766. /**
  74767. * Creates a plane from an origin point and a normal
  74768. * @param origin origin of the plane to be constructed
  74769. * @param normal normal of the plane to be constructed
  74770. * @returns a new Plane the normal vector to this plane at the given origin point.
  74771. * Note : the vector "normal" is updated because normalized.
  74772. */
  74773. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74774. /**
  74775. * Calculates the distance from a plane and a point
  74776. * @param origin origin of the plane to be constructed
  74777. * @param normal normal of the plane to be constructed
  74778. * @param point point to calculate distance to
  74779. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74780. */
  74781. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74782. }
  74783. }
  74784. declare module BABYLON {
  74785. /**
  74786. * Class used to store bounding sphere information
  74787. */
  74788. export class BoundingSphere {
  74789. /**
  74790. * Gets the center of the bounding sphere in local space
  74791. */
  74792. readonly center: Vector3;
  74793. /**
  74794. * Radius of the bounding sphere in local space
  74795. */
  74796. radius: number;
  74797. /**
  74798. * Gets the center of the bounding sphere in world space
  74799. */
  74800. readonly centerWorld: Vector3;
  74801. /**
  74802. * Radius of the bounding sphere in world space
  74803. */
  74804. radiusWorld: number;
  74805. /**
  74806. * Gets the minimum vector in local space
  74807. */
  74808. readonly minimum: Vector3;
  74809. /**
  74810. * Gets the maximum vector in local space
  74811. */
  74812. readonly maximum: Vector3;
  74813. private _worldMatrix;
  74814. private static readonly TmpVector3;
  74815. /**
  74816. * Creates a new bounding sphere
  74817. * @param min defines the minimum vector (in local space)
  74818. * @param max defines the maximum vector (in local space)
  74819. * @param worldMatrix defines the new world matrix
  74820. */
  74821. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74822. /**
  74823. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74824. * @param min defines the new minimum vector (in local space)
  74825. * @param max defines the new maximum vector (in local space)
  74826. * @param worldMatrix defines the new world matrix
  74827. */
  74828. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74829. /**
  74830. * Scale the current bounding sphere by applying a scale factor
  74831. * @param factor defines the scale factor to apply
  74832. * @returns the current bounding box
  74833. */
  74834. scale(factor: number): BoundingSphere;
  74835. /**
  74836. * Gets the world matrix of the bounding box
  74837. * @returns a matrix
  74838. */
  74839. getWorldMatrix(): DeepImmutable<Matrix>;
  74840. /** @hidden */
  74841. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74842. /**
  74843. * Tests if the bounding sphere is intersecting the frustum planes
  74844. * @param frustumPlanes defines the frustum planes to test
  74845. * @returns true if there is an intersection
  74846. */
  74847. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74848. /**
  74849. * Tests if the bounding sphere center is in between the frustum planes.
  74850. * Used for optimistic fast inclusion.
  74851. * @param frustumPlanes defines the frustum planes to test
  74852. * @returns true if the sphere center is in between the frustum planes
  74853. */
  74854. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74855. /**
  74856. * Tests if a point is inside the bounding sphere
  74857. * @param point defines the point to test
  74858. * @returns true if the point is inside the bounding sphere
  74859. */
  74860. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74861. /**
  74862. * Checks if two sphere intersct
  74863. * @param sphere0 sphere 0
  74864. * @param sphere1 sphere 1
  74865. * @returns true if the speres intersect
  74866. */
  74867. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74868. }
  74869. }
  74870. declare module BABYLON {
  74871. /**
  74872. * Class used to store bounding box information
  74873. */
  74874. export class BoundingBox implements ICullable {
  74875. /**
  74876. * Gets the 8 vectors representing the bounding box in local space
  74877. */
  74878. readonly vectors: Vector3[];
  74879. /**
  74880. * Gets the center of the bounding box in local space
  74881. */
  74882. readonly center: Vector3;
  74883. /**
  74884. * Gets the center of the bounding box in world space
  74885. */
  74886. readonly centerWorld: Vector3;
  74887. /**
  74888. * Gets the extend size in local space
  74889. */
  74890. readonly extendSize: Vector3;
  74891. /**
  74892. * Gets the extend size in world space
  74893. */
  74894. readonly extendSizeWorld: Vector3;
  74895. /**
  74896. * Gets the OBB (object bounding box) directions
  74897. */
  74898. readonly directions: Vector3[];
  74899. /**
  74900. * Gets the 8 vectors representing the bounding box in world space
  74901. */
  74902. readonly vectorsWorld: Vector3[];
  74903. /**
  74904. * Gets the minimum vector in world space
  74905. */
  74906. readonly minimumWorld: Vector3;
  74907. /**
  74908. * Gets the maximum vector in world space
  74909. */
  74910. readonly maximumWorld: Vector3;
  74911. /**
  74912. * Gets the minimum vector in local space
  74913. */
  74914. readonly minimum: Vector3;
  74915. /**
  74916. * Gets the maximum vector in local space
  74917. */
  74918. readonly maximum: Vector3;
  74919. private _worldMatrix;
  74920. private static readonly TmpVector3;
  74921. /**
  74922. * @hidden
  74923. */
  74924. _tag: number;
  74925. /**
  74926. * Creates a new bounding box
  74927. * @param min defines the minimum vector (in local space)
  74928. * @param max defines the maximum vector (in local space)
  74929. * @param worldMatrix defines the new world matrix
  74930. */
  74931. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74932. /**
  74933. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74934. * @param min defines the new minimum vector (in local space)
  74935. * @param max defines the new maximum vector (in local space)
  74936. * @param worldMatrix defines the new world matrix
  74937. */
  74938. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74939. /**
  74940. * Scale the current bounding box by applying a scale factor
  74941. * @param factor defines the scale factor to apply
  74942. * @returns the current bounding box
  74943. */
  74944. scale(factor: number): BoundingBox;
  74945. /**
  74946. * Gets the world matrix of the bounding box
  74947. * @returns a matrix
  74948. */
  74949. getWorldMatrix(): DeepImmutable<Matrix>;
  74950. /** @hidden */
  74951. _update(world: DeepImmutable<Matrix>): void;
  74952. /**
  74953. * Tests if the bounding box is intersecting the frustum planes
  74954. * @param frustumPlanes defines the frustum planes to test
  74955. * @returns true if there is an intersection
  74956. */
  74957. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74958. /**
  74959. * Tests if the bounding box is entirely inside the frustum planes
  74960. * @param frustumPlanes defines the frustum planes to test
  74961. * @returns true if there is an inclusion
  74962. */
  74963. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74964. /**
  74965. * Tests if a point is inside the bounding box
  74966. * @param point defines the point to test
  74967. * @returns true if the point is inside the bounding box
  74968. */
  74969. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74970. /**
  74971. * Tests if the bounding box intersects with a bounding sphere
  74972. * @param sphere defines the sphere to test
  74973. * @returns true if there is an intersection
  74974. */
  74975. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74976. /**
  74977. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74978. * @param min defines the min vector to use
  74979. * @param max defines the max vector to use
  74980. * @returns true if there is an intersection
  74981. */
  74982. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74983. /**
  74984. * Tests if two bounding boxes are intersections
  74985. * @param box0 defines the first box to test
  74986. * @param box1 defines the second box to test
  74987. * @returns true if there is an intersection
  74988. */
  74989. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74990. /**
  74991. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74992. * @param minPoint defines the minimum vector of the bounding box
  74993. * @param maxPoint defines the maximum vector of the bounding box
  74994. * @param sphereCenter defines the sphere center
  74995. * @param sphereRadius defines the sphere radius
  74996. * @returns true if there is an intersection
  74997. */
  74998. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74999. /**
  75000. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75001. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75002. * @param frustumPlanes defines the frustum planes to test
  75003. * @return true if there is an inclusion
  75004. */
  75005. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75006. /**
  75007. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75009. * @param frustumPlanes defines the frustum planes to test
  75010. * @return true if there is an intersection
  75011. */
  75012. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75013. }
  75014. }
  75015. declare module BABYLON {
  75016. /** @hidden */
  75017. export class Collider {
  75018. /** Define if a collision was found */
  75019. collisionFound: boolean;
  75020. /**
  75021. * Define last intersection point in local space
  75022. */
  75023. intersectionPoint: Vector3;
  75024. /**
  75025. * Define last collided mesh
  75026. */
  75027. collidedMesh: Nullable<AbstractMesh>;
  75028. private _collisionPoint;
  75029. private _planeIntersectionPoint;
  75030. private _tempVector;
  75031. private _tempVector2;
  75032. private _tempVector3;
  75033. private _tempVector4;
  75034. private _edge;
  75035. private _baseToVertex;
  75036. private _destinationPoint;
  75037. private _slidePlaneNormal;
  75038. private _displacementVector;
  75039. /** @hidden */
  75040. _radius: Vector3;
  75041. /** @hidden */
  75042. _retry: number;
  75043. private _velocity;
  75044. private _basePoint;
  75045. private _epsilon;
  75046. /** @hidden */
  75047. _velocityWorldLength: number;
  75048. /** @hidden */
  75049. _basePointWorld: Vector3;
  75050. private _velocityWorld;
  75051. private _normalizedVelocity;
  75052. /** @hidden */
  75053. _initialVelocity: Vector3;
  75054. /** @hidden */
  75055. _initialPosition: Vector3;
  75056. private _nearestDistance;
  75057. private _collisionMask;
  75058. collisionMask: number;
  75059. /**
  75060. * Gets the plane normal used to compute the sliding response (in local space)
  75061. */
  75062. readonly slidePlaneNormal: Vector3;
  75063. /** @hidden */
  75064. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75065. /** @hidden */
  75066. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75067. /** @hidden */
  75068. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75069. /** @hidden */
  75070. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75071. /** @hidden */
  75072. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75073. /** @hidden */
  75074. _getResponse(pos: Vector3, vel: Vector3): void;
  75075. }
  75076. }
  75077. declare module BABYLON {
  75078. /**
  75079. * Interface for cullable objects
  75080. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75081. */
  75082. export interface ICullable {
  75083. /**
  75084. * Checks if the object or part of the object is in the frustum
  75085. * @param frustumPlanes Camera near/planes
  75086. * @returns true if the object is in frustum otherwise false
  75087. */
  75088. isInFrustum(frustumPlanes: Plane[]): boolean;
  75089. /**
  75090. * Checks if a cullable object (mesh...) is in the camera frustum
  75091. * Unlike isInFrustum this cheks the full bounding box
  75092. * @param frustumPlanes Camera near/planes
  75093. * @returns true if the object is in frustum otherwise false
  75094. */
  75095. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75096. }
  75097. /**
  75098. * Info for a bounding data of a mesh
  75099. */
  75100. export class BoundingInfo implements ICullable {
  75101. /**
  75102. * Bounding box for the mesh
  75103. */
  75104. readonly boundingBox: BoundingBox;
  75105. /**
  75106. * Bounding sphere for the mesh
  75107. */
  75108. readonly boundingSphere: BoundingSphere;
  75109. private _isLocked;
  75110. private static readonly TmpVector3;
  75111. /**
  75112. * Constructs bounding info
  75113. * @param minimum min vector of the bounding box/sphere
  75114. * @param maximum max vector of the bounding box/sphere
  75115. * @param worldMatrix defines the new world matrix
  75116. */
  75117. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75118. /**
  75119. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75120. * @param min defines the new minimum vector (in local space)
  75121. * @param max defines the new maximum vector (in local space)
  75122. * @param worldMatrix defines the new world matrix
  75123. */
  75124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75125. /**
  75126. * min vector of the bounding box/sphere
  75127. */
  75128. readonly minimum: Vector3;
  75129. /**
  75130. * max vector of the bounding box/sphere
  75131. */
  75132. readonly maximum: Vector3;
  75133. /**
  75134. * If the info is locked and won't be updated to avoid perf overhead
  75135. */
  75136. isLocked: boolean;
  75137. /**
  75138. * Updates the bounding sphere and box
  75139. * @param world world matrix to be used to update
  75140. */
  75141. update(world: DeepImmutable<Matrix>): void;
  75142. /**
  75143. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75144. * @param center New center of the bounding info
  75145. * @param extend New extend of the bounding info
  75146. * @returns the current bounding info
  75147. */
  75148. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75149. /**
  75150. * Scale the current bounding info by applying a scale factor
  75151. * @param factor defines the scale factor to apply
  75152. * @returns the current bounding info
  75153. */
  75154. scale(factor: number): BoundingInfo;
  75155. /**
  75156. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75157. * @param frustumPlanes defines the frustum to test
  75158. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75159. * @returns true if the bounding info is in the frustum planes
  75160. */
  75161. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75162. /**
  75163. * Gets the world distance between the min and max points of the bounding box
  75164. */
  75165. readonly diagonalLength: number;
  75166. /**
  75167. * Checks if a cullable object (mesh...) is in the camera frustum
  75168. * Unlike isInFrustum this cheks the full bounding box
  75169. * @param frustumPlanes Camera near/planes
  75170. * @returns true if the object is in frustum otherwise false
  75171. */
  75172. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75173. /** @hidden */
  75174. _checkCollision(collider: Collider): boolean;
  75175. /**
  75176. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75177. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75178. * @param point the point to check intersection with
  75179. * @returns if the point intersects
  75180. */
  75181. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75182. /**
  75183. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75185. * @param boundingInfo the bounding info to check intersection with
  75186. * @param precise if the intersection should be done using OBB
  75187. * @returns if the bounding info intersects
  75188. */
  75189. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75190. }
  75191. }
  75192. declare module BABYLON {
  75193. /**
  75194. * Extracts minimum and maximum values from a list of indexed positions
  75195. * @param positions defines the positions to use
  75196. * @param indices defines the indices to the positions
  75197. * @param indexStart defines the start index
  75198. * @param indexCount defines the end index
  75199. * @param bias defines bias value to add to the result
  75200. * @return minimum and maximum values
  75201. */
  75202. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75203. minimum: Vector3;
  75204. maximum: Vector3;
  75205. };
  75206. /**
  75207. * Extracts minimum and maximum values from a list of positions
  75208. * @param positions defines the positions to use
  75209. * @param start defines the start index in the positions array
  75210. * @param count defines the number of positions to handle
  75211. * @param bias defines bias value to add to the result
  75212. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75213. * @return minimum and maximum values
  75214. */
  75215. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75216. minimum: Vector3;
  75217. maximum: Vector3;
  75218. };
  75219. }
  75220. declare module BABYLON {
  75221. /** @hidden */
  75222. export class WebGLDataBuffer extends DataBuffer {
  75223. private _buffer;
  75224. constructor(resource: WebGLBuffer);
  75225. readonly underlyingResource: any;
  75226. }
  75227. }
  75228. declare module BABYLON {
  75229. /** @hidden */
  75230. export class WebGLPipelineContext implements IPipelineContext {
  75231. engine: ThinEngine;
  75232. program: Nullable<WebGLProgram>;
  75233. context?: WebGLRenderingContext;
  75234. vertexShader?: WebGLShader;
  75235. fragmentShader?: WebGLShader;
  75236. isParallelCompiled: boolean;
  75237. onCompiled?: () => void;
  75238. transformFeedback?: WebGLTransformFeedback | null;
  75239. readonly isAsync: boolean;
  75240. readonly isReady: boolean;
  75241. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75242. }
  75243. }
  75244. declare module BABYLON {
  75245. interface ThinEngine {
  75246. /**
  75247. * Create an uniform buffer
  75248. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75249. * @param elements defines the content of the uniform buffer
  75250. * @returns the webGL uniform buffer
  75251. */
  75252. createUniformBuffer(elements: FloatArray): DataBuffer;
  75253. /**
  75254. * Create a dynamic uniform buffer
  75255. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75256. * @param elements defines the content of the uniform buffer
  75257. * @returns the webGL uniform buffer
  75258. */
  75259. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75260. /**
  75261. * Update an existing uniform buffer
  75262. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75263. * @param uniformBuffer defines the target uniform buffer
  75264. * @param elements defines the content to update
  75265. * @param offset defines the offset in the uniform buffer where update should start
  75266. * @param count defines the size of the data to update
  75267. */
  75268. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75269. /**
  75270. * Bind an uniform buffer to the current webGL context
  75271. * @param buffer defines the buffer to bind
  75272. */
  75273. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75274. /**
  75275. * Bind a buffer to the current webGL context at a given location
  75276. * @param buffer defines the buffer to bind
  75277. * @param location defines the index where to bind the buffer
  75278. */
  75279. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75280. /**
  75281. * Bind a specific block at a given index in a specific shader program
  75282. * @param pipelineContext defines the pipeline context to use
  75283. * @param blockName defines the block name
  75284. * @param index defines the index where to bind the block
  75285. */
  75286. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75287. }
  75288. }
  75289. declare module BABYLON {
  75290. /**
  75291. * Uniform buffer objects.
  75292. *
  75293. * Handles blocks of uniform on the GPU.
  75294. *
  75295. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75296. *
  75297. * For more information, please refer to :
  75298. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75299. */
  75300. export class UniformBuffer {
  75301. private _engine;
  75302. private _buffer;
  75303. private _data;
  75304. private _bufferData;
  75305. private _dynamic?;
  75306. private _uniformLocations;
  75307. private _uniformSizes;
  75308. private _uniformLocationPointer;
  75309. private _needSync;
  75310. private _noUBO;
  75311. private _currentEffect;
  75312. /** @hidden */
  75313. _alreadyBound: boolean;
  75314. private static _MAX_UNIFORM_SIZE;
  75315. private static _tempBuffer;
  75316. /**
  75317. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75318. * This is dynamic to allow compat with webgl 1 and 2.
  75319. * You will need to pass the name of the uniform as well as the value.
  75320. */
  75321. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75322. /**
  75323. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75324. * This is dynamic to allow compat with webgl 1 and 2.
  75325. * You will need to pass the name of the uniform as well as the value.
  75326. */
  75327. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75328. /**
  75329. * Lambda to Update a single float in a uniform buffer.
  75330. * This is dynamic to allow compat with webgl 1 and 2.
  75331. * You will need to pass the name of the uniform as well as the value.
  75332. */
  75333. updateFloat: (name: string, x: number) => void;
  75334. /**
  75335. * Lambda to Update a vec2 of float in a uniform buffer.
  75336. * This is dynamic to allow compat with webgl 1 and 2.
  75337. * You will need to pass the name of the uniform as well as the value.
  75338. */
  75339. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75340. /**
  75341. * Lambda to Update a vec3 of float in a uniform buffer.
  75342. * This is dynamic to allow compat with webgl 1 and 2.
  75343. * You will need to pass the name of the uniform as well as the value.
  75344. */
  75345. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75346. /**
  75347. * Lambda to Update a vec4 of float in a uniform buffer.
  75348. * This is dynamic to allow compat with webgl 1 and 2.
  75349. * You will need to pass the name of the uniform as well as the value.
  75350. */
  75351. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75352. /**
  75353. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75354. * This is dynamic to allow compat with webgl 1 and 2.
  75355. * You will need to pass the name of the uniform as well as the value.
  75356. */
  75357. updateMatrix: (name: string, mat: Matrix) => void;
  75358. /**
  75359. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75360. * This is dynamic to allow compat with webgl 1 and 2.
  75361. * You will need to pass the name of the uniform as well as the value.
  75362. */
  75363. updateVector3: (name: string, vector: Vector3) => void;
  75364. /**
  75365. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75366. * This is dynamic to allow compat with webgl 1 and 2.
  75367. * You will need to pass the name of the uniform as well as the value.
  75368. */
  75369. updateVector4: (name: string, vector: Vector4) => void;
  75370. /**
  75371. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75372. * This is dynamic to allow compat with webgl 1 and 2.
  75373. * You will need to pass the name of the uniform as well as the value.
  75374. */
  75375. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75376. /**
  75377. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75378. * This is dynamic to allow compat with webgl 1 and 2.
  75379. * You will need to pass the name of the uniform as well as the value.
  75380. */
  75381. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75382. /**
  75383. * Instantiates a new Uniform buffer objects.
  75384. *
  75385. * Handles blocks of uniform on the GPU.
  75386. *
  75387. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75388. *
  75389. * For more information, please refer to :
  75390. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75391. * @param engine Define the engine the buffer is associated with
  75392. * @param data Define the data contained in the buffer
  75393. * @param dynamic Define if the buffer is updatable
  75394. */
  75395. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75396. /**
  75397. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75398. * or just falling back on setUniformXXX calls.
  75399. */
  75400. readonly useUbo: boolean;
  75401. /**
  75402. * Indicates if the WebGL underlying uniform buffer is in sync
  75403. * with the javascript cache data.
  75404. */
  75405. readonly isSync: boolean;
  75406. /**
  75407. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75408. * Also, a dynamic UniformBuffer will disable cache verification and always
  75409. * update the underlying WebGL uniform buffer to the GPU.
  75410. * @returns if Dynamic, otherwise false
  75411. */
  75412. isDynamic(): boolean;
  75413. /**
  75414. * The data cache on JS side.
  75415. * @returns the underlying data as a float array
  75416. */
  75417. getData(): Float32Array;
  75418. /**
  75419. * The underlying WebGL Uniform buffer.
  75420. * @returns the webgl buffer
  75421. */
  75422. getBuffer(): Nullable<DataBuffer>;
  75423. /**
  75424. * std140 layout specifies how to align data within an UBO structure.
  75425. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75426. * for specs.
  75427. */
  75428. private _fillAlignment;
  75429. /**
  75430. * Adds an uniform in the buffer.
  75431. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75432. * for the layout to be correct !
  75433. * @param name Name of the uniform, as used in the uniform block in the shader.
  75434. * @param size Data size, or data directly.
  75435. */
  75436. addUniform(name: string, size: number | number[]): void;
  75437. /**
  75438. * Adds a Matrix 4x4 to the uniform buffer.
  75439. * @param name Name of the uniform, as used in the uniform block in the shader.
  75440. * @param mat A 4x4 matrix.
  75441. */
  75442. addMatrix(name: string, mat: Matrix): void;
  75443. /**
  75444. * Adds a vec2 to the uniform buffer.
  75445. * @param name Name of the uniform, as used in the uniform block in the shader.
  75446. * @param x Define the x component value of the vec2
  75447. * @param y Define the y component value of the vec2
  75448. */
  75449. addFloat2(name: string, x: number, y: number): void;
  75450. /**
  75451. * Adds a vec3 to the uniform buffer.
  75452. * @param name Name of the uniform, as used in the uniform block in the shader.
  75453. * @param x Define the x component value of the vec3
  75454. * @param y Define the y component value of the vec3
  75455. * @param z Define the z component value of the vec3
  75456. */
  75457. addFloat3(name: string, x: number, y: number, z: number): void;
  75458. /**
  75459. * Adds a vec3 to the uniform buffer.
  75460. * @param name Name of the uniform, as used in the uniform block in the shader.
  75461. * @param color Define the vec3 from a Color
  75462. */
  75463. addColor3(name: string, color: Color3): void;
  75464. /**
  75465. * Adds a vec4 to the uniform buffer.
  75466. * @param name Name of the uniform, as used in the uniform block in the shader.
  75467. * @param color Define the rgb components from a Color
  75468. * @param alpha Define the a component of the vec4
  75469. */
  75470. addColor4(name: string, color: Color3, alpha: number): void;
  75471. /**
  75472. * Adds a vec3 to the uniform buffer.
  75473. * @param name Name of the uniform, as used in the uniform block in the shader.
  75474. * @param vector Define the vec3 components from a Vector
  75475. */
  75476. addVector3(name: string, vector: Vector3): void;
  75477. /**
  75478. * Adds a Matrix 3x3 to the uniform buffer.
  75479. * @param name Name of the uniform, as used in the uniform block in the shader.
  75480. */
  75481. addMatrix3x3(name: string): void;
  75482. /**
  75483. * Adds a Matrix 2x2 to the uniform buffer.
  75484. * @param name Name of the uniform, as used in the uniform block in the shader.
  75485. */
  75486. addMatrix2x2(name: string): void;
  75487. /**
  75488. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75489. */
  75490. create(): void;
  75491. /** @hidden */
  75492. _rebuild(): void;
  75493. /**
  75494. * Updates the WebGL Uniform Buffer on the GPU.
  75495. * If the `dynamic` flag is set to true, no cache comparison is done.
  75496. * Otherwise, the buffer will be updated only if the cache differs.
  75497. */
  75498. update(): void;
  75499. /**
  75500. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75501. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75502. * @param data Define the flattened data
  75503. * @param size Define the size of the data.
  75504. */
  75505. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75506. private _valueCache;
  75507. private _cacheMatrix;
  75508. private _updateMatrix3x3ForUniform;
  75509. private _updateMatrix3x3ForEffect;
  75510. private _updateMatrix2x2ForEffect;
  75511. private _updateMatrix2x2ForUniform;
  75512. private _updateFloatForEffect;
  75513. private _updateFloatForUniform;
  75514. private _updateFloat2ForEffect;
  75515. private _updateFloat2ForUniform;
  75516. private _updateFloat3ForEffect;
  75517. private _updateFloat3ForUniform;
  75518. private _updateFloat4ForEffect;
  75519. private _updateFloat4ForUniform;
  75520. private _updateMatrixForEffect;
  75521. private _updateMatrixForUniform;
  75522. private _updateVector3ForEffect;
  75523. private _updateVector3ForUniform;
  75524. private _updateVector4ForEffect;
  75525. private _updateVector4ForUniform;
  75526. private _updateColor3ForEffect;
  75527. private _updateColor3ForUniform;
  75528. private _updateColor4ForEffect;
  75529. private _updateColor4ForUniform;
  75530. /**
  75531. * Sets a sampler uniform on the effect.
  75532. * @param name Define the name of the sampler.
  75533. * @param texture Define the texture to set in the sampler
  75534. */
  75535. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75536. /**
  75537. * Directly updates the value of the uniform in the cache AND on the GPU.
  75538. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75539. * @param data Define the flattened data
  75540. */
  75541. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75542. /**
  75543. * Binds this uniform buffer to an effect.
  75544. * @param effect Define the effect to bind the buffer to
  75545. * @param name Name of the uniform block in the shader.
  75546. */
  75547. bindToEffect(effect: Effect, name: string): void;
  75548. /**
  75549. * Disposes the uniform buffer.
  75550. */
  75551. dispose(): void;
  75552. }
  75553. }
  75554. declare module BABYLON {
  75555. /**
  75556. * Enum that determines the text-wrapping mode to use.
  75557. */
  75558. export enum InspectableType {
  75559. /**
  75560. * Checkbox for booleans
  75561. */
  75562. Checkbox = 0,
  75563. /**
  75564. * Sliders for numbers
  75565. */
  75566. Slider = 1,
  75567. /**
  75568. * Vector3
  75569. */
  75570. Vector3 = 2,
  75571. /**
  75572. * Quaternions
  75573. */
  75574. Quaternion = 3,
  75575. /**
  75576. * Color3
  75577. */
  75578. Color3 = 4,
  75579. /**
  75580. * String
  75581. */
  75582. String = 5
  75583. }
  75584. /**
  75585. * Interface used to define custom inspectable properties.
  75586. * This interface is used by the inspector to display custom property grids
  75587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75588. */
  75589. export interface IInspectable {
  75590. /**
  75591. * Gets the label to display
  75592. */
  75593. label: string;
  75594. /**
  75595. * Gets the name of the property to edit
  75596. */
  75597. propertyName: string;
  75598. /**
  75599. * Gets the type of the editor to use
  75600. */
  75601. type: InspectableType;
  75602. /**
  75603. * Gets the minimum value of the property when using in "slider" mode
  75604. */
  75605. min?: number;
  75606. /**
  75607. * Gets the maximum value of the property when using in "slider" mode
  75608. */
  75609. max?: number;
  75610. /**
  75611. * Gets the setp to use when using in "slider" mode
  75612. */
  75613. step?: number;
  75614. }
  75615. }
  75616. declare module BABYLON {
  75617. /**
  75618. * Class used to provide helper for timing
  75619. */
  75620. export class TimingTools {
  75621. /**
  75622. * Polyfill for setImmediate
  75623. * @param action defines the action to execute after the current execution block
  75624. */
  75625. static SetImmediate(action: () => void): void;
  75626. }
  75627. }
  75628. declare module BABYLON {
  75629. /**
  75630. * Class used to enable instatition of objects by class name
  75631. */
  75632. export class InstantiationTools {
  75633. /**
  75634. * Use this object to register external classes like custom textures or material
  75635. * to allow the laoders to instantiate them
  75636. */
  75637. static RegisteredExternalClasses: {
  75638. [key: string]: Object;
  75639. };
  75640. /**
  75641. * Tries to instantiate a new object from a given class name
  75642. * @param className defines the class name to instantiate
  75643. * @returns the new object or null if the system was not able to do the instantiation
  75644. */
  75645. static Instantiate(className: string): any;
  75646. }
  75647. }
  75648. declare module BABYLON {
  75649. /**
  75650. * Define options used to create a depth texture
  75651. */
  75652. export class DepthTextureCreationOptions {
  75653. /** Specifies whether or not a stencil should be allocated in the texture */
  75654. generateStencil?: boolean;
  75655. /** Specifies whether or not bilinear filtering is enable on the texture */
  75656. bilinearFiltering?: boolean;
  75657. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75658. comparisonFunction?: number;
  75659. /** Specifies if the created texture is a cube texture */
  75660. isCube?: boolean;
  75661. }
  75662. }
  75663. declare module BABYLON {
  75664. interface ThinEngine {
  75665. /**
  75666. * Creates a depth stencil cube texture.
  75667. * This is only available in WebGL 2.
  75668. * @param size The size of face edge in the cube texture.
  75669. * @param options The options defining the cube texture.
  75670. * @returns The cube texture
  75671. */
  75672. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75673. /**
  75674. * Creates a cube texture
  75675. * @param rootUrl defines the url where the files to load is located
  75676. * @param scene defines the current scene
  75677. * @param files defines the list of files to load (1 per face)
  75678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75679. * @param onLoad defines an optional callback raised when the texture is loaded
  75680. * @param onError defines an optional callback raised if there is an issue to load the texture
  75681. * @param format defines the format of the data
  75682. * @param forcedExtension defines the extension to use to pick the right loader
  75683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75686. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75687. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75688. * @returns the cube texture as an InternalTexture
  75689. */
  75690. 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;
  75691. /**
  75692. * Creates a cube texture
  75693. * @param rootUrl defines the url where the files to load is located
  75694. * @param scene defines the current scene
  75695. * @param files defines the list of files to load (1 per face)
  75696. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75697. * @param onLoad defines an optional callback raised when the texture is loaded
  75698. * @param onError defines an optional callback raised if there is an issue to load the texture
  75699. * @param format defines the format of the data
  75700. * @param forcedExtension defines the extension to use to pick the right loader
  75701. * @returns the cube texture as an InternalTexture
  75702. */
  75703. 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;
  75704. /**
  75705. * Creates a cube texture
  75706. * @param rootUrl defines the url where the files to load is located
  75707. * @param scene defines the current scene
  75708. * @param files defines the list of files to load (1 per face)
  75709. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75710. * @param onLoad defines an optional callback raised when the texture is loaded
  75711. * @param onError defines an optional callback raised if there is an issue to load the texture
  75712. * @param format defines the format of the data
  75713. * @param forcedExtension defines the extension to use to pick the right loader
  75714. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75715. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75716. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75717. * @returns the cube texture as an InternalTexture
  75718. */
  75719. 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;
  75720. /** @hidden */
  75721. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75722. /** @hidden */
  75723. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75724. /** @hidden */
  75725. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75726. /** @hidden */
  75727. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75728. /**
  75729. * @hidden
  75730. */
  75731. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75732. }
  75733. }
  75734. declare module BABYLON {
  75735. /**
  75736. * Class for creating a cube texture
  75737. */
  75738. export class CubeTexture extends BaseTexture {
  75739. private _delayedOnLoad;
  75740. /**
  75741. * The url of the texture
  75742. */
  75743. url: string;
  75744. /**
  75745. * Gets or sets the center of the bounding box associated with the cube texture.
  75746. * It must define where the camera used to render the texture was set
  75747. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75748. */
  75749. boundingBoxPosition: Vector3;
  75750. private _boundingBoxSize;
  75751. /**
  75752. * Gets or sets the size of the bounding box associated with the cube texture
  75753. * When defined, the cubemap will switch to local mode
  75754. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75755. * @example https://www.babylonjs-playground.com/#RNASML
  75756. */
  75757. /**
  75758. * Returns the bounding box size
  75759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75760. */
  75761. boundingBoxSize: Vector3;
  75762. protected _rotationY: number;
  75763. /**
  75764. * Sets texture matrix rotation angle around Y axis in radians.
  75765. */
  75766. /**
  75767. * Gets texture matrix rotation angle around Y axis radians.
  75768. */
  75769. rotationY: number;
  75770. /**
  75771. * Are mip maps generated for this texture or not.
  75772. */
  75773. readonly noMipmap: boolean;
  75774. private _noMipmap;
  75775. private _files;
  75776. protected _forcedExtension: Nullable<string>;
  75777. private _extensions;
  75778. private _textureMatrix;
  75779. private _format;
  75780. private _createPolynomials;
  75781. /** @hidden */
  75782. _prefiltered: boolean;
  75783. /**
  75784. * Creates a cube texture from an array of image urls
  75785. * @param files defines an array of image urls
  75786. * @param scene defines the hosting scene
  75787. * @param noMipmap specifies if mip maps are not used
  75788. * @returns a cube texture
  75789. */
  75790. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75791. /**
  75792. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75793. * @param url defines the url of the prefiltered texture
  75794. * @param scene defines the scene the texture is attached to
  75795. * @param forcedExtension defines the extension of the file if different from the url
  75796. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75797. * @return the prefiltered texture
  75798. */
  75799. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75800. /**
  75801. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75802. * as prefiltered data.
  75803. * @param rootUrl defines the url of the texture or the root name of the six images
  75804. * @param scene defines the scene the texture is attached to
  75805. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75806. * @param noMipmap defines if mipmaps should be created or not
  75807. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75808. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75809. * @param onError defines a callback triggered in case of error during load
  75810. * @param format defines the internal format to use for the texture once loaded
  75811. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75812. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75813. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75816. * @return the cube texture
  75817. */
  75818. 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);
  75819. /**
  75820. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75821. */
  75822. readonly isPrefiltered: boolean;
  75823. /**
  75824. * Get the current class name of the texture useful for serialization or dynamic coding.
  75825. * @returns "CubeTexture"
  75826. */
  75827. getClassName(): string;
  75828. /**
  75829. * Update the url (and optional buffer) of this texture if url was null during construction.
  75830. * @param url the url of the texture
  75831. * @param forcedExtension defines the extension to use
  75832. * @param onLoad callback called when the texture is loaded (defaults to null)
  75833. */
  75834. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75835. /**
  75836. * Delays loading of the cube texture
  75837. * @param forcedExtension defines the extension to use
  75838. */
  75839. delayLoad(forcedExtension?: string): void;
  75840. /**
  75841. * Returns the reflection texture matrix
  75842. * @returns the reflection texture matrix
  75843. */
  75844. getReflectionTextureMatrix(): Matrix;
  75845. /**
  75846. * Sets the reflection texture matrix
  75847. * @param value Reflection texture matrix
  75848. */
  75849. setReflectionTextureMatrix(value: Matrix): void;
  75850. /**
  75851. * Parses text to create a cube texture
  75852. * @param parsedTexture define the serialized text to read from
  75853. * @param scene defines the hosting scene
  75854. * @param rootUrl defines the root url of the cube texture
  75855. * @returns a cube texture
  75856. */
  75857. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75858. /**
  75859. * Makes a clone, or deep copy, of the cube texture
  75860. * @returns a new cube texture
  75861. */
  75862. clone(): CubeTexture;
  75863. }
  75864. }
  75865. declare module BABYLON {
  75866. /**
  75867. * Manages the defines for the Material
  75868. */
  75869. export class MaterialDefines {
  75870. /** @hidden */
  75871. protected _keys: string[];
  75872. private _isDirty;
  75873. /** @hidden */
  75874. _renderId: number;
  75875. /** @hidden */
  75876. _areLightsDirty: boolean;
  75877. /** @hidden */
  75878. _areLightsDisposed: boolean;
  75879. /** @hidden */
  75880. _areAttributesDirty: boolean;
  75881. /** @hidden */
  75882. _areTexturesDirty: boolean;
  75883. /** @hidden */
  75884. _areFresnelDirty: boolean;
  75885. /** @hidden */
  75886. _areMiscDirty: boolean;
  75887. /** @hidden */
  75888. _areImageProcessingDirty: boolean;
  75889. /** @hidden */
  75890. _normals: boolean;
  75891. /** @hidden */
  75892. _uvs: boolean;
  75893. /** @hidden */
  75894. _needNormals: boolean;
  75895. /** @hidden */
  75896. _needUVs: boolean;
  75897. [id: string]: any;
  75898. /**
  75899. * Specifies if the material needs to be re-calculated
  75900. */
  75901. readonly isDirty: boolean;
  75902. /**
  75903. * Marks the material to indicate that it has been re-calculated
  75904. */
  75905. markAsProcessed(): void;
  75906. /**
  75907. * Marks the material to indicate that it needs to be re-calculated
  75908. */
  75909. markAsUnprocessed(): void;
  75910. /**
  75911. * Marks the material to indicate all of its defines need to be re-calculated
  75912. */
  75913. markAllAsDirty(): void;
  75914. /**
  75915. * Marks the material to indicate that image processing needs to be re-calculated
  75916. */
  75917. markAsImageProcessingDirty(): void;
  75918. /**
  75919. * Marks the material to indicate the lights need to be re-calculated
  75920. * @param disposed Defines whether the light is dirty due to dispose or not
  75921. */
  75922. markAsLightDirty(disposed?: boolean): void;
  75923. /**
  75924. * Marks the attribute state as changed
  75925. */
  75926. markAsAttributesDirty(): void;
  75927. /**
  75928. * Marks the texture state as changed
  75929. */
  75930. markAsTexturesDirty(): void;
  75931. /**
  75932. * Marks the fresnel state as changed
  75933. */
  75934. markAsFresnelDirty(): void;
  75935. /**
  75936. * Marks the misc state as changed
  75937. */
  75938. markAsMiscDirty(): void;
  75939. /**
  75940. * Rebuilds the material defines
  75941. */
  75942. rebuild(): void;
  75943. /**
  75944. * Specifies if two material defines are equal
  75945. * @param other - A material define instance to compare to
  75946. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75947. */
  75948. isEqual(other: MaterialDefines): boolean;
  75949. /**
  75950. * Clones this instance's defines to another instance
  75951. * @param other - material defines to clone values to
  75952. */
  75953. cloneTo(other: MaterialDefines): void;
  75954. /**
  75955. * Resets the material define values
  75956. */
  75957. reset(): void;
  75958. /**
  75959. * Converts the material define values to a string
  75960. * @returns - String of material define information
  75961. */
  75962. toString(): string;
  75963. }
  75964. }
  75965. declare module BABYLON {
  75966. /**
  75967. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75968. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75969. * 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;
  75970. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75971. */
  75972. export class ColorCurves {
  75973. private _dirty;
  75974. private _tempColor;
  75975. private _globalCurve;
  75976. private _highlightsCurve;
  75977. private _midtonesCurve;
  75978. private _shadowsCurve;
  75979. private _positiveCurve;
  75980. private _negativeCurve;
  75981. private _globalHue;
  75982. private _globalDensity;
  75983. private _globalSaturation;
  75984. private _globalExposure;
  75985. /**
  75986. * Gets the global Hue value.
  75987. * 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).
  75988. */
  75989. /**
  75990. * Sets the global Hue value.
  75991. * 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).
  75992. */
  75993. globalHue: number;
  75994. /**
  75995. * Gets the global Density value.
  75996. * 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.
  75997. * Values less than zero provide a filter of opposite hue.
  75998. */
  75999. /**
  76000. * Sets the global Density value.
  76001. * 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.
  76002. * Values less than zero provide a filter of opposite hue.
  76003. */
  76004. globalDensity: number;
  76005. /**
  76006. * Gets the global Saturation value.
  76007. * 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.
  76008. */
  76009. /**
  76010. * Sets the global Saturation value.
  76011. * 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.
  76012. */
  76013. globalSaturation: number;
  76014. /**
  76015. * Gets the global Exposure value.
  76016. * 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.
  76017. */
  76018. /**
  76019. * Sets the global Exposure value.
  76020. * 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.
  76021. */
  76022. globalExposure: number;
  76023. private _highlightsHue;
  76024. private _highlightsDensity;
  76025. private _highlightsSaturation;
  76026. private _highlightsExposure;
  76027. /**
  76028. * Gets the highlights Hue value.
  76029. * 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).
  76030. */
  76031. /**
  76032. * Sets the highlights Hue value.
  76033. * 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).
  76034. */
  76035. highlightsHue: number;
  76036. /**
  76037. * Gets the highlights Density value.
  76038. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  76039. * Values less than zero provide a filter of opposite hue.
  76040. */
  76041. /**
  76042. * Sets the highlights Density value.
  76043. * 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.
  76044. * Values less than zero provide a filter of opposite hue.
  76045. */
  76046. highlightsDensity: number;
  76047. /**
  76048. * Gets the highlights Saturation value.
  76049. * 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.
  76050. */
  76051. /**
  76052. * Sets the highlights Saturation value.
  76053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  76054. */
  76055. highlightsSaturation: number;
  76056. /**
  76057. * Gets the highlights Exposure value.
  76058. * 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.
  76059. */
  76060. /**
  76061. * Sets the highlights Exposure value.
  76062. * 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.
  76063. */
  76064. highlightsExposure: number;
  76065. private _midtonesHue;
  76066. private _midtonesDensity;
  76067. private _midtonesSaturation;
  76068. private _midtonesExposure;
  76069. /**
  76070. * Gets the midtones Hue value.
  76071. * 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).
  76072. */
  76073. /**
  76074. * Sets the midtones Hue value.
  76075. * 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).
  76076. */
  76077. midtonesHue: number;
  76078. /**
  76079. * Gets the midtones Density value.
  76080. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  76081. * Values less than zero provide a filter of opposite hue.
  76082. */
  76083. /**
  76084. * Sets the midtones Density value.
  76085. * 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.
  76086. * Values less than zero provide a filter of opposite hue.
  76087. */
  76088. midtonesDensity: number;
  76089. /**
  76090. * Gets the midtones Saturation value.
  76091. * 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.
  76092. */
  76093. /**
  76094. * Sets the midtones Saturation value.
  76095. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  76096. */
  76097. midtonesSaturation: number;
  76098. /**
  76099. * Gets the midtones Exposure value.
  76100. * 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.
  76101. */
  76102. /**
  76103. * Sets the midtones Exposure value.
  76104. * 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.
  76105. */
  76106. midtonesExposure: number;
  76107. private _shadowsHue;
  76108. private _shadowsDensity;
  76109. private _shadowsSaturation;
  76110. private _shadowsExposure;
  76111. /**
  76112. * Gets the shadows Hue value.
  76113. * 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).
  76114. */
  76115. /**
  76116. * Sets the shadows Hue value.
  76117. * 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).
  76118. */
  76119. shadowsHue: number;
  76120. /**
  76121. * Gets the shadows Density value.
  76122. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  76123. * Values less than zero provide a filter of opposite hue.
  76124. */
  76125. /**
  76126. * Sets the shadows Density value.
  76127. * 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.
  76128. * Values less than zero provide a filter of opposite hue.
  76129. */
  76130. shadowsDensity: number;
  76131. /**
  76132. * Gets the shadows Saturation value.
  76133. * 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.
  76134. */
  76135. /**
  76136. * Sets the shadows Saturation value.
  76137. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  76138. */
  76139. shadowsSaturation: number;
  76140. /**
  76141. * Gets the shadows Exposure value.
  76142. * 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.
  76143. */
  76144. /**
  76145. * Sets the shadows Exposure value.
  76146. * 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.
  76147. */
  76148. shadowsExposure: number;
  76149. /**
  76150. * Returns the class name
  76151. * @returns The class name
  76152. */
  76153. getClassName(): string;
  76154. /**
  76155. * Binds the color curves to the shader.
  76156. * @param colorCurves The color curve to bind
  76157. * @param effect The effect to bind to
  76158. * @param positiveUniform The positive uniform shader parameter
  76159. * @param neutralUniform The neutral uniform shader parameter
  76160. * @param negativeUniform The negative uniform shader parameter
  76161. */
  76162. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76163. /**
  76164. * Prepare the list of uniforms associated with the ColorCurves effects.
  76165. * @param uniformsList The list of uniforms used in the effect
  76166. */
  76167. static PrepareUniforms(uniformsList: string[]): void;
  76168. /**
  76169. * Returns color grading data based on a hue, density, saturation and exposure value.
  76170. * @param filterHue The hue of the color filter.
  76171. * @param filterDensity The density of the color filter.
  76172. * @param saturation The saturation.
  76173. * @param exposure The exposure.
  76174. * @param result The result data container.
  76175. */
  76176. private getColorGradingDataToRef;
  76177. /**
  76178. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76179. * @param value The input slider value in range [-100,100].
  76180. * @returns Adjusted value.
  76181. */
  76182. private static applyColorGradingSliderNonlinear;
  76183. /**
  76184. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76185. * @param hue The hue (H) input.
  76186. * @param saturation The saturation (S) input.
  76187. * @param brightness The brightness (B) input.
  76188. * @result An RGBA color represented as Vector4.
  76189. */
  76190. private static fromHSBToRef;
  76191. /**
  76192. * Returns a value clamped between min and max
  76193. * @param value The value to clamp
  76194. * @param min The minimum of value
  76195. * @param max The maximum of value
  76196. * @returns The clamped value.
  76197. */
  76198. private static clamp;
  76199. /**
  76200. * Clones the current color curve instance.
  76201. * @return The cloned curves
  76202. */
  76203. clone(): ColorCurves;
  76204. /**
  76205. * Serializes the current color curve instance to a json representation.
  76206. * @return a JSON representation
  76207. */
  76208. serialize(): any;
  76209. /**
  76210. * Parses the color curve from a json representation.
  76211. * @param source the JSON source to parse
  76212. * @return The parsed curves
  76213. */
  76214. static Parse(source: any): ColorCurves;
  76215. }
  76216. }
  76217. declare module BABYLON {
  76218. /**
  76219. * Interface to follow in your material defines to integrate easily the
  76220. * Image proccessing functions.
  76221. * @hidden
  76222. */
  76223. export interface IImageProcessingConfigurationDefines {
  76224. IMAGEPROCESSING: boolean;
  76225. VIGNETTE: boolean;
  76226. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76227. VIGNETTEBLENDMODEOPAQUE: boolean;
  76228. TONEMAPPING: boolean;
  76229. TONEMAPPING_ACES: boolean;
  76230. CONTRAST: boolean;
  76231. EXPOSURE: boolean;
  76232. COLORCURVES: boolean;
  76233. COLORGRADING: boolean;
  76234. COLORGRADING3D: boolean;
  76235. SAMPLER3DGREENDEPTH: boolean;
  76236. SAMPLER3DBGRMAP: boolean;
  76237. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76238. }
  76239. /**
  76240. * @hidden
  76241. */
  76242. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76243. IMAGEPROCESSING: boolean;
  76244. VIGNETTE: boolean;
  76245. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76246. VIGNETTEBLENDMODEOPAQUE: boolean;
  76247. TONEMAPPING: boolean;
  76248. TONEMAPPING_ACES: boolean;
  76249. CONTRAST: boolean;
  76250. COLORCURVES: boolean;
  76251. COLORGRADING: boolean;
  76252. COLORGRADING3D: boolean;
  76253. SAMPLER3DGREENDEPTH: boolean;
  76254. SAMPLER3DBGRMAP: boolean;
  76255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76256. EXPOSURE: boolean;
  76257. constructor();
  76258. }
  76259. /**
  76260. * This groups together the common properties used for image processing either in direct forward pass
  76261. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76262. * or not.
  76263. */
  76264. export class ImageProcessingConfiguration {
  76265. /**
  76266. * Default tone mapping applied in BabylonJS.
  76267. */
  76268. static readonly TONEMAPPING_STANDARD: number;
  76269. /**
  76270. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76271. * to other engines rendering to increase portability.
  76272. */
  76273. static readonly TONEMAPPING_ACES: number;
  76274. /**
  76275. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76276. */
  76277. colorCurves: Nullable<ColorCurves>;
  76278. private _colorCurvesEnabled;
  76279. /**
  76280. * Gets wether the color curves effect is enabled.
  76281. */
  76282. /**
  76283. * Sets wether the color curves effect is enabled.
  76284. */
  76285. colorCurvesEnabled: boolean;
  76286. private _colorGradingTexture;
  76287. /**
  76288. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76289. */
  76290. /**
  76291. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76292. */
  76293. colorGradingTexture: Nullable<BaseTexture>;
  76294. private _colorGradingEnabled;
  76295. /**
  76296. * Gets wether the color grading effect is enabled.
  76297. */
  76298. /**
  76299. * Sets wether the color grading effect is enabled.
  76300. */
  76301. colorGradingEnabled: boolean;
  76302. private _colorGradingWithGreenDepth;
  76303. /**
  76304. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76305. */
  76306. /**
  76307. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76308. */
  76309. colorGradingWithGreenDepth: boolean;
  76310. private _colorGradingBGR;
  76311. /**
  76312. * Gets wether the color grading texture contains BGR values.
  76313. */
  76314. /**
  76315. * Sets wether the color grading texture contains BGR values.
  76316. */
  76317. colorGradingBGR: boolean;
  76318. /** @hidden */
  76319. _exposure: number;
  76320. /**
  76321. * Gets the Exposure used in the effect.
  76322. */
  76323. /**
  76324. * Sets the Exposure used in the effect.
  76325. */
  76326. exposure: number;
  76327. private _toneMappingEnabled;
  76328. /**
  76329. * Gets wether the tone mapping effect is enabled.
  76330. */
  76331. /**
  76332. * Sets wether the tone mapping effect is enabled.
  76333. */
  76334. toneMappingEnabled: boolean;
  76335. private _toneMappingType;
  76336. /**
  76337. * Gets the type of tone mapping effect.
  76338. */
  76339. /**
  76340. * Sets the type of tone mapping effect used in BabylonJS.
  76341. */
  76342. toneMappingType: number;
  76343. protected _contrast: number;
  76344. /**
  76345. * Gets the contrast used in the effect.
  76346. */
  76347. /**
  76348. * Sets the contrast used in the effect.
  76349. */
  76350. contrast: number;
  76351. /**
  76352. * Vignette stretch size.
  76353. */
  76354. vignetteStretch: number;
  76355. /**
  76356. * Vignette centre X Offset.
  76357. */
  76358. vignetteCentreX: number;
  76359. /**
  76360. * Vignette centre Y Offset.
  76361. */
  76362. vignetteCentreY: number;
  76363. /**
  76364. * Vignette weight or intensity of the vignette effect.
  76365. */
  76366. vignetteWeight: number;
  76367. /**
  76368. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76369. * if vignetteEnabled is set to true.
  76370. */
  76371. vignetteColor: Color4;
  76372. /**
  76373. * Camera field of view used by the Vignette effect.
  76374. */
  76375. vignetteCameraFov: number;
  76376. private _vignetteBlendMode;
  76377. /**
  76378. * Gets the vignette blend mode allowing different kind of effect.
  76379. */
  76380. /**
  76381. * Sets the vignette blend mode allowing different kind of effect.
  76382. */
  76383. vignetteBlendMode: number;
  76384. private _vignetteEnabled;
  76385. /**
  76386. * Gets wether the vignette effect is enabled.
  76387. */
  76388. /**
  76389. * Sets wether the vignette effect is enabled.
  76390. */
  76391. vignetteEnabled: boolean;
  76392. private _applyByPostProcess;
  76393. /**
  76394. * Gets wether the image processing is applied through a post process or not.
  76395. */
  76396. /**
  76397. * Sets wether the image processing is applied through a post process or not.
  76398. */
  76399. applyByPostProcess: boolean;
  76400. private _isEnabled;
  76401. /**
  76402. * Gets wether the image processing is enabled or not.
  76403. */
  76404. /**
  76405. * Sets wether the image processing is enabled or not.
  76406. */
  76407. isEnabled: boolean;
  76408. /**
  76409. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76410. */
  76411. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76412. /**
  76413. * Method called each time the image processing information changes requires to recompile the effect.
  76414. */
  76415. protected _updateParameters(): void;
  76416. /**
  76417. * Gets the current class name.
  76418. * @return "ImageProcessingConfiguration"
  76419. */
  76420. getClassName(): string;
  76421. /**
  76422. * Prepare the list of uniforms associated with the Image Processing effects.
  76423. * @param uniforms The list of uniforms used in the effect
  76424. * @param defines the list of defines currently in use
  76425. */
  76426. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76427. /**
  76428. * Prepare the list of samplers associated with the Image Processing effects.
  76429. * @param samplersList The list of uniforms used in the effect
  76430. * @param defines the list of defines currently in use
  76431. */
  76432. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76433. /**
  76434. * Prepare the list of defines associated to the shader.
  76435. * @param defines the list of defines to complete
  76436. * @param forPostProcess Define if we are currently in post process mode or not
  76437. */
  76438. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76439. /**
  76440. * Returns true if all the image processing information are ready.
  76441. * @returns True if ready, otherwise, false
  76442. */
  76443. isReady(): boolean;
  76444. /**
  76445. * Binds the image processing to the shader.
  76446. * @param effect The effect to bind to
  76447. * @param overrideAspectRatio Override the aspect ratio of the effect
  76448. */
  76449. bind(effect: Effect, overrideAspectRatio?: number): void;
  76450. /**
  76451. * Clones the current image processing instance.
  76452. * @return The cloned image processing
  76453. */
  76454. clone(): ImageProcessingConfiguration;
  76455. /**
  76456. * Serializes the current image processing instance to a json representation.
  76457. * @return a JSON representation
  76458. */
  76459. serialize(): any;
  76460. /**
  76461. * Parses the image processing from a json representation.
  76462. * @param source the JSON source to parse
  76463. * @return The parsed image processing
  76464. */
  76465. static Parse(source: any): ImageProcessingConfiguration;
  76466. private static _VIGNETTEMODE_MULTIPLY;
  76467. private static _VIGNETTEMODE_OPAQUE;
  76468. /**
  76469. * Used to apply the vignette as a mix with the pixel color.
  76470. */
  76471. static readonly VIGNETTEMODE_MULTIPLY: number;
  76472. /**
  76473. * Used to apply the vignette as a replacement of the pixel color.
  76474. */
  76475. static readonly VIGNETTEMODE_OPAQUE: number;
  76476. }
  76477. }
  76478. declare module BABYLON {
  76479. /** @hidden */
  76480. export var postprocessVertexShader: {
  76481. name: string;
  76482. shader: string;
  76483. };
  76484. }
  76485. declare module BABYLON {
  76486. interface ThinEngine {
  76487. /**
  76488. * Creates a new render target texture
  76489. * @param size defines the size of the texture
  76490. * @param options defines the options used to create the texture
  76491. * @returns a new render target texture stored in an InternalTexture
  76492. */
  76493. createRenderTargetTexture(size: number | {
  76494. width: number;
  76495. height: number;
  76496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76497. /**
  76498. * Creates a depth stencil texture.
  76499. * This is only available in WebGL 2 or with the depth texture extension available.
  76500. * @param size The size of face edge in the texture.
  76501. * @param options The options defining the texture.
  76502. * @returns The texture
  76503. */
  76504. createDepthStencilTexture(size: number | {
  76505. width: number;
  76506. height: number;
  76507. }, options: DepthTextureCreationOptions): InternalTexture;
  76508. /** @hidden */
  76509. _createDepthStencilTexture(size: number | {
  76510. width: number;
  76511. height: number;
  76512. }, options: DepthTextureCreationOptions): InternalTexture;
  76513. }
  76514. }
  76515. declare module BABYLON {
  76516. /** Defines supported spaces */
  76517. export enum Space {
  76518. /** Local (object) space */
  76519. LOCAL = 0,
  76520. /** World space */
  76521. WORLD = 1,
  76522. /** Bone space */
  76523. BONE = 2
  76524. }
  76525. /** Defines the 3 main axes */
  76526. export class Axis {
  76527. /** X axis */
  76528. static X: Vector3;
  76529. /** Y axis */
  76530. static Y: Vector3;
  76531. /** Z axis */
  76532. static Z: Vector3;
  76533. }
  76534. }
  76535. declare module BABYLON {
  76536. /**
  76537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76538. * This is the base of the follow, arc rotate cameras and Free camera
  76539. * @see http://doc.babylonjs.com/features/cameras
  76540. */
  76541. export class TargetCamera extends Camera {
  76542. private static _RigCamTransformMatrix;
  76543. private static _TargetTransformMatrix;
  76544. private static _TargetFocalPoint;
  76545. /**
  76546. * Define the current direction the camera is moving to
  76547. */
  76548. cameraDirection: Vector3;
  76549. /**
  76550. * Define the current rotation the camera is rotating to
  76551. */
  76552. cameraRotation: Vector2;
  76553. /**
  76554. * When set, the up vector of the camera will be updated by the rotation of the camera
  76555. */
  76556. updateUpVectorFromRotation: boolean;
  76557. private _tmpQuaternion;
  76558. /**
  76559. * Define the current rotation of the camera
  76560. */
  76561. rotation: Vector3;
  76562. /**
  76563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76564. */
  76565. rotationQuaternion: Quaternion;
  76566. /**
  76567. * Define the current speed of the camera
  76568. */
  76569. speed: number;
  76570. /**
  76571. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76572. * around all axis.
  76573. */
  76574. noRotationConstraint: boolean;
  76575. /**
  76576. * Define the current target of the camera as an object or a position.
  76577. */
  76578. lockedTarget: any;
  76579. /** @hidden */
  76580. _currentTarget: Vector3;
  76581. /** @hidden */
  76582. _initialFocalDistance: number;
  76583. /** @hidden */
  76584. _viewMatrix: Matrix;
  76585. /** @hidden */
  76586. _camMatrix: Matrix;
  76587. /** @hidden */
  76588. _cameraTransformMatrix: Matrix;
  76589. /** @hidden */
  76590. _cameraRotationMatrix: Matrix;
  76591. /** @hidden */
  76592. _referencePoint: Vector3;
  76593. /** @hidden */
  76594. _transformedReferencePoint: Vector3;
  76595. protected _globalCurrentTarget: Vector3;
  76596. protected _globalCurrentUpVector: Vector3;
  76597. /** @hidden */
  76598. _reset: () => void;
  76599. private _defaultUp;
  76600. /**
  76601. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76602. * This is the base of the follow, arc rotate cameras and Free camera
  76603. * @see http://doc.babylonjs.com/features/cameras
  76604. * @param name Defines the name of the camera in the scene
  76605. * @param position Defines the start position of the camera in the scene
  76606. * @param scene Defines the scene the camera belongs to
  76607. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76608. */
  76609. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76610. /**
  76611. * Gets the position in front of the camera at a given distance.
  76612. * @param distance The distance from the camera we want the position to be
  76613. * @returns the position
  76614. */
  76615. getFrontPosition(distance: number): Vector3;
  76616. /** @hidden */
  76617. _getLockedTargetPosition(): Nullable<Vector3>;
  76618. private _storedPosition;
  76619. private _storedRotation;
  76620. private _storedRotationQuaternion;
  76621. /**
  76622. * Store current camera state of the camera (fov, position, rotation, etc..)
  76623. * @returns the camera
  76624. */
  76625. storeState(): Camera;
  76626. /**
  76627. * Restored camera state. You must call storeState() first
  76628. * @returns whether it was successful or not
  76629. * @hidden
  76630. */
  76631. _restoreStateValues(): boolean;
  76632. /** @hidden */
  76633. _initCache(): void;
  76634. /** @hidden */
  76635. _updateCache(ignoreParentClass?: boolean): void;
  76636. /** @hidden */
  76637. _isSynchronizedViewMatrix(): boolean;
  76638. /** @hidden */
  76639. _computeLocalCameraSpeed(): number;
  76640. /**
  76641. * Defines the target the camera should look at.
  76642. * @param target Defines the new target as a Vector or a mesh
  76643. */
  76644. setTarget(target: Vector3): void;
  76645. /**
  76646. * Return the current target position of the camera. This value is expressed in local space.
  76647. * @returns the target position
  76648. */
  76649. getTarget(): Vector3;
  76650. /** @hidden */
  76651. _decideIfNeedsToMove(): boolean;
  76652. /** @hidden */
  76653. _updatePosition(): void;
  76654. /** @hidden */
  76655. _checkInputs(): void;
  76656. protected _updateCameraRotationMatrix(): void;
  76657. /**
  76658. * 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)
  76659. * @returns the current camera
  76660. */
  76661. private _rotateUpVectorWithCameraRotationMatrix;
  76662. private _cachedRotationZ;
  76663. private _cachedQuaternionRotationZ;
  76664. /** @hidden */
  76665. _getViewMatrix(): Matrix;
  76666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76667. /**
  76668. * @hidden
  76669. */
  76670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76671. /**
  76672. * @hidden
  76673. */
  76674. _updateRigCameras(): void;
  76675. private _getRigCamPositionAndTarget;
  76676. /**
  76677. * Gets the current object class name.
  76678. * @return the class name
  76679. */
  76680. getClassName(): string;
  76681. }
  76682. }
  76683. declare module BABYLON {
  76684. /**
  76685. * Gather the list of keyboard event types as constants.
  76686. */
  76687. export class KeyboardEventTypes {
  76688. /**
  76689. * The keydown event is fired when a key becomes active (pressed).
  76690. */
  76691. static readonly KEYDOWN: number;
  76692. /**
  76693. * The keyup event is fired when a key has been released.
  76694. */
  76695. static readonly KEYUP: number;
  76696. }
  76697. /**
  76698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76699. */
  76700. export class KeyboardInfo {
  76701. /**
  76702. * Defines the type of event (KeyboardEventTypes)
  76703. */
  76704. type: number;
  76705. /**
  76706. * Defines the related dom event
  76707. */
  76708. event: KeyboardEvent;
  76709. /**
  76710. * Instantiates a new keyboard info.
  76711. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76712. * @param type Defines the type of event (KeyboardEventTypes)
  76713. * @param event Defines the related dom event
  76714. */
  76715. constructor(
  76716. /**
  76717. * Defines the type of event (KeyboardEventTypes)
  76718. */
  76719. type: number,
  76720. /**
  76721. * Defines the related dom event
  76722. */
  76723. event: KeyboardEvent);
  76724. }
  76725. /**
  76726. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76727. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76728. */
  76729. export class KeyboardInfoPre extends KeyboardInfo {
  76730. /**
  76731. * Defines the type of event (KeyboardEventTypes)
  76732. */
  76733. type: number;
  76734. /**
  76735. * Defines the related dom event
  76736. */
  76737. event: KeyboardEvent;
  76738. /**
  76739. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76740. */
  76741. skipOnPointerObservable: boolean;
  76742. /**
  76743. * Instantiates a new keyboard pre info.
  76744. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76745. * @param type Defines the type of event (KeyboardEventTypes)
  76746. * @param event Defines the related dom event
  76747. */
  76748. constructor(
  76749. /**
  76750. * Defines the type of event (KeyboardEventTypes)
  76751. */
  76752. type: number,
  76753. /**
  76754. * Defines the related dom event
  76755. */
  76756. event: KeyboardEvent);
  76757. }
  76758. }
  76759. declare module BABYLON {
  76760. /**
  76761. * Manage the keyboard inputs to control the movement of a free camera.
  76762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76763. */
  76764. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76765. /**
  76766. * Defines the camera the input is attached to.
  76767. */
  76768. camera: FreeCamera;
  76769. /**
  76770. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76771. */
  76772. keysUp: number[];
  76773. /**
  76774. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76775. */
  76776. keysDown: number[];
  76777. /**
  76778. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76779. */
  76780. keysLeft: number[];
  76781. /**
  76782. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76783. */
  76784. keysRight: number[];
  76785. private _keys;
  76786. private _onCanvasBlurObserver;
  76787. private _onKeyboardObserver;
  76788. private _engine;
  76789. private _scene;
  76790. /**
  76791. * Attach the input controls to a specific dom element to get the input from.
  76792. * @param element Defines the element the controls should be listened from
  76793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76794. */
  76795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76796. /**
  76797. * Detach the current controls from the specified dom element.
  76798. * @param element Defines the element to stop listening the inputs from
  76799. */
  76800. detachControl(element: Nullable<HTMLElement>): void;
  76801. /**
  76802. * Update the current camera state depending on the inputs that have been used this frame.
  76803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76804. */
  76805. checkInputs(): void;
  76806. /**
  76807. * Gets the class name of the current intput.
  76808. * @returns the class name
  76809. */
  76810. getClassName(): string;
  76811. /** @hidden */
  76812. _onLostFocus(): void;
  76813. /**
  76814. * Get the friendly name associated with the input class.
  76815. * @returns the input friendly name
  76816. */
  76817. getSimpleName(): string;
  76818. }
  76819. }
  76820. declare module BABYLON {
  76821. /**
  76822. * Interface describing all the common properties and methods a shadow light needs to implement.
  76823. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76824. * as well as binding the different shadow properties to the effects.
  76825. */
  76826. export interface IShadowLight extends Light {
  76827. /**
  76828. * The light id in the scene (used in scene.findLighById for instance)
  76829. */
  76830. id: string;
  76831. /**
  76832. * The position the shdow will be casted from.
  76833. */
  76834. position: Vector3;
  76835. /**
  76836. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76837. */
  76838. direction: Vector3;
  76839. /**
  76840. * The transformed position. Position of the light in world space taking parenting in account.
  76841. */
  76842. transformedPosition: Vector3;
  76843. /**
  76844. * The transformed direction. Direction of the light in world space taking parenting in account.
  76845. */
  76846. transformedDirection: Vector3;
  76847. /**
  76848. * The friendly name of the light in the scene.
  76849. */
  76850. name: string;
  76851. /**
  76852. * Defines the shadow projection clipping minimum z value.
  76853. */
  76854. shadowMinZ: number;
  76855. /**
  76856. * Defines the shadow projection clipping maximum z value.
  76857. */
  76858. shadowMaxZ: number;
  76859. /**
  76860. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76861. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76862. */
  76863. computeTransformedInformation(): boolean;
  76864. /**
  76865. * Gets the scene the light belongs to.
  76866. * @returns The scene
  76867. */
  76868. getScene(): Scene;
  76869. /**
  76870. * Callback defining a custom Projection Matrix Builder.
  76871. * This can be used to override the default projection matrix computation.
  76872. */
  76873. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76874. /**
  76875. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76876. * @param matrix The materix to updated with the projection information
  76877. * @param viewMatrix The transform matrix of the light
  76878. * @param renderList The list of mesh to render in the map
  76879. * @returns The current light
  76880. */
  76881. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76882. /**
  76883. * Gets the current depth scale used in ESM.
  76884. * @returns The scale
  76885. */
  76886. getDepthScale(): number;
  76887. /**
  76888. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76889. * @returns true if a cube texture needs to be use
  76890. */
  76891. needCube(): boolean;
  76892. /**
  76893. * Detects if the projection matrix requires to be recomputed this frame.
  76894. * @returns true if it requires to be recomputed otherwise, false.
  76895. */
  76896. needProjectionMatrixCompute(): boolean;
  76897. /**
  76898. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76899. */
  76900. forceProjectionMatrixCompute(): void;
  76901. /**
  76902. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76903. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76904. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76905. */
  76906. getShadowDirection(faceIndex?: number): Vector3;
  76907. /**
  76908. * Gets the minZ used for shadow according to both the scene and the light.
  76909. * @param activeCamera The camera we are returning the min for
  76910. * @returns the depth min z
  76911. */
  76912. getDepthMinZ(activeCamera: Camera): number;
  76913. /**
  76914. * Gets the maxZ used for shadow according to both the scene and the light.
  76915. * @param activeCamera The camera we are returning the max for
  76916. * @returns the depth max z
  76917. */
  76918. getDepthMaxZ(activeCamera: Camera): number;
  76919. }
  76920. /**
  76921. * Base implementation IShadowLight
  76922. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76923. */
  76924. export abstract class ShadowLight extends Light implements IShadowLight {
  76925. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76926. protected _position: Vector3;
  76927. protected _setPosition(value: Vector3): void;
  76928. /**
  76929. * Sets the position the shadow will be casted from. Also use as the light position for both
  76930. * point and spot lights.
  76931. */
  76932. /**
  76933. * Sets the position the shadow will be casted from. Also use as the light position for both
  76934. * point and spot lights.
  76935. */
  76936. position: Vector3;
  76937. protected _direction: Vector3;
  76938. protected _setDirection(value: Vector3): void;
  76939. /**
  76940. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76941. * Also use as the light direction on spot and directional lights.
  76942. */
  76943. /**
  76944. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76945. * Also use as the light direction on spot and directional lights.
  76946. */
  76947. direction: Vector3;
  76948. private _shadowMinZ;
  76949. /**
  76950. * Gets the shadow projection clipping minimum z value.
  76951. */
  76952. /**
  76953. * Sets the shadow projection clipping minimum z value.
  76954. */
  76955. shadowMinZ: number;
  76956. private _shadowMaxZ;
  76957. /**
  76958. * Sets the shadow projection clipping maximum z value.
  76959. */
  76960. /**
  76961. * Gets the shadow projection clipping maximum z value.
  76962. */
  76963. shadowMaxZ: number;
  76964. /**
  76965. * Callback defining a custom Projection Matrix Builder.
  76966. * This can be used to override the default projection matrix computation.
  76967. */
  76968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76969. /**
  76970. * The transformed position. Position of the light in world space taking parenting in account.
  76971. */
  76972. transformedPosition: Vector3;
  76973. /**
  76974. * The transformed direction. Direction of the light in world space taking parenting in account.
  76975. */
  76976. transformedDirection: Vector3;
  76977. private _needProjectionMatrixCompute;
  76978. /**
  76979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76981. */
  76982. computeTransformedInformation(): boolean;
  76983. /**
  76984. * Return the depth scale used for the shadow map.
  76985. * @returns the depth scale.
  76986. */
  76987. getDepthScale(): number;
  76988. /**
  76989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76992. */
  76993. getShadowDirection(faceIndex?: number): Vector3;
  76994. /**
  76995. * Returns the ShadowLight absolute position in the World.
  76996. * @returns the position vector in world space
  76997. */
  76998. getAbsolutePosition(): Vector3;
  76999. /**
  77000. * Sets the ShadowLight direction toward the passed target.
  77001. * @param target The point to target in local space
  77002. * @returns the updated ShadowLight direction
  77003. */
  77004. setDirectionToTarget(target: Vector3): Vector3;
  77005. /**
  77006. * Returns the light rotation in euler definition.
  77007. * @returns the x y z rotation in local space.
  77008. */
  77009. getRotation(): Vector3;
  77010. /**
  77011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77012. * @returns true if a cube texture needs to be use
  77013. */
  77014. needCube(): boolean;
  77015. /**
  77016. * Detects if the projection matrix requires to be recomputed this frame.
  77017. * @returns true if it requires to be recomputed otherwise, false.
  77018. */
  77019. needProjectionMatrixCompute(): boolean;
  77020. /**
  77021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77022. */
  77023. forceProjectionMatrixCompute(): void;
  77024. /** @hidden */
  77025. _initCache(): void;
  77026. /** @hidden */
  77027. _isSynchronized(): boolean;
  77028. /**
  77029. * Computes the world matrix of the node
  77030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77031. * @returns the world matrix
  77032. */
  77033. computeWorldMatrix(force?: boolean): Matrix;
  77034. /**
  77035. * Gets the minZ used for shadow according to both the scene and the light.
  77036. * @param activeCamera The camera we are returning the min for
  77037. * @returns the depth min z
  77038. */
  77039. getDepthMinZ(activeCamera: Camera): number;
  77040. /**
  77041. * Gets the maxZ used for shadow according to both the scene and the light.
  77042. * @param activeCamera The camera we are returning the max for
  77043. * @returns the depth max z
  77044. */
  77045. getDepthMaxZ(activeCamera: Camera): number;
  77046. /**
  77047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77048. * @param matrix The materix to updated with the projection information
  77049. * @param viewMatrix The transform matrix of the light
  77050. * @param renderList The list of mesh to render in the map
  77051. * @returns The current light
  77052. */
  77053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77054. }
  77055. }
  77056. declare module BABYLON {
  77057. /**
  77058. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77059. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77060. */
  77061. export class EffectFallbacks implements IEffectFallbacks {
  77062. private _defines;
  77063. private _currentRank;
  77064. private _maxRank;
  77065. private _mesh;
  77066. /**
  77067. * Removes the fallback from the bound mesh.
  77068. */
  77069. unBindMesh(): void;
  77070. /**
  77071. * Adds a fallback on the specified property.
  77072. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77073. * @param define The name of the define in the shader
  77074. */
  77075. addFallback(rank: number, define: string): void;
  77076. /**
  77077. * Sets the mesh to use CPU skinning when needing to fallback.
  77078. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77079. * @param mesh The mesh to use the fallbacks.
  77080. */
  77081. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77082. /**
  77083. * Checks to see if more fallbacks are still availible.
  77084. */
  77085. readonly hasMoreFallbacks: boolean;
  77086. /**
  77087. * Removes the defines that should be removed when falling back.
  77088. * @param currentDefines defines the current define statements for the shader.
  77089. * @param effect defines the current effect we try to compile
  77090. * @returns The resulting defines with defines of the current rank removed.
  77091. */
  77092. reduce(currentDefines: string, effect: Effect): string;
  77093. }
  77094. }
  77095. declare module BABYLON {
  77096. /**
  77097. * "Static Class" containing the most commonly used helper while dealing with material for
  77098. * rendering purpose.
  77099. *
  77100. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77101. *
  77102. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77103. */
  77104. export class MaterialHelper {
  77105. /**
  77106. * Bind the current view position to an effect.
  77107. * @param effect The effect to be bound
  77108. * @param scene The scene the eyes position is used from
  77109. */
  77110. static BindEyePosition(effect: Effect, scene: Scene): void;
  77111. /**
  77112. * Helps preparing the defines values about the UVs in used in the effect.
  77113. * UVs are shared as much as we can accross channels in the shaders.
  77114. * @param texture The texture we are preparing the UVs for
  77115. * @param defines The defines to update
  77116. * @param key The channel key "diffuse", "specular"... used in the shader
  77117. */
  77118. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77119. /**
  77120. * Binds a texture matrix value to its corrsponding uniform
  77121. * @param texture The texture to bind the matrix for
  77122. * @param uniformBuffer The uniform buffer receivin the data
  77123. * @param key The channel key "diffuse", "specular"... used in the shader
  77124. */
  77125. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77126. /**
  77127. * Gets the current status of the fog (should it be enabled?)
  77128. * @param mesh defines the mesh to evaluate for fog support
  77129. * @param scene defines the hosting scene
  77130. * @returns true if fog must be enabled
  77131. */
  77132. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77133. /**
  77134. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77135. * @param mesh defines the current mesh
  77136. * @param scene defines the current scene
  77137. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77138. * @param pointsCloud defines if point cloud rendering has to be turned on
  77139. * @param fogEnabled defines if fog has to be turned on
  77140. * @param alphaTest defines if alpha testing has to be turned on
  77141. * @param defines defines the current list of defines
  77142. */
  77143. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77144. /**
  77145. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77146. * @param scene defines the current scene
  77147. * @param engine defines the current engine
  77148. * @param defines specifies the list of active defines
  77149. * @param useInstances defines if instances have to be turned on
  77150. * @param useClipPlane defines if clip plane have to be turned on
  77151. */
  77152. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77153. /**
  77154. * Prepares the defines for bones
  77155. * @param mesh The mesh containing the geometry data we will draw
  77156. * @param defines The defines to update
  77157. */
  77158. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77159. /**
  77160. * Prepares the defines for morph targets
  77161. * @param mesh The mesh containing the geometry data we will draw
  77162. * @param defines The defines to update
  77163. */
  77164. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77165. /**
  77166. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77167. * @param mesh The mesh containing the geometry data we will draw
  77168. * @param defines The defines to update
  77169. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77170. * @param useBones Precise whether bones should be used or not (override mesh info)
  77171. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77172. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77173. * @returns false if defines are considered not dirty and have not been checked
  77174. */
  77175. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77176. /**
  77177. * Prepares the defines related to multiview
  77178. * @param scene The scene we are intending to draw
  77179. * @param defines The defines to update
  77180. */
  77181. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77182. /**
  77183. * Prepares the defines related to the light information passed in parameter
  77184. * @param scene The scene we are intending to draw
  77185. * @param mesh The mesh the effect is compiling for
  77186. * @param light The light the effect is compiling for
  77187. * @param lightIndex The index of the light
  77188. * @param defines The defines to update
  77189. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77190. * @param state Defines the current state regarding what is needed (normals, etc...)
  77191. */
  77192. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77193. needNormals: boolean;
  77194. needRebuild: boolean;
  77195. shadowEnabled: boolean;
  77196. specularEnabled: boolean;
  77197. lightmapMode: boolean;
  77198. }): void;
  77199. /**
  77200. * Prepares the defines related to the light information passed in parameter
  77201. * @param scene The scene we are intending to draw
  77202. * @param mesh The mesh the effect is compiling for
  77203. * @param defines The defines to update
  77204. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77205. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77206. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77207. * @returns true if normals will be required for the rest of the effect
  77208. */
  77209. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77210. /**
  77211. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77212. * @param lightIndex defines the light index
  77213. * @param uniformsList The uniform list
  77214. * @param samplersList The sampler list
  77215. * @param projectedLightTexture defines if projected texture must be used
  77216. * @param uniformBuffersList defines an optional list of uniform buffers
  77217. */
  77218. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77219. /**
  77220. * Prepares the uniforms and samplers list to be used in the effect
  77221. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77222. * @param samplersList The sampler list
  77223. * @param defines The defines helping in the list generation
  77224. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77225. */
  77226. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77227. /**
  77228. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77229. * @param defines The defines to update while falling back
  77230. * @param fallbacks The authorized effect fallbacks
  77231. * @param maxSimultaneousLights The maximum number of lights allowed
  77232. * @param rank the current rank of the Effect
  77233. * @returns The newly affected rank
  77234. */
  77235. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77236. private static _TmpMorphInfluencers;
  77237. /**
  77238. * Prepares the list of attributes required for morph targets according to the effect defines.
  77239. * @param attribs The current list of supported attribs
  77240. * @param mesh The mesh to prepare the morph targets attributes for
  77241. * @param influencers The number of influencers
  77242. */
  77243. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77244. /**
  77245. * Prepares the list of attributes required for morph targets according to the effect defines.
  77246. * @param attribs The current list of supported attribs
  77247. * @param mesh The mesh to prepare the morph targets attributes for
  77248. * @param defines The current Defines of the effect
  77249. */
  77250. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77251. /**
  77252. * Prepares the list of attributes required for bones according to the effect defines.
  77253. * @param attribs The current list of supported attribs
  77254. * @param mesh The mesh to prepare the bones attributes for
  77255. * @param defines The current Defines of the effect
  77256. * @param fallbacks The current efffect fallback strategy
  77257. */
  77258. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77259. /**
  77260. * Check and prepare the list of attributes required for instances according to the effect defines.
  77261. * @param attribs The current list of supported attribs
  77262. * @param defines The current MaterialDefines of the effect
  77263. */
  77264. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77265. /**
  77266. * Add the list of attributes required for instances to the attribs array.
  77267. * @param attribs The current list of supported attribs
  77268. */
  77269. static PushAttributesForInstances(attribs: string[]): void;
  77270. /**
  77271. * Binds the light information to the effect.
  77272. * @param light The light containing the generator
  77273. * @param effect The effect we are binding the data to
  77274. * @param lightIndex The light index in the effect used to render
  77275. */
  77276. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77277. /**
  77278. * Binds the lights information from the scene to the effect for the given mesh.
  77279. * @param light Light to bind
  77280. * @param lightIndex Light index
  77281. * @param scene The scene where the light belongs to
  77282. * @param effect The effect we are binding the data to
  77283. * @param useSpecular Defines if specular is supported
  77284. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77285. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77286. */
  77287. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77288. /**
  77289. * Binds the lights information from the scene to the effect for the given mesh.
  77290. * @param scene The scene the lights belongs to
  77291. * @param mesh The mesh we are binding the information to render
  77292. * @param effect The effect we are binding the data to
  77293. * @param defines The generated defines for the effect
  77294. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77295. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77296. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77297. */
  77298. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77299. private static _tempFogColor;
  77300. /**
  77301. * Binds the fog information from the scene to the effect for the given mesh.
  77302. * @param scene The scene the lights belongs to
  77303. * @param mesh The mesh we are binding the information to render
  77304. * @param effect The effect we are binding the data to
  77305. * @param linearSpace Defines if the fog effect is applied in linear space
  77306. */
  77307. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77308. /**
  77309. * Binds the bones information from the mesh to the effect.
  77310. * @param mesh The mesh we are binding the information to render
  77311. * @param effect The effect we are binding the data to
  77312. */
  77313. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77314. /**
  77315. * Binds the morph targets information from the mesh to the effect.
  77316. * @param abstractMesh The mesh we are binding the information to render
  77317. * @param effect The effect we are binding the data to
  77318. */
  77319. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77320. /**
  77321. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77322. * @param defines The generated defines used in the effect
  77323. * @param effect The effect we are binding the data to
  77324. * @param scene The scene we are willing to render with logarithmic scale for
  77325. */
  77326. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77327. /**
  77328. * Binds the clip plane information from the scene to the effect.
  77329. * @param scene The scene the clip plane information are extracted from
  77330. * @param effect The effect we are binding the data to
  77331. */
  77332. static BindClipPlane(effect: Effect, scene: Scene): void;
  77333. }
  77334. }
  77335. declare module BABYLON {
  77336. /** @hidden */
  77337. export var packingFunctions: {
  77338. name: string;
  77339. shader: string;
  77340. };
  77341. }
  77342. declare module BABYLON {
  77343. /** @hidden */
  77344. export var shadowMapPixelShader: {
  77345. name: string;
  77346. shader: string;
  77347. };
  77348. }
  77349. declare module BABYLON {
  77350. /** @hidden */
  77351. export var bonesDeclaration: {
  77352. name: string;
  77353. shader: string;
  77354. };
  77355. }
  77356. declare module BABYLON {
  77357. /** @hidden */
  77358. export var morphTargetsVertexGlobalDeclaration: {
  77359. name: string;
  77360. shader: string;
  77361. };
  77362. }
  77363. declare module BABYLON {
  77364. /** @hidden */
  77365. export var morphTargetsVertexDeclaration: {
  77366. name: string;
  77367. shader: string;
  77368. };
  77369. }
  77370. declare module BABYLON {
  77371. /** @hidden */
  77372. export var instancesDeclaration: {
  77373. name: string;
  77374. shader: string;
  77375. };
  77376. }
  77377. declare module BABYLON {
  77378. /** @hidden */
  77379. export var helperFunctions: {
  77380. name: string;
  77381. shader: string;
  77382. };
  77383. }
  77384. declare module BABYLON {
  77385. /** @hidden */
  77386. export var morphTargetsVertex: {
  77387. name: string;
  77388. shader: string;
  77389. };
  77390. }
  77391. declare module BABYLON {
  77392. /** @hidden */
  77393. export var instancesVertex: {
  77394. name: string;
  77395. shader: string;
  77396. };
  77397. }
  77398. declare module BABYLON {
  77399. /** @hidden */
  77400. export var bonesVertex: {
  77401. name: string;
  77402. shader: string;
  77403. };
  77404. }
  77405. declare module BABYLON {
  77406. /** @hidden */
  77407. export var shadowMapVertexShader: {
  77408. name: string;
  77409. shader: string;
  77410. };
  77411. }
  77412. declare module BABYLON {
  77413. /** @hidden */
  77414. export var depthBoxBlurPixelShader: {
  77415. name: string;
  77416. shader: string;
  77417. };
  77418. }
  77419. declare module BABYLON {
  77420. /**
  77421. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77422. */
  77423. export interface ICustomShaderOptions {
  77424. /**
  77425. * Gets or sets the custom shader name to use
  77426. */
  77427. shaderName: string;
  77428. /**
  77429. * The list of attribute names used in the shader
  77430. */
  77431. attributes?: string[];
  77432. /**
  77433. * The list of unifrom names used in the shader
  77434. */
  77435. uniforms?: string[];
  77436. /**
  77437. * The list of sampler names used in the shader
  77438. */
  77439. samplers?: string[];
  77440. /**
  77441. * The list of defines used in the shader
  77442. */
  77443. defines?: string[];
  77444. }
  77445. /**
  77446. * Interface to implement to create a shadow generator compatible with BJS.
  77447. */
  77448. export interface IShadowGenerator {
  77449. /**
  77450. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77451. * @returns The render target texture if present otherwise, null
  77452. */
  77453. getShadowMap(): Nullable<RenderTargetTexture>;
  77454. /**
  77455. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77456. * @returns The render target texture if the shadow map is present otherwise, null
  77457. */
  77458. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77459. /**
  77460. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77461. * @param subMesh The submesh we want to render in the shadow map
  77462. * @param useInstances Defines wether will draw in the map using instances
  77463. * @returns true if ready otherwise, false
  77464. */
  77465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77466. /**
  77467. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77468. * @param defines Defines of the material we want to update
  77469. * @param lightIndex Index of the light in the enabled light list of the material
  77470. */
  77471. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77472. /**
  77473. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77474. * defined in the generator but impacting the effect).
  77475. * It implies the unifroms available on the materials are the standard BJS ones.
  77476. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77477. * @param effect The effect we are binfing the information for
  77478. */
  77479. bindShadowLight(lightIndex: string, effect: Effect): void;
  77480. /**
  77481. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77482. * (eq to shadow prjection matrix * light transform matrix)
  77483. * @returns The transform matrix used to create the shadow map
  77484. */
  77485. getTransformMatrix(): Matrix;
  77486. /**
  77487. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77488. * Cube and 2D textures for instance.
  77489. */
  77490. recreateShadowMap(): void;
  77491. /**
  77492. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77493. * @param onCompiled Callback triggered at the and of the effects compilation
  77494. * @param options Sets of optional options forcing the compilation with different modes
  77495. */
  77496. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77497. useInstances: boolean;
  77498. }>): void;
  77499. /**
  77500. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77501. * @param options Sets of optional options forcing the compilation with different modes
  77502. * @returns A promise that resolves when the compilation completes
  77503. */
  77504. forceCompilationAsync(options?: Partial<{
  77505. useInstances: boolean;
  77506. }>): Promise<void>;
  77507. /**
  77508. * Serializes the shadow generator setup to a json object.
  77509. * @returns The serialized JSON object
  77510. */
  77511. serialize(): any;
  77512. /**
  77513. * Disposes the Shadow map and related Textures and effects.
  77514. */
  77515. dispose(): void;
  77516. }
  77517. /**
  77518. * Default implementation IShadowGenerator.
  77519. * This is the main object responsible of generating shadows in the framework.
  77520. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77521. */
  77522. export class ShadowGenerator implements IShadowGenerator {
  77523. /**
  77524. * Shadow generator mode None: no filtering applied.
  77525. */
  77526. static readonly FILTER_NONE: number;
  77527. /**
  77528. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77529. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77530. */
  77531. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77532. /**
  77533. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77534. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77535. */
  77536. static readonly FILTER_POISSONSAMPLING: number;
  77537. /**
  77538. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77539. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77540. */
  77541. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77542. /**
  77543. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77544. * edge artifacts on steep falloff.
  77545. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77546. */
  77547. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77548. /**
  77549. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77550. * edge artifacts on steep falloff.
  77551. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77552. */
  77553. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77554. /**
  77555. * Shadow generator mode PCF: Percentage Closer Filtering
  77556. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77557. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77558. */
  77559. static readonly FILTER_PCF: number;
  77560. /**
  77561. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77562. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77563. * Contact Hardening
  77564. */
  77565. static readonly FILTER_PCSS: number;
  77566. /**
  77567. * Reserved for PCF and PCSS
  77568. * Highest Quality.
  77569. *
  77570. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77571. *
  77572. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77573. */
  77574. static readonly QUALITY_HIGH: number;
  77575. /**
  77576. * Reserved for PCF and PCSS
  77577. * Good tradeoff for quality/perf cross devices
  77578. *
  77579. * Execute PCF on a 3*3 kernel.
  77580. *
  77581. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77582. */
  77583. static readonly QUALITY_MEDIUM: number;
  77584. /**
  77585. * Reserved for PCF and PCSS
  77586. * The lowest quality but the fastest.
  77587. *
  77588. * Execute PCF on a 1*1 kernel.
  77589. *
  77590. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77591. */
  77592. static readonly QUALITY_LOW: number;
  77593. /** Gets or sets the custom shader name to use */
  77594. customShaderOptions: ICustomShaderOptions;
  77595. /**
  77596. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77597. */
  77598. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77599. /**
  77600. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77601. */
  77602. onAfterShadowMapRenderObservable: Observable<Effect>;
  77603. /**
  77604. * Observable triggered before a mesh is rendered in the shadow map.
  77605. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77606. */
  77607. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77608. /**
  77609. * Observable triggered after a mesh is rendered in the shadow map.
  77610. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77611. */
  77612. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77613. private _bias;
  77614. /**
  77615. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77616. */
  77617. /**
  77618. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77619. */
  77620. bias: number;
  77621. private _normalBias;
  77622. /**
  77623. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77624. */
  77625. /**
  77626. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77627. */
  77628. normalBias: number;
  77629. private _blurBoxOffset;
  77630. /**
  77631. * Gets the blur box offset: offset applied during the blur pass.
  77632. * Only useful if useKernelBlur = false
  77633. */
  77634. /**
  77635. * Sets the blur box offset: offset applied during the blur pass.
  77636. * Only useful if useKernelBlur = false
  77637. */
  77638. blurBoxOffset: number;
  77639. private _blurScale;
  77640. /**
  77641. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77642. * 2 means half of the size.
  77643. */
  77644. /**
  77645. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77646. * 2 means half of the size.
  77647. */
  77648. blurScale: number;
  77649. private _blurKernel;
  77650. /**
  77651. * Gets the blur kernel: kernel size of the blur pass.
  77652. * Only useful if useKernelBlur = true
  77653. */
  77654. /**
  77655. * Sets the blur kernel: kernel size of the blur pass.
  77656. * Only useful if useKernelBlur = true
  77657. */
  77658. blurKernel: number;
  77659. private _useKernelBlur;
  77660. /**
  77661. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77662. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77663. */
  77664. /**
  77665. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77666. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77667. */
  77668. useKernelBlur: boolean;
  77669. private _depthScale;
  77670. /**
  77671. * Gets the depth scale used in ESM mode.
  77672. */
  77673. /**
  77674. * Sets the depth scale used in ESM mode.
  77675. * This can override the scale stored on the light.
  77676. */
  77677. depthScale: number;
  77678. private _filter;
  77679. /**
  77680. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77681. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77682. */
  77683. /**
  77684. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77685. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77686. */
  77687. filter: number;
  77688. /**
  77689. * Gets if the current filter is set to Poisson Sampling.
  77690. */
  77691. /**
  77692. * Sets the current filter to Poisson Sampling.
  77693. */
  77694. usePoissonSampling: boolean;
  77695. /**
  77696. * Gets if the current filter is set to ESM.
  77697. */
  77698. /**
  77699. * Sets the current filter is to ESM.
  77700. */
  77701. useExponentialShadowMap: boolean;
  77702. /**
  77703. * Gets if the current filter is set to filtered ESM.
  77704. */
  77705. /**
  77706. * Gets if the current filter is set to filtered ESM.
  77707. */
  77708. useBlurExponentialShadowMap: boolean;
  77709. /**
  77710. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77711. * exponential to prevent steep falloff artifacts).
  77712. */
  77713. /**
  77714. * Sets the current filter to "close ESM" (using the inverse of the
  77715. * exponential to prevent steep falloff artifacts).
  77716. */
  77717. useCloseExponentialShadowMap: boolean;
  77718. /**
  77719. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77720. * exponential to prevent steep falloff artifacts).
  77721. */
  77722. /**
  77723. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77724. * exponential to prevent steep falloff artifacts).
  77725. */
  77726. useBlurCloseExponentialShadowMap: boolean;
  77727. /**
  77728. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77729. */
  77730. /**
  77731. * Sets the current filter to "PCF" (percentage closer filtering).
  77732. */
  77733. usePercentageCloserFiltering: boolean;
  77734. private _filteringQuality;
  77735. /**
  77736. * Gets the PCF or PCSS Quality.
  77737. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77738. */
  77739. /**
  77740. * Sets the PCF or PCSS Quality.
  77741. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77742. */
  77743. filteringQuality: number;
  77744. /**
  77745. * Gets if the current filter is set to "PCSS" (contact hardening).
  77746. */
  77747. /**
  77748. * Sets the current filter to "PCSS" (contact hardening).
  77749. */
  77750. useContactHardeningShadow: boolean;
  77751. private _contactHardeningLightSizeUVRatio;
  77752. /**
  77753. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77754. * Using a ratio helps keeping shape stability independently of the map size.
  77755. *
  77756. * It does not account for the light projection as it was having too much
  77757. * instability during the light setup or during light position changes.
  77758. *
  77759. * Only valid if useContactHardeningShadow is true.
  77760. */
  77761. /**
  77762. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77763. * Using a ratio helps keeping shape stability independently of the map size.
  77764. *
  77765. * It does not account for the light projection as it was having too much
  77766. * instability during the light setup or during light position changes.
  77767. *
  77768. * Only valid if useContactHardeningShadow is true.
  77769. */
  77770. contactHardeningLightSizeUVRatio: number;
  77771. private _darkness;
  77772. /** Gets or sets the actual darkness of a shadow */
  77773. darkness: number;
  77774. /**
  77775. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77776. * 0 means strongest and 1 would means no shadow.
  77777. * @returns the darkness.
  77778. */
  77779. getDarkness(): number;
  77780. /**
  77781. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77782. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77783. * @returns the shadow generator allowing fluent coding.
  77784. */
  77785. setDarkness(darkness: number): ShadowGenerator;
  77786. private _transparencyShadow;
  77787. /** Gets or sets the ability to have transparent shadow */
  77788. transparencyShadow: boolean;
  77789. /**
  77790. * Sets the ability to have transparent shadow (boolean).
  77791. * @param transparent True if transparent else False
  77792. * @returns the shadow generator allowing fluent coding
  77793. */
  77794. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77795. private _shadowMap;
  77796. private _shadowMap2;
  77797. /**
  77798. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77799. * @returns The render target texture if present otherwise, null
  77800. */
  77801. getShadowMap(): Nullable<RenderTargetTexture>;
  77802. /**
  77803. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77804. * @returns The render target texture if the shadow map is present otherwise, null
  77805. */
  77806. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77807. /**
  77808. * Gets the class name of that object
  77809. * @returns "ShadowGenerator"
  77810. */
  77811. getClassName(): string;
  77812. /**
  77813. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77814. * @param mesh Mesh to add
  77815. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77816. * @returns the Shadow Generator itself
  77817. */
  77818. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77819. /**
  77820. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77821. * @param mesh Mesh to remove
  77822. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77823. * @returns the Shadow Generator itself
  77824. */
  77825. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77826. /**
  77827. * Controls the extent to which the shadows fade out at the edge of the frustum
  77828. * Used only by directionals and spots
  77829. */
  77830. frustumEdgeFalloff: number;
  77831. private _light;
  77832. /**
  77833. * Returns the associated light object.
  77834. * @returns the light generating the shadow
  77835. */
  77836. getLight(): IShadowLight;
  77837. /**
  77838. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77839. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77840. * It might on the other hand introduce peter panning.
  77841. */
  77842. forceBackFacesOnly: boolean;
  77843. private _scene;
  77844. private _lightDirection;
  77845. private _effect;
  77846. private _viewMatrix;
  77847. private _projectionMatrix;
  77848. private _transformMatrix;
  77849. private _cachedPosition;
  77850. private _cachedDirection;
  77851. private _cachedDefines;
  77852. private _currentRenderID;
  77853. private _boxBlurPostprocess;
  77854. private _kernelBlurXPostprocess;
  77855. private _kernelBlurYPostprocess;
  77856. private _blurPostProcesses;
  77857. private _mapSize;
  77858. private _currentFaceIndex;
  77859. private _currentFaceIndexCache;
  77860. private _textureType;
  77861. private _defaultTextureMatrix;
  77862. private _storedUniqueId;
  77863. /** @hidden */
  77864. static _SceneComponentInitialization: (scene: Scene) => void;
  77865. /**
  77866. * Creates a ShadowGenerator object.
  77867. * A ShadowGenerator is the required tool to use the shadows.
  77868. * Each light casting shadows needs to use its own ShadowGenerator.
  77869. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77870. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77871. * @param light The light object generating the shadows.
  77872. * @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.
  77873. */
  77874. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77875. private _initializeGenerator;
  77876. private _initializeShadowMap;
  77877. private _initializeBlurRTTAndPostProcesses;
  77878. private _renderForShadowMap;
  77879. private _renderSubMeshForShadowMap;
  77880. private _applyFilterValues;
  77881. /**
  77882. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77883. * @param onCompiled Callback triggered at the and of the effects compilation
  77884. * @param options Sets of optional options forcing the compilation with different modes
  77885. */
  77886. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77887. useInstances: boolean;
  77888. }>): void;
  77889. /**
  77890. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77891. * @param options Sets of optional options forcing the compilation with different modes
  77892. * @returns A promise that resolves when the compilation completes
  77893. */
  77894. forceCompilationAsync(options?: Partial<{
  77895. useInstances: boolean;
  77896. }>): Promise<void>;
  77897. /**
  77898. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77899. * @param subMesh The submesh we want to render in the shadow map
  77900. * @param useInstances Defines wether will draw in the map using instances
  77901. * @returns true if ready otherwise, false
  77902. */
  77903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77904. /**
  77905. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77906. * @param defines Defines of the material we want to update
  77907. * @param lightIndex Index of the light in the enabled light list of the material
  77908. */
  77909. prepareDefines(defines: any, lightIndex: number): void;
  77910. /**
  77911. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77912. * defined in the generator but impacting the effect).
  77913. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77914. * @param effect The effect we are binfing the information for
  77915. */
  77916. bindShadowLight(lightIndex: string, effect: Effect): void;
  77917. /**
  77918. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77919. * (eq to shadow prjection matrix * light transform matrix)
  77920. * @returns The transform matrix used to create the shadow map
  77921. */
  77922. getTransformMatrix(): Matrix;
  77923. /**
  77924. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77925. * Cube and 2D textures for instance.
  77926. */
  77927. recreateShadowMap(): void;
  77928. private _disposeBlurPostProcesses;
  77929. private _disposeRTTandPostProcesses;
  77930. /**
  77931. * Disposes the ShadowGenerator.
  77932. * Returns nothing.
  77933. */
  77934. dispose(): void;
  77935. /**
  77936. * Serializes the shadow generator setup to a json object.
  77937. * @returns The serialized JSON object
  77938. */
  77939. serialize(): any;
  77940. /**
  77941. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77942. * @param parsedShadowGenerator The JSON object to parse
  77943. * @param scene The scene to create the shadow map for
  77944. * @returns The parsed shadow generator
  77945. */
  77946. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77947. }
  77948. }
  77949. declare module BABYLON {
  77950. /**
  77951. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77952. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77953. * 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.
  77954. */
  77955. export abstract class Light extends Node {
  77956. /**
  77957. * Falloff Default: light is falling off following the material specification:
  77958. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77959. */
  77960. static readonly FALLOFF_DEFAULT: number;
  77961. /**
  77962. * Falloff Physical: light is falling off following the inverse squared distance law.
  77963. */
  77964. static readonly FALLOFF_PHYSICAL: number;
  77965. /**
  77966. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77967. * to enhance interoperability with other engines.
  77968. */
  77969. static readonly FALLOFF_GLTF: number;
  77970. /**
  77971. * Falloff Standard: light is falling off like in the standard material
  77972. * to enhance interoperability with other materials.
  77973. */
  77974. static readonly FALLOFF_STANDARD: number;
  77975. /**
  77976. * If every light affecting the material is in this lightmapMode,
  77977. * material.lightmapTexture adds or multiplies
  77978. * (depends on material.useLightmapAsShadowmap)
  77979. * after every other light calculations.
  77980. */
  77981. static readonly LIGHTMAP_DEFAULT: number;
  77982. /**
  77983. * material.lightmapTexture as only diffuse lighting from this light
  77984. * adds only specular lighting from this light
  77985. * adds dynamic shadows
  77986. */
  77987. static readonly LIGHTMAP_SPECULAR: number;
  77988. /**
  77989. * material.lightmapTexture as only lighting
  77990. * no light calculation from this light
  77991. * only adds dynamic shadows from this light
  77992. */
  77993. static readonly LIGHTMAP_SHADOWSONLY: number;
  77994. /**
  77995. * Each light type uses the default quantity according to its type:
  77996. * point/spot lights use luminous intensity
  77997. * directional lights use illuminance
  77998. */
  77999. static readonly INTENSITYMODE_AUTOMATIC: number;
  78000. /**
  78001. * lumen (lm)
  78002. */
  78003. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78004. /**
  78005. * candela (lm/sr)
  78006. */
  78007. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78008. /**
  78009. * lux (lm/m^2)
  78010. */
  78011. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78012. /**
  78013. * nit (cd/m^2)
  78014. */
  78015. static readonly INTENSITYMODE_LUMINANCE: number;
  78016. /**
  78017. * Light type const id of the point light.
  78018. */
  78019. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78020. /**
  78021. * Light type const id of the directional light.
  78022. */
  78023. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78024. /**
  78025. * Light type const id of the spot light.
  78026. */
  78027. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78028. /**
  78029. * Light type const id of the hemispheric light.
  78030. */
  78031. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78032. /**
  78033. * Diffuse gives the basic color to an object.
  78034. */
  78035. diffuse: Color3;
  78036. /**
  78037. * Specular produces a highlight color on an object.
  78038. * Note: This is note affecting PBR materials.
  78039. */
  78040. specular: Color3;
  78041. /**
  78042. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78043. * falling off base on range or angle.
  78044. * This can be set to any values in Light.FALLOFF_x.
  78045. *
  78046. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78047. * other types of materials.
  78048. */
  78049. falloffType: number;
  78050. /**
  78051. * Strength of the light.
  78052. * Note: By default it is define in the framework own unit.
  78053. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78054. */
  78055. intensity: number;
  78056. private _range;
  78057. protected _inverseSquaredRange: number;
  78058. /**
  78059. * Defines how far from the source the light is impacting in scene units.
  78060. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78061. */
  78062. /**
  78063. * Defines how far from the source the light is impacting in scene units.
  78064. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78065. */
  78066. range: number;
  78067. /**
  78068. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78069. * of light.
  78070. */
  78071. private _photometricScale;
  78072. private _intensityMode;
  78073. /**
  78074. * Gets the photometric scale used to interpret the intensity.
  78075. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78076. */
  78077. /**
  78078. * Sets the photometric scale used to interpret the intensity.
  78079. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78080. */
  78081. intensityMode: number;
  78082. private _radius;
  78083. /**
  78084. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78085. */
  78086. /**
  78087. * sets the light radius used by PBR Materials to simulate soft area lights.
  78088. */
  78089. radius: number;
  78090. private _renderPriority;
  78091. /**
  78092. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78093. * exceeding the number allowed of the materials.
  78094. */
  78095. renderPriority: number;
  78096. private _shadowEnabled;
  78097. /**
  78098. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78099. * the current shadow generator.
  78100. */
  78101. /**
  78102. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78103. * the current shadow generator.
  78104. */
  78105. shadowEnabled: boolean;
  78106. private _includedOnlyMeshes;
  78107. /**
  78108. * Gets the only meshes impacted by this light.
  78109. */
  78110. /**
  78111. * Sets the only meshes impacted by this light.
  78112. */
  78113. includedOnlyMeshes: AbstractMesh[];
  78114. private _excludedMeshes;
  78115. /**
  78116. * Gets the meshes not impacted by this light.
  78117. */
  78118. /**
  78119. * Sets the meshes not impacted by this light.
  78120. */
  78121. excludedMeshes: AbstractMesh[];
  78122. private _excludeWithLayerMask;
  78123. /**
  78124. * Gets the layer id use to find what meshes are not impacted by the light.
  78125. * Inactive if 0
  78126. */
  78127. /**
  78128. * Sets the layer id use to find what meshes are not impacted by the light.
  78129. * Inactive if 0
  78130. */
  78131. excludeWithLayerMask: number;
  78132. private _includeOnlyWithLayerMask;
  78133. /**
  78134. * Gets the layer id use to find what meshes are impacted by the light.
  78135. * Inactive if 0
  78136. */
  78137. /**
  78138. * Sets the layer id use to find what meshes are impacted by the light.
  78139. * Inactive if 0
  78140. */
  78141. includeOnlyWithLayerMask: number;
  78142. private _lightmapMode;
  78143. /**
  78144. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78145. */
  78146. /**
  78147. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78148. */
  78149. lightmapMode: number;
  78150. /**
  78151. * Shadow generator associted to the light.
  78152. * @hidden Internal use only.
  78153. */
  78154. _shadowGenerator: Nullable<IShadowGenerator>;
  78155. /**
  78156. * @hidden Internal use only.
  78157. */
  78158. _excludedMeshesIds: string[];
  78159. /**
  78160. * @hidden Internal use only.
  78161. */
  78162. _includedOnlyMeshesIds: string[];
  78163. /**
  78164. * The current light unifom buffer.
  78165. * @hidden Internal use only.
  78166. */
  78167. _uniformBuffer: UniformBuffer;
  78168. /** @hidden */
  78169. _renderId: number;
  78170. /**
  78171. * Creates a Light object in the scene.
  78172. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78173. * @param name The firendly name of the light
  78174. * @param scene The scene the light belongs too
  78175. */
  78176. constructor(name: string, scene: Scene);
  78177. protected abstract _buildUniformLayout(): void;
  78178. /**
  78179. * Sets the passed Effect "effect" with the Light information.
  78180. * @param effect The effect to update
  78181. * @param lightIndex The index of the light in the effect to update
  78182. * @returns The light
  78183. */
  78184. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78185. /**
  78186. * Sets the passed Effect "effect" with the Light information.
  78187. * @param effect The effect to update
  78188. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78189. * @returns The light
  78190. */
  78191. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78192. /**
  78193. * Returns the string "Light".
  78194. * @returns the class name
  78195. */
  78196. getClassName(): string;
  78197. /** @hidden */
  78198. readonly _isLight: boolean;
  78199. /**
  78200. * Converts the light information to a readable string for debug purpose.
  78201. * @param fullDetails Supports for multiple levels of logging within scene loading
  78202. * @returns the human readable light info
  78203. */
  78204. toString(fullDetails?: boolean): string;
  78205. /** @hidden */
  78206. protected _syncParentEnabledState(): void;
  78207. /**
  78208. * Set the enabled state of this node.
  78209. * @param value - the new enabled state
  78210. */
  78211. setEnabled(value: boolean): void;
  78212. /**
  78213. * Returns the Light associated shadow generator if any.
  78214. * @return the associated shadow generator.
  78215. */
  78216. getShadowGenerator(): Nullable<IShadowGenerator>;
  78217. /**
  78218. * Returns a Vector3, the absolute light position in the World.
  78219. * @returns the world space position of the light
  78220. */
  78221. getAbsolutePosition(): Vector3;
  78222. /**
  78223. * Specifies if the light will affect the passed mesh.
  78224. * @param mesh The mesh to test against the light
  78225. * @return true the mesh is affected otherwise, false.
  78226. */
  78227. canAffectMesh(mesh: AbstractMesh): boolean;
  78228. /**
  78229. * Sort function to order lights for rendering.
  78230. * @param a First Light object to compare to second.
  78231. * @param b Second Light object to compare first.
  78232. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78233. */
  78234. static CompareLightsPriority(a: Light, b: Light): number;
  78235. /**
  78236. * Releases resources associated with this node.
  78237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78239. */
  78240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78241. /**
  78242. * Returns the light type ID (integer).
  78243. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78244. */
  78245. getTypeID(): number;
  78246. /**
  78247. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78248. * @returns the scaled intensity in intensity mode unit
  78249. */
  78250. getScaledIntensity(): number;
  78251. /**
  78252. * Returns a new Light object, named "name", from the current one.
  78253. * @param name The name of the cloned light
  78254. * @returns the new created light
  78255. */
  78256. clone(name: string): Nullable<Light>;
  78257. /**
  78258. * Serializes the current light into a Serialization object.
  78259. * @returns the serialized object.
  78260. */
  78261. serialize(): any;
  78262. /**
  78263. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78264. * This new light is named "name" and added to the passed scene.
  78265. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78266. * @param name The friendly name of the light
  78267. * @param scene The scene the new light will belong to
  78268. * @returns the constructor function
  78269. */
  78270. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78271. /**
  78272. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78273. * @param parsedLight The JSON representation of the light
  78274. * @param scene The scene to create the parsed light in
  78275. * @returns the created light after parsing
  78276. */
  78277. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78278. private _hookArrayForExcluded;
  78279. private _hookArrayForIncludedOnly;
  78280. private _resyncMeshes;
  78281. /**
  78282. * Forces the meshes to update their light related information in their rendering used effects
  78283. * @hidden Internal Use Only
  78284. */
  78285. _markMeshesAsLightDirty(): void;
  78286. /**
  78287. * Recomputes the cached photometric scale if needed.
  78288. */
  78289. private _computePhotometricScale;
  78290. /**
  78291. * Returns the Photometric Scale according to the light type and intensity mode.
  78292. */
  78293. private _getPhotometricScale;
  78294. /**
  78295. * Reorder the light in the scene according to their defined priority.
  78296. * @hidden Internal Use Only
  78297. */
  78298. _reorderLightsInScene(): void;
  78299. /**
  78300. * Prepares the list of defines specific to the light type.
  78301. * @param defines the list of defines
  78302. * @param lightIndex defines the index of the light for the effect
  78303. */
  78304. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /**
  78309. * Interface used to define Action
  78310. */
  78311. export interface IAction {
  78312. /**
  78313. * Trigger for the action
  78314. */
  78315. trigger: number;
  78316. /** Options of the trigger */
  78317. triggerOptions: any;
  78318. /**
  78319. * Gets the trigger parameters
  78320. * @returns the trigger parameters
  78321. */
  78322. getTriggerParameter(): any;
  78323. /**
  78324. * Internal only - executes current action event
  78325. * @hidden
  78326. */
  78327. _executeCurrent(evt?: ActionEvent): void;
  78328. /**
  78329. * Serialize placeholder for child classes
  78330. * @param parent of child
  78331. * @returns the serialized object
  78332. */
  78333. serialize(parent: any): any;
  78334. /**
  78335. * Internal only
  78336. * @hidden
  78337. */
  78338. _prepare(): void;
  78339. /**
  78340. * Internal only - manager for action
  78341. * @hidden
  78342. */
  78343. _actionManager: AbstractActionManager;
  78344. /**
  78345. * Adds action to chain of actions, may be a DoNothingAction
  78346. * @param action defines the next action to execute
  78347. * @returns The action passed in
  78348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78349. */
  78350. then(action: IAction): IAction;
  78351. }
  78352. /**
  78353. * The action to be carried out following a trigger
  78354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78355. */
  78356. export class Action implements IAction {
  78357. /** the trigger, with or without parameters, for the action */
  78358. triggerOptions: any;
  78359. /**
  78360. * Trigger for the action
  78361. */
  78362. trigger: number;
  78363. /**
  78364. * Internal only - manager for action
  78365. * @hidden
  78366. */
  78367. _actionManager: ActionManager;
  78368. private _nextActiveAction;
  78369. private _child;
  78370. private _condition?;
  78371. private _triggerParameter;
  78372. /**
  78373. * An event triggered prior to action being executed.
  78374. */
  78375. onBeforeExecuteObservable: Observable<Action>;
  78376. /**
  78377. * Creates a new Action
  78378. * @param triggerOptions the trigger, with or without parameters, for the action
  78379. * @param condition an optional determinant of action
  78380. */
  78381. constructor(
  78382. /** the trigger, with or without parameters, for the action */
  78383. triggerOptions: any, condition?: Condition);
  78384. /**
  78385. * Internal only
  78386. * @hidden
  78387. */
  78388. _prepare(): void;
  78389. /**
  78390. * Gets the trigger parameters
  78391. * @returns the trigger parameters
  78392. */
  78393. getTriggerParameter(): any;
  78394. /**
  78395. * Internal only - executes current action event
  78396. * @hidden
  78397. */
  78398. _executeCurrent(evt?: ActionEvent): void;
  78399. /**
  78400. * Execute placeholder for child classes
  78401. * @param evt optional action event
  78402. */
  78403. execute(evt?: ActionEvent): void;
  78404. /**
  78405. * Skips to next active action
  78406. */
  78407. skipToNextActiveAction(): void;
  78408. /**
  78409. * Adds action to chain of actions, may be a DoNothingAction
  78410. * @param action defines the next action to execute
  78411. * @returns The action passed in
  78412. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78413. */
  78414. then(action: Action): Action;
  78415. /**
  78416. * Internal only
  78417. * @hidden
  78418. */
  78419. _getProperty(propertyPath: string): string;
  78420. /**
  78421. * Internal only
  78422. * @hidden
  78423. */
  78424. _getEffectiveTarget(target: any, propertyPath: string): any;
  78425. /**
  78426. * Serialize placeholder for child classes
  78427. * @param parent of child
  78428. * @returns the serialized object
  78429. */
  78430. serialize(parent: any): any;
  78431. /**
  78432. * Internal only called by serialize
  78433. * @hidden
  78434. */
  78435. protected _serialize(serializedAction: any, parent?: any): any;
  78436. /**
  78437. * Internal only
  78438. * @hidden
  78439. */
  78440. static _SerializeValueAsString: (value: any) => string;
  78441. /**
  78442. * Internal only
  78443. * @hidden
  78444. */
  78445. static _GetTargetProperty: (target: Node | Scene) => {
  78446. name: string;
  78447. targetType: string;
  78448. value: string;
  78449. };
  78450. }
  78451. }
  78452. declare module BABYLON {
  78453. /**
  78454. * A Condition applied to an Action
  78455. */
  78456. export class Condition {
  78457. /**
  78458. * Internal only - manager for action
  78459. * @hidden
  78460. */
  78461. _actionManager: ActionManager;
  78462. /**
  78463. * Internal only
  78464. * @hidden
  78465. */
  78466. _evaluationId: number;
  78467. /**
  78468. * Internal only
  78469. * @hidden
  78470. */
  78471. _currentResult: boolean;
  78472. /**
  78473. * Creates a new Condition
  78474. * @param actionManager the manager of the action the condition is applied to
  78475. */
  78476. constructor(actionManager: ActionManager);
  78477. /**
  78478. * Check if the current condition is valid
  78479. * @returns a boolean
  78480. */
  78481. isValid(): boolean;
  78482. /**
  78483. * Internal only
  78484. * @hidden
  78485. */
  78486. _getProperty(propertyPath: string): string;
  78487. /**
  78488. * Internal only
  78489. * @hidden
  78490. */
  78491. _getEffectiveTarget(target: any, propertyPath: string): any;
  78492. /**
  78493. * Serialize placeholder for child classes
  78494. * @returns the serialized object
  78495. */
  78496. serialize(): any;
  78497. /**
  78498. * Internal only
  78499. * @hidden
  78500. */
  78501. protected _serialize(serializedCondition: any): any;
  78502. }
  78503. /**
  78504. * Defines specific conditional operators as extensions of Condition
  78505. */
  78506. export class ValueCondition extends Condition {
  78507. /** path to specify the property of the target the conditional operator uses */
  78508. propertyPath: string;
  78509. /** the value compared by the conditional operator against the current value of the property */
  78510. value: any;
  78511. /** the conditional operator, default ValueCondition.IsEqual */
  78512. operator: number;
  78513. /**
  78514. * Internal only
  78515. * @hidden
  78516. */
  78517. private static _IsEqual;
  78518. /**
  78519. * Internal only
  78520. * @hidden
  78521. */
  78522. private static _IsDifferent;
  78523. /**
  78524. * Internal only
  78525. * @hidden
  78526. */
  78527. private static _IsGreater;
  78528. /**
  78529. * Internal only
  78530. * @hidden
  78531. */
  78532. private static _IsLesser;
  78533. /**
  78534. * returns the number for IsEqual
  78535. */
  78536. static readonly IsEqual: number;
  78537. /**
  78538. * Returns the number for IsDifferent
  78539. */
  78540. static readonly IsDifferent: number;
  78541. /**
  78542. * Returns the number for IsGreater
  78543. */
  78544. static readonly IsGreater: number;
  78545. /**
  78546. * Returns the number for IsLesser
  78547. */
  78548. static readonly IsLesser: number;
  78549. /**
  78550. * Internal only The action manager for the condition
  78551. * @hidden
  78552. */
  78553. _actionManager: ActionManager;
  78554. /**
  78555. * Internal only
  78556. * @hidden
  78557. */
  78558. private _target;
  78559. /**
  78560. * Internal only
  78561. * @hidden
  78562. */
  78563. private _effectiveTarget;
  78564. /**
  78565. * Internal only
  78566. * @hidden
  78567. */
  78568. private _property;
  78569. /**
  78570. * Creates a new ValueCondition
  78571. * @param actionManager manager for the action the condition applies to
  78572. * @param target for the action
  78573. * @param propertyPath path to specify the property of the target the conditional operator uses
  78574. * @param value the value compared by the conditional operator against the current value of the property
  78575. * @param operator the conditional operator, default ValueCondition.IsEqual
  78576. */
  78577. constructor(actionManager: ActionManager, target: any,
  78578. /** path to specify the property of the target the conditional operator uses */
  78579. propertyPath: string,
  78580. /** the value compared by the conditional operator against the current value of the property */
  78581. value: any,
  78582. /** the conditional operator, default ValueCondition.IsEqual */
  78583. operator?: number);
  78584. /**
  78585. * Compares the given value with the property value for the specified conditional operator
  78586. * @returns the result of the comparison
  78587. */
  78588. isValid(): boolean;
  78589. /**
  78590. * Serialize the ValueCondition into a JSON compatible object
  78591. * @returns serialization object
  78592. */
  78593. serialize(): any;
  78594. /**
  78595. * Gets the name of the conditional operator for the ValueCondition
  78596. * @param operator the conditional operator
  78597. * @returns the name
  78598. */
  78599. static GetOperatorName(operator: number): string;
  78600. }
  78601. /**
  78602. * Defines a predicate condition as an extension of Condition
  78603. */
  78604. export class PredicateCondition extends Condition {
  78605. /** defines the predicate function used to validate the condition */
  78606. predicate: () => boolean;
  78607. /**
  78608. * Internal only - manager for action
  78609. * @hidden
  78610. */
  78611. _actionManager: ActionManager;
  78612. /**
  78613. * Creates a new PredicateCondition
  78614. * @param actionManager manager for the action the condition applies to
  78615. * @param predicate defines the predicate function used to validate the condition
  78616. */
  78617. constructor(actionManager: ActionManager,
  78618. /** defines the predicate function used to validate the condition */
  78619. predicate: () => boolean);
  78620. /**
  78621. * @returns the validity of the predicate condition
  78622. */
  78623. isValid(): boolean;
  78624. }
  78625. /**
  78626. * Defines a state condition as an extension of Condition
  78627. */
  78628. export class StateCondition extends Condition {
  78629. /** Value to compare with target state */
  78630. value: string;
  78631. /**
  78632. * Internal only - manager for action
  78633. * @hidden
  78634. */
  78635. _actionManager: ActionManager;
  78636. /**
  78637. * Internal only
  78638. * @hidden
  78639. */
  78640. private _target;
  78641. /**
  78642. * Creates a new StateCondition
  78643. * @param actionManager manager for the action the condition applies to
  78644. * @param target of the condition
  78645. * @param value to compare with target state
  78646. */
  78647. constructor(actionManager: ActionManager, target: any,
  78648. /** Value to compare with target state */
  78649. value: string);
  78650. /**
  78651. * Gets a boolean indicating if the current condition is met
  78652. * @returns the validity of the state
  78653. */
  78654. isValid(): boolean;
  78655. /**
  78656. * Serialize the StateCondition into a JSON compatible object
  78657. * @returns serialization object
  78658. */
  78659. serialize(): any;
  78660. }
  78661. }
  78662. declare module BABYLON {
  78663. /**
  78664. * This defines an action responsible to toggle a boolean once triggered.
  78665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78666. */
  78667. export class SwitchBooleanAction extends Action {
  78668. /**
  78669. * The path to the boolean property in the target object
  78670. */
  78671. propertyPath: string;
  78672. private _target;
  78673. private _effectiveTarget;
  78674. private _property;
  78675. /**
  78676. * Instantiate the action
  78677. * @param triggerOptions defines the trigger options
  78678. * @param target defines the object containing the boolean
  78679. * @param propertyPath defines the path to the boolean property in the target object
  78680. * @param condition defines the trigger related conditions
  78681. */
  78682. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78683. /** @hidden */
  78684. _prepare(): void;
  78685. /**
  78686. * Execute the action toggle the boolean value.
  78687. */
  78688. execute(): void;
  78689. /**
  78690. * Serializes the actions and its related information.
  78691. * @param parent defines the object to serialize in
  78692. * @returns the serialized object
  78693. */
  78694. serialize(parent: any): any;
  78695. }
  78696. /**
  78697. * This defines an action responsible to set a the state field of the target
  78698. * to a desired value once triggered.
  78699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78700. */
  78701. export class SetStateAction extends Action {
  78702. /**
  78703. * The value to store in the state field.
  78704. */
  78705. value: string;
  78706. private _target;
  78707. /**
  78708. * Instantiate the action
  78709. * @param triggerOptions defines the trigger options
  78710. * @param target defines the object containing the state property
  78711. * @param value defines the value to store in the state field
  78712. * @param condition defines the trigger related conditions
  78713. */
  78714. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78715. /**
  78716. * Execute the action and store the value on the target state property.
  78717. */
  78718. execute(): void;
  78719. /**
  78720. * Serializes the actions and its related information.
  78721. * @param parent defines the object to serialize in
  78722. * @returns the serialized object
  78723. */
  78724. serialize(parent: any): any;
  78725. }
  78726. /**
  78727. * This defines an action responsible to set a property of the target
  78728. * to a desired value once triggered.
  78729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78730. */
  78731. export class SetValueAction extends Action {
  78732. /**
  78733. * The path of the property to set in the target.
  78734. */
  78735. propertyPath: string;
  78736. /**
  78737. * The value to set in the property
  78738. */
  78739. value: any;
  78740. private _target;
  78741. private _effectiveTarget;
  78742. private _property;
  78743. /**
  78744. * Instantiate the action
  78745. * @param triggerOptions defines the trigger options
  78746. * @param target defines the object containing the property
  78747. * @param propertyPath defines the path of the property to set in the target
  78748. * @param value defines the value to set in the property
  78749. * @param condition defines the trigger related conditions
  78750. */
  78751. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78752. /** @hidden */
  78753. _prepare(): void;
  78754. /**
  78755. * Execute the action and set the targetted property to the desired value.
  78756. */
  78757. execute(): void;
  78758. /**
  78759. * Serializes the actions and its related information.
  78760. * @param parent defines the object to serialize in
  78761. * @returns the serialized object
  78762. */
  78763. serialize(parent: any): any;
  78764. }
  78765. /**
  78766. * This defines an action responsible to increment the target value
  78767. * to a desired value once triggered.
  78768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78769. */
  78770. export class IncrementValueAction extends Action {
  78771. /**
  78772. * The path of the property to increment in the target.
  78773. */
  78774. propertyPath: string;
  78775. /**
  78776. * The value we should increment the property by.
  78777. */
  78778. value: any;
  78779. private _target;
  78780. private _effectiveTarget;
  78781. private _property;
  78782. /**
  78783. * Instantiate the action
  78784. * @param triggerOptions defines the trigger options
  78785. * @param target defines the object containing the property
  78786. * @param propertyPath defines the path of the property to increment in the target
  78787. * @param value defines the value value we should increment the property by
  78788. * @param condition defines the trigger related conditions
  78789. */
  78790. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78791. /** @hidden */
  78792. _prepare(): void;
  78793. /**
  78794. * Execute the action and increment the target of the value amount.
  78795. */
  78796. execute(): void;
  78797. /**
  78798. * Serializes the actions and its related information.
  78799. * @param parent defines the object to serialize in
  78800. * @returns the serialized object
  78801. */
  78802. serialize(parent: any): any;
  78803. }
  78804. /**
  78805. * This defines an action responsible to start an animation once triggered.
  78806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78807. */
  78808. export class PlayAnimationAction extends Action {
  78809. /**
  78810. * Where the animation should start (animation frame)
  78811. */
  78812. from: number;
  78813. /**
  78814. * Where the animation should stop (animation frame)
  78815. */
  78816. to: number;
  78817. /**
  78818. * Define if the animation should loop or stop after the first play.
  78819. */
  78820. loop?: boolean;
  78821. private _target;
  78822. /**
  78823. * Instantiate the action
  78824. * @param triggerOptions defines the trigger options
  78825. * @param target defines the target animation or animation name
  78826. * @param from defines from where the animation should start (animation frame)
  78827. * @param end defines where the animation should stop (animation frame)
  78828. * @param loop defines if the animation should loop or stop after the first play
  78829. * @param condition defines the trigger related conditions
  78830. */
  78831. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78832. /** @hidden */
  78833. _prepare(): void;
  78834. /**
  78835. * Execute the action and play the animation.
  78836. */
  78837. execute(): void;
  78838. /**
  78839. * Serializes the actions and its related information.
  78840. * @param parent defines the object to serialize in
  78841. * @returns the serialized object
  78842. */
  78843. serialize(parent: any): any;
  78844. }
  78845. /**
  78846. * This defines an action responsible to stop an animation once triggered.
  78847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78848. */
  78849. export class StopAnimationAction extends Action {
  78850. private _target;
  78851. /**
  78852. * Instantiate the action
  78853. * @param triggerOptions defines the trigger options
  78854. * @param target defines the target animation or animation name
  78855. * @param condition defines the trigger related conditions
  78856. */
  78857. constructor(triggerOptions: any, target: any, condition?: Condition);
  78858. /** @hidden */
  78859. _prepare(): void;
  78860. /**
  78861. * Execute the action and stop the animation.
  78862. */
  78863. execute(): void;
  78864. /**
  78865. * Serializes the actions and its related information.
  78866. * @param parent defines the object to serialize in
  78867. * @returns the serialized object
  78868. */
  78869. serialize(parent: any): any;
  78870. }
  78871. /**
  78872. * This defines an action responsible that does nothing once triggered.
  78873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78874. */
  78875. export class DoNothingAction extends Action {
  78876. /**
  78877. * Instantiate the action
  78878. * @param triggerOptions defines the trigger options
  78879. * @param condition defines the trigger related conditions
  78880. */
  78881. constructor(triggerOptions?: any, condition?: Condition);
  78882. /**
  78883. * Execute the action and do nothing.
  78884. */
  78885. execute(): void;
  78886. /**
  78887. * Serializes the actions and its related information.
  78888. * @param parent defines the object to serialize in
  78889. * @returns the serialized object
  78890. */
  78891. serialize(parent: any): any;
  78892. }
  78893. /**
  78894. * This defines an action responsible to trigger several actions once triggered.
  78895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78896. */
  78897. export class CombineAction extends Action {
  78898. /**
  78899. * The list of aggregated animations to run.
  78900. */
  78901. children: Action[];
  78902. /**
  78903. * Instantiate the action
  78904. * @param triggerOptions defines the trigger options
  78905. * @param children defines the list of aggregated animations to run
  78906. * @param condition defines the trigger related conditions
  78907. */
  78908. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78909. /** @hidden */
  78910. _prepare(): void;
  78911. /**
  78912. * Execute the action and executes all the aggregated actions.
  78913. */
  78914. execute(evt: ActionEvent): void;
  78915. /**
  78916. * Serializes the actions and its related information.
  78917. * @param parent defines the object to serialize in
  78918. * @returns the serialized object
  78919. */
  78920. serialize(parent: any): any;
  78921. }
  78922. /**
  78923. * This defines an action responsible to run code (external event) once triggered.
  78924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78925. */
  78926. export class ExecuteCodeAction extends Action {
  78927. /**
  78928. * The callback function to run.
  78929. */
  78930. func: (evt: ActionEvent) => void;
  78931. /**
  78932. * Instantiate the action
  78933. * @param triggerOptions defines the trigger options
  78934. * @param func defines the callback function to run
  78935. * @param condition defines the trigger related conditions
  78936. */
  78937. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78938. /**
  78939. * Execute the action and run the attached code.
  78940. */
  78941. execute(evt: ActionEvent): void;
  78942. }
  78943. /**
  78944. * This defines an action responsible to set the parent property of the target once triggered.
  78945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78946. */
  78947. export class SetParentAction extends Action {
  78948. private _parent;
  78949. private _target;
  78950. /**
  78951. * Instantiate the action
  78952. * @param triggerOptions defines the trigger options
  78953. * @param target defines the target containing the parent property
  78954. * @param parent defines from where the animation should start (animation frame)
  78955. * @param condition defines the trigger related conditions
  78956. */
  78957. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78958. /** @hidden */
  78959. _prepare(): void;
  78960. /**
  78961. * Execute the action and set the parent property.
  78962. */
  78963. execute(): void;
  78964. /**
  78965. * Serializes the actions and its related information.
  78966. * @param parent defines the object to serialize in
  78967. * @returns the serialized object
  78968. */
  78969. serialize(parent: any): any;
  78970. }
  78971. }
  78972. declare module BABYLON {
  78973. /**
  78974. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78975. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78977. */
  78978. export class ActionManager extends AbstractActionManager {
  78979. /**
  78980. * Nothing
  78981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78982. */
  78983. static readonly NothingTrigger: number;
  78984. /**
  78985. * On pick
  78986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78987. */
  78988. static readonly OnPickTrigger: number;
  78989. /**
  78990. * On left pick
  78991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78992. */
  78993. static readonly OnLeftPickTrigger: number;
  78994. /**
  78995. * On right pick
  78996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78997. */
  78998. static readonly OnRightPickTrigger: number;
  78999. /**
  79000. * On center pick
  79001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79002. */
  79003. static readonly OnCenterPickTrigger: number;
  79004. /**
  79005. * On pick down
  79006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79007. */
  79008. static readonly OnPickDownTrigger: number;
  79009. /**
  79010. * On double pick
  79011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79012. */
  79013. static readonly OnDoublePickTrigger: number;
  79014. /**
  79015. * On pick up
  79016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79017. */
  79018. static readonly OnPickUpTrigger: number;
  79019. /**
  79020. * On pick out.
  79021. * This trigger will only be raised if you also declared a OnPickDown
  79022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79023. */
  79024. static readonly OnPickOutTrigger: number;
  79025. /**
  79026. * On long press
  79027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79028. */
  79029. static readonly OnLongPressTrigger: number;
  79030. /**
  79031. * On pointer over
  79032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79033. */
  79034. static readonly OnPointerOverTrigger: number;
  79035. /**
  79036. * On pointer out
  79037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79038. */
  79039. static readonly OnPointerOutTrigger: number;
  79040. /**
  79041. * On every frame
  79042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79043. */
  79044. static readonly OnEveryFrameTrigger: number;
  79045. /**
  79046. * On intersection enter
  79047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79048. */
  79049. static readonly OnIntersectionEnterTrigger: number;
  79050. /**
  79051. * On intersection exit
  79052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79053. */
  79054. static readonly OnIntersectionExitTrigger: number;
  79055. /**
  79056. * On key down
  79057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79058. */
  79059. static readonly OnKeyDownTrigger: number;
  79060. /**
  79061. * On key up
  79062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79063. */
  79064. static readonly OnKeyUpTrigger: number;
  79065. private _scene;
  79066. /**
  79067. * Creates a new action manager
  79068. * @param scene defines the hosting scene
  79069. */
  79070. constructor(scene: Scene);
  79071. /**
  79072. * Releases all associated resources
  79073. */
  79074. dispose(): void;
  79075. /**
  79076. * Gets hosting scene
  79077. * @returns the hosting scene
  79078. */
  79079. getScene(): Scene;
  79080. /**
  79081. * Does this action manager handles actions of any of the given triggers
  79082. * @param triggers defines the triggers to be tested
  79083. * @return a boolean indicating whether one (or more) of the triggers is handled
  79084. */
  79085. hasSpecificTriggers(triggers: number[]): boolean;
  79086. /**
  79087. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79088. * speed.
  79089. * @param triggerA defines the trigger to be tested
  79090. * @param triggerB defines the trigger to be tested
  79091. * @return a boolean indicating whether one (or more) of the triggers is handled
  79092. */
  79093. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79094. /**
  79095. * Does this action manager handles actions of a given trigger
  79096. * @param trigger defines the trigger to be tested
  79097. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79098. * @return whether the trigger is handled
  79099. */
  79100. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79101. /**
  79102. * Does this action manager has pointer triggers
  79103. */
  79104. readonly hasPointerTriggers: boolean;
  79105. /**
  79106. * Does this action manager has pick triggers
  79107. */
  79108. readonly hasPickTriggers: boolean;
  79109. /**
  79110. * Registers an action to this action manager
  79111. * @param action defines the action to be registered
  79112. * @return the action amended (prepared) after registration
  79113. */
  79114. registerAction(action: IAction): Nullable<IAction>;
  79115. /**
  79116. * Unregisters an action to this action manager
  79117. * @param action defines the action to be unregistered
  79118. * @return a boolean indicating whether the action has been unregistered
  79119. */
  79120. unregisterAction(action: IAction): Boolean;
  79121. /**
  79122. * Process a specific trigger
  79123. * @param trigger defines the trigger to process
  79124. * @param evt defines the event details to be processed
  79125. */
  79126. processTrigger(trigger: number, evt?: IActionEvent): void;
  79127. /** @hidden */
  79128. _getEffectiveTarget(target: any, propertyPath: string): any;
  79129. /** @hidden */
  79130. _getProperty(propertyPath: string): string;
  79131. /**
  79132. * Serialize this manager to a JSON object
  79133. * @param name defines the property name to store this manager
  79134. * @returns a JSON representation of this manager
  79135. */
  79136. serialize(name: string): any;
  79137. /**
  79138. * Creates a new ActionManager from a JSON data
  79139. * @param parsedActions defines the JSON data to read from
  79140. * @param object defines the hosting mesh
  79141. * @param scene defines the hosting scene
  79142. */
  79143. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79144. /**
  79145. * Get a trigger name by index
  79146. * @param trigger defines the trigger index
  79147. * @returns a trigger name
  79148. */
  79149. static GetTriggerName(trigger: number): string;
  79150. }
  79151. }
  79152. declare module BABYLON {
  79153. /**
  79154. * Class representing a ray with position and direction
  79155. */
  79156. export class Ray {
  79157. /** origin point */
  79158. origin: Vector3;
  79159. /** direction */
  79160. direction: Vector3;
  79161. /** length of the ray */
  79162. length: number;
  79163. private static readonly TmpVector3;
  79164. private _tmpRay;
  79165. /**
  79166. * Creates a new ray
  79167. * @param origin origin point
  79168. * @param direction direction
  79169. * @param length length of the ray
  79170. */
  79171. constructor(
  79172. /** origin point */
  79173. origin: Vector3,
  79174. /** direction */
  79175. direction: Vector3,
  79176. /** length of the ray */
  79177. length?: number);
  79178. /**
  79179. * Checks if the ray intersects a box
  79180. * @param minimum bound of the box
  79181. * @param maximum bound of the box
  79182. * @param intersectionTreshold extra extend to be added to the box in all direction
  79183. * @returns if the box was hit
  79184. */
  79185. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79186. /**
  79187. * Checks if the ray intersects a box
  79188. * @param box the bounding box to check
  79189. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79190. * @returns if the box was hit
  79191. */
  79192. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79193. /**
  79194. * If the ray hits a sphere
  79195. * @param sphere the bounding sphere to check
  79196. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79197. * @returns true if it hits the sphere
  79198. */
  79199. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79200. /**
  79201. * If the ray hits a triange
  79202. * @param vertex0 triangle vertex
  79203. * @param vertex1 triangle vertex
  79204. * @param vertex2 triangle vertex
  79205. * @returns intersection information if hit
  79206. */
  79207. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79208. /**
  79209. * Checks if ray intersects a plane
  79210. * @param plane the plane to check
  79211. * @returns the distance away it was hit
  79212. */
  79213. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79214. /**
  79215. * Calculate the intercept of a ray on a given axis
  79216. * @param axis to check 'x' | 'y' | 'z'
  79217. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79218. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79219. */
  79220. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79221. /**
  79222. * Checks if ray intersects a mesh
  79223. * @param mesh the mesh to check
  79224. * @param fastCheck if only the bounding box should checked
  79225. * @returns picking info of the intersecton
  79226. */
  79227. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79228. /**
  79229. * Checks if ray intersects a mesh
  79230. * @param meshes the meshes to check
  79231. * @param fastCheck if only the bounding box should checked
  79232. * @param results array to store result in
  79233. * @returns Array of picking infos
  79234. */
  79235. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79236. private _comparePickingInfo;
  79237. private static smallnum;
  79238. private static rayl;
  79239. /**
  79240. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79241. * @param sega the first point of the segment to test the intersection against
  79242. * @param segb the second point of the segment to test the intersection against
  79243. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79244. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79245. */
  79246. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79247. /**
  79248. * Update the ray from viewport position
  79249. * @param x position
  79250. * @param y y position
  79251. * @param viewportWidth viewport width
  79252. * @param viewportHeight viewport height
  79253. * @param world world matrix
  79254. * @param view view matrix
  79255. * @param projection projection matrix
  79256. * @returns this ray updated
  79257. */
  79258. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79259. /**
  79260. * Creates a ray with origin and direction of 0,0,0
  79261. * @returns the new ray
  79262. */
  79263. static Zero(): Ray;
  79264. /**
  79265. * Creates a new ray from screen space and viewport
  79266. * @param x position
  79267. * @param y y position
  79268. * @param viewportWidth viewport width
  79269. * @param viewportHeight viewport height
  79270. * @param world world matrix
  79271. * @param view view matrix
  79272. * @param projection projection matrix
  79273. * @returns new ray
  79274. */
  79275. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79276. /**
  79277. * 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
  79278. * transformed to the given world matrix.
  79279. * @param origin The origin point
  79280. * @param end The end point
  79281. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79282. * @returns the new ray
  79283. */
  79284. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79285. /**
  79286. * Transforms a ray by a matrix
  79287. * @param ray ray to transform
  79288. * @param matrix matrix to apply
  79289. * @returns the resulting new ray
  79290. */
  79291. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79292. /**
  79293. * Transforms a ray by a matrix
  79294. * @param ray ray to transform
  79295. * @param matrix matrix to apply
  79296. * @param result ray to store result in
  79297. */
  79298. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79299. /**
  79300. * Unproject a ray from screen space to object space
  79301. * @param sourceX defines the screen space x coordinate to use
  79302. * @param sourceY defines the screen space y coordinate to use
  79303. * @param viewportWidth defines the current width of the viewport
  79304. * @param viewportHeight defines the current height of the viewport
  79305. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79306. * @param view defines the view matrix to use
  79307. * @param projection defines the projection matrix to use
  79308. */
  79309. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79310. }
  79311. /**
  79312. * Type used to define predicate used to select faces when a mesh intersection is detected
  79313. */
  79314. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79315. interface Scene {
  79316. /** @hidden */
  79317. _tempPickingRay: Nullable<Ray>;
  79318. /** @hidden */
  79319. _cachedRayForTransform: Ray;
  79320. /** @hidden */
  79321. _pickWithRayInverseMatrix: Matrix;
  79322. /** @hidden */
  79323. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79324. /** @hidden */
  79325. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79326. }
  79327. }
  79328. declare module BABYLON {
  79329. /**
  79330. * Groups all the scene component constants in one place to ease maintenance.
  79331. * @hidden
  79332. */
  79333. export class SceneComponentConstants {
  79334. static readonly NAME_EFFECTLAYER: string;
  79335. static readonly NAME_LAYER: string;
  79336. static readonly NAME_LENSFLARESYSTEM: string;
  79337. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79338. static readonly NAME_PARTICLESYSTEM: string;
  79339. static readonly NAME_GAMEPAD: string;
  79340. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79341. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79342. static readonly NAME_DEPTHRENDERER: string;
  79343. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79344. static readonly NAME_SPRITE: string;
  79345. static readonly NAME_OUTLINERENDERER: string;
  79346. static readonly NAME_PROCEDURALTEXTURE: string;
  79347. static readonly NAME_SHADOWGENERATOR: string;
  79348. static readonly NAME_OCTREE: string;
  79349. static readonly NAME_PHYSICSENGINE: string;
  79350. static readonly NAME_AUDIO: string;
  79351. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79352. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79353. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79354. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79355. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79356. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79357. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79358. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79359. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79360. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79361. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79362. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79363. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79364. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79365. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79366. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79367. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79368. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79369. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79370. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79371. static readonly STEP_AFTERRENDER_AUDIO: number;
  79372. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79373. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79374. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79375. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79376. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79377. static readonly STEP_POINTERMOVE_SPRITE: number;
  79378. static readonly STEP_POINTERDOWN_SPRITE: number;
  79379. static readonly STEP_POINTERUP_SPRITE: number;
  79380. }
  79381. /**
  79382. * This represents a scene component.
  79383. *
  79384. * This is used to decouple the dependency the scene is having on the different workloads like
  79385. * layers, post processes...
  79386. */
  79387. export interface ISceneComponent {
  79388. /**
  79389. * The name of the component. Each component must have a unique name.
  79390. */
  79391. name: string;
  79392. /**
  79393. * The scene the component belongs to.
  79394. */
  79395. scene: Scene;
  79396. /**
  79397. * Register the component to one instance of a scene.
  79398. */
  79399. register(): void;
  79400. /**
  79401. * Rebuilds the elements related to this component in case of
  79402. * context lost for instance.
  79403. */
  79404. rebuild(): void;
  79405. /**
  79406. * Disposes the component and the associated ressources.
  79407. */
  79408. dispose(): void;
  79409. }
  79410. /**
  79411. * This represents a SERIALIZABLE scene component.
  79412. *
  79413. * This extends Scene Component to add Serialization methods on top.
  79414. */
  79415. export interface ISceneSerializableComponent extends ISceneComponent {
  79416. /**
  79417. * Adds all the elements from the container to the scene
  79418. * @param container the container holding the elements
  79419. */
  79420. addFromContainer(container: AbstractScene): void;
  79421. /**
  79422. * Removes all the elements in the container from the scene
  79423. * @param container contains the elements to remove
  79424. * @param dispose if the removed element should be disposed (default: false)
  79425. */
  79426. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79427. /**
  79428. * Serializes the component data to the specified json object
  79429. * @param serializationObject The object to serialize to
  79430. */
  79431. serialize(serializationObject: any): void;
  79432. }
  79433. /**
  79434. * Strong typing of a Mesh related stage step action
  79435. */
  79436. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79437. /**
  79438. * Strong typing of a Evaluate Sub Mesh related stage step action
  79439. */
  79440. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79441. /**
  79442. * Strong typing of a Active Mesh related stage step action
  79443. */
  79444. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79445. /**
  79446. * Strong typing of a Camera related stage step action
  79447. */
  79448. export type CameraStageAction = (camera: Camera) => void;
  79449. /**
  79450. * Strong typing of a Camera Frame buffer related stage step action
  79451. */
  79452. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79453. /**
  79454. * Strong typing of a Render Target related stage step action
  79455. */
  79456. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79457. /**
  79458. * Strong typing of a RenderingGroup related stage step action
  79459. */
  79460. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79461. /**
  79462. * Strong typing of a Mesh Render related stage step action
  79463. */
  79464. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79465. /**
  79466. * Strong typing of a simple stage step action
  79467. */
  79468. export type SimpleStageAction = () => void;
  79469. /**
  79470. * Strong typing of a render target action.
  79471. */
  79472. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79473. /**
  79474. * Strong typing of a pointer move action.
  79475. */
  79476. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79477. /**
  79478. * Strong typing of a pointer up/down action.
  79479. */
  79480. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79481. /**
  79482. * Representation of a stage in the scene (Basically a list of ordered steps)
  79483. * @hidden
  79484. */
  79485. export class Stage<T extends Function> extends Array<{
  79486. index: number;
  79487. component: ISceneComponent;
  79488. action: T;
  79489. }> {
  79490. /**
  79491. * Hide ctor from the rest of the world.
  79492. * @param items The items to add.
  79493. */
  79494. private constructor();
  79495. /**
  79496. * Creates a new Stage.
  79497. * @returns A new instance of a Stage
  79498. */
  79499. static Create<T extends Function>(): Stage<T>;
  79500. /**
  79501. * Registers a step in an ordered way in the targeted stage.
  79502. * @param index Defines the position to register the step in
  79503. * @param component Defines the component attached to the step
  79504. * @param action Defines the action to launch during the step
  79505. */
  79506. registerStep(index: number, component: ISceneComponent, action: T): void;
  79507. /**
  79508. * Clears all the steps from the stage.
  79509. */
  79510. clear(): void;
  79511. }
  79512. }
  79513. declare module BABYLON {
  79514. interface Scene {
  79515. /** @hidden */
  79516. _pointerOverSprite: Nullable<Sprite>;
  79517. /** @hidden */
  79518. _pickedDownSprite: Nullable<Sprite>;
  79519. /** @hidden */
  79520. _tempSpritePickingRay: Nullable<Ray>;
  79521. /**
  79522. * All of the sprite managers added to this scene
  79523. * @see http://doc.babylonjs.com/babylon101/sprites
  79524. */
  79525. spriteManagers: Array<ISpriteManager>;
  79526. /**
  79527. * An event triggered when sprites rendering is about to start
  79528. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79529. */
  79530. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79531. /**
  79532. * An event triggered when sprites rendering is done
  79533. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79534. */
  79535. onAfterSpritesRenderingObservable: Observable<Scene>;
  79536. /** @hidden */
  79537. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79538. /** Launch a ray to try to pick a sprite in the scene
  79539. * @param x position on screen
  79540. * @param y position on screen
  79541. * @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
  79542. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79543. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79544. * @returns a PickingInfo
  79545. */
  79546. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79547. /** Use the given ray to pick a sprite in the scene
  79548. * @param ray The ray (in world space) to use to pick meshes
  79549. * @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
  79550. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79551. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79552. * @returns a PickingInfo
  79553. */
  79554. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79555. /** @hidden */
  79556. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79557. /** Launch a ray to try to pick sprites in the scene
  79558. * @param x position on screen
  79559. * @param y position on screen
  79560. * @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
  79561. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79562. * @returns a PickingInfo array
  79563. */
  79564. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79565. /** Use the given ray to pick sprites in the scene
  79566. * @param ray The ray (in world space) to use to pick meshes
  79567. * @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
  79568. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79569. * @returns a PickingInfo array
  79570. */
  79571. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79572. /**
  79573. * Force the sprite under the pointer
  79574. * @param sprite defines the sprite to use
  79575. */
  79576. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79577. /**
  79578. * Gets the sprite under the pointer
  79579. * @returns a Sprite or null if no sprite is under the pointer
  79580. */
  79581. getPointerOverSprite(): Nullable<Sprite>;
  79582. }
  79583. /**
  79584. * Defines the sprite scene component responsible to manage sprites
  79585. * in a given scene.
  79586. */
  79587. export class SpriteSceneComponent implements ISceneComponent {
  79588. /**
  79589. * The component name helpfull to identify the component in the list of scene components.
  79590. */
  79591. readonly name: string;
  79592. /**
  79593. * The scene the component belongs to.
  79594. */
  79595. scene: Scene;
  79596. /** @hidden */
  79597. private _spritePredicate;
  79598. /**
  79599. * Creates a new instance of the component for the given scene
  79600. * @param scene Defines the scene to register the component in
  79601. */
  79602. constructor(scene: Scene);
  79603. /**
  79604. * Registers the component in a given scene
  79605. */
  79606. register(): void;
  79607. /**
  79608. * Rebuilds the elements related to this component in case of
  79609. * context lost for instance.
  79610. */
  79611. rebuild(): void;
  79612. /**
  79613. * Disposes the component and the associated ressources.
  79614. */
  79615. dispose(): void;
  79616. private _pickSpriteButKeepRay;
  79617. private _pointerMove;
  79618. private _pointerDown;
  79619. private _pointerUp;
  79620. }
  79621. }
  79622. declare module BABYLON {
  79623. /** @hidden */
  79624. export var fogFragmentDeclaration: {
  79625. name: string;
  79626. shader: string;
  79627. };
  79628. }
  79629. declare module BABYLON {
  79630. /** @hidden */
  79631. export var fogFragment: {
  79632. name: string;
  79633. shader: string;
  79634. };
  79635. }
  79636. declare module BABYLON {
  79637. /** @hidden */
  79638. export var spritesPixelShader: {
  79639. name: string;
  79640. shader: string;
  79641. };
  79642. }
  79643. declare module BABYLON {
  79644. /** @hidden */
  79645. export var fogVertexDeclaration: {
  79646. name: string;
  79647. shader: string;
  79648. };
  79649. }
  79650. declare module BABYLON {
  79651. /** @hidden */
  79652. export var spritesVertexShader: {
  79653. name: string;
  79654. shader: string;
  79655. };
  79656. }
  79657. declare module BABYLON {
  79658. /**
  79659. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79660. */
  79661. export interface ISpriteManager extends IDisposable {
  79662. /**
  79663. * Restricts the camera to viewing objects with the same layerMask.
  79664. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79665. */
  79666. layerMask: number;
  79667. /**
  79668. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79669. */
  79670. isPickable: boolean;
  79671. /**
  79672. * Specifies the rendering group id for this mesh (0 by default)
  79673. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79674. */
  79675. renderingGroupId: number;
  79676. /**
  79677. * Defines the list of sprites managed by the manager.
  79678. */
  79679. sprites: Array<Sprite>;
  79680. /**
  79681. * Tests the intersection of a sprite with a specific ray.
  79682. * @param ray The ray we are sending to test the collision
  79683. * @param camera The camera space we are sending rays in
  79684. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79685. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79686. * @returns picking info or null.
  79687. */
  79688. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79689. /**
  79690. * Intersects the sprites with a ray
  79691. * @param ray defines the ray to intersect with
  79692. * @param camera defines the current active camera
  79693. * @param predicate defines a predicate used to select candidate sprites
  79694. * @returns null if no hit or a PickingInfo array
  79695. */
  79696. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79697. /**
  79698. * Renders the list of sprites on screen.
  79699. */
  79700. render(): void;
  79701. }
  79702. /**
  79703. * Class used to manage multiple sprites on the same spritesheet
  79704. * @see http://doc.babylonjs.com/babylon101/sprites
  79705. */
  79706. export class SpriteManager implements ISpriteManager {
  79707. /** defines the manager's name */
  79708. name: string;
  79709. /** Gets the list of sprites */
  79710. sprites: Sprite[];
  79711. /** Gets or sets the rendering group id (0 by default) */
  79712. renderingGroupId: number;
  79713. /** Gets or sets camera layer mask */
  79714. layerMask: number;
  79715. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79716. fogEnabled: boolean;
  79717. /** Gets or sets a boolean indicating if the sprites are pickable */
  79718. isPickable: boolean;
  79719. /** Defines the default width of a cell in the spritesheet */
  79720. cellWidth: number;
  79721. /** Defines the default height of a cell in the spritesheet */
  79722. cellHeight: number;
  79723. /** Associative array from JSON sprite data file */
  79724. private _cellData;
  79725. /** Array of sprite names from JSON sprite data file */
  79726. private _spriteMap;
  79727. /** True when packed cell data from JSON file is ready*/
  79728. private _packedAndReady;
  79729. /**
  79730. * An event triggered when the manager is disposed.
  79731. */
  79732. onDisposeObservable: Observable<SpriteManager>;
  79733. private _onDisposeObserver;
  79734. /**
  79735. * Callback called when the manager is disposed
  79736. */
  79737. onDispose: () => void;
  79738. private _capacity;
  79739. private _fromPacked;
  79740. private _spriteTexture;
  79741. private _epsilon;
  79742. private _scene;
  79743. private _vertexData;
  79744. private _buffer;
  79745. private _vertexBuffers;
  79746. private _indexBuffer;
  79747. private _effectBase;
  79748. private _effectFog;
  79749. /**
  79750. * Gets or sets the spritesheet texture
  79751. */
  79752. texture: Texture;
  79753. /**
  79754. * Creates a new sprite manager
  79755. * @param name defines the manager's name
  79756. * @param imgUrl defines the sprite sheet url
  79757. * @param capacity defines the maximum allowed number of sprites
  79758. * @param cellSize defines the size of a sprite cell
  79759. * @param scene defines the hosting scene
  79760. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79761. * @param samplingMode defines the smapling mode to use with spritesheet
  79762. * @param fromPacked set to false; do not alter
  79763. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79764. */
  79765. constructor(
  79766. /** defines the manager's name */
  79767. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79768. private _makePacked;
  79769. private _appendSpriteVertex;
  79770. /**
  79771. * Intersects the sprites with a ray
  79772. * @param ray defines the ray to intersect with
  79773. * @param camera defines the current active camera
  79774. * @param predicate defines a predicate used to select candidate sprites
  79775. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79776. * @returns null if no hit or a PickingInfo
  79777. */
  79778. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79779. /**
  79780. * Intersects the sprites with a ray
  79781. * @param ray defines the ray to intersect with
  79782. * @param camera defines the current active camera
  79783. * @param predicate defines a predicate used to select candidate sprites
  79784. * @returns null if no hit or a PickingInfo array
  79785. */
  79786. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79787. /**
  79788. * Render all child sprites
  79789. */
  79790. render(): void;
  79791. /**
  79792. * Release associated resources
  79793. */
  79794. dispose(): void;
  79795. }
  79796. }
  79797. declare module BABYLON {
  79798. /**
  79799. * Class used to represent a sprite
  79800. * @see http://doc.babylonjs.com/babylon101/sprites
  79801. */
  79802. export class Sprite {
  79803. /** defines the name */
  79804. name: string;
  79805. /** Gets or sets the current world position */
  79806. position: Vector3;
  79807. /** Gets or sets the main color */
  79808. color: Color4;
  79809. /** Gets or sets the width */
  79810. width: number;
  79811. /** Gets or sets the height */
  79812. height: number;
  79813. /** Gets or sets rotation angle */
  79814. angle: number;
  79815. /** Gets or sets the cell index in the sprite sheet */
  79816. cellIndex: number;
  79817. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79818. cellRef: string;
  79819. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79820. invertU: number;
  79821. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79822. invertV: number;
  79823. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79824. disposeWhenFinishedAnimating: boolean;
  79825. /** Gets the list of attached animations */
  79826. animations: Animation[];
  79827. /** Gets or sets a boolean indicating if the sprite can be picked */
  79828. isPickable: boolean;
  79829. /**
  79830. * Gets or sets the associated action manager
  79831. */
  79832. actionManager: Nullable<ActionManager>;
  79833. private _animationStarted;
  79834. private _loopAnimation;
  79835. private _fromIndex;
  79836. private _toIndex;
  79837. private _delay;
  79838. private _direction;
  79839. private _manager;
  79840. private _time;
  79841. private _onAnimationEnd;
  79842. /**
  79843. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79844. */
  79845. isVisible: boolean;
  79846. /**
  79847. * Gets or sets the sprite size
  79848. */
  79849. size: number;
  79850. /**
  79851. * Creates a new Sprite
  79852. * @param name defines the name
  79853. * @param manager defines the manager
  79854. */
  79855. constructor(
  79856. /** defines the name */
  79857. name: string, manager: ISpriteManager);
  79858. /**
  79859. * Starts an animation
  79860. * @param from defines the initial key
  79861. * @param to defines the end key
  79862. * @param loop defines if the animation must loop
  79863. * @param delay defines the start delay (in ms)
  79864. * @param onAnimationEnd defines a callback to call when animation ends
  79865. */
  79866. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79867. /** Stops current animation (if any) */
  79868. stopAnimation(): void;
  79869. /** @hidden */
  79870. _animate(deltaTime: number): void;
  79871. /** Release associated resources */
  79872. dispose(): void;
  79873. }
  79874. }
  79875. declare module BABYLON {
  79876. /**
  79877. * Information about the result of picking within a scene
  79878. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79879. */
  79880. export class PickingInfo {
  79881. /** @hidden */
  79882. _pickingUnavailable: boolean;
  79883. /**
  79884. * If the pick collided with an object
  79885. */
  79886. hit: boolean;
  79887. /**
  79888. * Distance away where the pick collided
  79889. */
  79890. distance: number;
  79891. /**
  79892. * The location of pick collision
  79893. */
  79894. pickedPoint: Nullable<Vector3>;
  79895. /**
  79896. * The mesh corresponding the the pick collision
  79897. */
  79898. pickedMesh: Nullable<AbstractMesh>;
  79899. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79900. bu: number;
  79901. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79902. bv: number;
  79903. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79904. faceId: number;
  79905. /** Id of the the submesh that was picked */
  79906. subMeshId: number;
  79907. /** If a sprite was picked, this will be the sprite the pick collided with */
  79908. pickedSprite: Nullable<Sprite>;
  79909. /**
  79910. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79911. */
  79912. originMesh: Nullable<AbstractMesh>;
  79913. /**
  79914. * The ray that was used to perform the picking.
  79915. */
  79916. ray: Nullable<Ray>;
  79917. /**
  79918. * Gets the normal correspodning to the face the pick collided with
  79919. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79920. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79921. * @returns The normal correspodning to the face the pick collided with
  79922. */
  79923. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79924. /**
  79925. * Gets the texture coordinates of where the pick occured
  79926. * @returns the vector containing the coordnates of the texture
  79927. */
  79928. getTextureCoordinates(): Nullable<Vector2>;
  79929. }
  79930. }
  79931. declare module BABYLON {
  79932. /**
  79933. * Gather the list of pointer event types as constants.
  79934. */
  79935. export class PointerEventTypes {
  79936. /**
  79937. * 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.
  79938. */
  79939. static readonly POINTERDOWN: number;
  79940. /**
  79941. * The pointerup event is fired when a pointer is no longer active.
  79942. */
  79943. static readonly POINTERUP: number;
  79944. /**
  79945. * The pointermove event is fired when a pointer changes coordinates.
  79946. */
  79947. static readonly POINTERMOVE: number;
  79948. /**
  79949. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79950. */
  79951. static readonly POINTERWHEEL: number;
  79952. /**
  79953. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79954. */
  79955. static readonly POINTERPICK: number;
  79956. /**
  79957. * The pointertap event is fired when a the object has been touched and released without drag.
  79958. */
  79959. static readonly POINTERTAP: number;
  79960. /**
  79961. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79962. */
  79963. static readonly POINTERDOUBLETAP: number;
  79964. }
  79965. /**
  79966. * Base class of pointer info types.
  79967. */
  79968. export class PointerInfoBase {
  79969. /**
  79970. * Defines the type of event (PointerEventTypes)
  79971. */
  79972. type: number;
  79973. /**
  79974. * Defines the related dom event
  79975. */
  79976. event: PointerEvent | MouseWheelEvent;
  79977. /**
  79978. * Instantiates the base class of pointers info.
  79979. * @param type Defines the type of event (PointerEventTypes)
  79980. * @param event Defines the related dom event
  79981. */
  79982. constructor(
  79983. /**
  79984. * Defines the type of event (PointerEventTypes)
  79985. */
  79986. type: number,
  79987. /**
  79988. * Defines the related dom event
  79989. */
  79990. event: PointerEvent | MouseWheelEvent);
  79991. }
  79992. /**
  79993. * This class is used to store pointer related info for the onPrePointerObservable event.
  79994. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79995. */
  79996. export class PointerInfoPre extends PointerInfoBase {
  79997. /**
  79998. * Ray from a pointer if availible (eg. 6dof controller)
  79999. */
  80000. ray: Nullable<Ray>;
  80001. /**
  80002. * Defines the local position of the pointer on the canvas.
  80003. */
  80004. localPosition: Vector2;
  80005. /**
  80006. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80007. */
  80008. skipOnPointerObservable: boolean;
  80009. /**
  80010. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80011. * @param type Defines the type of event (PointerEventTypes)
  80012. * @param event Defines the related dom event
  80013. * @param localX Defines the local x coordinates of the pointer when the event occured
  80014. * @param localY Defines the local y coordinates of the pointer when the event occured
  80015. */
  80016. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80017. }
  80018. /**
  80019. * This type contains all the data related to a pointer event in Babylon.js.
  80020. * 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.
  80021. */
  80022. export class PointerInfo extends PointerInfoBase {
  80023. /**
  80024. * Defines the picking info associated to the info (if any)\
  80025. */
  80026. pickInfo: Nullable<PickingInfo>;
  80027. /**
  80028. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80029. * @param type Defines the type of event (PointerEventTypes)
  80030. * @param event Defines the related dom event
  80031. * @param pickInfo Defines the picking info associated to the info (if any)\
  80032. */
  80033. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80034. /**
  80035. * Defines the picking info associated to the info (if any)\
  80036. */
  80037. pickInfo: Nullable<PickingInfo>);
  80038. }
  80039. /**
  80040. * Data relating to a touch event on the screen.
  80041. */
  80042. export interface PointerTouch {
  80043. /**
  80044. * X coordinate of touch.
  80045. */
  80046. x: number;
  80047. /**
  80048. * Y coordinate of touch.
  80049. */
  80050. y: number;
  80051. /**
  80052. * Id of touch. Unique for each finger.
  80053. */
  80054. pointerId: number;
  80055. /**
  80056. * Event type passed from DOM.
  80057. */
  80058. type: any;
  80059. }
  80060. }
  80061. declare module BABYLON {
  80062. /**
  80063. * Manage the mouse inputs to control the movement of a free camera.
  80064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80065. */
  80066. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80067. /**
  80068. * Define if touch is enabled in the mouse input
  80069. */
  80070. touchEnabled: boolean;
  80071. /**
  80072. * Defines the camera the input is attached to.
  80073. */
  80074. camera: FreeCamera;
  80075. /**
  80076. * Defines the buttons associated with the input to handle camera move.
  80077. */
  80078. buttons: number[];
  80079. /**
  80080. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80081. */
  80082. angularSensibility: number;
  80083. private _pointerInput;
  80084. private _onMouseMove;
  80085. private _observer;
  80086. private previousPosition;
  80087. /**
  80088. * Observable for when a pointer move event occurs containing the move offset
  80089. */
  80090. onPointerMovedObservable: Observable<{
  80091. offsetX: number;
  80092. offsetY: number;
  80093. }>;
  80094. /**
  80095. * @hidden
  80096. * If the camera should be rotated automatically based on pointer movement
  80097. */
  80098. _allowCameraRotation: boolean;
  80099. /**
  80100. * Manage the mouse inputs to control the movement of a free camera.
  80101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80102. * @param touchEnabled Defines if touch is enabled or not
  80103. */
  80104. constructor(
  80105. /**
  80106. * Define if touch is enabled in the mouse input
  80107. */
  80108. touchEnabled?: boolean);
  80109. /**
  80110. * Attach the input controls to a specific dom element to get the input from.
  80111. * @param element Defines the element the controls should be listened from
  80112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80113. */
  80114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80115. /**
  80116. * Called on JS contextmenu event.
  80117. * Override this method to provide functionality.
  80118. */
  80119. protected onContextMenu(evt: PointerEvent): void;
  80120. /**
  80121. * Detach the current controls from the specified dom element.
  80122. * @param element Defines the element to stop listening the inputs from
  80123. */
  80124. detachControl(element: Nullable<HTMLElement>): void;
  80125. /**
  80126. * Gets the class name of the current intput.
  80127. * @returns the class name
  80128. */
  80129. getClassName(): string;
  80130. /**
  80131. * Get the friendly name associated with the input class.
  80132. * @returns the input friendly name
  80133. */
  80134. getSimpleName(): string;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. /**
  80139. * Manage the touch inputs to control the movement of a free camera.
  80140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80141. */
  80142. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80143. /**
  80144. * Defines the camera the input is attached to.
  80145. */
  80146. camera: FreeCamera;
  80147. /**
  80148. * Defines the touch sensibility for rotation.
  80149. * The higher the faster.
  80150. */
  80151. touchAngularSensibility: number;
  80152. /**
  80153. * Defines the touch sensibility for move.
  80154. * The higher the faster.
  80155. */
  80156. touchMoveSensibility: number;
  80157. private _offsetX;
  80158. private _offsetY;
  80159. private _pointerPressed;
  80160. private _pointerInput;
  80161. private _observer;
  80162. private _onLostFocus;
  80163. /**
  80164. * Attach the input controls to a specific dom element to get the input from.
  80165. * @param element Defines the element the controls should be listened from
  80166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80167. */
  80168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80169. /**
  80170. * Detach the current controls from the specified dom element.
  80171. * @param element Defines the element to stop listening the inputs from
  80172. */
  80173. detachControl(element: Nullable<HTMLElement>): void;
  80174. /**
  80175. * Update the current camera state depending on the inputs that have been used this frame.
  80176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80177. */
  80178. checkInputs(): void;
  80179. /**
  80180. * Gets the class name of the current intput.
  80181. * @returns the class name
  80182. */
  80183. getClassName(): string;
  80184. /**
  80185. * Get the friendly name associated with the input class.
  80186. * @returns the input friendly name
  80187. */
  80188. getSimpleName(): string;
  80189. }
  80190. }
  80191. declare module BABYLON {
  80192. /**
  80193. * Default Inputs manager for the FreeCamera.
  80194. * It groups all the default supported inputs for ease of use.
  80195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80196. */
  80197. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80198. /**
  80199. * @hidden
  80200. */
  80201. _mouseInput: Nullable<FreeCameraMouseInput>;
  80202. /**
  80203. * Instantiates a new FreeCameraInputsManager.
  80204. * @param camera Defines the camera the inputs belong to
  80205. */
  80206. constructor(camera: FreeCamera);
  80207. /**
  80208. * Add keyboard input support to the input manager.
  80209. * @returns the current input manager
  80210. */
  80211. addKeyboard(): FreeCameraInputsManager;
  80212. /**
  80213. * Add mouse input support to the input manager.
  80214. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80215. * @returns the current input manager
  80216. */
  80217. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80218. /**
  80219. * Removes the mouse input support from the manager
  80220. * @returns the current input manager
  80221. */
  80222. removeMouse(): FreeCameraInputsManager;
  80223. /**
  80224. * Add touch input support to the input manager.
  80225. * @returns the current input manager
  80226. */
  80227. addTouch(): FreeCameraInputsManager;
  80228. /**
  80229. * Remove all attached input methods from a camera
  80230. */
  80231. clear(): void;
  80232. }
  80233. }
  80234. declare module BABYLON {
  80235. /**
  80236. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80237. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80239. */
  80240. export class FreeCamera extends TargetCamera {
  80241. /**
  80242. * Define the collision ellipsoid of the camera.
  80243. * This is helpful to simulate a camera body like the player body around the camera
  80244. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80245. */
  80246. ellipsoid: Vector3;
  80247. /**
  80248. * Define an offset for the position of the ellipsoid around the camera.
  80249. * This can be helpful to determine the center of the body near the gravity center of the body
  80250. * instead of its head.
  80251. */
  80252. ellipsoidOffset: Vector3;
  80253. /**
  80254. * Enable or disable collisions of the camera with the rest of the scene objects.
  80255. */
  80256. checkCollisions: boolean;
  80257. /**
  80258. * Enable or disable gravity on the camera.
  80259. */
  80260. applyGravity: boolean;
  80261. /**
  80262. * Define the input manager associated to the camera.
  80263. */
  80264. inputs: FreeCameraInputsManager;
  80265. /**
  80266. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80267. * Higher values reduce sensitivity.
  80268. */
  80269. /**
  80270. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80271. * Higher values reduce sensitivity.
  80272. */
  80273. angularSensibility: number;
  80274. /**
  80275. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80276. */
  80277. keysUp: number[];
  80278. /**
  80279. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80280. */
  80281. keysDown: number[];
  80282. /**
  80283. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80284. */
  80285. keysLeft: number[];
  80286. /**
  80287. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80288. */
  80289. keysRight: number[];
  80290. /**
  80291. * Event raised when the camera collide with a mesh in the scene.
  80292. */
  80293. onCollide: (collidedMesh: AbstractMesh) => void;
  80294. private _collider;
  80295. private _needMoveForGravity;
  80296. private _oldPosition;
  80297. private _diffPosition;
  80298. private _newPosition;
  80299. /** @hidden */
  80300. _localDirection: Vector3;
  80301. /** @hidden */
  80302. _transformedDirection: Vector3;
  80303. /**
  80304. * Instantiates a Free Camera.
  80305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80308. * @param name Define the name of the camera in the scene
  80309. * @param position Define the start position of the camera in the scene
  80310. * @param scene Define the scene the camera belongs to
  80311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80312. */
  80313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80314. /**
  80315. * Attached controls to the current camera.
  80316. * @param element Defines the element the controls should be listened from
  80317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80318. */
  80319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80320. /**
  80321. * Detach the current controls from the camera.
  80322. * The camera will stop reacting to inputs.
  80323. * @param element Defines the element to stop listening the inputs from
  80324. */
  80325. detachControl(element: HTMLElement): void;
  80326. private _collisionMask;
  80327. /**
  80328. * Define a collision mask to limit the list of object the camera can collide with
  80329. */
  80330. collisionMask: number;
  80331. /** @hidden */
  80332. _collideWithWorld(displacement: Vector3): void;
  80333. private _onCollisionPositionChange;
  80334. /** @hidden */
  80335. _checkInputs(): void;
  80336. /** @hidden */
  80337. _decideIfNeedsToMove(): boolean;
  80338. /** @hidden */
  80339. _updatePosition(): void;
  80340. /**
  80341. * Destroy the camera and release the current resources hold by it.
  80342. */
  80343. dispose(): void;
  80344. /**
  80345. * Gets the current object class name.
  80346. * @return the class name
  80347. */
  80348. getClassName(): string;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. /**
  80353. * Represents a gamepad control stick position
  80354. */
  80355. export class StickValues {
  80356. /**
  80357. * The x component of the control stick
  80358. */
  80359. x: number;
  80360. /**
  80361. * The y component of the control stick
  80362. */
  80363. y: number;
  80364. /**
  80365. * Initializes the gamepad x and y control stick values
  80366. * @param x The x component of the gamepad control stick value
  80367. * @param y The y component of the gamepad control stick value
  80368. */
  80369. constructor(
  80370. /**
  80371. * The x component of the control stick
  80372. */
  80373. x: number,
  80374. /**
  80375. * The y component of the control stick
  80376. */
  80377. y: number);
  80378. }
  80379. /**
  80380. * An interface which manages callbacks for gamepad button changes
  80381. */
  80382. export interface GamepadButtonChanges {
  80383. /**
  80384. * Called when a gamepad has been changed
  80385. */
  80386. changed: boolean;
  80387. /**
  80388. * Called when a gamepad press event has been triggered
  80389. */
  80390. pressChanged: boolean;
  80391. /**
  80392. * Called when a touch event has been triggered
  80393. */
  80394. touchChanged: boolean;
  80395. /**
  80396. * Called when a value has changed
  80397. */
  80398. valueChanged: boolean;
  80399. }
  80400. /**
  80401. * Represents a gamepad
  80402. */
  80403. export class Gamepad {
  80404. /**
  80405. * The id of the gamepad
  80406. */
  80407. id: string;
  80408. /**
  80409. * The index of the gamepad
  80410. */
  80411. index: number;
  80412. /**
  80413. * The browser gamepad
  80414. */
  80415. browserGamepad: any;
  80416. /**
  80417. * Specifies what type of gamepad this represents
  80418. */
  80419. type: number;
  80420. private _leftStick;
  80421. private _rightStick;
  80422. /** @hidden */
  80423. _isConnected: boolean;
  80424. private _leftStickAxisX;
  80425. private _leftStickAxisY;
  80426. private _rightStickAxisX;
  80427. private _rightStickAxisY;
  80428. /**
  80429. * Triggered when the left control stick has been changed
  80430. */
  80431. private _onleftstickchanged;
  80432. /**
  80433. * Triggered when the right control stick has been changed
  80434. */
  80435. private _onrightstickchanged;
  80436. /**
  80437. * Represents a gamepad controller
  80438. */
  80439. static GAMEPAD: number;
  80440. /**
  80441. * Represents a generic controller
  80442. */
  80443. static GENERIC: number;
  80444. /**
  80445. * Represents an XBox controller
  80446. */
  80447. static XBOX: number;
  80448. /**
  80449. * Represents a pose-enabled controller
  80450. */
  80451. static POSE_ENABLED: number;
  80452. /**
  80453. * Represents an Dual Shock controller
  80454. */
  80455. static DUALSHOCK: number;
  80456. /**
  80457. * Specifies whether the left control stick should be Y-inverted
  80458. */
  80459. protected _invertLeftStickY: boolean;
  80460. /**
  80461. * Specifies if the gamepad has been connected
  80462. */
  80463. readonly isConnected: boolean;
  80464. /**
  80465. * Initializes the gamepad
  80466. * @param id The id of the gamepad
  80467. * @param index The index of the gamepad
  80468. * @param browserGamepad The browser gamepad
  80469. * @param leftStickX The x component of the left joystick
  80470. * @param leftStickY The y component of the left joystick
  80471. * @param rightStickX The x component of the right joystick
  80472. * @param rightStickY The y component of the right joystick
  80473. */
  80474. constructor(
  80475. /**
  80476. * The id of the gamepad
  80477. */
  80478. id: string,
  80479. /**
  80480. * The index of the gamepad
  80481. */
  80482. index: number,
  80483. /**
  80484. * The browser gamepad
  80485. */
  80486. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80487. /**
  80488. * Callback triggered when the left joystick has changed
  80489. * @param callback
  80490. */
  80491. onleftstickchanged(callback: (values: StickValues) => void): void;
  80492. /**
  80493. * Callback triggered when the right joystick has changed
  80494. * @param callback
  80495. */
  80496. onrightstickchanged(callback: (values: StickValues) => void): void;
  80497. /**
  80498. * Gets the left joystick
  80499. */
  80500. /**
  80501. * Sets the left joystick values
  80502. */
  80503. leftStick: StickValues;
  80504. /**
  80505. * Gets the right joystick
  80506. */
  80507. /**
  80508. * Sets the right joystick value
  80509. */
  80510. rightStick: StickValues;
  80511. /**
  80512. * Updates the gamepad joystick positions
  80513. */
  80514. update(): void;
  80515. /**
  80516. * Disposes the gamepad
  80517. */
  80518. dispose(): void;
  80519. }
  80520. /**
  80521. * Represents a generic gamepad
  80522. */
  80523. export class GenericPad extends Gamepad {
  80524. private _buttons;
  80525. private _onbuttondown;
  80526. private _onbuttonup;
  80527. /**
  80528. * Observable triggered when a button has been pressed
  80529. */
  80530. onButtonDownObservable: Observable<number>;
  80531. /**
  80532. * Observable triggered when a button has been released
  80533. */
  80534. onButtonUpObservable: Observable<number>;
  80535. /**
  80536. * Callback triggered when a button has been pressed
  80537. * @param callback Called when a button has been pressed
  80538. */
  80539. onbuttondown(callback: (buttonPressed: number) => void): void;
  80540. /**
  80541. * Callback triggered when a button has been released
  80542. * @param callback Called when a button has been released
  80543. */
  80544. onbuttonup(callback: (buttonReleased: number) => void): void;
  80545. /**
  80546. * Initializes the generic gamepad
  80547. * @param id The id of the generic gamepad
  80548. * @param index The index of the generic gamepad
  80549. * @param browserGamepad The browser gamepad
  80550. */
  80551. constructor(id: string, index: number, browserGamepad: any);
  80552. private _setButtonValue;
  80553. /**
  80554. * Updates the generic gamepad
  80555. */
  80556. update(): void;
  80557. /**
  80558. * Disposes the generic gamepad
  80559. */
  80560. dispose(): void;
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. interface Engine {
  80565. /**
  80566. * Creates a raw texture
  80567. * @param data defines the data to store in the texture
  80568. * @param width defines the width of the texture
  80569. * @param height defines the height of the texture
  80570. * @param format defines the format of the data
  80571. * @param generateMipMaps defines if the engine should generate the mip levels
  80572. * @param invertY defines if data must be stored with Y axis inverted
  80573. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80574. * @param compression defines the compression used (null by default)
  80575. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80576. * @returns the raw texture inside an InternalTexture
  80577. */
  80578. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80579. /**
  80580. * Update a raw texture
  80581. * @param texture defines the texture to update
  80582. * @param data defines the data to store in the texture
  80583. * @param format defines the format of the data
  80584. * @param invertY defines if data must be stored with Y axis inverted
  80585. */
  80586. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80587. /**
  80588. * Update a raw texture
  80589. * @param texture defines the texture to update
  80590. * @param data defines the data to store in the texture
  80591. * @param format defines the format of the data
  80592. * @param invertY defines if data must be stored with Y axis inverted
  80593. * @param compression defines the compression used (null by default)
  80594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80595. */
  80596. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80597. /**
  80598. * Creates a new raw cube texture
  80599. * @param data defines the array of data to use to create each face
  80600. * @param size defines the size of the textures
  80601. * @param format defines the format of the data
  80602. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80603. * @param generateMipMaps defines if the engine should generate the mip levels
  80604. * @param invertY defines if data must be stored with Y axis inverted
  80605. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80606. * @param compression defines the compression used (null by default)
  80607. * @returns the cube texture as an InternalTexture
  80608. */
  80609. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80610. /**
  80611. * Update a raw cube texture
  80612. * @param texture defines the texture to udpdate
  80613. * @param data defines the data to store
  80614. * @param format defines the data format
  80615. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80616. * @param invertY defines if data must be stored with Y axis inverted
  80617. */
  80618. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80619. /**
  80620. * Update a raw cube texture
  80621. * @param texture defines the texture to udpdate
  80622. * @param data defines the data to store
  80623. * @param format defines the data format
  80624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80625. * @param invertY defines if data must be stored with Y axis inverted
  80626. * @param compression defines the compression used (null by default)
  80627. */
  80628. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80629. /**
  80630. * Update a raw cube texture
  80631. * @param texture defines the texture to udpdate
  80632. * @param data defines the data to store
  80633. * @param format defines the data format
  80634. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80635. * @param invertY defines if data must be stored with Y axis inverted
  80636. * @param compression defines the compression used (null by default)
  80637. * @param level defines which level of the texture to update
  80638. */
  80639. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80640. /**
  80641. * Creates a new raw cube texture from a specified url
  80642. * @param url defines the url where the data is located
  80643. * @param scene defines the current scene
  80644. * @param size defines the size of the textures
  80645. * @param format defines the format of the data
  80646. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80647. * @param noMipmap defines if the engine should avoid generating the mip levels
  80648. * @param callback defines a callback used to extract texture data from loaded data
  80649. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80650. * @param onLoad defines a callback called when texture is loaded
  80651. * @param onError defines a callback called if there is an error
  80652. * @returns the cube texture as an InternalTexture
  80653. */
  80654. 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;
  80655. /**
  80656. * Creates a new raw cube texture from a specified url
  80657. * @param url defines the url where the data is located
  80658. * @param scene defines the current scene
  80659. * @param size defines the size of the textures
  80660. * @param format defines the format of the data
  80661. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80662. * @param noMipmap defines if the engine should avoid generating the mip levels
  80663. * @param callback defines a callback used to extract texture data from loaded data
  80664. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80665. * @param onLoad defines a callback called when texture is loaded
  80666. * @param onError defines a callback called if there is an error
  80667. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80668. * @param invertY defines if data must be stored with Y axis inverted
  80669. * @returns the cube texture as an InternalTexture
  80670. */
  80671. 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;
  80672. /**
  80673. * Creates a new raw 3D texture
  80674. * @param data defines the data used to create the texture
  80675. * @param width defines the width of the texture
  80676. * @param height defines the height of the texture
  80677. * @param depth defines the depth of the texture
  80678. * @param format defines the format of the texture
  80679. * @param generateMipMaps defines if the engine must generate mip levels
  80680. * @param invertY defines if data must be stored with Y axis inverted
  80681. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80682. * @param compression defines the compressed used (can be null)
  80683. * @param textureType defines the compressed used (can be null)
  80684. * @returns a new raw 3D texture (stored in an InternalTexture)
  80685. */
  80686. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80687. /**
  80688. * Update a raw 3D texture
  80689. * @param texture defines the texture to update
  80690. * @param data defines the data to store
  80691. * @param format defines the data format
  80692. * @param invertY defines if data must be stored with Y axis inverted
  80693. */
  80694. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80695. /**
  80696. * Update a raw 3D texture
  80697. * @param texture defines the texture to update
  80698. * @param data defines the data to store
  80699. * @param format defines the data format
  80700. * @param invertY defines if data must be stored with Y axis inverted
  80701. * @param compression defines the used compression (can be null)
  80702. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80703. */
  80704. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80705. /**
  80706. * Creates a new raw 2D array texture
  80707. * @param data defines the data used to create the texture
  80708. * @param width defines the width of the texture
  80709. * @param height defines the height of the texture
  80710. * @param depth defines the number of layers of the texture
  80711. * @param format defines the format of the texture
  80712. * @param generateMipMaps defines if the engine must generate mip levels
  80713. * @param invertY defines if data must be stored with Y axis inverted
  80714. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80715. * @param compression defines the compressed used (can be null)
  80716. * @param textureType defines the compressed used (can be null)
  80717. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80718. */
  80719. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80720. /**
  80721. * Update a raw 2D array texture
  80722. * @param texture defines the texture to update
  80723. * @param data defines the data to store
  80724. * @param format defines the data format
  80725. * @param invertY defines if data must be stored with Y axis inverted
  80726. */
  80727. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80728. /**
  80729. * Update a raw 2D array texture
  80730. * @param texture defines the texture to update
  80731. * @param data defines the data to store
  80732. * @param format defines the data format
  80733. * @param invertY defines if data must be stored with Y axis inverted
  80734. * @param compression defines the used compression (can be null)
  80735. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80736. */
  80737. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80738. }
  80739. }
  80740. declare module BABYLON {
  80741. /**
  80742. * Raw texture can help creating a texture directly from an array of data.
  80743. * This can be super useful if you either get the data from an uncompressed source or
  80744. * if you wish to create your texture pixel by pixel.
  80745. */
  80746. export class RawTexture extends Texture {
  80747. /**
  80748. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80749. */
  80750. format: number;
  80751. private _engine;
  80752. /**
  80753. * Instantiates a new RawTexture.
  80754. * Raw texture can help creating a texture directly from an array of data.
  80755. * This can be super useful if you either get the data from an uncompressed source or
  80756. * if you wish to create your texture pixel by pixel.
  80757. * @param data define the array of data to use to create the texture
  80758. * @param width define the width of the texture
  80759. * @param height define the height of the texture
  80760. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80761. * @param scene define the scene the texture belongs to
  80762. * @param generateMipMaps define whether mip maps should be generated or not
  80763. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80764. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80765. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80766. */
  80767. constructor(data: ArrayBufferView, width: number, height: number,
  80768. /**
  80769. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80770. */
  80771. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80772. /**
  80773. * Updates the texture underlying data.
  80774. * @param data Define the new data of the texture
  80775. */
  80776. update(data: ArrayBufferView): void;
  80777. /**
  80778. * Creates a luminance texture from some data.
  80779. * @param data Define the texture data
  80780. * @param width Define the width of the texture
  80781. * @param height Define the height of the texture
  80782. * @param scene Define the scene the texture belongs to
  80783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80786. * @returns the luminance texture
  80787. */
  80788. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80789. /**
  80790. * Creates a luminance alpha texture from some data.
  80791. * @param data Define the texture data
  80792. * @param width Define the width of the texture
  80793. * @param height Define the height of the texture
  80794. * @param scene Define the scene the texture belongs to
  80795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80798. * @returns the luminance alpha texture
  80799. */
  80800. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80801. /**
  80802. * Creates an alpha texture from some data.
  80803. * @param data Define the texture data
  80804. * @param width Define the width of the texture
  80805. * @param height Define the height of the texture
  80806. * @param scene Define the scene the texture belongs to
  80807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80810. * @returns the alpha texture
  80811. */
  80812. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80813. /**
  80814. * Creates a RGB texture from some data.
  80815. * @param data Define the texture data
  80816. * @param width Define the width of the texture
  80817. * @param height Define the height of the texture
  80818. * @param scene Define the scene the texture belongs to
  80819. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80820. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80821. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80822. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80823. * @returns the RGB alpha texture
  80824. */
  80825. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80826. /**
  80827. * Creates a RGBA texture from some data.
  80828. * @param data Define the texture data
  80829. * @param width Define the width of the texture
  80830. * @param height Define the height of the texture
  80831. * @param scene Define the scene the texture belongs to
  80832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80836. * @returns the RGBA texture
  80837. */
  80838. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80839. /**
  80840. * Creates a R texture from some data.
  80841. * @param data Define the texture data
  80842. * @param width Define the width of the texture
  80843. * @param height Define the height of the texture
  80844. * @param scene Define the scene the texture belongs to
  80845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80849. * @returns the R texture
  80850. */
  80851. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80852. }
  80853. }
  80854. declare module BABYLON {
  80855. /**
  80856. * Interface for the size containing width and height
  80857. */
  80858. export interface ISize {
  80859. /**
  80860. * Width
  80861. */
  80862. width: number;
  80863. /**
  80864. * Heighht
  80865. */
  80866. height: number;
  80867. }
  80868. /**
  80869. * Size containing widht and height
  80870. */
  80871. export class Size implements ISize {
  80872. /**
  80873. * Width
  80874. */
  80875. width: number;
  80876. /**
  80877. * Height
  80878. */
  80879. height: number;
  80880. /**
  80881. * Creates a Size object from the given width and height (floats).
  80882. * @param width width of the new size
  80883. * @param height height of the new size
  80884. */
  80885. constructor(width: number, height: number);
  80886. /**
  80887. * Returns a string with the Size width and height
  80888. * @returns a string with the Size width and height
  80889. */
  80890. toString(): string;
  80891. /**
  80892. * "Size"
  80893. * @returns the string "Size"
  80894. */
  80895. getClassName(): string;
  80896. /**
  80897. * Returns the Size hash code.
  80898. * @returns a hash code for a unique width and height
  80899. */
  80900. getHashCode(): number;
  80901. /**
  80902. * Updates the current size from the given one.
  80903. * @param src the given size
  80904. */
  80905. copyFrom(src: Size): void;
  80906. /**
  80907. * Updates in place the current Size from the given floats.
  80908. * @param width width of the new size
  80909. * @param height height of the new size
  80910. * @returns the updated Size.
  80911. */
  80912. copyFromFloats(width: number, height: number): Size;
  80913. /**
  80914. * Updates in place the current Size from the given floats.
  80915. * @param width width to set
  80916. * @param height height to set
  80917. * @returns the updated Size.
  80918. */
  80919. set(width: number, height: number): Size;
  80920. /**
  80921. * Multiplies the width and height by numbers
  80922. * @param w factor to multiple the width by
  80923. * @param h factor to multiple the height by
  80924. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80925. */
  80926. multiplyByFloats(w: number, h: number): Size;
  80927. /**
  80928. * Clones the size
  80929. * @returns a new Size copied from the given one.
  80930. */
  80931. clone(): Size;
  80932. /**
  80933. * True if the current Size and the given one width and height are strictly equal.
  80934. * @param other the other size to compare against
  80935. * @returns True if the current Size and the given one width and height are strictly equal.
  80936. */
  80937. equals(other: Size): boolean;
  80938. /**
  80939. * The surface of the Size : width * height (float).
  80940. */
  80941. readonly surface: number;
  80942. /**
  80943. * Create a new size of zero
  80944. * @returns a new Size set to (0.0, 0.0)
  80945. */
  80946. static Zero(): Size;
  80947. /**
  80948. * Sums the width and height of two sizes
  80949. * @param otherSize size to add to this size
  80950. * @returns a new Size set as the addition result of the current Size and the given one.
  80951. */
  80952. add(otherSize: Size): Size;
  80953. /**
  80954. * Subtracts the width and height of two
  80955. * @param otherSize size to subtract to this size
  80956. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80957. */
  80958. subtract(otherSize: Size): Size;
  80959. /**
  80960. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80961. * @param start starting size to lerp between
  80962. * @param end end size to lerp between
  80963. * @param amount amount to lerp between the start and end values
  80964. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80965. */
  80966. static Lerp(start: Size, end: Size, amount: number): Size;
  80967. }
  80968. }
  80969. declare module BABYLON {
  80970. /**
  80971. * Defines a runtime animation
  80972. */
  80973. export class RuntimeAnimation {
  80974. private _events;
  80975. /**
  80976. * The current frame of the runtime animation
  80977. */
  80978. private _currentFrame;
  80979. /**
  80980. * The animation used by the runtime animation
  80981. */
  80982. private _animation;
  80983. /**
  80984. * The target of the runtime animation
  80985. */
  80986. private _target;
  80987. /**
  80988. * The initiating animatable
  80989. */
  80990. private _host;
  80991. /**
  80992. * The original value of the runtime animation
  80993. */
  80994. private _originalValue;
  80995. /**
  80996. * The original blend value of the runtime animation
  80997. */
  80998. private _originalBlendValue;
  80999. /**
  81000. * The offsets cache of the runtime animation
  81001. */
  81002. private _offsetsCache;
  81003. /**
  81004. * The high limits cache of the runtime animation
  81005. */
  81006. private _highLimitsCache;
  81007. /**
  81008. * Specifies if the runtime animation has been stopped
  81009. */
  81010. private _stopped;
  81011. /**
  81012. * The blending factor of the runtime animation
  81013. */
  81014. private _blendingFactor;
  81015. /**
  81016. * The BabylonJS scene
  81017. */
  81018. private _scene;
  81019. /**
  81020. * The current value of the runtime animation
  81021. */
  81022. private _currentValue;
  81023. /** @hidden */
  81024. _animationState: _IAnimationState;
  81025. /**
  81026. * The active target of the runtime animation
  81027. */
  81028. private _activeTargets;
  81029. private _currentActiveTarget;
  81030. private _directTarget;
  81031. /**
  81032. * The target path of the runtime animation
  81033. */
  81034. private _targetPath;
  81035. /**
  81036. * The weight of the runtime animation
  81037. */
  81038. private _weight;
  81039. /**
  81040. * The ratio offset of the runtime animation
  81041. */
  81042. private _ratioOffset;
  81043. /**
  81044. * The previous delay of the runtime animation
  81045. */
  81046. private _previousDelay;
  81047. /**
  81048. * The previous ratio of the runtime animation
  81049. */
  81050. private _previousRatio;
  81051. private _enableBlending;
  81052. private _keys;
  81053. private _minFrame;
  81054. private _maxFrame;
  81055. private _minValue;
  81056. private _maxValue;
  81057. private _targetIsArray;
  81058. /**
  81059. * Gets the current frame of the runtime animation
  81060. */
  81061. readonly currentFrame: number;
  81062. /**
  81063. * Gets the weight of the runtime animation
  81064. */
  81065. readonly weight: number;
  81066. /**
  81067. * Gets the current value of the runtime animation
  81068. */
  81069. readonly currentValue: any;
  81070. /**
  81071. * Gets the target path of the runtime animation
  81072. */
  81073. readonly targetPath: string;
  81074. /**
  81075. * Gets the actual target of the runtime animation
  81076. */
  81077. readonly target: any;
  81078. /** @hidden */
  81079. _onLoop: () => void;
  81080. /**
  81081. * Create a new RuntimeAnimation object
  81082. * @param target defines the target of the animation
  81083. * @param animation defines the source animation object
  81084. * @param scene defines the hosting scene
  81085. * @param host defines the initiating Animatable
  81086. */
  81087. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81088. private _preparePath;
  81089. /**
  81090. * Gets the animation from the runtime animation
  81091. */
  81092. readonly animation: Animation;
  81093. /**
  81094. * Resets the runtime animation to the beginning
  81095. * @param restoreOriginal defines whether to restore the target property to the original value
  81096. */
  81097. reset(restoreOriginal?: boolean): void;
  81098. /**
  81099. * Specifies if the runtime animation is stopped
  81100. * @returns Boolean specifying if the runtime animation is stopped
  81101. */
  81102. isStopped(): boolean;
  81103. /**
  81104. * Disposes of the runtime animation
  81105. */
  81106. dispose(): void;
  81107. /**
  81108. * Apply the interpolated value to the target
  81109. * @param currentValue defines the value computed by the animation
  81110. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81111. */
  81112. setValue(currentValue: any, weight: number): void;
  81113. private _getOriginalValues;
  81114. private _setValue;
  81115. /**
  81116. * Gets the loop pmode of the runtime animation
  81117. * @returns Loop Mode
  81118. */
  81119. private _getCorrectLoopMode;
  81120. /**
  81121. * Move the current animation to a given frame
  81122. * @param frame defines the frame to move to
  81123. */
  81124. goToFrame(frame: number): void;
  81125. /**
  81126. * @hidden Internal use only
  81127. */
  81128. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81129. /**
  81130. * Execute the current animation
  81131. * @param delay defines the delay to add to the current frame
  81132. * @param from defines the lower bound of the animation range
  81133. * @param to defines the upper bound of the animation range
  81134. * @param loop defines if the current animation must loop
  81135. * @param speedRatio defines the current speed ratio
  81136. * @param weight defines the weight of the animation (default is -1 so no weight)
  81137. * @param onLoop optional callback called when animation loops
  81138. * @returns a boolean indicating if the animation is running
  81139. */
  81140. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81141. }
  81142. }
  81143. declare module BABYLON {
  81144. /**
  81145. * Class used to store an actual running animation
  81146. */
  81147. export class Animatable {
  81148. /** defines the target object */
  81149. target: any;
  81150. /** defines the starting frame number (default is 0) */
  81151. fromFrame: number;
  81152. /** defines the ending frame number (default is 100) */
  81153. toFrame: number;
  81154. /** defines if the animation must loop (default is false) */
  81155. loopAnimation: boolean;
  81156. /** defines a callback to call when animation ends if it is not looping */
  81157. onAnimationEnd?: (() => void) | null | undefined;
  81158. /** defines a callback to call when animation loops */
  81159. onAnimationLoop?: (() => void) | null | undefined;
  81160. private _localDelayOffset;
  81161. private _pausedDelay;
  81162. private _runtimeAnimations;
  81163. private _paused;
  81164. private _scene;
  81165. private _speedRatio;
  81166. private _weight;
  81167. private _syncRoot;
  81168. /**
  81169. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81170. * This will only apply for non looping animation (default is true)
  81171. */
  81172. disposeOnEnd: boolean;
  81173. /**
  81174. * Gets a boolean indicating if the animation has started
  81175. */
  81176. animationStarted: boolean;
  81177. /**
  81178. * Observer raised when the animation ends
  81179. */
  81180. onAnimationEndObservable: Observable<Animatable>;
  81181. /**
  81182. * Observer raised when the animation loops
  81183. */
  81184. onAnimationLoopObservable: Observable<Animatable>;
  81185. /**
  81186. * Gets the root Animatable used to synchronize and normalize animations
  81187. */
  81188. readonly syncRoot: Nullable<Animatable>;
  81189. /**
  81190. * Gets the current frame of the first RuntimeAnimation
  81191. * Used to synchronize Animatables
  81192. */
  81193. readonly masterFrame: number;
  81194. /**
  81195. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81196. */
  81197. weight: number;
  81198. /**
  81199. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81200. */
  81201. speedRatio: number;
  81202. /**
  81203. * Creates a new Animatable
  81204. * @param scene defines the hosting scene
  81205. * @param target defines the target object
  81206. * @param fromFrame defines the starting frame number (default is 0)
  81207. * @param toFrame defines the ending frame number (default is 100)
  81208. * @param loopAnimation defines if the animation must loop (default is false)
  81209. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81210. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81211. * @param animations defines a group of animation to add to the new Animatable
  81212. * @param onAnimationLoop defines a callback to call when animation loops
  81213. */
  81214. constructor(scene: Scene,
  81215. /** defines the target object */
  81216. target: any,
  81217. /** defines the starting frame number (default is 0) */
  81218. fromFrame?: number,
  81219. /** defines the ending frame number (default is 100) */
  81220. toFrame?: number,
  81221. /** defines if the animation must loop (default is false) */
  81222. loopAnimation?: boolean, speedRatio?: number,
  81223. /** defines a callback to call when animation ends if it is not looping */
  81224. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81225. /** defines a callback to call when animation loops */
  81226. onAnimationLoop?: (() => void) | null | undefined);
  81227. /**
  81228. * Synchronize and normalize current Animatable with a source Animatable
  81229. * This is useful when using animation weights and when animations are not of the same length
  81230. * @param root defines the root Animatable to synchronize with
  81231. * @returns the current Animatable
  81232. */
  81233. syncWith(root: Animatable): Animatable;
  81234. /**
  81235. * Gets the list of runtime animations
  81236. * @returns an array of RuntimeAnimation
  81237. */
  81238. getAnimations(): RuntimeAnimation[];
  81239. /**
  81240. * Adds more animations to the current animatable
  81241. * @param target defines the target of the animations
  81242. * @param animations defines the new animations to add
  81243. */
  81244. appendAnimations(target: any, animations: Animation[]): void;
  81245. /**
  81246. * Gets the source animation for a specific property
  81247. * @param property defines the propertyu to look for
  81248. * @returns null or the source animation for the given property
  81249. */
  81250. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81251. /**
  81252. * Gets the runtime animation for a specific property
  81253. * @param property defines the propertyu to look for
  81254. * @returns null or the runtime animation for the given property
  81255. */
  81256. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81257. /**
  81258. * Resets the animatable to its original state
  81259. */
  81260. reset(): void;
  81261. /**
  81262. * Allows the animatable to blend with current running animations
  81263. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81264. * @param blendingSpeed defines the blending speed to use
  81265. */
  81266. enableBlending(blendingSpeed: number): void;
  81267. /**
  81268. * Disable animation blending
  81269. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81270. */
  81271. disableBlending(): void;
  81272. /**
  81273. * Jump directly to a given frame
  81274. * @param frame defines the frame to jump to
  81275. */
  81276. goToFrame(frame: number): void;
  81277. /**
  81278. * Pause the animation
  81279. */
  81280. pause(): void;
  81281. /**
  81282. * Restart the animation
  81283. */
  81284. restart(): void;
  81285. private _raiseOnAnimationEnd;
  81286. /**
  81287. * Stop and delete the current animation
  81288. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81289. * @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)
  81290. */
  81291. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81292. /**
  81293. * Wait asynchronously for the animation to end
  81294. * @returns a promise which will be fullfilled when the animation ends
  81295. */
  81296. waitAsync(): Promise<Animatable>;
  81297. /** @hidden */
  81298. _animate(delay: number): boolean;
  81299. }
  81300. interface Scene {
  81301. /** @hidden */
  81302. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81303. /** @hidden */
  81304. _processLateAnimationBindingsForMatrices(holder: {
  81305. totalWeight: number;
  81306. animations: RuntimeAnimation[];
  81307. originalValue: Matrix;
  81308. }): any;
  81309. /** @hidden */
  81310. _processLateAnimationBindingsForQuaternions(holder: {
  81311. totalWeight: number;
  81312. animations: RuntimeAnimation[];
  81313. originalValue: Quaternion;
  81314. }, refQuaternion: Quaternion): Quaternion;
  81315. /** @hidden */
  81316. _processLateAnimationBindings(): void;
  81317. /**
  81318. * Will start the animation sequence of a given target
  81319. * @param target defines the target
  81320. * @param from defines from which frame should animation start
  81321. * @param to defines until which frame should animation run.
  81322. * @param weight defines the weight to apply to the animation (1.0 by default)
  81323. * @param loop defines if the animation loops
  81324. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81325. * @param onAnimationEnd defines the function to be executed when the animation ends
  81326. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81327. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81328. * @param onAnimationLoop defines the callback to call when an animation loops
  81329. * @returns the animatable object created for this animation
  81330. */
  81331. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81332. /**
  81333. * Will start the animation sequence of a given target
  81334. * @param target defines the target
  81335. * @param from defines from which frame should animation start
  81336. * @param to defines until which frame should animation run.
  81337. * @param loop defines if the animation loops
  81338. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81339. * @param onAnimationEnd defines the function to be executed when the animation ends
  81340. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81341. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81342. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81343. * @param onAnimationLoop defines the callback to call when an animation loops
  81344. * @returns the animatable object created for this animation
  81345. */
  81346. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81347. /**
  81348. * Will start the animation sequence of a given target and its hierarchy
  81349. * @param target defines the target
  81350. * @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.
  81351. * @param from defines from which frame should animation start
  81352. * @param to defines until which frame should animation run.
  81353. * @param loop defines if the animation loops
  81354. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81355. * @param onAnimationEnd defines the function to be executed when the animation ends
  81356. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81357. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81358. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81359. * @param onAnimationLoop defines the callback to call when an animation loops
  81360. * @returns the list of created animatables
  81361. */
  81362. 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[];
  81363. /**
  81364. * Begin a new animation on a given node
  81365. * @param target defines the target where the animation will take place
  81366. * @param animations defines the list of animations to start
  81367. * @param from defines the initial value
  81368. * @param to defines the final value
  81369. * @param loop defines if you want animation to loop (off by default)
  81370. * @param speedRatio defines the speed ratio to apply to all animations
  81371. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81372. * @param onAnimationLoop defines the callback to call when an animation loops
  81373. * @returns the list of created animatables
  81374. */
  81375. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81376. /**
  81377. * Begin a new animation on a given node and its hierarchy
  81378. * @param target defines the root node where the animation will take place
  81379. * @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.
  81380. * @param animations defines the list of animations to start
  81381. * @param from defines the initial value
  81382. * @param to defines the final value
  81383. * @param loop defines if you want animation to loop (off by default)
  81384. * @param speedRatio defines the speed ratio to apply to all animations
  81385. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81386. * @param onAnimationLoop defines the callback to call when an animation loops
  81387. * @returns the list of animatables created for all nodes
  81388. */
  81389. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81390. /**
  81391. * Gets the animatable associated with a specific target
  81392. * @param target defines the target of the animatable
  81393. * @returns the required animatable if found
  81394. */
  81395. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81396. /**
  81397. * Gets all animatables associated with a given target
  81398. * @param target defines the target to look animatables for
  81399. * @returns an array of Animatables
  81400. */
  81401. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81402. /**
  81403. * Stops and removes all animations that have been applied to the scene
  81404. */
  81405. stopAllAnimations(): void;
  81406. /**
  81407. * Gets the current delta time used by animation engine
  81408. */
  81409. deltaTime: number;
  81410. }
  81411. interface Bone {
  81412. /**
  81413. * Copy an animation range from another bone
  81414. * @param source defines the source bone
  81415. * @param rangeName defines the range name to copy
  81416. * @param frameOffset defines the frame offset
  81417. * @param rescaleAsRequired defines if rescaling must be applied if required
  81418. * @param skelDimensionsRatio defines the scaling ratio
  81419. * @returns true if operation was successful
  81420. */
  81421. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81422. }
  81423. }
  81424. declare module BABYLON {
  81425. /**
  81426. * Class used to override all child animations of a given target
  81427. */
  81428. export class AnimationPropertiesOverride {
  81429. /**
  81430. * Gets or sets a value indicating if animation blending must be used
  81431. */
  81432. enableBlending: boolean;
  81433. /**
  81434. * Gets or sets the blending speed to use when enableBlending is true
  81435. */
  81436. blendingSpeed: number;
  81437. /**
  81438. * Gets or sets the default loop mode to use
  81439. */
  81440. loopMode: number;
  81441. }
  81442. }
  81443. declare module BABYLON {
  81444. /**
  81445. * Class used to handle skinning animations
  81446. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81447. */
  81448. export class Skeleton implements IAnimatable {
  81449. /** defines the skeleton name */
  81450. name: string;
  81451. /** defines the skeleton Id */
  81452. id: string;
  81453. /**
  81454. * Defines the list of child bones
  81455. */
  81456. bones: Bone[];
  81457. /**
  81458. * Defines an estimate of the dimension of the skeleton at rest
  81459. */
  81460. dimensionsAtRest: Vector3;
  81461. /**
  81462. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81463. */
  81464. needInitialSkinMatrix: boolean;
  81465. /**
  81466. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81467. */
  81468. overrideMesh: Nullable<AbstractMesh>;
  81469. /**
  81470. * Gets the list of animations attached to this skeleton
  81471. */
  81472. animations: Array<Animation>;
  81473. private _scene;
  81474. private _isDirty;
  81475. private _transformMatrices;
  81476. private _transformMatrixTexture;
  81477. private _meshesWithPoseMatrix;
  81478. private _animatables;
  81479. private _identity;
  81480. private _synchronizedWithMesh;
  81481. private _ranges;
  81482. private _lastAbsoluteTransformsUpdateId;
  81483. private _canUseTextureForBones;
  81484. private _uniqueId;
  81485. /** @hidden */
  81486. _numBonesWithLinkedTransformNode: number;
  81487. /** @hidden */
  81488. _hasWaitingData: Nullable<boolean>;
  81489. /**
  81490. * Specifies if the skeleton should be serialized
  81491. */
  81492. doNotSerialize: boolean;
  81493. private _useTextureToStoreBoneMatrices;
  81494. /**
  81495. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81496. * Please note that this option is not available if the hardware does not support it
  81497. */
  81498. useTextureToStoreBoneMatrices: boolean;
  81499. private _animationPropertiesOverride;
  81500. /**
  81501. * Gets or sets the animation properties override
  81502. */
  81503. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81504. /**
  81505. * List of inspectable custom properties (used by the Inspector)
  81506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81507. */
  81508. inspectableCustomProperties: IInspectable[];
  81509. /**
  81510. * An observable triggered before computing the skeleton's matrices
  81511. */
  81512. onBeforeComputeObservable: Observable<Skeleton>;
  81513. /**
  81514. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81515. */
  81516. readonly isUsingTextureForMatrices: boolean;
  81517. /**
  81518. * Gets the unique ID of this skeleton
  81519. */
  81520. readonly uniqueId: number;
  81521. /**
  81522. * Creates a new skeleton
  81523. * @param name defines the skeleton name
  81524. * @param id defines the skeleton Id
  81525. * @param scene defines the hosting scene
  81526. */
  81527. constructor(
  81528. /** defines the skeleton name */
  81529. name: string,
  81530. /** defines the skeleton Id */
  81531. id: string, scene: Scene);
  81532. /**
  81533. * Gets the current object class name.
  81534. * @return the class name
  81535. */
  81536. getClassName(): string;
  81537. /**
  81538. * Returns an array containing the root bones
  81539. * @returns an array containing the root bones
  81540. */
  81541. getChildren(): Array<Bone>;
  81542. /**
  81543. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81544. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81545. * @returns a Float32Array containing matrices data
  81546. */
  81547. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81548. /**
  81549. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81550. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81551. * @returns a raw texture containing the data
  81552. */
  81553. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81554. /**
  81555. * Gets the current hosting scene
  81556. * @returns a scene object
  81557. */
  81558. getScene(): Scene;
  81559. /**
  81560. * Gets a string representing the current skeleton data
  81561. * @param fullDetails defines a boolean indicating if we want a verbose version
  81562. * @returns a string representing the current skeleton data
  81563. */
  81564. toString(fullDetails?: boolean): string;
  81565. /**
  81566. * Get bone's index searching by name
  81567. * @param name defines bone's name to search for
  81568. * @return the indice of the bone. Returns -1 if not found
  81569. */
  81570. getBoneIndexByName(name: string): number;
  81571. /**
  81572. * Creater a new animation range
  81573. * @param name defines the name of the range
  81574. * @param from defines the start key
  81575. * @param to defines the end key
  81576. */
  81577. createAnimationRange(name: string, from: number, to: number): void;
  81578. /**
  81579. * Delete a specific animation range
  81580. * @param name defines the name of the range
  81581. * @param deleteFrames defines if frames must be removed as well
  81582. */
  81583. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81584. /**
  81585. * Gets a specific animation range
  81586. * @param name defines the name of the range to look for
  81587. * @returns the requested animation range or null if not found
  81588. */
  81589. getAnimationRange(name: string): Nullable<AnimationRange>;
  81590. /**
  81591. * Gets the list of all animation ranges defined on this skeleton
  81592. * @returns an array
  81593. */
  81594. getAnimationRanges(): Nullable<AnimationRange>[];
  81595. /**
  81596. * Copy animation range from a source skeleton.
  81597. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81598. * @param source defines the source skeleton
  81599. * @param name defines the name of the range to copy
  81600. * @param rescaleAsRequired defines if rescaling must be applied if required
  81601. * @returns true if operation was successful
  81602. */
  81603. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81604. /**
  81605. * Forces the skeleton to go to rest pose
  81606. */
  81607. returnToRest(): void;
  81608. private _getHighestAnimationFrame;
  81609. /**
  81610. * Begin a specific animation range
  81611. * @param name defines the name of the range to start
  81612. * @param loop defines if looping must be turned on (false by default)
  81613. * @param speedRatio defines the speed ratio to apply (1 by default)
  81614. * @param onAnimationEnd defines a callback which will be called when animation will end
  81615. * @returns a new animatable
  81616. */
  81617. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81618. /** @hidden */
  81619. _markAsDirty(): void;
  81620. /** @hidden */
  81621. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81622. /** @hidden */
  81623. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81624. private _computeTransformMatrices;
  81625. /**
  81626. * Build all resources required to render a skeleton
  81627. */
  81628. prepare(): void;
  81629. /**
  81630. * Gets the list of animatables currently running for this skeleton
  81631. * @returns an array of animatables
  81632. */
  81633. getAnimatables(): IAnimatable[];
  81634. /**
  81635. * Clone the current skeleton
  81636. * @param name defines the name of the new skeleton
  81637. * @param id defines the id of the new skeleton
  81638. * @returns the new skeleton
  81639. */
  81640. clone(name: string, id?: string): Skeleton;
  81641. /**
  81642. * Enable animation blending for this skeleton
  81643. * @param blendingSpeed defines the blending speed to apply
  81644. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81645. */
  81646. enableBlending(blendingSpeed?: number): void;
  81647. /**
  81648. * Releases all resources associated with the current skeleton
  81649. */
  81650. dispose(): void;
  81651. /**
  81652. * Serialize the skeleton in a JSON object
  81653. * @returns a JSON object
  81654. */
  81655. serialize(): any;
  81656. /**
  81657. * Creates a new skeleton from serialized data
  81658. * @param parsedSkeleton defines the serialized data
  81659. * @param scene defines the hosting scene
  81660. * @returns a new skeleton
  81661. */
  81662. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81663. /**
  81664. * Compute all node absolute transforms
  81665. * @param forceUpdate defines if computation must be done even if cache is up to date
  81666. */
  81667. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81668. /**
  81669. * Gets the root pose matrix
  81670. * @returns a matrix
  81671. */
  81672. getPoseMatrix(): Nullable<Matrix>;
  81673. /**
  81674. * Sorts bones per internal index
  81675. */
  81676. sortBones(): void;
  81677. private _sortBones;
  81678. }
  81679. }
  81680. declare module BABYLON {
  81681. /**
  81682. * Class used to store bone information
  81683. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81684. */
  81685. export class Bone extends Node {
  81686. /**
  81687. * defines the bone name
  81688. */
  81689. name: string;
  81690. private static _tmpVecs;
  81691. private static _tmpQuat;
  81692. private static _tmpMats;
  81693. /**
  81694. * Gets the list of child bones
  81695. */
  81696. children: Bone[];
  81697. /** Gets the animations associated with this bone */
  81698. animations: Animation[];
  81699. /**
  81700. * Gets or sets bone length
  81701. */
  81702. length: number;
  81703. /**
  81704. * @hidden Internal only
  81705. * Set this value to map this bone to a different index in the transform matrices
  81706. * Set this value to -1 to exclude the bone from the transform matrices
  81707. */
  81708. _index: Nullable<number>;
  81709. private _skeleton;
  81710. private _localMatrix;
  81711. private _restPose;
  81712. private _baseMatrix;
  81713. private _absoluteTransform;
  81714. private _invertedAbsoluteTransform;
  81715. private _parent;
  81716. private _scalingDeterminant;
  81717. private _worldTransform;
  81718. private _localScaling;
  81719. private _localRotation;
  81720. private _localPosition;
  81721. private _needToDecompose;
  81722. private _needToCompose;
  81723. /** @hidden */
  81724. _linkedTransformNode: Nullable<TransformNode>;
  81725. /** @hidden */
  81726. _waitingTransformNodeId: Nullable<string>;
  81727. /** @hidden */
  81728. /** @hidden */
  81729. _matrix: Matrix;
  81730. /**
  81731. * Create a new bone
  81732. * @param name defines the bone name
  81733. * @param skeleton defines the parent skeleton
  81734. * @param parentBone defines the parent (can be null if the bone is the root)
  81735. * @param localMatrix defines the local matrix
  81736. * @param restPose defines the rest pose matrix
  81737. * @param baseMatrix defines the base matrix
  81738. * @param index defines index of the bone in the hiearchy
  81739. */
  81740. constructor(
  81741. /**
  81742. * defines the bone name
  81743. */
  81744. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81745. /**
  81746. * Gets the current object class name.
  81747. * @return the class name
  81748. */
  81749. getClassName(): string;
  81750. /**
  81751. * Gets the parent skeleton
  81752. * @returns a skeleton
  81753. */
  81754. getSkeleton(): Skeleton;
  81755. /**
  81756. * Gets parent bone
  81757. * @returns a bone or null if the bone is the root of the bone hierarchy
  81758. */
  81759. getParent(): Nullable<Bone>;
  81760. /**
  81761. * Returns an array containing the root bones
  81762. * @returns an array containing the root bones
  81763. */
  81764. getChildren(): Array<Bone>;
  81765. /**
  81766. * Gets the node index in matrix array generated for rendering
  81767. * @returns the node index
  81768. */
  81769. getIndex(): number;
  81770. /**
  81771. * Sets the parent bone
  81772. * @param parent defines the parent (can be null if the bone is the root)
  81773. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81774. */
  81775. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81776. /**
  81777. * Gets the local matrix
  81778. * @returns a matrix
  81779. */
  81780. getLocalMatrix(): Matrix;
  81781. /**
  81782. * Gets the base matrix (initial matrix which remains unchanged)
  81783. * @returns a matrix
  81784. */
  81785. getBaseMatrix(): Matrix;
  81786. /**
  81787. * Gets the rest pose matrix
  81788. * @returns a matrix
  81789. */
  81790. getRestPose(): Matrix;
  81791. /**
  81792. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81793. */
  81794. getWorldMatrix(): Matrix;
  81795. /**
  81796. * Sets the local matrix to rest pose matrix
  81797. */
  81798. returnToRest(): void;
  81799. /**
  81800. * Gets the inverse of the absolute transform matrix.
  81801. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81802. * @returns a matrix
  81803. */
  81804. getInvertedAbsoluteTransform(): Matrix;
  81805. /**
  81806. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81807. * @returns a matrix
  81808. */
  81809. getAbsoluteTransform(): Matrix;
  81810. /**
  81811. * Links with the given transform node.
  81812. * The local matrix of this bone is copied from the transform node every frame.
  81813. * @param transformNode defines the transform node to link to
  81814. */
  81815. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81816. /**
  81817. * Gets the node used to drive the bone's transformation
  81818. * @returns a transform node or null
  81819. */
  81820. getTransformNode(): Nullable<TransformNode>;
  81821. /** Gets or sets current position (in local space) */
  81822. position: Vector3;
  81823. /** Gets or sets current rotation (in local space) */
  81824. rotation: Vector3;
  81825. /** Gets or sets current rotation quaternion (in local space) */
  81826. rotationQuaternion: Quaternion;
  81827. /** Gets or sets current scaling (in local space) */
  81828. scaling: Vector3;
  81829. /**
  81830. * Gets the animation properties override
  81831. */
  81832. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81833. private _decompose;
  81834. private _compose;
  81835. /**
  81836. * Update the base and local matrices
  81837. * @param matrix defines the new base or local matrix
  81838. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81839. * @param updateLocalMatrix defines if the local matrix should be updated
  81840. */
  81841. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81842. /** @hidden */
  81843. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81844. /**
  81845. * Flag the bone as dirty (Forcing it to update everything)
  81846. */
  81847. markAsDirty(): void;
  81848. /** @hidden */
  81849. _markAsDirtyAndCompose(): void;
  81850. private _markAsDirtyAndDecompose;
  81851. /**
  81852. * Translate the bone in local or world space
  81853. * @param vec The amount to translate the bone
  81854. * @param space The space that the translation is in
  81855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81856. */
  81857. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81858. /**
  81859. * Set the postion of the bone in local or world space
  81860. * @param position The position to set the bone
  81861. * @param space The space that the position is in
  81862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81863. */
  81864. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81865. /**
  81866. * Set the absolute position of the bone (world space)
  81867. * @param position The position to set the bone
  81868. * @param mesh The mesh that this bone is attached to
  81869. */
  81870. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81871. /**
  81872. * Scale the bone on the x, y and z axes (in local space)
  81873. * @param x The amount to scale the bone on the x axis
  81874. * @param y The amount to scale the bone on the y axis
  81875. * @param z The amount to scale the bone on the z axis
  81876. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81877. */
  81878. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81879. /**
  81880. * Set the bone scaling in local space
  81881. * @param scale defines the scaling vector
  81882. */
  81883. setScale(scale: Vector3): void;
  81884. /**
  81885. * Gets the current scaling in local space
  81886. * @returns the current scaling vector
  81887. */
  81888. getScale(): Vector3;
  81889. /**
  81890. * Gets the current scaling in local space and stores it in a target vector
  81891. * @param result defines the target vector
  81892. */
  81893. getScaleToRef(result: Vector3): void;
  81894. /**
  81895. * Set the yaw, pitch, and roll of the bone in local or world space
  81896. * @param yaw The rotation of the bone on the y axis
  81897. * @param pitch The rotation of the bone on the x axis
  81898. * @param roll The rotation of the bone on the z axis
  81899. * @param space The space that the axes of rotation are in
  81900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81901. */
  81902. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81903. /**
  81904. * Add a rotation to the bone on an axis in local or world space
  81905. * @param axis The axis to rotate the bone on
  81906. * @param amount The amount to rotate the bone
  81907. * @param space The space that the axis is in
  81908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81909. */
  81910. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81911. /**
  81912. * Set the rotation of the bone to a particular axis angle in local or world space
  81913. * @param axis The axis to rotate the bone on
  81914. * @param angle The angle that the bone should be rotated to
  81915. * @param space The space that the axis is in
  81916. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81917. */
  81918. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81919. /**
  81920. * Set the euler rotation of the bone in local of world space
  81921. * @param rotation The euler rotation that the bone should be set to
  81922. * @param space The space that the rotation is in
  81923. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81924. */
  81925. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81926. /**
  81927. * Set the quaternion rotation of the bone in local of world space
  81928. * @param quat The quaternion rotation that the bone should be set to
  81929. * @param space The space that the rotation is in
  81930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81931. */
  81932. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81933. /**
  81934. * Set the rotation matrix of the bone in local of world space
  81935. * @param rotMat The rotation matrix that the bone should be set to
  81936. * @param space The space that the rotation is in
  81937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81938. */
  81939. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81940. private _rotateWithMatrix;
  81941. private _getNegativeRotationToRef;
  81942. /**
  81943. * Get the position of the bone in local or world space
  81944. * @param space The space that the returned position is in
  81945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81946. * @returns The position of the bone
  81947. */
  81948. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81949. /**
  81950. * Copy the position of the bone to a vector3 in local or world space
  81951. * @param space The space that the returned position is in
  81952. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81953. * @param result The vector3 to copy the position to
  81954. */
  81955. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81956. /**
  81957. * Get the absolute position of the bone (world space)
  81958. * @param mesh The mesh that this bone is attached to
  81959. * @returns The absolute position of the bone
  81960. */
  81961. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81962. /**
  81963. * Copy the absolute position of the bone (world space) to the result param
  81964. * @param mesh The mesh that this bone is attached to
  81965. * @param result The vector3 to copy the absolute position to
  81966. */
  81967. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81968. /**
  81969. * Compute the absolute transforms of this bone and its children
  81970. */
  81971. computeAbsoluteTransforms(): void;
  81972. /**
  81973. * Get the world direction from an axis that is in the local space of the bone
  81974. * @param localAxis The local direction that is used to compute the world direction
  81975. * @param mesh The mesh that this bone is attached to
  81976. * @returns The world direction
  81977. */
  81978. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81979. /**
  81980. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81981. * @param localAxis The local direction that is used to compute the world direction
  81982. * @param mesh The mesh that this bone is attached to
  81983. * @param result The vector3 that the world direction will be copied to
  81984. */
  81985. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81986. /**
  81987. * Get the euler rotation of the bone in local or world space
  81988. * @param space The space that the rotation should be in
  81989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81990. * @returns The euler rotation
  81991. */
  81992. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81993. /**
  81994. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81995. * @param space The space that the rotation should be in
  81996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81997. * @param result The vector3 that the rotation should be copied to
  81998. */
  81999. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82000. /**
  82001. * Get the quaternion rotation of the bone in either local or world space
  82002. * @param space The space that the rotation should be in
  82003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82004. * @returns The quaternion rotation
  82005. */
  82006. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82007. /**
  82008. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82009. * @param space The space that the rotation should be in
  82010. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82011. * @param result The quaternion that the rotation should be copied to
  82012. */
  82013. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82014. /**
  82015. * Get the rotation matrix of the bone in local or world space
  82016. * @param space The space that the rotation should be in
  82017. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82018. * @returns The rotation matrix
  82019. */
  82020. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82021. /**
  82022. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82023. * @param space The space that the rotation should be in
  82024. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82025. * @param result The quaternion that the rotation should be copied to
  82026. */
  82027. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82028. /**
  82029. * Get the world position of a point that is in the local space of the bone
  82030. * @param position The local position
  82031. * @param mesh The mesh that this bone is attached to
  82032. * @returns The world position
  82033. */
  82034. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82035. /**
  82036. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82037. * @param position The local position
  82038. * @param mesh The mesh that this bone is attached to
  82039. * @param result The vector3 that the world position should be copied to
  82040. */
  82041. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82042. /**
  82043. * Get the local position of a point that is in world space
  82044. * @param position The world position
  82045. * @param mesh The mesh that this bone is attached to
  82046. * @returns The local position
  82047. */
  82048. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82049. /**
  82050. * Get the local position of a point that is in world space and copy it to the result param
  82051. * @param position The world position
  82052. * @param mesh The mesh that this bone is attached to
  82053. * @param result The vector3 that the local position should be copied to
  82054. */
  82055. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82056. }
  82057. }
  82058. declare module BABYLON {
  82059. /**
  82060. * 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.
  82061. * @see https://doc.babylonjs.com/how_to/transformnode
  82062. */
  82063. export class TransformNode extends Node {
  82064. /**
  82065. * Object will not rotate to face the camera
  82066. */
  82067. static BILLBOARDMODE_NONE: number;
  82068. /**
  82069. * Object will rotate to face the camera but only on the x axis
  82070. */
  82071. static BILLBOARDMODE_X: number;
  82072. /**
  82073. * Object will rotate to face the camera but only on the y axis
  82074. */
  82075. static BILLBOARDMODE_Y: number;
  82076. /**
  82077. * Object will rotate to face the camera but only on the z axis
  82078. */
  82079. static BILLBOARDMODE_Z: number;
  82080. /**
  82081. * Object will rotate to face the camera
  82082. */
  82083. static BILLBOARDMODE_ALL: number;
  82084. /**
  82085. * Object will rotate to face the camera's position instead of orientation
  82086. */
  82087. static BILLBOARDMODE_USE_POSITION: number;
  82088. private _forward;
  82089. private _forwardInverted;
  82090. private _up;
  82091. private _right;
  82092. private _rightInverted;
  82093. private _position;
  82094. private _rotation;
  82095. private _rotationQuaternion;
  82096. protected _scaling: Vector3;
  82097. protected _isDirty: boolean;
  82098. private _transformToBoneReferal;
  82099. private _isAbsoluteSynced;
  82100. private _billboardMode;
  82101. /**
  82102. * Gets or sets the billboard mode. Default is 0.
  82103. *
  82104. * | Value | Type | Description |
  82105. * | --- | --- | --- |
  82106. * | 0 | BILLBOARDMODE_NONE | |
  82107. * | 1 | BILLBOARDMODE_X | |
  82108. * | 2 | BILLBOARDMODE_Y | |
  82109. * | 4 | BILLBOARDMODE_Z | |
  82110. * | 7 | BILLBOARDMODE_ALL | |
  82111. *
  82112. */
  82113. billboardMode: number;
  82114. private _preserveParentRotationForBillboard;
  82115. /**
  82116. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82117. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82118. */
  82119. preserveParentRotationForBillboard: boolean;
  82120. /**
  82121. * 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
  82122. */
  82123. scalingDeterminant: number;
  82124. private _infiniteDistance;
  82125. /**
  82126. * Gets or sets the distance of the object to max, often used by skybox
  82127. */
  82128. infiniteDistance: boolean;
  82129. /**
  82130. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82131. * By default the system will update normals to compensate
  82132. */
  82133. ignoreNonUniformScaling: boolean;
  82134. /**
  82135. * 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
  82136. */
  82137. reIntegrateRotationIntoRotationQuaternion: boolean;
  82138. /** @hidden */
  82139. _poseMatrix: Nullable<Matrix>;
  82140. /** @hidden */
  82141. _localMatrix: Matrix;
  82142. private _usePivotMatrix;
  82143. private _absolutePosition;
  82144. private _absoluteScaling;
  82145. private _absoluteRotationQuaternion;
  82146. private _pivotMatrix;
  82147. private _pivotMatrixInverse;
  82148. protected _postMultiplyPivotMatrix: boolean;
  82149. protected _isWorldMatrixFrozen: boolean;
  82150. /** @hidden */
  82151. _indexInSceneTransformNodesArray: number;
  82152. /**
  82153. * An event triggered after the world matrix is updated
  82154. */
  82155. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82156. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82157. /**
  82158. * Gets a string identifying the name of the class
  82159. * @returns "TransformNode" string
  82160. */
  82161. getClassName(): string;
  82162. /**
  82163. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82164. */
  82165. position: Vector3;
  82166. /**
  82167. * 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)).
  82168. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82169. */
  82170. rotation: Vector3;
  82171. /**
  82172. * 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)).
  82173. */
  82174. scaling: Vector3;
  82175. /**
  82176. * 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).
  82177. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82178. */
  82179. rotationQuaternion: Nullable<Quaternion>;
  82180. /**
  82181. * The forward direction of that transform in world space.
  82182. */
  82183. readonly forward: Vector3;
  82184. /**
  82185. * The up direction of that transform in world space.
  82186. */
  82187. readonly up: Vector3;
  82188. /**
  82189. * The right direction of that transform in world space.
  82190. */
  82191. readonly right: Vector3;
  82192. /**
  82193. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82194. * @param matrix the matrix to copy the pose from
  82195. * @returns this TransformNode.
  82196. */
  82197. updatePoseMatrix(matrix: Matrix): TransformNode;
  82198. /**
  82199. * Returns the mesh Pose matrix.
  82200. * @returns the pose matrix
  82201. */
  82202. getPoseMatrix(): Matrix;
  82203. /** @hidden */
  82204. _isSynchronized(): boolean;
  82205. /** @hidden */
  82206. _initCache(): void;
  82207. /**
  82208. * Flag the transform node as dirty (Forcing it to update everything)
  82209. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82210. * @returns this transform node
  82211. */
  82212. markAsDirty(property: string): TransformNode;
  82213. /**
  82214. * Returns the current mesh absolute position.
  82215. * Returns a Vector3.
  82216. */
  82217. readonly absolutePosition: Vector3;
  82218. /**
  82219. * Returns the current mesh absolute scaling.
  82220. * Returns a Vector3.
  82221. */
  82222. readonly absoluteScaling: Vector3;
  82223. /**
  82224. * Returns the current mesh absolute rotation.
  82225. * Returns a Quaternion.
  82226. */
  82227. readonly absoluteRotationQuaternion: Quaternion;
  82228. /**
  82229. * Sets a new matrix to apply before all other transformation
  82230. * @param matrix defines the transform matrix
  82231. * @returns the current TransformNode
  82232. */
  82233. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82234. /**
  82235. * Sets a new pivot matrix to the current node
  82236. * @param matrix defines the new pivot matrix to use
  82237. * @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
  82238. * @returns the current TransformNode
  82239. */
  82240. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82241. /**
  82242. * Returns the mesh pivot matrix.
  82243. * Default : Identity.
  82244. * @returns the matrix
  82245. */
  82246. getPivotMatrix(): Matrix;
  82247. /**
  82248. * Instantiate (when possible) or clone that node with its hierarchy
  82249. * @param newParent defines the new parent to use for the instance (or clone)
  82250. * @param options defines options to configure how copy is done
  82251. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82252. * @returns an instance (or a clone) of the current node with its hiearchy
  82253. */
  82254. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82255. doNotInstantiate: boolean;
  82256. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82257. /**
  82258. * Prevents the World matrix to be computed any longer
  82259. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82260. * @returns the TransformNode.
  82261. */
  82262. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82263. /**
  82264. * Allows back the World matrix computation.
  82265. * @returns the TransformNode.
  82266. */
  82267. unfreezeWorldMatrix(): this;
  82268. /**
  82269. * True if the World matrix has been frozen.
  82270. */
  82271. readonly isWorldMatrixFrozen: boolean;
  82272. /**
  82273. * Retuns the mesh absolute position in the World.
  82274. * @returns a Vector3.
  82275. */
  82276. getAbsolutePosition(): Vector3;
  82277. /**
  82278. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82279. * @param absolutePosition the absolute position to set
  82280. * @returns the TransformNode.
  82281. */
  82282. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82283. /**
  82284. * Sets the mesh position in its local space.
  82285. * @param vector3 the position to set in localspace
  82286. * @returns the TransformNode.
  82287. */
  82288. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82289. /**
  82290. * Returns the mesh position in the local space from the current World matrix values.
  82291. * @returns a new Vector3.
  82292. */
  82293. getPositionExpressedInLocalSpace(): Vector3;
  82294. /**
  82295. * Translates the mesh along the passed Vector3 in its local space.
  82296. * @param vector3 the distance to translate in localspace
  82297. * @returns the TransformNode.
  82298. */
  82299. locallyTranslate(vector3: Vector3): TransformNode;
  82300. private static _lookAtVectorCache;
  82301. /**
  82302. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82303. * @param targetPoint the position (must be in same space as current mesh) to look at
  82304. * @param yawCor optional yaw (y-axis) correction in radians
  82305. * @param pitchCor optional pitch (x-axis) correction in radians
  82306. * @param rollCor optional roll (z-axis) correction in radians
  82307. * @param space the choosen space of the target
  82308. * @returns the TransformNode.
  82309. */
  82310. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82311. /**
  82312. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82313. * This Vector3 is expressed in the World space.
  82314. * @param localAxis axis to rotate
  82315. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82316. */
  82317. getDirection(localAxis: Vector3): Vector3;
  82318. /**
  82319. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82320. * localAxis is expressed in the mesh local space.
  82321. * result is computed in the Wordl space from the mesh World matrix.
  82322. * @param localAxis axis to rotate
  82323. * @param result the resulting transformnode
  82324. * @returns this TransformNode.
  82325. */
  82326. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82327. /**
  82328. * Sets this transform node rotation to the given local axis.
  82329. * @param localAxis the axis in local space
  82330. * @param yawCor optional yaw (y-axis) correction in radians
  82331. * @param pitchCor optional pitch (x-axis) correction in radians
  82332. * @param rollCor optional roll (z-axis) correction in radians
  82333. * @returns this TransformNode
  82334. */
  82335. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82336. /**
  82337. * Sets a new pivot point to the current node
  82338. * @param point defines the new pivot point to use
  82339. * @param space defines if the point is in world or local space (local by default)
  82340. * @returns the current TransformNode
  82341. */
  82342. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82343. /**
  82344. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82345. * @returns the pivot point
  82346. */
  82347. getPivotPoint(): Vector3;
  82348. /**
  82349. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82350. * @param result the vector3 to store the result
  82351. * @returns this TransformNode.
  82352. */
  82353. getPivotPointToRef(result: Vector3): TransformNode;
  82354. /**
  82355. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82356. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82357. */
  82358. getAbsolutePivotPoint(): Vector3;
  82359. /**
  82360. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82361. * @param result vector3 to store the result
  82362. * @returns this TransformNode.
  82363. */
  82364. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82365. /**
  82366. * Defines the passed node as the parent of the current node.
  82367. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82368. * @see https://doc.babylonjs.com/how_to/parenting
  82369. * @param node the node ot set as the parent
  82370. * @returns this TransformNode.
  82371. */
  82372. setParent(node: Nullable<Node>): TransformNode;
  82373. private _nonUniformScaling;
  82374. /**
  82375. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82376. */
  82377. readonly nonUniformScaling: boolean;
  82378. /** @hidden */
  82379. _updateNonUniformScalingState(value: boolean): boolean;
  82380. /**
  82381. * Attach the current TransformNode to another TransformNode associated with a bone
  82382. * @param bone Bone affecting the TransformNode
  82383. * @param affectedTransformNode TransformNode associated with the bone
  82384. * @returns this object
  82385. */
  82386. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82387. /**
  82388. * Detach the transform node if its associated with a bone
  82389. * @returns this object
  82390. */
  82391. detachFromBone(): TransformNode;
  82392. private static _rotationAxisCache;
  82393. /**
  82394. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82395. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82396. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82397. * The passed axis is also normalized.
  82398. * @param axis the axis to rotate around
  82399. * @param amount the amount to rotate in radians
  82400. * @param space Space to rotate in (Default: local)
  82401. * @returns the TransformNode.
  82402. */
  82403. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82404. /**
  82405. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82406. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82407. * The passed axis is also normalized. .
  82408. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82409. * @param point the point to rotate around
  82410. * @param axis the axis to rotate around
  82411. * @param amount the amount to rotate in radians
  82412. * @returns the TransformNode
  82413. */
  82414. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82415. /**
  82416. * Translates the mesh along the axis vector for the passed distance in the given space.
  82417. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82418. * @param axis the axis to translate in
  82419. * @param distance the distance to translate
  82420. * @param space Space to rotate in (Default: local)
  82421. * @returns the TransformNode.
  82422. */
  82423. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82424. /**
  82425. * Adds a rotation step to the mesh current rotation.
  82426. * x, y, z are Euler angles expressed in radians.
  82427. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82428. * This means this rotation is made in the mesh local space only.
  82429. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82430. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82431. * ```javascript
  82432. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82433. * ```
  82434. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82435. * 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.
  82436. * @param x Rotation to add
  82437. * @param y Rotation to add
  82438. * @param z Rotation to add
  82439. * @returns the TransformNode.
  82440. */
  82441. addRotation(x: number, y: number, z: number): TransformNode;
  82442. /**
  82443. * @hidden
  82444. */
  82445. protected _getEffectiveParent(): Nullable<Node>;
  82446. /**
  82447. * Computes the world matrix of the node
  82448. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82449. * @returns the world matrix
  82450. */
  82451. computeWorldMatrix(force?: boolean): Matrix;
  82452. protected _afterComputeWorldMatrix(): void;
  82453. /**
  82454. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82455. * @param func callback function to add
  82456. *
  82457. * @returns the TransformNode.
  82458. */
  82459. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82460. /**
  82461. * Removes a registered callback function.
  82462. * @param func callback function to remove
  82463. * @returns the TransformNode.
  82464. */
  82465. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82466. /**
  82467. * Gets the position of the current mesh in camera space
  82468. * @param camera defines the camera to use
  82469. * @returns a position
  82470. */
  82471. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82472. /**
  82473. * Returns the distance from the mesh to the active camera
  82474. * @param camera defines the camera to use
  82475. * @returns the distance
  82476. */
  82477. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82478. /**
  82479. * Clone the current transform node
  82480. * @param name Name of the new clone
  82481. * @param newParent New parent for the clone
  82482. * @param doNotCloneChildren Do not clone children hierarchy
  82483. * @returns the new transform node
  82484. */
  82485. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82486. /**
  82487. * Serializes the objects information.
  82488. * @param currentSerializationObject defines the object to serialize in
  82489. * @returns the serialized object
  82490. */
  82491. serialize(currentSerializationObject?: any): any;
  82492. /**
  82493. * Returns a new TransformNode object parsed from the source provided.
  82494. * @param parsedTransformNode is the source.
  82495. * @param scene the scne the object belongs to
  82496. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82497. * @returns a new TransformNode object parsed from the source provided.
  82498. */
  82499. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82500. /**
  82501. * Get all child-transformNodes of this node
  82502. * @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
  82503. * @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
  82504. * @returns an array of TransformNode
  82505. */
  82506. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82507. /**
  82508. * Releases resources associated with this transform node.
  82509. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82510. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82511. */
  82512. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82513. /**
  82514. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82515. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82516. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82517. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82518. * @returns the current mesh
  82519. */
  82520. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82521. private _syncAbsoluteScalingAndRotation;
  82522. }
  82523. }
  82524. declare module BABYLON {
  82525. /**
  82526. * Defines the types of pose enabled controllers that are supported
  82527. */
  82528. export enum PoseEnabledControllerType {
  82529. /**
  82530. * HTC Vive
  82531. */
  82532. VIVE = 0,
  82533. /**
  82534. * Oculus Rift
  82535. */
  82536. OCULUS = 1,
  82537. /**
  82538. * Windows mixed reality
  82539. */
  82540. WINDOWS = 2,
  82541. /**
  82542. * Samsung gear VR
  82543. */
  82544. GEAR_VR = 3,
  82545. /**
  82546. * Google Daydream
  82547. */
  82548. DAYDREAM = 4,
  82549. /**
  82550. * Generic
  82551. */
  82552. GENERIC = 5
  82553. }
  82554. /**
  82555. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82556. */
  82557. export interface MutableGamepadButton {
  82558. /**
  82559. * Value of the button/trigger
  82560. */
  82561. value: number;
  82562. /**
  82563. * If the button/trigger is currently touched
  82564. */
  82565. touched: boolean;
  82566. /**
  82567. * If the button/trigger is currently pressed
  82568. */
  82569. pressed: boolean;
  82570. }
  82571. /**
  82572. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82573. * @hidden
  82574. */
  82575. export interface ExtendedGamepadButton extends GamepadButton {
  82576. /**
  82577. * If the button/trigger is currently pressed
  82578. */
  82579. readonly pressed: boolean;
  82580. /**
  82581. * If the button/trigger is currently touched
  82582. */
  82583. readonly touched: boolean;
  82584. /**
  82585. * Value of the button/trigger
  82586. */
  82587. readonly value: number;
  82588. }
  82589. /** @hidden */
  82590. export interface _GamePadFactory {
  82591. /**
  82592. * Returns wether or not the current gamepad can be created for this type of controller.
  82593. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82594. * @returns true if it can be created, otherwise false
  82595. */
  82596. canCreate(gamepadInfo: any): boolean;
  82597. /**
  82598. * Creates a new instance of the Gamepad.
  82599. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82600. * @returns the new gamepad instance
  82601. */
  82602. create(gamepadInfo: any): Gamepad;
  82603. }
  82604. /**
  82605. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82606. */
  82607. export class PoseEnabledControllerHelper {
  82608. /** @hidden */
  82609. static _ControllerFactories: _GamePadFactory[];
  82610. /** @hidden */
  82611. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82612. /**
  82613. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82614. * @param vrGamepad the gamepad to initialized
  82615. * @returns a vr controller of the type the gamepad identified as
  82616. */
  82617. static InitiateController(vrGamepad: any): Gamepad;
  82618. }
  82619. /**
  82620. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82621. */
  82622. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82623. /**
  82624. * If the controller is used in a webXR session
  82625. */
  82626. isXR: boolean;
  82627. private _deviceRoomPosition;
  82628. private _deviceRoomRotationQuaternion;
  82629. /**
  82630. * The device position in babylon space
  82631. */
  82632. devicePosition: Vector3;
  82633. /**
  82634. * The device rotation in babylon space
  82635. */
  82636. deviceRotationQuaternion: Quaternion;
  82637. /**
  82638. * The scale factor of the device in babylon space
  82639. */
  82640. deviceScaleFactor: number;
  82641. /**
  82642. * (Likely devicePosition should be used instead) The device position in its room space
  82643. */
  82644. position: Vector3;
  82645. /**
  82646. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82647. */
  82648. rotationQuaternion: Quaternion;
  82649. /**
  82650. * The type of controller (Eg. Windows mixed reality)
  82651. */
  82652. controllerType: PoseEnabledControllerType;
  82653. protected _calculatedPosition: Vector3;
  82654. private _calculatedRotation;
  82655. /**
  82656. * The raw pose from the device
  82657. */
  82658. rawPose: DevicePose;
  82659. private _trackPosition;
  82660. private _maxRotationDistFromHeadset;
  82661. private _draggedRoomRotation;
  82662. /**
  82663. * @hidden
  82664. */
  82665. _disableTrackPosition(fixedPosition: Vector3): void;
  82666. /**
  82667. * Internal, the mesh attached to the controller
  82668. * @hidden
  82669. */
  82670. _mesh: Nullable<AbstractMesh>;
  82671. private _poseControlledCamera;
  82672. private _leftHandSystemQuaternion;
  82673. /**
  82674. * Internal, matrix used to convert room space to babylon space
  82675. * @hidden
  82676. */
  82677. _deviceToWorld: Matrix;
  82678. /**
  82679. * Node to be used when casting a ray from the controller
  82680. * @hidden
  82681. */
  82682. _pointingPoseNode: Nullable<TransformNode>;
  82683. /**
  82684. * Name of the child mesh that can be used to cast a ray from the controller
  82685. */
  82686. static readonly POINTING_POSE: string;
  82687. /**
  82688. * Creates a new PoseEnabledController from a gamepad
  82689. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82690. */
  82691. constructor(browserGamepad: any);
  82692. private _workingMatrix;
  82693. /**
  82694. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82695. */
  82696. update(): void;
  82697. /**
  82698. * Updates only the pose device and mesh without doing any button event checking
  82699. */
  82700. protected _updatePoseAndMesh(): void;
  82701. /**
  82702. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82703. * @param poseData raw pose fromthe device
  82704. */
  82705. updateFromDevice(poseData: DevicePose): void;
  82706. /**
  82707. * @hidden
  82708. */
  82709. _meshAttachedObservable: Observable<AbstractMesh>;
  82710. /**
  82711. * Attaches a mesh to the controller
  82712. * @param mesh the mesh to be attached
  82713. */
  82714. attachToMesh(mesh: AbstractMesh): void;
  82715. /**
  82716. * Attaches the controllers mesh to a camera
  82717. * @param camera the camera the mesh should be attached to
  82718. */
  82719. attachToPoseControlledCamera(camera: TargetCamera): void;
  82720. /**
  82721. * Disposes of the controller
  82722. */
  82723. dispose(): void;
  82724. /**
  82725. * The mesh that is attached to the controller
  82726. */
  82727. readonly mesh: Nullable<AbstractMesh>;
  82728. /**
  82729. * Gets the ray of the controller in the direction the controller is pointing
  82730. * @param length the length the resulting ray should be
  82731. * @returns a ray in the direction the controller is pointing
  82732. */
  82733. getForwardRay(length?: number): Ray;
  82734. }
  82735. }
  82736. declare module BABYLON {
  82737. /**
  82738. * Defines the WebVRController object that represents controllers tracked in 3D space
  82739. */
  82740. export abstract class WebVRController extends PoseEnabledController {
  82741. /**
  82742. * Internal, the default controller model for the controller
  82743. */
  82744. protected _defaultModel: Nullable<AbstractMesh>;
  82745. /**
  82746. * Fired when the trigger state has changed
  82747. */
  82748. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82749. /**
  82750. * Fired when the main button state has changed
  82751. */
  82752. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82753. /**
  82754. * Fired when the secondary button state has changed
  82755. */
  82756. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82757. /**
  82758. * Fired when the pad state has changed
  82759. */
  82760. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82761. /**
  82762. * Fired when controllers stick values have changed
  82763. */
  82764. onPadValuesChangedObservable: Observable<StickValues>;
  82765. /**
  82766. * Array of button availible on the controller
  82767. */
  82768. protected _buttons: Array<MutableGamepadButton>;
  82769. private _onButtonStateChange;
  82770. /**
  82771. * Fired when a controller button's state has changed
  82772. * @param callback the callback containing the button that was modified
  82773. */
  82774. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82775. /**
  82776. * X and Y axis corresponding to the controllers joystick
  82777. */
  82778. pad: StickValues;
  82779. /**
  82780. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82781. */
  82782. hand: string;
  82783. /**
  82784. * The default controller model for the controller
  82785. */
  82786. readonly defaultModel: Nullable<AbstractMesh>;
  82787. /**
  82788. * Creates a new WebVRController from a gamepad
  82789. * @param vrGamepad the gamepad that the WebVRController should be created from
  82790. */
  82791. constructor(vrGamepad: any);
  82792. /**
  82793. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82794. */
  82795. update(): void;
  82796. /**
  82797. * Function to be called when a button is modified
  82798. */
  82799. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82800. /**
  82801. * Loads a mesh and attaches it to the controller
  82802. * @param scene the scene the mesh should be added to
  82803. * @param meshLoaded callback for when the mesh has been loaded
  82804. */
  82805. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82806. private _setButtonValue;
  82807. private _changes;
  82808. private _checkChanges;
  82809. /**
  82810. * Disposes of th webVRCOntroller
  82811. */
  82812. dispose(): void;
  82813. }
  82814. }
  82815. declare module BABYLON {
  82816. /**
  82817. * The HemisphericLight simulates the ambient environment light,
  82818. * so the passed direction is the light reflection direction, not the incoming direction.
  82819. */
  82820. export class HemisphericLight extends Light {
  82821. /**
  82822. * The groundColor is the light in the opposite direction to the one specified during creation.
  82823. * 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.
  82824. */
  82825. groundColor: Color3;
  82826. /**
  82827. * The light reflection direction, not the incoming direction.
  82828. */
  82829. direction: Vector3;
  82830. /**
  82831. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82832. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82833. * The HemisphericLight can't cast shadows.
  82834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82835. * @param name The friendly name of the light
  82836. * @param direction The direction of the light reflection
  82837. * @param scene The scene the light belongs to
  82838. */
  82839. constructor(name: string, direction: Vector3, scene: Scene);
  82840. protected _buildUniformLayout(): void;
  82841. /**
  82842. * Returns the string "HemisphericLight".
  82843. * @return The class name
  82844. */
  82845. getClassName(): string;
  82846. /**
  82847. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82848. * Returns the updated direction.
  82849. * @param target The target the direction should point to
  82850. * @return The computed direction
  82851. */
  82852. setDirectionToTarget(target: Vector3): Vector3;
  82853. /**
  82854. * Returns the shadow generator associated to the light.
  82855. * @returns Always null for hemispheric lights because it does not support shadows.
  82856. */
  82857. getShadowGenerator(): Nullable<IShadowGenerator>;
  82858. /**
  82859. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82860. * @param effect The effect to update
  82861. * @param lightIndex The index of the light in the effect to update
  82862. * @returns The hemispheric light
  82863. */
  82864. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82865. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82866. /**
  82867. * Computes the world matrix of the node
  82868. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82869. * @param useWasUpdatedFlag defines a reserved property
  82870. * @returns the world matrix
  82871. */
  82872. computeWorldMatrix(): Matrix;
  82873. /**
  82874. * Returns the integer 3.
  82875. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82876. */
  82877. getTypeID(): number;
  82878. /**
  82879. * Prepares the list of defines specific to the light type.
  82880. * @param defines the list of defines
  82881. * @param lightIndex defines the index of the light for the effect
  82882. */
  82883. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82884. }
  82885. }
  82886. declare module BABYLON {
  82887. /** @hidden */
  82888. export var vrMultiviewToSingleviewPixelShader: {
  82889. name: string;
  82890. shader: string;
  82891. };
  82892. }
  82893. declare module BABYLON {
  82894. /**
  82895. * Renders to multiple views with a single draw call
  82896. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82897. */
  82898. export class MultiviewRenderTarget extends RenderTargetTexture {
  82899. /**
  82900. * Creates a multiview render target
  82901. * @param scene scene used with the render target
  82902. * @param size the size of the render target (used for each view)
  82903. */
  82904. constructor(scene: Scene, size?: number | {
  82905. width: number;
  82906. height: number;
  82907. } | {
  82908. ratio: number;
  82909. });
  82910. /**
  82911. * @hidden
  82912. * @param faceIndex the face index, if its a cube texture
  82913. */
  82914. _bindFrameBuffer(faceIndex?: number): void;
  82915. /**
  82916. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82917. * @returns the view count
  82918. */
  82919. getViewCount(): number;
  82920. }
  82921. }
  82922. declare module BABYLON {
  82923. /**
  82924. * Represents a camera frustum
  82925. */
  82926. export class Frustum {
  82927. /**
  82928. * Gets the planes representing the frustum
  82929. * @param transform matrix to be applied to the returned planes
  82930. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82931. */
  82932. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82933. /**
  82934. * Gets the near frustum plane transformed by the transform matrix
  82935. * @param transform transformation matrix to be applied to the resulting frustum plane
  82936. * @param frustumPlane the resuling frustum plane
  82937. */
  82938. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82939. /**
  82940. * Gets the far frustum plane transformed by the transform matrix
  82941. * @param transform transformation matrix to be applied to the resulting frustum plane
  82942. * @param frustumPlane the resuling frustum plane
  82943. */
  82944. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82945. /**
  82946. * Gets the left frustum plane transformed by the transform matrix
  82947. * @param transform transformation matrix to be applied to the resulting frustum plane
  82948. * @param frustumPlane the resuling frustum plane
  82949. */
  82950. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82951. /**
  82952. * Gets the right frustum plane transformed by the transform matrix
  82953. * @param transform transformation matrix to be applied to the resulting frustum plane
  82954. * @param frustumPlane the resuling frustum plane
  82955. */
  82956. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82957. /**
  82958. * Gets the top frustum plane transformed by the transform matrix
  82959. * @param transform transformation matrix to be applied to the resulting frustum plane
  82960. * @param frustumPlane the resuling frustum plane
  82961. */
  82962. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82963. /**
  82964. * Gets the bottom frustum plane transformed by the transform matrix
  82965. * @param transform transformation matrix to be applied to the resulting frustum plane
  82966. * @param frustumPlane the resuling frustum plane
  82967. */
  82968. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82969. /**
  82970. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82971. * @param transform transformation matrix to be applied to the resulting frustum planes
  82972. * @param frustumPlanes the resuling frustum planes
  82973. */
  82974. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82975. }
  82976. }
  82977. declare module BABYLON {
  82978. interface Engine {
  82979. /**
  82980. * Creates a new multiview render target
  82981. * @param width defines the width of the texture
  82982. * @param height defines the height of the texture
  82983. * @returns the created multiview texture
  82984. */
  82985. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82986. /**
  82987. * Binds a multiview framebuffer to be drawn to
  82988. * @param multiviewTexture texture to bind
  82989. */
  82990. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82991. }
  82992. interface Camera {
  82993. /**
  82994. * @hidden
  82995. * 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)
  82996. */
  82997. _useMultiviewToSingleView: boolean;
  82998. /**
  82999. * @hidden
  83000. * 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)
  83001. */
  83002. _multiviewTexture: Nullable<RenderTargetTexture>;
  83003. /**
  83004. * @hidden
  83005. * ensures the multiview texture of the camera exists and has the specified width/height
  83006. * @param width height to set on the multiview texture
  83007. * @param height width to set on the multiview texture
  83008. */
  83009. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83010. }
  83011. interface Scene {
  83012. /** @hidden */
  83013. _transformMatrixR: Matrix;
  83014. /** @hidden */
  83015. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83016. /** @hidden */
  83017. _createMultiviewUbo(): void;
  83018. /** @hidden */
  83019. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83020. /** @hidden */
  83021. _renderMultiviewToSingleView(camera: Camera): void;
  83022. }
  83023. }
  83024. declare module BABYLON {
  83025. /**
  83026. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83027. * This will not be used for webXR as it supports displaying texture arrays directly
  83028. */
  83029. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83030. /**
  83031. * Initializes a VRMultiviewToSingleview
  83032. * @param name name of the post process
  83033. * @param camera camera to be applied to
  83034. * @param scaleFactor scaling factor to the size of the output texture
  83035. */
  83036. constructor(name: string, camera: Camera, scaleFactor: number);
  83037. }
  83038. }
  83039. declare module BABYLON {
  83040. /**
  83041. * Interface used to define additional presentation attributes
  83042. */
  83043. export interface IVRPresentationAttributes {
  83044. /**
  83045. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83046. */
  83047. highRefreshRate: boolean;
  83048. /**
  83049. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83050. */
  83051. foveationLevel: number;
  83052. }
  83053. interface Engine {
  83054. /** @hidden */
  83055. _vrDisplay: any;
  83056. /** @hidden */
  83057. _vrSupported: boolean;
  83058. /** @hidden */
  83059. _oldSize: Size;
  83060. /** @hidden */
  83061. _oldHardwareScaleFactor: number;
  83062. /** @hidden */
  83063. _vrExclusivePointerMode: boolean;
  83064. /** @hidden */
  83065. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83066. /** @hidden */
  83067. _onVRDisplayPointerRestricted: () => void;
  83068. /** @hidden */
  83069. _onVRDisplayPointerUnrestricted: () => void;
  83070. /** @hidden */
  83071. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83072. /** @hidden */
  83073. _onVrDisplayDisconnect: Nullable<() => void>;
  83074. /** @hidden */
  83075. _onVrDisplayPresentChange: Nullable<() => void>;
  83076. /**
  83077. * Observable signaled when VR display mode changes
  83078. */
  83079. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83080. /**
  83081. * Observable signaled when VR request present is complete
  83082. */
  83083. onVRRequestPresentComplete: Observable<boolean>;
  83084. /**
  83085. * Observable signaled when VR request present starts
  83086. */
  83087. onVRRequestPresentStart: Observable<Engine>;
  83088. /**
  83089. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83090. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83091. */
  83092. isInVRExclusivePointerMode: boolean;
  83093. /**
  83094. * Gets a boolean indicating if a webVR device was detected
  83095. * @returns true if a webVR device was detected
  83096. */
  83097. isVRDevicePresent(): boolean;
  83098. /**
  83099. * Gets the current webVR device
  83100. * @returns the current webVR device (or null)
  83101. */
  83102. getVRDevice(): any;
  83103. /**
  83104. * Initializes a webVR display and starts listening to display change events
  83105. * The onVRDisplayChangedObservable will be notified upon these changes
  83106. * @returns A promise containing a VRDisplay and if vr is supported
  83107. */
  83108. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83109. /** @hidden */
  83110. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83111. /**
  83112. * Gets or sets the presentation attributes used to configure VR rendering
  83113. */
  83114. vrPresentationAttributes?: IVRPresentationAttributes;
  83115. /**
  83116. * Call this function to switch to webVR mode
  83117. * Will do nothing if webVR is not supported or if there is no webVR device
  83118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83119. */
  83120. enableVR(): void;
  83121. /** @hidden */
  83122. _onVRFullScreenTriggered(): void;
  83123. }
  83124. }
  83125. declare module BABYLON {
  83126. /**
  83127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83128. * IMPORTANT!! The data is right-hand data.
  83129. * @export
  83130. * @interface DevicePose
  83131. */
  83132. export interface DevicePose {
  83133. /**
  83134. * The position of the device, values in array are [x,y,z].
  83135. */
  83136. readonly position: Nullable<Float32Array>;
  83137. /**
  83138. * The linearVelocity of the device, values in array are [x,y,z].
  83139. */
  83140. readonly linearVelocity: Nullable<Float32Array>;
  83141. /**
  83142. * The linearAcceleration of the device, values in array are [x,y,z].
  83143. */
  83144. readonly linearAcceleration: Nullable<Float32Array>;
  83145. /**
  83146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83147. */
  83148. readonly orientation: Nullable<Float32Array>;
  83149. /**
  83150. * The angularVelocity of the device, values in array are [x,y,z].
  83151. */
  83152. readonly angularVelocity: Nullable<Float32Array>;
  83153. /**
  83154. * The angularAcceleration of the device, values in array are [x,y,z].
  83155. */
  83156. readonly angularAcceleration: Nullable<Float32Array>;
  83157. }
  83158. /**
  83159. * Interface representing a pose controlled object in Babylon.
  83160. * A pose controlled object has both regular pose values as well as pose values
  83161. * from an external device such as a VR head mounted display
  83162. */
  83163. export interface PoseControlled {
  83164. /**
  83165. * The position of the object in babylon space.
  83166. */
  83167. position: Vector3;
  83168. /**
  83169. * The rotation quaternion of the object in babylon space.
  83170. */
  83171. rotationQuaternion: Quaternion;
  83172. /**
  83173. * The position of the device in babylon space.
  83174. */
  83175. devicePosition?: Vector3;
  83176. /**
  83177. * The rotation quaternion of the device in babylon space.
  83178. */
  83179. deviceRotationQuaternion: Quaternion;
  83180. /**
  83181. * The raw pose coming from the device.
  83182. */
  83183. rawPose: Nullable<DevicePose>;
  83184. /**
  83185. * The scale of the device to be used when translating from device space to babylon space.
  83186. */
  83187. deviceScaleFactor: number;
  83188. /**
  83189. * Updates the poseControlled values based on the input device pose.
  83190. * @param poseData the pose data to update the object with
  83191. */
  83192. updateFromDevice(poseData: DevicePose): void;
  83193. }
  83194. /**
  83195. * Set of options to customize the webVRCamera
  83196. */
  83197. export interface WebVROptions {
  83198. /**
  83199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83200. */
  83201. trackPosition?: boolean;
  83202. /**
  83203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83204. */
  83205. positionScale?: number;
  83206. /**
  83207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83208. */
  83209. displayName?: string;
  83210. /**
  83211. * Should the native controller meshes be initialized. (default: true)
  83212. */
  83213. controllerMeshes?: boolean;
  83214. /**
  83215. * Creating a default HemiLight only on controllers. (default: true)
  83216. */
  83217. defaultLightingOnControllers?: boolean;
  83218. /**
  83219. * If you don't want to use the default VR button of the helper. (default: false)
  83220. */
  83221. useCustomVRButton?: boolean;
  83222. /**
  83223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83224. */
  83225. customVRButton?: HTMLButtonElement;
  83226. /**
  83227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83228. */
  83229. rayLength?: number;
  83230. /**
  83231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83232. */
  83233. defaultHeight?: number;
  83234. /**
  83235. * If multiview should be used if availible (default: false)
  83236. */
  83237. useMultiview?: boolean;
  83238. }
  83239. /**
  83240. * This represents a WebVR camera.
  83241. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83242. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83243. */
  83244. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83245. private webVROptions;
  83246. /**
  83247. * @hidden
  83248. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83249. */
  83250. _vrDevice: any;
  83251. /**
  83252. * The rawPose of the vrDevice.
  83253. */
  83254. rawPose: Nullable<DevicePose>;
  83255. private _onVREnabled;
  83256. private _specsVersion;
  83257. private _attached;
  83258. private _frameData;
  83259. protected _descendants: Array<Node>;
  83260. private _deviceRoomPosition;
  83261. /** @hidden */
  83262. _deviceRoomRotationQuaternion: Quaternion;
  83263. private _standingMatrix;
  83264. /**
  83265. * Represents device position in babylon space.
  83266. */
  83267. devicePosition: Vector3;
  83268. /**
  83269. * Represents device rotation in babylon space.
  83270. */
  83271. deviceRotationQuaternion: Quaternion;
  83272. /**
  83273. * The scale of the device to be used when translating from device space to babylon space.
  83274. */
  83275. deviceScaleFactor: number;
  83276. private _deviceToWorld;
  83277. private _worldToDevice;
  83278. /**
  83279. * References to the webVR controllers for the vrDevice.
  83280. */
  83281. controllers: Array<WebVRController>;
  83282. /**
  83283. * Emits an event when a controller is attached.
  83284. */
  83285. onControllersAttachedObservable: Observable<WebVRController[]>;
  83286. /**
  83287. * Emits an event when a controller's mesh has been loaded;
  83288. */
  83289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83290. /**
  83291. * Emits an event when the HMD's pose has been updated.
  83292. */
  83293. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83294. private _poseSet;
  83295. /**
  83296. * If the rig cameras be used as parent instead of this camera.
  83297. */
  83298. rigParenting: boolean;
  83299. private _lightOnControllers;
  83300. private _defaultHeight?;
  83301. /**
  83302. * Instantiates a WebVRFreeCamera.
  83303. * @param name The name of the WebVRFreeCamera
  83304. * @param position The starting anchor position for the camera
  83305. * @param scene The scene the camera belongs to
  83306. * @param webVROptions a set of customizable options for the webVRCamera
  83307. */
  83308. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83309. /**
  83310. * Gets the device distance from the ground in meters.
  83311. * @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.
  83312. */
  83313. deviceDistanceToRoomGround(): number;
  83314. /**
  83315. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83316. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83317. */
  83318. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83319. /**
  83320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83321. * @returns A promise with a boolean set to if the standing matrix is supported.
  83322. */
  83323. useStandingMatrixAsync(): Promise<boolean>;
  83324. /**
  83325. * Disposes the camera
  83326. */
  83327. dispose(): void;
  83328. /**
  83329. * Gets a vrController by name.
  83330. * @param name The name of the controller to retreive
  83331. * @returns the controller matching the name specified or null if not found
  83332. */
  83333. getControllerByName(name: string): Nullable<WebVRController>;
  83334. private _leftController;
  83335. /**
  83336. * The controller corresponding to the users left hand.
  83337. */
  83338. readonly leftController: Nullable<WebVRController>;
  83339. private _rightController;
  83340. /**
  83341. * The controller corresponding to the users right hand.
  83342. */
  83343. readonly rightController: Nullable<WebVRController>;
  83344. /**
  83345. * Casts a ray forward from the vrCamera's gaze.
  83346. * @param length Length of the ray (default: 100)
  83347. * @returns the ray corresponding to the gaze
  83348. */
  83349. getForwardRay(length?: number): Ray;
  83350. /**
  83351. * @hidden
  83352. * Updates the camera based on device's frame data
  83353. */
  83354. _checkInputs(): void;
  83355. /**
  83356. * Updates the poseControlled values based on the input device pose.
  83357. * @param poseData Pose coming from the device
  83358. */
  83359. updateFromDevice(poseData: DevicePose): void;
  83360. private _htmlElementAttached;
  83361. private _detachIfAttached;
  83362. /**
  83363. * WebVR's attach control will start broadcasting frames to the device.
  83364. * Note that in certain browsers (chrome for example) this function must be called
  83365. * within a user-interaction callback. Example:
  83366. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83367. *
  83368. * @param element html element to attach the vrDevice to
  83369. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83370. */
  83371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83372. /**
  83373. * Detaches the camera from the html element and disables VR
  83374. *
  83375. * @param element html element to detach from
  83376. */
  83377. detachControl(element: HTMLElement): void;
  83378. /**
  83379. * @returns the name of this class
  83380. */
  83381. getClassName(): string;
  83382. /**
  83383. * Calls resetPose on the vrDisplay
  83384. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83385. */
  83386. resetToCurrentRotation(): void;
  83387. /**
  83388. * @hidden
  83389. * Updates the rig cameras (left and right eye)
  83390. */
  83391. _updateRigCameras(): void;
  83392. private _workingVector;
  83393. private _oneVector;
  83394. private _workingMatrix;
  83395. private updateCacheCalled;
  83396. private _correctPositionIfNotTrackPosition;
  83397. /**
  83398. * @hidden
  83399. * Updates the cached values of the camera
  83400. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83401. */
  83402. _updateCache(ignoreParentClass?: boolean): void;
  83403. /**
  83404. * @hidden
  83405. * Get current device position in babylon world
  83406. */
  83407. _computeDevicePosition(): void;
  83408. /**
  83409. * Updates the current device position and rotation in the babylon world
  83410. */
  83411. update(): void;
  83412. /**
  83413. * @hidden
  83414. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83415. * @returns an identity matrix
  83416. */
  83417. _getViewMatrix(): Matrix;
  83418. private _tmpMatrix;
  83419. /**
  83420. * This function is called by the two RIG cameras.
  83421. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83422. * @hidden
  83423. */
  83424. _getWebVRViewMatrix(): Matrix;
  83425. /** @hidden */
  83426. _getWebVRProjectionMatrix(): Matrix;
  83427. private _onGamepadConnectedObserver;
  83428. private _onGamepadDisconnectedObserver;
  83429. private _updateCacheWhenTrackingDisabledObserver;
  83430. /**
  83431. * Initializes the controllers and their meshes
  83432. */
  83433. initControllers(): void;
  83434. }
  83435. }
  83436. declare module BABYLON {
  83437. /**
  83438. * Size options for a post process
  83439. */
  83440. export type PostProcessOptions = {
  83441. width: number;
  83442. height: number;
  83443. };
  83444. /**
  83445. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83446. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83447. */
  83448. export class PostProcess {
  83449. /** Name of the PostProcess. */
  83450. name: string;
  83451. /**
  83452. * Gets or sets the unique id of the post process
  83453. */
  83454. uniqueId: number;
  83455. /**
  83456. * Width of the texture to apply the post process on
  83457. */
  83458. width: number;
  83459. /**
  83460. * Height of the texture to apply the post process on
  83461. */
  83462. height: number;
  83463. /**
  83464. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83465. * @hidden
  83466. */
  83467. _outputTexture: Nullable<InternalTexture>;
  83468. /**
  83469. * Sampling mode used by the shader
  83470. * See https://doc.babylonjs.com/classes/3.1/texture
  83471. */
  83472. renderTargetSamplingMode: number;
  83473. /**
  83474. * Clear color to use when screen clearing
  83475. */
  83476. clearColor: Color4;
  83477. /**
  83478. * If the buffer needs to be cleared before applying the post process. (default: true)
  83479. * Should be set to false if shader will overwrite all previous pixels.
  83480. */
  83481. autoClear: boolean;
  83482. /**
  83483. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83484. */
  83485. alphaMode: number;
  83486. /**
  83487. * Sets the setAlphaBlendConstants of the babylon engine
  83488. */
  83489. alphaConstants: Color4;
  83490. /**
  83491. * Animations to be used for the post processing
  83492. */
  83493. animations: Animation[];
  83494. /**
  83495. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83496. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83497. */
  83498. enablePixelPerfectMode: boolean;
  83499. /**
  83500. * Force the postprocess to be applied without taking in account viewport
  83501. */
  83502. forceFullscreenViewport: boolean;
  83503. /**
  83504. * List of inspectable custom properties (used by the Inspector)
  83505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83506. */
  83507. inspectableCustomProperties: IInspectable[];
  83508. /**
  83509. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83510. *
  83511. * | Value | Type | Description |
  83512. * | ----- | ----------------------------------- | ----------- |
  83513. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83514. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83515. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83516. *
  83517. */
  83518. scaleMode: number;
  83519. /**
  83520. * Force textures to be a power of two (default: false)
  83521. */
  83522. alwaysForcePOT: boolean;
  83523. private _samples;
  83524. /**
  83525. * Number of sample textures (default: 1)
  83526. */
  83527. samples: number;
  83528. /**
  83529. * Modify the scale of the post process to be the same as the viewport (default: false)
  83530. */
  83531. adaptScaleToCurrentViewport: boolean;
  83532. private _camera;
  83533. private _scene;
  83534. private _engine;
  83535. private _options;
  83536. private _reusable;
  83537. private _textureType;
  83538. /**
  83539. * Smart array of input and output textures for the post process.
  83540. * @hidden
  83541. */
  83542. _textures: SmartArray<InternalTexture>;
  83543. /**
  83544. * The index in _textures that corresponds to the output texture.
  83545. * @hidden
  83546. */
  83547. _currentRenderTextureInd: number;
  83548. private _effect;
  83549. private _samplers;
  83550. private _fragmentUrl;
  83551. private _vertexUrl;
  83552. private _parameters;
  83553. private _scaleRatio;
  83554. protected _indexParameters: any;
  83555. private _shareOutputWithPostProcess;
  83556. private _texelSize;
  83557. private _forcedOutputTexture;
  83558. /**
  83559. * Returns the fragment url or shader name used in the post process.
  83560. * @returns the fragment url or name in the shader store.
  83561. */
  83562. getEffectName(): string;
  83563. /**
  83564. * An event triggered when the postprocess is activated.
  83565. */
  83566. onActivateObservable: Observable<Camera>;
  83567. private _onActivateObserver;
  83568. /**
  83569. * A function that is added to the onActivateObservable
  83570. */
  83571. onActivate: Nullable<(camera: Camera) => void>;
  83572. /**
  83573. * An event triggered when the postprocess changes its size.
  83574. */
  83575. onSizeChangedObservable: Observable<PostProcess>;
  83576. private _onSizeChangedObserver;
  83577. /**
  83578. * A function that is added to the onSizeChangedObservable
  83579. */
  83580. onSizeChanged: (postProcess: PostProcess) => void;
  83581. /**
  83582. * An event triggered when the postprocess applies its effect.
  83583. */
  83584. onApplyObservable: Observable<Effect>;
  83585. private _onApplyObserver;
  83586. /**
  83587. * A function that is added to the onApplyObservable
  83588. */
  83589. onApply: (effect: Effect) => void;
  83590. /**
  83591. * An event triggered before rendering the postprocess
  83592. */
  83593. onBeforeRenderObservable: Observable<Effect>;
  83594. private _onBeforeRenderObserver;
  83595. /**
  83596. * A function that is added to the onBeforeRenderObservable
  83597. */
  83598. onBeforeRender: (effect: Effect) => void;
  83599. /**
  83600. * An event triggered after rendering the postprocess
  83601. */
  83602. onAfterRenderObservable: Observable<Effect>;
  83603. private _onAfterRenderObserver;
  83604. /**
  83605. * A function that is added to the onAfterRenderObservable
  83606. */
  83607. onAfterRender: (efect: Effect) => void;
  83608. /**
  83609. * 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
  83610. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83611. */
  83612. inputTexture: InternalTexture;
  83613. /**
  83614. * Gets the camera which post process is applied to.
  83615. * @returns The camera the post process is applied to.
  83616. */
  83617. getCamera(): Camera;
  83618. /**
  83619. * Gets the texel size of the postprocess.
  83620. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83621. */
  83622. readonly texelSize: Vector2;
  83623. /**
  83624. * Creates a new instance PostProcess
  83625. * @param name The name of the PostProcess.
  83626. * @param fragmentUrl The url of the fragment shader to be used.
  83627. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83628. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83629. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83630. * @param camera The camera to apply the render pass to.
  83631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83632. * @param engine The engine which the post process will be applied. (default: current engine)
  83633. * @param reusable If the post process can be reused on the same frame. (default: false)
  83634. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83635. * @param textureType Type of textures used when performing the post process. (default: 0)
  83636. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83637. * @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
  83638. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83639. */
  83640. constructor(
  83641. /** Name of the PostProcess. */
  83642. 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);
  83643. /**
  83644. * Gets a string idenfifying the name of the class
  83645. * @returns "PostProcess" string
  83646. */
  83647. getClassName(): string;
  83648. /**
  83649. * Gets the engine which this post process belongs to.
  83650. * @returns The engine the post process was enabled with.
  83651. */
  83652. getEngine(): Engine;
  83653. /**
  83654. * The effect that is created when initializing the post process.
  83655. * @returns The created effect corresponding the the postprocess.
  83656. */
  83657. getEffect(): Effect;
  83658. /**
  83659. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83660. * @param postProcess The post process to share the output with.
  83661. * @returns This post process.
  83662. */
  83663. shareOutputWith(postProcess: PostProcess): PostProcess;
  83664. /**
  83665. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83666. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83667. */
  83668. useOwnOutput(): void;
  83669. /**
  83670. * Updates the effect with the current post process compile time values and recompiles the shader.
  83671. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83672. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83673. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83674. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  83675. * @param onCompiled Called when the shader has been compiled.
  83676. * @param onError Called if there is an error when compiling a shader.
  83677. */
  83678. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83679. /**
  83680. * The post process is reusable if it can be used multiple times within one frame.
  83681. * @returns If the post process is reusable
  83682. */
  83683. isReusable(): boolean;
  83684. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83685. markTextureDirty(): void;
  83686. /**
  83687. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83688. * 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.
  83689. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83690. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83691. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83692. * @returns The target texture that was bound to be written to.
  83693. */
  83694. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83695. /**
  83696. * If the post process is supported.
  83697. */
  83698. readonly isSupported: boolean;
  83699. /**
  83700. * The aspect ratio of the output texture.
  83701. */
  83702. readonly aspectRatio: number;
  83703. /**
  83704. * Get a value indicating if the post-process is ready to be used
  83705. * @returns true if the post-process is ready (shader is compiled)
  83706. */
  83707. isReady(): boolean;
  83708. /**
  83709. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83710. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83711. */
  83712. apply(): Nullable<Effect>;
  83713. private _disposeTextures;
  83714. /**
  83715. * Disposes the post process.
  83716. * @param camera The camera to dispose the post process on.
  83717. */
  83718. dispose(camera?: Camera): void;
  83719. }
  83720. }
  83721. declare module BABYLON {
  83722. /** @hidden */
  83723. export var kernelBlurVaryingDeclaration: {
  83724. name: string;
  83725. shader: string;
  83726. };
  83727. }
  83728. declare module BABYLON {
  83729. /** @hidden */
  83730. export var kernelBlurFragment: {
  83731. name: string;
  83732. shader: string;
  83733. };
  83734. }
  83735. declare module BABYLON {
  83736. /** @hidden */
  83737. export var kernelBlurFragment2: {
  83738. name: string;
  83739. shader: string;
  83740. };
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var kernelBlurPixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. /** @hidden */
  83751. export var kernelBlurVertex: {
  83752. name: string;
  83753. shader: string;
  83754. };
  83755. }
  83756. declare module BABYLON {
  83757. /** @hidden */
  83758. export var kernelBlurVertexShader: {
  83759. name: string;
  83760. shader: string;
  83761. };
  83762. }
  83763. declare module BABYLON {
  83764. /**
  83765. * The Blur Post Process which blurs an image based on a kernel and direction.
  83766. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83767. */
  83768. export class BlurPostProcess extends PostProcess {
  83769. /** The direction in which to blur the image. */
  83770. direction: Vector2;
  83771. private blockCompilation;
  83772. protected _kernel: number;
  83773. protected _idealKernel: number;
  83774. protected _packedFloat: boolean;
  83775. private _staticDefines;
  83776. /**
  83777. * Sets the length in pixels of the blur sample region
  83778. */
  83779. /**
  83780. * Gets the length in pixels of the blur sample region
  83781. */
  83782. kernel: number;
  83783. /**
  83784. * Sets wether or not the blur needs to unpack/repack floats
  83785. */
  83786. /**
  83787. * Gets wether or not the blur is unpacking/repacking floats
  83788. */
  83789. packedFloat: boolean;
  83790. /**
  83791. * Creates a new instance BlurPostProcess
  83792. * @param name The name of the effect.
  83793. * @param direction The direction in which to blur the image.
  83794. * @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.
  83795. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83796. * @param camera The camera to apply the render pass to.
  83797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83798. * @param engine The engine which the post process will be applied. (default: current engine)
  83799. * @param reusable If the post process can be reused on the same frame. (default: false)
  83800. * @param textureType Type of textures used when performing the post process. (default: 0)
  83801. * @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)
  83802. */
  83803. constructor(name: string,
  83804. /** The direction in which to blur the image. */
  83805. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83806. /**
  83807. * Updates the effect with the current post process compile time values and recompiles the shader.
  83808. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83809. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83810. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83811. * @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
  83812. * @param onCompiled Called when the shader has been compiled.
  83813. * @param onError Called if there is an error when compiling a shader.
  83814. */
  83815. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83816. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83817. /**
  83818. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83819. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83820. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83821. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83822. * The gaps between physical kernels are compensated for in the weighting of the samples
  83823. * @param idealKernel Ideal blur kernel.
  83824. * @return Nearest best kernel.
  83825. */
  83826. protected _nearestBestKernel(idealKernel: number): number;
  83827. /**
  83828. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83829. * @param x The point on the Gaussian distribution to sample.
  83830. * @return the value of the Gaussian function at x.
  83831. */
  83832. protected _gaussianWeight(x: number): number;
  83833. /**
  83834. * Generates a string that can be used as a floating point number in GLSL.
  83835. * @param x Value to print.
  83836. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83837. * @return GLSL float string.
  83838. */
  83839. protected _glslFloat(x: number, decimalFigures?: number): string;
  83840. }
  83841. }
  83842. declare module BABYLON {
  83843. /**
  83844. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83845. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83846. * You can then easily use it as a reflectionTexture on a flat surface.
  83847. * In case the surface is not a plane, please consider relying on reflection probes.
  83848. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83849. */
  83850. export class MirrorTexture extends RenderTargetTexture {
  83851. private scene;
  83852. /**
  83853. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83854. * 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.
  83855. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83856. */
  83857. mirrorPlane: Plane;
  83858. /**
  83859. * Define the blur ratio used to blur the reflection if needed.
  83860. */
  83861. blurRatio: number;
  83862. /**
  83863. * Define the adaptive blur kernel used to blur the reflection if needed.
  83864. * This will autocompute the closest best match for the `blurKernel`
  83865. */
  83866. adaptiveBlurKernel: number;
  83867. /**
  83868. * Define the blur kernel used to blur the reflection if needed.
  83869. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83870. */
  83871. blurKernel: number;
  83872. /**
  83873. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83875. */
  83876. blurKernelX: number;
  83877. /**
  83878. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83880. */
  83881. blurKernelY: number;
  83882. private _autoComputeBlurKernel;
  83883. protected _onRatioRescale(): void;
  83884. private _updateGammaSpace;
  83885. private _imageProcessingConfigChangeObserver;
  83886. private _transformMatrix;
  83887. private _mirrorMatrix;
  83888. private _savedViewMatrix;
  83889. private _blurX;
  83890. private _blurY;
  83891. private _adaptiveBlurKernel;
  83892. private _blurKernelX;
  83893. private _blurKernelY;
  83894. private _blurRatio;
  83895. /**
  83896. * Instantiates a Mirror Texture.
  83897. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83898. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83899. * You can then easily use it as a reflectionTexture on a flat surface.
  83900. * In case the surface is not a plane, please consider relying on reflection probes.
  83901. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83902. * @param name
  83903. * @param size
  83904. * @param scene
  83905. * @param generateMipMaps
  83906. * @param type
  83907. * @param samplingMode
  83908. * @param generateDepthBuffer
  83909. */
  83910. constructor(name: string, size: number | {
  83911. width: number;
  83912. height: number;
  83913. } | {
  83914. ratio: number;
  83915. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83916. private _preparePostProcesses;
  83917. /**
  83918. * Clone the mirror texture.
  83919. * @returns the cloned texture
  83920. */
  83921. clone(): MirrorTexture;
  83922. /**
  83923. * Serialize the texture to a JSON representation you could use in Parse later on
  83924. * @returns the serialized JSON representation
  83925. */
  83926. serialize(): any;
  83927. /**
  83928. * Dispose the texture and release its associated resources.
  83929. */
  83930. dispose(): void;
  83931. }
  83932. }
  83933. declare module BABYLON {
  83934. /**
  83935. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83936. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83937. */
  83938. export class Texture extends BaseTexture {
  83939. /**
  83940. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83941. */
  83942. static SerializeBuffers: boolean;
  83943. /** @hidden */
  83944. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83945. /** @hidden */
  83946. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83947. /** @hidden */
  83948. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83949. /** nearest is mag = nearest and min = nearest and mip = linear */
  83950. static readonly NEAREST_SAMPLINGMODE: number;
  83951. /** nearest is mag = nearest and min = nearest and mip = linear */
  83952. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83954. static readonly BILINEAR_SAMPLINGMODE: number;
  83955. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83956. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83957. /** Trilinear is mag = linear and min = linear and mip = linear */
  83958. static readonly TRILINEAR_SAMPLINGMODE: number;
  83959. /** Trilinear is mag = linear and min = linear and mip = linear */
  83960. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83961. /** mag = nearest and min = nearest and mip = nearest */
  83962. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83963. /** mag = nearest and min = linear and mip = nearest */
  83964. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83965. /** mag = nearest and min = linear and mip = linear */
  83966. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83967. /** mag = nearest and min = linear and mip = none */
  83968. static readonly NEAREST_LINEAR: number;
  83969. /** mag = nearest and min = nearest and mip = none */
  83970. static readonly NEAREST_NEAREST: number;
  83971. /** mag = linear and min = nearest and mip = nearest */
  83972. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83973. /** mag = linear and min = nearest and mip = linear */
  83974. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83975. /** mag = linear and min = linear and mip = none */
  83976. static readonly LINEAR_LINEAR: number;
  83977. /** mag = linear and min = nearest and mip = none */
  83978. static readonly LINEAR_NEAREST: number;
  83979. /** Explicit coordinates mode */
  83980. static readonly EXPLICIT_MODE: number;
  83981. /** Spherical coordinates mode */
  83982. static readonly SPHERICAL_MODE: number;
  83983. /** Planar coordinates mode */
  83984. static readonly PLANAR_MODE: number;
  83985. /** Cubic coordinates mode */
  83986. static readonly CUBIC_MODE: number;
  83987. /** Projection coordinates mode */
  83988. static readonly PROJECTION_MODE: number;
  83989. /** Inverse Cubic coordinates mode */
  83990. static readonly SKYBOX_MODE: number;
  83991. /** Inverse Cubic coordinates mode */
  83992. static readonly INVCUBIC_MODE: number;
  83993. /** Equirectangular coordinates mode */
  83994. static readonly EQUIRECTANGULAR_MODE: number;
  83995. /** Equirectangular Fixed coordinates mode */
  83996. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83997. /** Equirectangular Fixed Mirrored coordinates mode */
  83998. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83999. /** Texture is not repeating outside of 0..1 UVs */
  84000. static readonly CLAMP_ADDRESSMODE: number;
  84001. /** Texture is repeating outside of 0..1 UVs */
  84002. static readonly WRAP_ADDRESSMODE: number;
  84003. /** Texture is repeating and mirrored */
  84004. static readonly MIRROR_ADDRESSMODE: number;
  84005. /**
  84006. * 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
  84007. */
  84008. static UseSerializedUrlIfAny: boolean;
  84009. /**
  84010. * Define the url of the texture.
  84011. */
  84012. url: Nullable<string>;
  84013. /**
  84014. * Define an offset on the texture to offset the u coordinates of the UVs
  84015. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84016. */
  84017. uOffset: number;
  84018. /**
  84019. * Define an offset on the texture to offset the v coordinates of the UVs
  84020. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84021. */
  84022. vOffset: number;
  84023. /**
  84024. * Define an offset on the texture to scale the u coordinates of the UVs
  84025. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84026. */
  84027. uScale: number;
  84028. /**
  84029. * Define an offset on the texture to scale the v coordinates of the UVs
  84030. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84031. */
  84032. vScale: number;
  84033. /**
  84034. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84035. * @see http://doc.babylonjs.com/how_to/more_materials
  84036. */
  84037. uAng: number;
  84038. /**
  84039. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84040. * @see http://doc.babylonjs.com/how_to/more_materials
  84041. */
  84042. vAng: number;
  84043. /**
  84044. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84045. * @see http://doc.babylonjs.com/how_to/more_materials
  84046. */
  84047. wAng: number;
  84048. /**
  84049. * Defines the center of rotation (U)
  84050. */
  84051. uRotationCenter: number;
  84052. /**
  84053. * Defines the center of rotation (V)
  84054. */
  84055. vRotationCenter: number;
  84056. /**
  84057. * Defines the center of rotation (W)
  84058. */
  84059. wRotationCenter: number;
  84060. /**
  84061. * Are mip maps generated for this texture or not.
  84062. */
  84063. readonly noMipmap: boolean;
  84064. /**
  84065. * List of inspectable custom properties (used by the Inspector)
  84066. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84067. */
  84068. inspectableCustomProperties: Nullable<IInspectable[]>;
  84069. private _noMipmap;
  84070. /** @hidden */
  84071. _invertY: boolean;
  84072. private _rowGenerationMatrix;
  84073. private _cachedTextureMatrix;
  84074. private _projectionModeMatrix;
  84075. private _t0;
  84076. private _t1;
  84077. private _t2;
  84078. private _cachedUOffset;
  84079. private _cachedVOffset;
  84080. private _cachedUScale;
  84081. private _cachedVScale;
  84082. private _cachedUAng;
  84083. private _cachedVAng;
  84084. private _cachedWAng;
  84085. private _cachedProjectionMatrixId;
  84086. private _cachedCoordinatesMode;
  84087. /** @hidden */
  84088. protected _initialSamplingMode: number;
  84089. /** @hidden */
  84090. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84091. private _deleteBuffer;
  84092. protected _format: Nullable<number>;
  84093. private _delayedOnLoad;
  84094. private _delayedOnError;
  84095. private _mimeType?;
  84096. /**
  84097. * Observable triggered once the texture has been loaded.
  84098. */
  84099. onLoadObservable: Observable<Texture>;
  84100. protected _isBlocking: boolean;
  84101. /**
  84102. * Is the texture preventing material to render while loading.
  84103. * If false, a default texture will be used instead of the loading one during the preparation step.
  84104. */
  84105. isBlocking: boolean;
  84106. /**
  84107. * Get the current sampling mode associated with the texture.
  84108. */
  84109. readonly samplingMode: number;
  84110. /**
  84111. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84112. */
  84113. readonly invertY: boolean;
  84114. /**
  84115. * Instantiates a new texture.
  84116. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84117. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84118. * @param url defines the url of the picture to load as a texture
  84119. * @param scene defines the scene or engine the texture will belong to
  84120. * @param noMipmap defines if the texture will require mip maps or not
  84121. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84122. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84123. * @param onLoad defines a callback triggered when the texture has been loaded
  84124. * @param onError defines a callback triggered when an error occurred during the loading session
  84125. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84126. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84127. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84128. * @param mimeType defines an optional mime type information
  84129. */
  84130. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  84131. /**
  84132. * Update the url (and optional buffer) of this texture if url was null during construction.
  84133. * @param url the url of the texture
  84134. * @param buffer the buffer of the texture (defaults to null)
  84135. * @param onLoad callback called when the texture is loaded (defaults to null)
  84136. */
  84137. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84138. /**
  84139. * Finish the loading sequence of a texture flagged as delayed load.
  84140. * @hidden
  84141. */
  84142. delayLoad(): void;
  84143. private _prepareRowForTextureGeneration;
  84144. /**
  84145. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84146. * @returns the transform matrix of the texture.
  84147. */
  84148. getTextureMatrix(): Matrix;
  84149. /**
  84150. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84151. * @returns The reflection texture transform
  84152. */
  84153. getReflectionTextureMatrix(): Matrix;
  84154. /**
  84155. * Clones the texture.
  84156. * @returns the cloned texture
  84157. */
  84158. clone(): Texture;
  84159. /**
  84160. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84161. * @returns The JSON representation of the texture
  84162. */
  84163. serialize(): any;
  84164. /**
  84165. * Get the current class name of the texture useful for serialization or dynamic coding.
  84166. * @returns "Texture"
  84167. */
  84168. getClassName(): string;
  84169. /**
  84170. * Dispose the texture and release its associated resources.
  84171. */
  84172. dispose(): void;
  84173. /**
  84174. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84175. * @param parsedTexture Define the JSON representation of the texture
  84176. * @param scene Define the scene the parsed texture should be instantiated in
  84177. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84178. * @returns The parsed texture if successful
  84179. */
  84180. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84181. /**
  84182. * Creates a texture from its base 64 representation.
  84183. * @param data Define the base64 payload without the data: prefix
  84184. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84185. * @param scene Define the scene the texture should belong to
  84186. * @param noMipmap Forces the texture to not create mip map information if true
  84187. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84188. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84189. * @param onLoad define a callback triggered when the texture has been loaded
  84190. * @param onError define a callback triggered when an error occurred during the loading session
  84191. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84192. * @returns the created texture
  84193. */
  84194. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84195. /**
  84196. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84197. * @param data Define the base64 payload without the data: prefix
  84198. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84199. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84200. * @param scene Define the scene the texture should belong to
  84201. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84202. * @param noMipmap Forces the texture to not create mip map information if true
  84203. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84204. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84205. * @param onLoad define a callback triggered when the texture has been loaded
  84206. * @param onError define a callback triggered when an error occurred during the loading session
  84207. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84208. * @returns the created texture
  84209. */
  84210. 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;
  84211. }
  84212. }
  84213. declare module BABYLON {
  84214. /**
  84215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84217. */
  84218. export class PostProcessManager {
  84219. private _scene;
  84220. private _indexBuffer;
  84221. private _vertexBuffers;
  84222. /**
  84223. * Creates a new instance PostProcess
  84224. * @param scene The scene that the post process is associated with.
  84225. */
  84226. constructor(scene: Scene);
  84227. private _prepareBuffers;
  84228. private _buildIndexBuffer;
  84229. /**
  84230. * Rebuilds the vertex buffers of the manager.
  84231. * @hidden
  84232. */
  84233. _rebuild(): void;
  84234. /**
  84235. * Prepares a frame to be run through a post process.
  84236. * @param sourceTexture The input texture to the post procesess. (default: null)
  84237. * @param postProcesses An array of post processes to be run. (default: null)
  84238. * @returns True if the post processes were able to be run.
  84239. * @hidden
  84240. */
  84241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84242. /**
  84243. * Manually render a set of post processes to a texture.
  84244. * @param postProcesses An array of post processes to be run.
  84245. * @param targetTexture The target texture to render to.
  84246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84248. * @param lodLevel defines which lod of the texture to render to
  84249. */
  84250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84251. /**
  84252. * Finalize the result of the output of the postprocesses.
  84253. * @param doNotPresent If true the result will not be displayed to the screen.
  84254. * @param targetTexture The target texture to render to.
  84255. * @param faceIndex The index of the face to bind the target texture to.
  84256. * @param postProcesses The array of post processes to render.
  84257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84258. * @hidden
  84259. */
  84260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84261. /**
  84262. * Disposes of the post process manager.
  84263. */
  84264. dispose(): void;
  84265. }
  84266. }
  84267. declare module BABYLON {
  84268. /** Interface used by value gradients (color, factor, ...) */
  84269. export interface IValueGradient {
  84270. /**
  84271. * Gets or sets the gradient value (between 0 and 1)
  84272. */
  84273. gradient: number;
  84274. }
  84275. /** Class used to store color4 gradient */
  84276. export class ColorGradient implements IValueGradient {
  84277. /**
  84278. * Gets or sets the gradient value (between 0 and 1)
  84279. */
  84280. gradient: number;
  84281. /**
  84282. * Gets or sets first associated color
  84283. */
  84284. color1: Color4;
  84285. /**
  84286. * Gets or sets second associated color
  84287. */
  84288. color2?: Color4;
  84289. /**
  84290. * Will get a color picked randomly between color1 and color2.
  84291. * If color2 is undefined then color1 will be used
  84292. * @param result defines the target Color4 to store the result in
  84293. */
  84294. getColorToRef(result: Color4): void;
  84295. }
  84296. /** Class used to store color 3 gradient */
  84297. export class Color3Gradient implements IValueGradient {
  84298. /**
  84299. * Gets or sets the gradient value (between 0 and 1)
  84300. */
  84301. gradient: number;
  84302. /**
  84303. * Gets or sets the associated color
  84304. */
  84305. color: Color3;
  84306. }
  84307. /** Class used to store factor gradient */
  84308. export class FactorGradient implements IValueGradient {
  84309. /**
  84310. * Gets or sets the gradient value (between 0 and 1)
  84311. */
  84312. gradient: number;
  84313. /**
  84314. * Gets or sets first associated factor
  84315. */
  84316. factor1: number;
  84317. /**
  84318. * Gets or sets second associated factor
  84319. */
  84320. factor2?: number;
  84321. /**
  84322. * Will get a number picked randomly between factor1 and factor2.
  84323. * If factor2 is undefined then factor1 will be used
  84324. * @returns the picked number
  84325. */
  84326. getFactor(): number;
  84327. }
  84328. /**
  84329. * Helper used to simplify some generic gradient tasks
  84330. */
  84331. export class GradientHelper {
  84332. /**
  84333. * Gets the current gradient from an array of IValueGradient
  84334. * @param ratio defines the current ratio to get
  84335. * @param gradients defines the array of IValueGradient
  84336. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84337. */
  84338. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84339. }
  84340. }
  84341. declare module BABYLON {
  84342. interface ThinEngine {
  84343. /**
  84344. * Creates a dynamic texture
  84345. * @param width defines the width of the texture
  84346. * @param height defines the height of the texture
  84347. * @param generateMipMaps defines if the engine should generate the mip levels
  84348. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84349. * @returns the dynamic texture inside an InternalTexture
  84350. */
  84351. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84352. /**
  84353. * Update the content of a dynamic texture
  84354. * @param texture defines the texture to update
  84355. * @param canvas defines the canvas containing the source
  84356. * @param invertY defines if data must be stored with Y axis inverted
  84357. * @param premulAlpha defines if alpha is stored as premultiplied
  84358. * @param format defines the format of the data
  84359. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84360. */
  84361. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84362. }
  84363. }
  84364. declare module BABYLON {
  84365. /**
  84366. * Helper class used to generate a canvas to manipulate images
  84367. */
  84368. export class CanvasGenerator {
  84369. /**
  84370. * Create a new canvas (or offscreen canvas depending on the context)
  84371. * @param width defines the expected width
  84372. * @param height defines the expected height
  84373. * @return a new canvas or offscreen canvas
  84374. */
  84375. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84376. }
  84377. }
  84378. declare module BABYLON {
  84379. /**
  84380. * A class extending Texture allowing drawing on a texture
  84381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84382. */
  84383. export class DynamicTexture extends Texture {
  84384. private _generateMipMaps;
  84385. private _canvas;
  84386. private _context;
  84387. private _engine;
  84388. /**
  84389. * Creates a DynamicTexture
  84390. * @param name defines the name of the texture
  84391. * @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
  84392. * @param scene defines the scene where you want the texture
  84393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84396. */
  84397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84398. /**
  84399. * Get the current class name of the texture useful for serialization or dynamic coding.
  84400. * @returns "DynamicTexture"
  84401. */
  84402. getClassName(): string;
  84403. /**
  84404. * Gets the current state of canRescale
  84405. */
  84406. readonly canRescale: boolean;
  84407. private _recreate;
  84408. /**
  84409. * Scales the texture
  84410. * @param ratio the scale factor to apply to both width and height
  84411. */
  84412. scale(ratio: number): void;
  84413. /**
  84414. * Resizes the texture
  84415. * @param width the new width
  84416. * @param height the new height
  84417. */
  84418. scaleTo(width: number, height: number): void;
  84419. /**
  84420. * Gets the context of the canvas used by the texture
  84421. * @returns the canvas context of the dynamic texture
  84422. */
  84423. getContext(): CanvasRenderingContext2D;
  84424. /**
  84425. * Clears the texture
  84426. */
  84427. clear(): void;
  84428. /**
  84429. * Updates the texture
  84430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84432. */
  84433. update(invertY?: boolean, premulAlpha?: boolean): void;
  84434. /**
  84435. * Draws text onto the texture
  84436. * @param text defines the text to be drawn
  84437. * @param x defines the placement of the text from the left
  84438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84439. * @param font defines the font to be used with font-style, font-size, font-name
  84440. * @param color defines the color used for the text
  84441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84443. * @param update defines whether texture is immediately update (default is true)
  84444. */
  84445. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84446. /**
  84447. * Clones the texture
  84448. * @returns the clone of the texture.
  84449. */
  84450. clone(): DynamicTexture;
  84451. /**
  84452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84453. * @returns a serialized dynamic texture object
  84454. */
  84455. serialize(): any;
  84456. /** @hidden */
  84457. _rebuild(): void;
  84458. }
  84459. }
  84460. declare module BABYLON {
  84461. interface AbstractScene {
  84462. /**
  84463. * The list of procedural textures added to the scene
  84464. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84465. */
  84466. proceduralTextures: Array<ProceduralTexture>;
  84467. }
  84468. /**
  84469. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84470. * in a given scene.
  84471. */
  84472. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84473. /**
  84474. * The component name helpfull to identify the component in the list of scene components.
  84475. */
  84476. readonly name: string;
  84477. /**
  84478. * The scene the component belongs to.
  84479. */
  84480. scene: Scene;
  84481. /**
  84482. * Creates a new instance of the component for the given scene
  84483. * @param scene Defines the scene to register the component in
  84484. */
  84485. constructor(scene: Scene);
  84486. /**
  84487. * Registers the component in a given scene
  84488. */
  84489. register(): void;
  84490. /**
  84491. * Rebuilds the elements related to this component in case of
  84492. * context lost for instance.
  84493. */
  84494. rebuild(): void;
  84495. /**
  84496. * Disposes the component and the associated ressources.
  84497. */
  84498. dispose(): void;
  84499. private _beforeClear;
  84500. }
  84501. }
  84502. declare module BABYLON {
  84503. interface ThinEngine {
  84504. /**
  84505. * Creates a new render target cube texture
  84506. * @param size defines the size of the texture
  84507. * @param options defines the options used to create the texture
  84508. * @returns a new render target cube texture stored in an InternalTexture
  84509. */
  84510. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84511. }
  84512. }
  84513. declare module BABYLON {
  84514. /** @hidden */
  84515. export var proceduralVertexShader: {
  84516. name: string;
  84517. shader: string;
  84518. };
  84519. }
  84520. declare module BABYLON {
  84521. /**
  84522. * 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.
  84523. * This is the base class of any Procedural texture and contains most of the shareable code.
  84524. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84525. */
  84526. export class ProceduralTexture extends Texture {
  84527. isCube: boolean;
  84528. /**
  84529. * Define if the texture is enabled or not (disabled texture will not render)
  84530. */
  84531. isEnabled: boolean;
  84532. /**
  84533. * Define if the texture must be cleared before rendering (default is true)
  84534. */
  84535. autoClear: boolean;
  84536. /**
  84537. * Callback called when the texture is generated
  84538. */
  84539. onGenerated: () => void;
  84540. /**
  84541. * Event raised when the texture is generated
  84542. */
  84543. onGeneratedObservable: Observable<ProceduralTexture>;
  84544. /** @hidden */
  84545. _generateMipMaps: boolean;
  84546. /** @hidden **/
  84547. _effect: Effect;
  84548. /** @hidden */
  84549. _textures: {
  84550. [key: string]: Texture;
  84551. };
  84552. private _size;
  84553. private _currentRefreshId;
  84554. private _refreshRate;
  84555. private _vertexBuffers;
  84556. private _indexBuffer;
  84557. private _uniforms;
  84558. private _samplers;
  84559. private _fragment;
  84560. private _floats;
  84561. private _ints;
  84562. private _floatsArrays;
  84563. private _colors3;
  84564. private _colors4;
  84565. private _vectors2;
  84566. private _vectors3;
  84567. private _matrices;
  84568. private _fallbackTexture;
  84569. private _fallbackTextureUsed;
  84570. private _engine;
  84571. private _cachedDefines;
  84572. private _contentUpdateId;
  84573. private _contentData;
  84574. /**
  84575. * Instantiates a new procedural texture.
  84576. * 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.
  84577. * This is the base class of any Procedural texture and contains most of the shareable code.
  84578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84579. * @param name Define the name of the texture
  84580. * @param size Define the size of the texture to create
  84581. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84582. * @param scene Define the scene the texture belongs to
  84583. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84584. * @param generateMipMaps Define if the texture should creates mip maps or not
  84585. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84586. */
  84587. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84588. /**
  84589. * The effect that is created when initializing the post process.
  84590. * @returns The created effect corresponding the the postprocess.
  84591. */
  84592. getEffect(): Effect;
  84593. /**
  84594. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84595. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84596. */
  84597. getContent(): Nullable<ArrayBufferView>;
  84598. private _createIndexBuffer;
  84599. /** @hidden */
  84600. _rebuild(): void;
  84601. /**
  84602. * Resets the texture in order to recreate its associated resources.
  84603. * This can be called in case of context loss
  84604. */
  84605. reset(): void;
  84606. protected _getDefines(): string;
  84607. /**
  84608. * Is the texture ready to be used ? (rendered at least once)
  84609. * @returns true if ready, otherwise, false.
  84610. */
  84611. isReady(): boolean;
  84612. /**
  84613. * Resets the refresh counter of the texture and start bak from scratch.
  84614. * Could be useful to regenerate the texture if it is setup to render only once.
  84615. */
  84616. resetRefreshCounter(): void;
  84617. /**
  84618. * Set the fragment shader to use in order to render the texture.
  84619. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84620. */
  84621. setFragment(fragment: any): void;
  84622. /**
  84623. * Define the refresh rate of the texture or the rendering frequency.
  84624. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84625. */
  84626. refreshRate: number;
  84627. /** @hidden */
  84628. _shouldRender(): boolean;
  84629. /**
  84630. * Get the size the texture is rendering at.
  84631. * @returns the size (texture is always squared)
  84632. */
  84633. getRenderSize(): number;
  84634. /**
  84635. * Resize the texture to new value.
  84636. * @param size Define the new size the texture should have
  84637. * @param generateMipMaps Define whether the new texture should create mip maps
  84638. */
  84639. resize(size: number, generateMipMaps: boolean): void;
  84640. private _checkUniform;
  84641. /**
  84642. * Set a texture in the shader program used to render.
  84643. * @param name Define the name of the uniform samplers as defined in the shader
  84644. * @param texture Define the texture to bind to this sampler
  84645. * @return the texture itself allowing "fluent" like uniform updates
  84646. */
  84647. setTexture(name: string, texture: Texture): ProceduralTexture;
  84648. /**
  84649. * Set a float in the shader.
  84650. * @param name Define the name of the uniform as defined in the shader
  84651. * @param value Define the value to give to the uniform
  84652. * @return the texture itself allowing "fluent" like uniform updates
  84653. */
  84654. setFloat(name: string, value: number): ProceduralTexture;
  84655. /**
  84656. * Set a int in the shader.
  84657. * @param name Define the name of the uniform as defined in the shader
  84658. * @param value Define the value to give to the uniform
  84659. * @return the texture itself allowing "fluent" like uniform updates
  84660. */
  84661. setInt(name: string, value: number): ProceduralTexture;
  84662. /**
  84663. * Set an array of floats in the shader.
  84664. * @param name Define the name of the uniform as defined in the shader
  84665. * @param value Define the value to give to the uniform
  84666. * @return the texture itself allowing "fluent" like uniform updates
  84667. */
  84668. setFloats(name: string, value: number[]): ProceduralTexture;
  84669. /**
  84670. * Set a vec3 in the shader from a Color3.
  84671. * @param name Define the name of the uniform as defined in the shader
  84672. * @param value Define the value to give to the uniform
  84673. * @return the texture itself allowing "fluent" like uniform updates
  84674. */
  84675. setColor3(name: string, value: Color3): ProceduralTexture;
  84676. /**
  84677. * Set a vec4 in the shader from a Color4.
  84678. * @param name Define the name of the uniform as defined in the shader
  84679. * @param value Define the value to give to the uniform
  84680. * @return the texture itself allowing "fluent" like uniform updates
  84681. */
  84682. setColor4(name: string, value: Color4): ProceduralTexture;
  84683. /**
  84684. * Set a vec2 in the shader from a Vector2.
  84685. * @param name Define the name of the uniform as defined in the shader
  84686. * @param value Define the value to give to the uniform
  84687. * @return the texture itself allowing "fluent" like uniform updates
  84688. */
  84689. setVector2(name: string, value: Vector2): ProceduralTexture;
  84690. /**
  84691. * Set a vec3 in the shader from a Vector3.
  84692. * @param name Define the name of the uniform as defined in the shader
  84693. * @param value Define the value to give to the uniform
  84694. * @return the texture itself allowing "fluent" like uniform updates
  84695. */
  84696. setVector3(name: string, value: Vector3): ProceduralTexture;
  84697. /**
  84698. * Set a mat4 in the shader from a MAtrix.
  84699. * @param name Define the name of the uniform as defined in the shader
  84700. * @param value Define the value to give to the uniform
  84701. * @return the texture itself allowing "fluent" like uniform updates
  84702. */
  84703. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84704. /**
  84705. * Render the texture to its associated render target.
  84706. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84707. */
  84708. render(useCameraPostProcess?: boolean): void;
  84709. /**
  84710. * Clone the texture.
  84711. * @returns the cloned texture
  84712. */
  84713. clone(): ProceduralTexture;
  84714. /**
  84715. * Dispose the texture and release its asoociated resources.
  84716. */
  84717. dispose(): void;
  84718. }
  84719. }
  84720. declare module BABYLON {
  84721. /**
  84722. * This represents the base class for particle system in Babylon.
  84723. * 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.
  84724. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84725. * @example https://doc.babylonjs.com/babylon101/particles
  84726. */
  84727. export class BaseParticleSystem {
  84728. /**
  84729. * Source color is added to the destination color without alpha affecting the result
  84730. */
  84731. static BLENDMODE_ONEONE: number;
  84732. /**
  84733. * Blend current color and particle color using particle’s alpha
  84734. */
  84735. static BLENDMODE_STANDARD: number;
  84736. /**
  84737. * Add current color and particle color multiplied by particle’s alpha
  84738. */
  84739. static BLENDMODE_ADD: number;
  84740. /**
  84741. * Multiply current color with particle color
  84742. */
  84743. static BLENDMODE_MULTIPLY: number;
  84744. /**
  84745. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84746. */
  84747. static BLENDMODE_MULTIPLYADD: number;
  84748. /**
  84749. * List of animations used by the particle system.
  84750. */
  84751. animations: Animation[];
  84752. /**
  84753. * The id of the Particle system.
  84754. */
  84755. id: string;
  84756. /**
  84757. * The friendly name of the Particle system.
  84758. */
  84759. name: string;
  84760. /**
  84761. * The rendering group used by the Particle system to chose when to render.
  84762. */
  84763. renderingGroupId: number;
  84764. /**
  84765. * The emitter represents the Mesh or position we are attaching the particle system to.
  84766. */
  84767. emitter: Nullable<AbstractMesh | Vector3>;
  84768. /**
  84769. * The maximum number of particles to emit per frame
  84770. */
  84771. emitRate: number;
  84772. /**
  84773. * If you want to launch only a few particles at once, that can be done, as well.
  84774. */
  84775. manualEmitCount: number;
  84776. /**
  84777. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84778. */
  84779. updateSpeed: number;
  84780. /**
  84781. * The amount of time the particle system is running (depends of the overall update speed).
  84782. */
  84783. targetStopDuration: number;
  84784. /**
  84785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84786. */
  84787. disposeOnStop: boolean;
  84788. /**
  84789. * Minimum power of emitting particles.
  84790. */
  84791. minEmitPower: number;
  84792. /**
  84793. * Maximum power of emitting particles.
  84794. */
  84795. maxEmitPower: number;
  84796. /**
  84797. * Minimum life time of emitting particles.
  84798. */
  84799. minLifeTime: number;
  84800. /**
  84801. * Maximum life time of emitting particles.
  84802. */
  84803. maxLifeTime: number;
  84804. /**
  84805. * Minimum Size of emitting particles.
  84806. */
  84807. minSize: number;
  84808. /**
  84809. * Maximum Size of emitting particles.
  84810. */
  84811. maxSize: number;
  84812. /**
  84813. * Minimum scale of emitting particles on X axis.
  84814. */
  84815. minScaleX: number;
  84816. /**
  84817. * Maximum scale of emitting particles on X axis.
  84818. */
  84819. maxScaleX: number;
  84820. /**
  84821. * Minimum scale of emitting particles on Y axis.
  84822. */
  84823. minScaleY: number;
  84824. /**
  84825. * Maximum scale of emitting particles on Y axis.
  84826. */
  84827. maxScaleY: number;
  84828. /**
  84829. * Gets or sets the minimal initial rotation in radians.
  84830. */
  84831. minInitialRotation: number;
  84832. /**
  84833. * Gets or sets the maximal initial rotation in radians.
  84834. */
  84835. maxInitialRotation: number;
  84836. /**
  84837. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84838. */
  84839. minAngularSpeed: number;
  84840. /**
  84841. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84842. */
  84843. maxAngularSpeed: number;
  84844. /**
  84845. * The texture used to render each particle. (this can be a spritesheet)
  84846. */
  84847. particleTexture: Nullable<Texture>;
  84848. /**
  84849. * The layer mask we are rendering the particles through.
  84850. */
  84851. layerMask: number;
  84852. /**
  84853. * This can help using your own shader to render the particle system.
  84854. * The according effect will be created
  84855. */
  84856. customShader: any;
  84857. /**
  84858. * By default particle system starts as soon as they are created. This prevents the
  84859. * automatic start to happen and let you decide when to start emitting particles.
  84860. */
  84861. preventAutoStart: boolean;
  84862. private _noiseTexture;
  84863. /**
  84864. * Gets or sets a texture used to add random noise to particle positions
  84865. */
  84866. noiseTexture: Nullable<ProceduralTexture>;
  84867. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84868. noiseStrength: Vector3;
  84869. /**
  84870. * Callback triggered when the particle animation is ending.
  84871. */
  84872. onAnimationEnd: Nullable<() => void>;
  84873. /**
  84874. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84875. */
  84876. blendMode: number;
  84877. /**
  84878. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84879. * to override the particles.
  84880. */
  84881. forceDepthWrite: boolean;
  84882. /** 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 */
  84883. preWarmCycles: number;
  84884. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84885. preWarmStepOffset: number;
  84886. /**
  84887. * 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)
  84888. */
  84889. spriteCellChangeSpeed: number;
  84890. /**
  84891. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84892. */
  84893. startSpriteCellID: number;
  84894. /**
  84895. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84896. */
  84897. endSpriteCellID: number;
  84898. /**
  84899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84900. */
  84901. spriteCellWidth: number;
  84902. /**
  84903. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84904. */
  84905. spriteCellHeight: number;
  84906. /**
  84907. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84908. */
  84909. spriteRandomStartCell: boolean;
  84910. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84911. translationPivot: Vector2;
  84912. /** @hidden */
  84913. protected _isAnimationSheetEnabled: boolean;
  84914. /**
  84915. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84916. */
  84917. beginAnimationOnStart: boolean;
  84918. /**
  84919. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84920. */
  84921. beginAnimationFrom: number;
  84922. /**
  84923. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84924. */
  84925. beginAnimationTo: number;
  84926. /**
  84927. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84928. */
  84929. beginAnimationLoop: boolean;
  84930. /**
  84931. * Gets or sets a world offset applied to all particles
  84932. */
  84933. worldOffset: Vector3;
  84934. /**
  84935. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84936. */
  84937. isAnimationSheetEnabled: boolean;
  84938. /**
  84939. * Get hosting scene
  84940. * @returns the scene
  84941. */
  84942. getScene(): Scene;
  84943. /**
  84944. * You can use gravity if you want to give an orientation to your particles.
  84945. */
  84946. gravity: Vector3;
  84947. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84948. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84949. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84950. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84951. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84952. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84953. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84954. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84955. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84956. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84957. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84958. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84959. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84960. /**
  84961. * Defines the delay in milliseconds before starting the system (0 by default)
  84962. */
  84963. startDelay: number;
  84964. /**
  84965. * Gets the current list of drag gradients.
  84966. * You must use addDragGradient and removeDragGradient to udpate this list
  84967. * @returns the list of drag gradients
  84968. */
  84969. getDragGradients(): Nullable<Array<FactorGradient>>;
  84970. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84971. limitVelocityDamping: number;
  84972. /**
  84973. * Gets the current list of limit velocity gradients.
  84974. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84975. * @returns the list of limit velocity gradients
  84976. */
  84977. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84978. /**
  84979. * Gets the current list of color gradients.
  84980. * You must use addColorGradient and removeColorGradient to udpate this list
  84981. * @returns the list of color gradients
  84982. */
  84983. getColorGradients(): Nullable<Array<ColorGradient>>;
  84984. /**
  84985. * Gets the current list of size gradients.
  84986. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84987. * @returns the list of size gradients
  84988. */
  84989. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84990. /**
  84991. * Gets the current list of color remap gradients.
  84992. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84993. * @returns the list of color remap gradients
  84994. */
  84995. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84996. /**
  84997. * Gets the current list of alpha remap gradients.
  84998. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84999. * @returns the list of alpha remap gradients
  85000. */
  85001. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85002. /**
  85003. * Gets the current list of life time gradients.
  85004. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85005. * @returns the list of life time gradients
  85006. */
  85007. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85008. /**
  85009. * Gets the current list of angular speed gradients.
  85010. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85011. * @returns the list of angular speed gradients
  85012. */
  85013. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85014. /**
  85015. * Gets the current list of velocity gradients.
  85016. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85017. * @returns the list of velocity gradients
  85018. */
  85019. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85020. /**
  85021. * Gets the current list of start size gradients.
  85022. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85023. * @returns the list of start size gradients
  85024. */
  85025. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85026. /**
  85027. * Gets the current list of emit rate gradients.
  85028. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85029. * @returns the list of emit rate gradients
  85030. */
  85031. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85032. /**
  85033. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85034. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85035. */
  85036. direction1: Vector3;
  85037. /**
  85038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85039. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85040. */
  85041. direction2: Vector3;
  85042. /**
  85043. * 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.
  85044. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85045. */
  85046. minEmitBox: Vector3;
  85047. /**
  85048. * 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.
  85049. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85050. */
  85051. maxEmitBox: Vector3;
  85052. /**
  85053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85054. */
  85055. color1: Color4;
  85056. /**
  85057. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85058. */
  85059. color2: Color4;
  85060. /**
  85061. * Color the particle will have at the end of its lifetime
  85062. */
  85063. colorDead: Color4;
  85064. /**
  85065. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85066. */
  85067. textureMask: Color4;
  85068. /**
  85069. * The particle emitter type defines the emitter used by the particle system.
  85070. * It can be for example box, sphere, or cone...
  85071. */
  85072. particleEmitterType: IParticleEmitterType;
  85073. /** @hidden */
  85074. _isSubEmitter: boolean;
  85075. /**
  85076. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85077. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85078. */
  85079. billboardMode: number;
  85080. protected _isBillboardBased: boolean;
  85081. /**
  85082. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85083. */
  85084. isBillboardBased: boolean;
  85085. /**
  85086. * The scene the particle system belongs to.
  85087. */
  85088. protected _scene: Scene;
  85089. /**
  85090. * Local cache of defines for image processing.
  85091. */
  85092. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85093. /**
  85094. * Default configuration related to image processing available in the standard Material.
  85095. */
  85096. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85097. /**
  85098. * Gets the image processing configuration used either in this material.
  85099. */
  85100. /**
  85101. * Sets the Default image processing configuration used either in the this material.
  85102. *
  85103. * If sets to null, the scene one is in use.
  85104. */
  85105. imageProcessingConfiguration: ImageProcessingConfiguration;
  85106. /**
  85107. * Attaches a new image processing configuration to the Standard Material.
  85108. * @param configuration
  85109. */
  85110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85111. /** @hidden */
  85112. protected _reset(): void;
  85113. /** @hidden */
  85114. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85115. /**
  85116. * Instantiates a particle system.
  85117. * 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.
  85118. * @param name The name of the particle system
  85119. */
  85120. constructor(name: string);
  85121. /**
  85122. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85123. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85124. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85125. * @returns the emitter
  85126. */
  85127. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85128. /**
  85129. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85130. * @param radius The radius of the hemisphere to emit from
  85131. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85132. * @returns the emitter
  85133. */
  85134. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85135. /**
  85136. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85137. * @param radius The radius of the sphere to emit from
  85138. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85139. * @returns the emitter
  85140. */
  85141. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85142. /**
  85143. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85144. * @param radius The radius of the sphere to emit from
  85145. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85146. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85147. * @returns the emitter
  85148. */
  85149. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85150. /**
  85151. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85152. * @param radius The radius of the emission cylinder
  85153. * @param height The height of the emission cylinder
  85154. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85155. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85156. * @returns the emitter
  85157. */
  85158. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85159. /**
  85160. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85161. * @param radius The radius of the cylinder to emit from
  85162. * @param height The height of the emission cylinder
  85163. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85164. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85165. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85166. * @returns the emitter
  85167. */
  85168. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85169. /**
  85170. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85171. * @param radius The radius of the cone to emit from
  85172. * @param angle The base angle of the cone
  85173. * @returns the emitter
  85174. */
  85175. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85176. /**
  85177. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85178. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85179. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85180. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85181. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85182. * @returns the emitter
  85183. */
  85184. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85185. }
  85186. }
  85187. declare module BABYLON {
  85188. /**
  85189. * Type of sub emitter
  85190. */
  85191. export enum SubEmitterType {
  85192. /**
  85193. * Attached to the particle over it's lifetime
  85194. */
  85195. ATTACHED = 0,
  85196. /**
  85197. * Created when the particle dies
  85198. */
  85199. END = 1
  85200. }
  85201. /**
  85202. * Sub emitter class used to emit particles from an existing particle
  85203. */
  85204. export class SubEmitter {
  85205. /**
  85206. * the particle system to be used by the sub emitter
  85207. */
  85208. particleSystem: ParticleSystem;
  85209. /**
  85210. * Type of the submitter (Default: END)
  85211. */
  85212. type: SubEmitterType;
  85213. /**
  85214. * 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)
  85215. * Note: This only is supported when using an emitter of type Mesh
  85216. */
  85217. inheritDirection: boolean;
  85218. /**
  85219. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85220. */
  85221. inheritedVelocityAmount: number;
  85222. /**
  85223. * Creates a sub emitter
  85224. * @param particleSystem the particle system to be used by the sub emitter
  85225. */
  85226. constructor(
  85227. /**
  85228. * the particle system to be used by the sub emitter
  85229. */
  85230. particleSystem: ParticleSystem);
  85231. /**
  85232. * Clones the sub emitter
  85233. * @returns the cloned sub emitter
  85234. */
  85235. clone(): SubEmitter;
  85236. /**
  85237. * Serialize current object to a JSON object
  85238. * @returns the serialized object
  85239. */
  85240. serialize(): any;
  85241. /** @hidden */
  85242. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85243. /**
  85244. * Creates a new SubEmitter from a serialized JSON version
  85245. * @param serializationObject defines the JSON object to read from
  85246. * @param scene defines the hosting scene
  85247. * @param rootUrl defines the rootUrl for data loading
  85248. * @returns a new SubEmitter
  85249. */
  85250. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85251. /** Release associated resources */
  85252. dispose(): void;
  85253. }
  85254. }
  85255. declare module BABYLON {
  85256. /** @hidden */
  85257. export var clipPlaneFragmentDeclaration: {
  85258. name: string;
  85259. shader: string;
  85260. };
  85261. }
  85262. declare module BABYLON {
  85263. /** @hidden */
  85264. export var imageProcessingDeclaration: {
  85265. name: string;
  85266. shader: string;
  85267. };
  85268. }
  85269. declare module BABYLON {
  85270. /** @hidden */
  85271. export var imageProcessingFunctions: {
  85272. name: string;
  85273. shader: string;
  85274. };
  85275. }
  85276. declare module BABYLON {
  85277. /** @hidden */
  85278. export var clipPlaneFragment: {
  85279. name: string;
  85280. shader: string;
  85281. };
  85282. }
  85283. declare module BABYLON {
  85284. /** @hidden */
  85285. export var particlesPixelShader: {
  85286. name: string;
  85287. shader: string;
  85288. };
  85289. }
  85290. declare module BABYLON {
  85291. /** @hidden */
  85292. export var clipPlaneVertexDeclaration: {
  85293. name: string;
  85294. shader: string;
  85295. };
  85296. }
  85297. declare module BABYLON {
  85298. /** @hidden */
  85299. export var clipPlaneVertex: {
  85300. name: string;
  85301. shader: string;
  85302. };
  85303. }
  85304. declare module BABYLON {
  85305. /** @hidden */
  85306. export var particlesVertexShader: {
  85307. name: string;
  85308. shader: string;
  85309. };
  85310. }
  85311. declare module BABYLON {
  85312. /**
  85313. * This represents a particle system in Babylon.
  85314. * 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.
  85315. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85316. * @example https://doc.babylonjs.com/babylon101/particles
  85317. */
  85318. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85319. /**
  85320. * Billboard mode will only apply to Y axis
  85321. */
  85322. static readonly BILLBOARDMODE_Y: number;
  85323. /**
  85324. * Billboard mode will apply to all axes
  85325. */
  85326. static readonly BILLBOARDMODE_ALL: number;
  85327. /**
  85328. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85329. */
  85330. static readonly BILLBOARDMODE_STRETCHED: number;
  85331. /**
  85332. * This function can be defined to provide custom update for active particles.
  85333. * This function will be called instead of regular update (age, position, color, etc.).
  85334. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85335. */
  85336. updateFunction: (particles: Particle[]) => void;
  85337. private _emitterWorldMatrix;
  85338. /**
  85339. * This function can be defined to specify initial direction for every new particle.
  85340. * It by default use the emitterType defined function
  85341. */
  85342. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85343. /**
  85344. * This function can be defined to specify initial position for every new particle.
  85345. * It by default use the emitterType defined function
  85346. */
  85347. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85348. /**
  85349. * @hidden
  85350. */
  85351. _inheritedVelocityOffset: Vector3;
  85352. /**
  85353. * An event triggered when the system is disposed
  85354. */
  85355. onDisposeObservable: Observable<ParticleSystem>;
  85356. private _onDisposeObserver;
  85357. /**
  85358. * Sets a callback that will be triggered when the system is disposed
  85359. */
  85360. onDispose: () => void;
  85361. private _particles;
  85362. private _epsilon;
  85363. private _capacity;
  85364. private _stockParticles;
  85365. private _newPartsExcess;
  85366. private _vertexData;
  85367. private _vertexBuffer;
  85368. private _vertexBuffers;
  85369. private _spriteBuffer;
  85370. private _indexBuffer;
  85371. private _effect;
  85372. private _customEffect;
  85373. private _cachedDefines;
  85374. private _scaledColorStep;
  85375. private _colorDiff;
  85376. private _scaledDirection;
  85377. private _scaledGravity;
  85378. private _currentRenderId;
  85379. private _alive;
  85380. private _useInstancing;
  85381. private _started;
  85382. private _stopped;
  85383. private _actualFrame;
  85384. private _scaledUpdateSpeed;
  85385. private _vertexBufferSize;
  85386. /** @hidden */
  85387. _currentEmitRateGradient: Nullable<FactorGradient>;
  85388. /** @hidden */
  85389. _currentEmitRate1: number;
  85390. /** @hidden */
  85391. _currentEmitRate2: number;
  85392. /** @hidden */
  85393. _currentStartSizeGradient: Nullable<FactorGradient>;
  85394. /** @hidden */
  85395. _currentStartSize1: number;
  85396. /** @hidden */
  85397. _currentStartSize2: number;
  85398. private readonly _rawTextureWidth;
  85399. private _rampGradientsTexture;
  85400. private _useRampGradients;
  85401. /** Gets or sets a boolean indicating that ramp gradients must be used
  85402. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85403. */
  85404. useRampGradients: boolean;
  85405. /**
  85406. * 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.
  85407. * 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: [])
  85408. */
  85409. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85410. private _subEmitters;
  85411. /**
  85412. * @hidden
  85413. * If the particle systems emitter should be disposed when the particle system is disposed
  85414. */
  85415. _disposeEmitterOnDispose: boolean;
  85416. /**
  85417. * The current active Sub-systems, this property is used by the root particle system only.
  85418. */
  85419. activeSubSystems: Array<ParticleSystem>;
  85420. private _rootParticleSystem;
  85421. /**
  85422. * Gets the current list of active particles
  85423. */
  85424. readonly particles: Particle[];
  85425. /**
  85426. * Returns the string "ParticleSystem"
  85427. * @returns a string containing the class name
  85428. */
  85429. getClassName(): string;
  85430. /**
  85431. * Instantiates a particle system.
  85432. * 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.
  85433. * @param name The name of the particle system
  85434. * @param capacity The max number of particles alive at the same time
  85435. * @param scene The scene the particle system belongs to
  85436. * @param customEffect a custom effect used to change the way particles are rendered by default
  85437. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85438. * @param epsilon Offset used to render the particles
  85439. */
  85440. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85441. private _addFactorGradient;
  85442. private _removeFactorGradient;
  85443. /**
  85444. * Adds a new life time gradient
  85445. * @param gradient defines the gradient to use (between 0 and 1)
  85446. * @param factor defines the life time factor to affect to the specified gradient
  85447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85448. * @returns the current particle system
  85449. */
  85450. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85451. /**
  85452. * Remove a specific life time gradient
  85453. * @param gradient defines the gradient to remove
  85454. * @returns the current particle system
  85455. */
  85456. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85457. /**
  85458. * Adds a new size gradient
  85459. * @param gradient defines the gradient to use (between 0 and 1)
  85460. * @param factor defines the size factor to affect to the specified gradient
  85461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85462. * @returns the current particle system
  85463. */
  85464. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85465. /**
  85466. * Remove a specific size gradient
  85467. * @param gradient defines the gradient to remove
  85468. * @returns the current particle system
  85469. */
  85470. removeSizeGradient(gradient: number): IParticleSystem;
  85471. /**
  85472. * Adds a new color remap gradient
  85473. * @param gradient defines the gradient to use (between 0 and 1)
  85474. * @param min defines the color remap minimal range
  85475. * @param max defines the color remap maximal range
  85476. * @returns the current particle system
  85477. */
  85478. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85479. /**
  85480. * Remove a specific color remap gradient
  85481. * @param gradient defines the gradient to remove
  85482. * @returns the current particle system
  85483. */
  85484. removeColorRemapGradient(gradient: number): IParticleSystem;
  85485. /**
  85486. * Adds a new alpha remap gradient
  85487. * @param gradient defines the gradient to use (between 0 and 1)
  85488. * @param min defines the alpha remap minimal range
  85489. * @param max defines the alpha remap maximal range
  85490. * @returns the current particle system
  85491. */
  85492. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85493. /**
  85494. * Remove a specific alpha remap gradient
  85495. * @param gradient defines the gradient to remove
  85496. * @returns the current particle system
  85497. */
  85498. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85499. /**
  85500. * Adds a new angular speed gradient
  85501. * @param gradient defines the gradient to use (between 0 and 1)
  85502. * @param factor defines the angular speed to affect to the specified gradient
  85503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85504. * @returns the current particle system
  85505. */
  85506. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85507. /**
  85508. * Remove a specific angular speed gradient
  85509. * @param gradient defines the gradient to remove
  85510. * @returns the current particle system
  85511. */
  85512. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85513. /**
  85514. * Adds a new velocity gradient
  85515. * @param gradient defines the gradient to use (between 0 and 1)
  85516. * @param factor defines the velocity to affect to the specified gradient
  85517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85518. * @returns the current particle system
  85519. */
  85520. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85521. /**
  85522. * Remove a specific velocity gradient
  85523. * @param gradient defines the gradient to remove
  85524. * @returns the current particle system
  85525. */
  85526. removeVelocityGradient(gradient: number): IParticleSystem;
  85527. /**
  85528. * Adds a new limit velocity gradient
  85529. * @param gradient defines the gradient to use (between 0 and 1)
  85530. * @param factor defines the limit velocity value to affect to the specified gradient
  85531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85532. * @returns the current particle system
  85533. */
  85534. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85535. /**
  85536. * Remove a specific limit velocity gradient
  85537. * @param gradient defines the gradient to remove
  85538. * @returns the current particle system
  85539. */
  85540. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85541. /**
  85542. * Adds a new drag gradient
  85543. * @param gradient defines the gradient to use (between 0 and 1)
  85544. * @param factor defines the drag value to affect to the specified gradient
  85545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85546. * @returns the current particle system
  85547. */
  85548. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85549. /**
  85550. * Remove a specific drag gradient
  85551. * @param gradient defines the gradient to remove
  85552. * @returns the current particle system
  85553. */
  85554. removeDragGradient(gradient: number): IParticleSystem;
  85555. /**
  85556. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85557. * @param gradient defines the gradient to use (between 0 and 1)
  85558. * @param factor defines the emit rate value to affect to the specified gradient
  85559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85560. * @returns the current particle system
  85561. */
  85562. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85563. /**
  85564. * Remove a specific emit rate gradient
  85565. * @param gradient defines the gradient to remove
  85566. * @returns the current particle system
  85567. */
  85568. removeEmitRateGradient(gradient: number): IParticleSystem;
  85569. /**
  85570. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85571. * @param gradient defines the gradient to use (between 0 and 1)
  85572. * @param factor defines the start size value to affect to the specified gradient
  85573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85574. * @returns the current particle system
  85575. */
  85576. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85577. /**
  85578. * Remove a specific start size gradient
  85579. * @param gradient defines the gradient to remove
  85580. * @returns the current particle system
  85581. */
  85582. removeStartSizeGradient(gradient: number): IParticleSystem;
  85583. private _createRampGradientTexture;
  85584. /**
  85585. * Gets the current list of ramp gradients.
  85586. * You must use addRampGradient and removeRampGradient to udpate this list
  85587. * @returns the list of ramp gradients
  85588. */
  85589. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85590. /**
  85591. * Adds a new ramp gradient used to remap particle colors
  85592. * @param gradient defines the gradient to use (between 0 and 1)
  85593. * @param color defines the color to affect to the specified gradient
  85594. * @returns the current particle system
  85595. */
  85596. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85597. /**
  85598. * Remove a specific ramp gradient
  85599. * @param gradient defines the gradient to remove
  85600. * @returns the current particle system
  85601. */
  85602. removeRampGradient(gradient: number): ParticleSystem;
  85603. /**
  85604. * Adds a new color gradient
  85605. * @param gradient defines the gradient to use (between 0 and 1)
  85606. * @param color1 defines the color to affect to the specified gradient
  85607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85608. * @returns this particle system
  85609. */
  85610. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85611. /**
  85612. * Remove a specific color gradient
  85613. * @param gradient defines the gradient to remove
  85614. * @returns this particle system
  85615. */
  85616. removeColorGradient(gradient: number): IParticleSystem;
  85617. private _fetchR;
  85618. protected _reset(): void;
  85619. private _resetEffect;
  85620. private _createVertexBuffers;
  85621. private _createIndexBuffer;
  85622. /**
  85623. * Gets the maximum number of particles active at the same time.
  85624. * @returns The max number of active particles.
  85625. */
  85626. getCapacity(): number;
  85627. /**
  85628. * Gets whether there are still active particles in the system.
  85629. * @returns True if it is alive, otherwise false.
  85630. */
  85631. isAlive(): boolean;
  85632. /**
  85633. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85634. * @returns True if it has been started, otherwise false.
  85635. */
  85636. isStarted(): boolean;
  85637. private _prepareSubEmitterInternalArray;
  85638. /**
  85639. * Starts the particle system and begins to emit
  85640. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85641. */
  85642. start(delay?: number): void;
  85643. /**
  85644. * Stops the particle system.
  85645. * @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.
  85646. */
  85647. stop(stopSubEmitters?: boolean): void;
  85648. /**
  85649. * Remove all active particles
  85650. */
  85651. reset(): void;
  85652. /**
  85653. * @hidden (for internal use only)
  85654. */
  85655. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85656. /**
  85657. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85658. * Its lifetime will start back at 0.
  85659. */
  85660. recycleParticle: (particle: Particle) => void;
  85661. private _stopSubEmitters;
  85662. private _createParticle;
  85663. private _removeFromRoot;
  85664. private _emitFromParticle;
  85665. private _update;
  85666. /** @hidden */
  85667. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85668. /** @hidden */
  85669. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85670. /** @hidden */
  85671. private _getEffect;
  85672. /**
  85673. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85674. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85675. */
  85676. animate(preWarmOnly?: boolean): void;
  85677. private _appendParticleVertices;
  85678. /**
  85679. * Rebuilds the particle system.
  85680. */
  85681. rebuild(): void;
  85682. /**
  85683. * Is this system ready to be used/rendered
  85684. * @return true if the system is ready
  85685. */
  85686. isReady(): boolean;
  85687. private _render;
  85688. /**
  85689. * Renders the particle system in its current state.
  85690. * @returns the current number of particles
  85691. */
  85692. render(): number;
  85693. /**
  85694. * Disposes the particle system and free the associated resources
  85695. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85696. */
  85697. dispose(disposeTexture?: boolean): void;
  85698. /**
  85699. * Clones the particle system.
  85700. * @param name The name of the cloned object
  85701. * @param newEmitter The new emitter to use
  85702. * @returns the cloned particle system
  85703. */
  85704. clone(name: string, newEmitter: any): ParticleSystem;
  85705. /**
  85706. * Serializes the particle system to a JSON object.
  85707. * @returns the JSON object
  85708. */
  85709. serialize(): any;
  85710. /** @hidden */
  85711. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85712. /** @hidden */
  85713. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85714. /**
  85715. * Parses a JSON object to create a particle system.
  85716. * @param parsedParticleSystem The JSON object to parse
  85717. * @param scene The scene to create the particle system in
  85718. * @param rootUrl The root url to use to load external dependencies like texture
  85719. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85720. * @returns the Parsed particle system
  85721. */
  85722. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85723. }
  85724. }
  85725. declare module BABYLON {
  85726. /**
  85727. * A particle represents one of the element emitted by a particle system.
  85728. * This is mainly define by its coordinates, direction, velocity and age.
  85729. */
  85730. export class Particle {
  85731. /**
  85732. * The particle system the particle belongs to.
  85733. */
  85734. particleSystem: ParticleSystem;
  85735. private static _Count;
  85736. /**
  85737. * Unique ID of the particle
  85738. */
  85739. id: number;
  85740. /**
  85741. * The world position of the particle in the scene.
  85742. */
  85743. position: Vector3;
  85744. /**
  85745. * The world direction of the particle in the scene.
  85746. */
  85747. direction: Vector3;
  85748. /**
  85749. * The color of the particle.
  85750. */
  85751. color: Color4;
  85752. /**
  85753. * The color change of the particle per step.
  85754. */
  85755. colorStep: Color4;
  85756. /**
  85757. * Defines how long will the life of the particle be.
  85758. */
  85759. lifeTime: number;
  85760. /**
  85761. * The current age of the particle.
  85762. */
  85763. age: number;
  85764. /**
  85765. * The current size of the particle.
  85766. */
  85767. size: number;
  85768. /**
  85769. * The current scale of the particle.
  85770. */
  85771. scale: Vector2;
  85772. /**
  85773. * The current angle of the particle.
  85774. */
  85775. angle: number;
  85776. /**
  85777. * Defines how fast is the angle changing.
  85778. */
  85779. angularSpeed: number;
  85780. /**
  85781. * Defines the cell index used by the particle to be rendered from a sprite.
  85782. */
  85783. cellIndex: number;
  85784. /**
  85785. * The information required to support color remapping
  85786. */
  85787. remapData: Vector4;
  85788. /** @hidden */
  85789. _randomCellOffset?: number;
  85790. /** @hidden */
  85791. _initialDirection: Nullable<Vector3>;
  85792. /** @hidden */
  85793. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85794. /** @hidden */
  85795. _initialStartSpriteCellID: number;
  85796. /** @hidden */
  85797. _initialEndSpriteCellID: number;
  85798. /** @hidden */
  85799. _currentColorGradient: Nullable<ColorGradient>;
  85800. /** @hidden */
  85801. _currentColor1: Color4;
  85802. /** @hidden */
  85803. _currentColor2: Color4;
  85804. /** @hidden */
  85805. _currentSizeGradient: Nullable<FactorGradient>;
  85806. /** @hidden */
  85807. _currentSize1: number;
  85808. /** @hidden */
  85809. _currentSize2: number;
  85810. /** @hidden */
  85811. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85812. /** @hidden */
  85813. _currentAngularSpeed1: number;
  85814. /** @hidden */
  85815. _currentAngularSpeed2: number;
  85816. /** @hidden */
  85817. _currentVelocityGradient: Nullable<FactorGradient>;
  85818. /** @hidden */
  85819. _currentVelocity1: number;
  85820. /** @hidden */
  85821. _currentVelocity2: number;
  85822. /** @hidden */
  85823. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85824. /** @hidden */
  85825. _currentLimitVelocity1: number;
  85826. /** @hidden */
  85827. _currentLimitVelocity2: number;
  85828. /** @hidden */
  85829. _currentDragGradient: Nullable<FactorGradient>;
  85830. /** @hidden */
  85831. _currentDrag1: number;
  85832. /** @hidden */
  85833. _currentDrag2: number;
  85834. /** @hidden */
  85835. _randomNoiseCoordinates1: Vector3;
  85836. /** @hidden */
  85837. _randomNoiseCoordinates2: Vector3;
  85838. /**
  85839. * Creates a new instance Particle
  85840. * @param particleSystem the particle system the particle belongs to
  85841. */
  85842. constructor(
  85843. /**
  85844. * The particle system the particle belongs to.
  85845. */
  85846. particleSystem: ParticleSystem);
  85847. private updateCellInfoFromSystem;
  85848. /**
  85849. * Defines how the sprite cell index is updated for the particle
  85850. */
  85851. updateCellIndex(): void;
  85852. /** @hidden */
  85853. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85854. /** @hidden */
  85855. _inheritParticleInfoToSubEmitters(): void;
  85856. /** @hidden */
  85857. _reset(): void;
  85858. /**
  85859. * Copy the properties of particle to another one.
  85860. * @param other the particle to copy the information to.
  85861. */
  85862. copyTo(other: Particle): void;
  85863. }
  85864. }
  85865. declare module BABYLON {
  85866. /**
  85867. * Particle emitter represents a volume emitting particles.
  85868. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85869. */
  85870. export interface IParticleEmitterType {
  85871. /**
  85872. * Called by the particle System when the direction is computed for the created particle.
  85873. * @param worldMatrix is the world matrix of the particle system
  85874. * @param directionToUpdate is the direction vector to update with the result
  85875. * @param particle is the particle we are computed the direction for
  85876. */
  85877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85878. /**
  85879. * Called by the particle System when the position is computed for the created particle.
  85880. * @param worldMatrix is the world matrix of the particle system
  85881. * @param positionToUpdate is the position vector to update with the result
  85882. * @param particle is the particle we are computed the position for
  85883. */
  85884. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85885. /**
  85886. * Clones the current emitter and returns a copy of it
  85887. * @returns the new emitter
  85888. */
  85889. clone(): IParticleEmitterType;
  85890. /**
  85891. * Called by the GPUParticleSystem to setup the update shader
  85892. * @param effect defines the update shader
  85893. */
  85894. applyToShader(effect: Effect): void;
  85895. /**
  85896. * Returns a string to use to update the GPU particles update shader
  85897. * @returns the effect defines string
  85898. */
  85899. getEffectDefines(): string;
  85900. /**
  85901. * Returns a string representing the class name
  85902. * @returns a string containing the class name
  85903. */
  85904. getClassName(): string;
  85905. /**
  85906. * Serializes the particle system to a JSON object.
  85907. * @returns the JSON object
  85908. */
  85909. serialize(): any;
  85910. /**
  85911. * Parse properties from a JSON object
  85912. * @param serializationObject defines the JSON object
  85913. */
  85914. parse(serializationObject: any): void;
  85915. }
  85916. }
  85917. declare module BABYLON {
  85918. /**
  85919. * Particle emitter emitting particles from the inside of a box.
  85920. * It emits the particles randomly between 2 given directions.
  85921. */
  85922. export class BoxParticleEmitter implements IParticleEmitterType {
  85923. /**
  85924. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85925. */
  85926. direction1: Vector3;
  85927. /**
  85928. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85929. */
  85930. direction2: Vector3;
  85931. /**
  85932. * 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.
  85933. */
  85934. minEmitBox: Vector3;
  85935. /**
  85936. * 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.
  85937. */
  85938. maxEmitBox: Vector3;
  85939. /**
  85940. * Creates a new instance BoxParticleEmitter
  85941. */
  85942. constructor();
  85943. /**
  85944. * Called by the particle System when the direction is computed for the created particle.
  85945. * @param worldMatrix is the world matrix of the particle system
  85946. * @param directionToUpdate is the direction vector to update with the result
  85947. * @param particle is the particle we are computed the direction for
  85948. */
  85949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85950. /**
  85951. * Called by the particle System when the position is computed for the created particle.
  85952. * @param worldMatrix is the world matrix of the particle system
  85953. * @param positionToUpdate is the position vector to update with the result
  85954. * @param particle is the particle we are computed the position for
  85955. */
  85956. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85957. /**
  85958. * Clones the current emitter and returns a copy of it
  85959. * @returns the new emitter
  85960. */
  85961. clone(): BoxParticleEmitter;
  85962. /**
  85963. * Called by the GPUParticleSystem to setup the update shader
  85964. * @param effect defines the update shader
  85965. */
  85966. applyToShader(effect: Effect): void;
  85967. /**
  85968. * Returns a string to use to update the GPU particles update shader
  85969. * @returns a string containng the defines string
  85970. */
  85971. getEffectDefines(): string;
  85972. /**
  85973. * Returns the string "BoxParticleEmitter"
  85974. * @returns a string containing the class name
  85975. */
  85976. getClassName(): string;
  85977. /**
  85978. * Serializes the particle system to a JSON object.
  85979. * @returns the JSON object
  85980. */
  85981. serialize(): any;
  85982. /**
  85983. * Parse properties from a JSON object
  85984. * @param serializationObject defines the JSON object
  85985. */
  85986. parse(serializationObject: any): void;
  85987. }
  85988. }
  85989. declare module BABYLON {
  85990. /**
  85991. * Particle emitter emitting particles from the inside of a cone.
  85992. * It emits the particles alongside the cone volume from the base to the particle.
  85993. * The emission direction might be randomized.
  85994. */
  85995. export class ConeParticleEmitter implements IParticleEmitterType {
  85996. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85997. directionRandomizer: number;
  85998. private _radius;
  85999. private _angle;
  86000. private _height;
  86001. /**
  86002. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86003. */
  86004. radiusRange: number;
  86005. /**
  86006. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86007. */
  86008. heightRange: number;
  86009. /**
  86010. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86011. */
  86012. emitFromSpawnPointOnly: boolean;
  86013. /**
  86014. * Gets or sets the radius of the emission cone
  86015. */
  86016. radius: number;
  86017. /**
  86018. * Gets or sets the angle of the emission cone
  86019. */
  86020. angle: number;
  86021. private _buildHeight;
  86022. /**
  86023. * Creates a new instance ConeParticleEmitter
  86024. * @param radius the radius of the emission cone (1 by default)
  86025. * @param angle the cone base angle (PI by default)
  86026. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86027. */
  86028. constructor(radius?: number, angle?: number,
  86029. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86030. directionRandomizer?: number);
  86031. /**
  86032. * Called by the particle System when the direction is computed for the created particle.
  86033. * @param worldMatrix is the world matrix of the particle system
  86034. * @param directionToUpdate is the direction vector to update with the result
  86035. * @param particle is the particle we are computed the direction for
  86036. */
  86037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86038. /**
  86039. * Called by the particle System when the position is computed for the created particle.
  86040. * @param worldMatrix is the world matrix of the particle system
  86041. * @param positionToUpdate is the position vector to update with the result
  86042. * @param particle is the particle we are computed the position for
  86043. */
  86044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86045. /**
  86046. * Clones the current emitter and returns a copy of it
  86047. * @returns the new emitter
  86048. */
  86049. clone(): ConeParticleEmitter;
  86050. /**
  86051. * Called by the GPUParticleSystem to setup the update shader
  86052. * @param effect defines the update shader
  86053. */
  86054. applyToShader(effect: Effect): void;
  86055. /**
  86056. * Returns a string to use to update the GPU particles update shader
  86057. * @returns a string containng the defines string
  86058. */
  86059. getEffectDefines(): string;
  86060. /**
  86061. * Returns the string "ConeParticleEmitter"
  86062. * @returns a string containing the class name
  86063. */
  86064. getClassName(): string;
  86065. /**
  86066. * Serializes the particle system to a JSON object.
  86067. * @returns the JSON object
  86068. */
  86069. serialize(): any;
  86070. /**
  86071. * Parse properties from a JSON object
  86072. * @param serializationObject defines the JSON object
  86073. */
  86074. parse(serializationObject: any): void;
  86075. }
  86076. }
  86077. declare module BABYLON {
  86078. /**
  86079. * Particle emitter emitting particles from the inside of a cylinder.
  86080. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86081. */
  86082. export class CylinderParticleEmitter implements IParticleEmitterType {
  86083. /**
  86084. * The radius of the emission cylinder.
  86085. */
  86086. radius: number;
  86087. /**
  86088. * The height of the emission cylinder.
  86089. */
  86090. height: number;
  86091. /**
  86092. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86093. */
  86094. radiusRange: number;
  86095. /**
  86096. * How much to randomize the particle direction [0-1].
  86097. */
  86098. directionRandomizer: number;
  86099. /**
  86100. * Creates a new instance CylinderParticleEmitter
  86101. * @param radius the radius of the emission cylinder (1 by default)
  86102. * @param height the height of the emission cylinder (1 by default)
  86103. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86104. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86105. */
  86106. constructor(
  86107. /**
  86108. * The radius of the emission cylinder.
  86109. */
  86110. radius?: number,
  86111. /**
  86112. * The height of the emission cylinder.
  86113. */
  86114. height?: number,
  86115. /**
  86116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86117. */
  86118. radiusRange?: number,
  86119. /**
  86120. * How much to randomize the particle direction [0-1].
  86121. */
  86122. directionRandomizer?: number);
  86123. /**
  86124. * Called by the particle System when the direction is computed for the created particle.
  86125. * @param worldMatrix is the world matrix of the particle system
  86126. * @param directionToUpdate is the direction vector to update with the result
  86127. * @param particle is the particle we are computed the direction for
  86128. */
  86129. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86130. /**
  86131. * Called by the particle System when the position is computed for the created particle.
  86132. * @param worldMatrix is the world matrix of the particle system
  86133. * @param positionToUpdate is the position vector to update with the result
  86134. * @param particle is the particle we are computed the position for
  86135. */
  86136. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86137. /**
  86138. * Clones the current emitter and returns a copy of it
  86139. * @returns the new emitter
  86140. */
  86141. clone(): CylinderParticleEmitter;
  86142. /**
  86143. * Called by the GPUParticleSystem to setup the update shader
  86144. * @param effect defines the update shader
  86145. */
  86146. applyToShader(effect: Effect): void;
  86147. /**
  86148. * Returns a string to use to update the GPU particles update shader
  86149. * @returns a string containng the defines string
  86150. */
  86151. getEffectDefines(): string;
  86152. /**
  86153. * Returns the string "CylinderParticleEmitter"
  86154. * @returns a string containing the class name
  86155. */
  86156. getClassName(): string;
  86157. /**
  86158. * Serializes the particle system to a JSON object.
  86159. * @returns the JSON object
  86160. */
  86161. serialize(): any;
  86162. /**
  86163. * Parse properties from a JSON object
  86164. * @param serializationObject defines the JSON object
  86165. */
  86166. parse(serializationObject: any): void;
  86167. }
  86168. /**
  86169. * Particle emitter emitting particles from the inside of a cylinder.
  86170. * It emits the particles randomly between two vectors.
  86171. */
  86172. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86173. /**
  86174. * The min limit of the emission direction.
  86175. */
  86176. direction1: Vector3;
  86177. /**
  86178. * The max limit of the emission direction.
  86179. */
  86180. direction2: Vector3;
  86181. /**
  86182. * Creates a new instance CylinderDirectedParticleEmitter
  86183. * @param radius the radius of the emission cylinder (1 by default)
  86184. * @param height the height of the emission cylinder (1 by default)
  86185. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86186. * @param direction1 the min limit of the emission direction (up vector by default)
  86187. * @param direction2 the max limit of the emission direction (up vector by default)
  86188. */
  86189. constructor(radius?: number, height?: number, radiusRange?: number,
  86190. /**
  86191. * The min limit of the emission direction.
  86192. */
  86193. direction1?: Vector3,
  86194. /**
  86195. * The max limit of the emission direction.
  86196. */
  86197. direction2?: Vector3);
  86198. /**
  86199. * Called by the particle System when the direction is computed for the created particle.
  86200. * @param worldMatrix is the world matrix of the particle system
  86201. * @param directionToUpdate is the direction vector to update with the result
  86202. * @param particle is the particle we are computed the direction for
  86203. */
  86204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86205. /**
  86206. * Clones the current emitter and returns a copy of it
  86207. * @returns the new emitter
  86208. */
  86209. clone(): CylinderDirectedParticleEmitter;
  86210. /**
  86211. * Called by the GPUParticleSystem to setup the update shader
  86212. * @param effect defines the update shader
  86213. */
  86214. applyToShader(effect: Effect): void;
  86215. /**
  86216. * Returns a string to use to update the GPU particles update shader
  86217. * @returns a string containng the defines string
  86218. */
  86219. getEffectDefines(): string;
  86220. /**
  86221. * Returns the string "CylinderDirectedParticleEmitter"
  86222. * @returns a string containing the class name
  86223. */
  86224. getClassName(): string;
  86225. /**
  86226. * Serializes the particle system to a JSON object.
  86227. * @returns the JSON object
  86228. */
  86229. serialize(): any;
  86230. /**
  86231. * Parse properties from a JSON object
  86232. * @param serializationObject defines the JSON object
  86233. */
  86234. parse(serializationObject: any): void;
  86235. }
  86236. }
  86237. declare module BABYLON {
  86238. /**
  86239. * Particle emitter emitting particles from the inside of a hemisphere.
  86240. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86241. */
  86242. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86243. /**
  86244. * The radius of the emission hemisphere.
  86245. */
  86246. radius: number;
  86247. /**
  86248. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86249. */
  86250. radiusRange: number;
  86251. /**
  86252. * How much to randomize the particle direction [0-1].
  86253. */
  86254. directionRandomizer: number;
  86255. /**
  86256. * Creates a new instance HemisphericParticleEmitter
  86257. * @param radius the radius of the emission hemisphere (1 by default)
  86258. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86259. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86260. */
  86261. constructor(
  86262. /**
  86263. * The radius of the emission hemisphere.
  86264. */
  86265. radius?: number,
  86266. /**
  86267. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86268. */
  86269. radiusRange?: number,
  86270. /**
  86271. * How much to randomize the particle direction [0-1].
  86272. */
  86273. directionRandomizer?: number);
  86274. /**
  86275. * Called by the particle System when the direction is computed for the created particle.
  86276. * @param worldMatrix is the world matrix of the particle system
  86277. * @param directionToUpdate is the direction vector to update with the result
  86278. * @param particle is the particle we are computed the direction for
  86279. */
  86280. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86281. /**
  86282. * Called by the particle System when the position is computed for the created particle.
  86283. * @param worldMatrix is the world matrix of the particle system
  86284. * @param positionToUpdate is the position vector to update with the result
  86285. * @param particle is the particle we are computed the position for
  86286. */
  86287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86288. /**
  86289. * Clones the current emitter and returns a copy of it
  86290. * @returns the new emitter
  86291. */
  86292. clone(): HemisphericParticleEmitter;
  86293. /**
  86294. * Called by the GPUParticleSystem to setup the update shader
  86295. * @param effect defines the update shader
  86296. */
  86297. applyToShader(effect: Effect): void;
  86298. /**
  86299. * Returns a string to use to update the GPU particles update shader
  86300. * @returns a string containng the defines string
  86301. */
  86302. getEffectDefines(): string;
  86303. /**
  86304. * Returns the string "HemisphericParticleEmitter"
  86305. * @returns a string containing the class name
  86306. */
  86307. getClassName(): string;
  86308. /**
  86309. * Serializes the particle system to a JSON object.
  86310. * @returns the JSON object
  86311. */
  86312. serialize(): any;
  86313. /**
  86314. * Parse properties from a JSON object
  86315. * @param serializationObject defines the JSON object
  86316. */
  86317. parse(serializationObject: any): void;
  86318. }
  86319. }
  86320. declare module BABYLON {
  86321. /**
  86322. * Particle emitter emitting particles from a point.
  86323. * It emits the particles randomly between 2 given directions.
  86324. */
  86325. export class PointParticleEmitter implements IParticleEmitterType {
  86326. /**
  86327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86328. */
  86329. direction1: Vector3;
  86330. /**
  86331. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86332. */
  86333. direction2: Vector3;
  86334. /**
  86335. * Creates a new instance PointParticleEmitter
  86336. */
  86337. constructor();
  86338. /**
  86339. * Called by the particle System when the direction is computed for the created particle.
  86340. * @param worldMatrix is the world matrix of the particle system
  86341. * @param directionToUpdate is the direction vector to update with the result
  86342. * @param particle is the particle we are computed the direction for
  86343. */
  86344. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86345. /**
  86346. * Called by the particle System when the position is computed for the created particle.
  86347. * @param worldMatrix is the world matrix of the particle system
  86348. * @param positionToUpdate is the position vector to update with the result
  86349. * @param particle is the particle we are computed the position for
  86350. */
  86351. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86352. /**
  86353. * Clones the current emitter and returns a copy of it
  86354. * @returns the new emitter
  86355. */
  86356. clone(): PointParticleEmitter;
  86357. /**
  86358. * Called by the GPUParticleSystem to setup the update shader
  86359. * @param effect defines the update shader
  86360. */
  86361. applyToShader(effect: Effect): void;
  86362. /**
  86363. * Returns a string to use to update the GPU particles update shader
  86364. * @returns a string containng the defines string
  86365. */
  86366. getEffectDefines(): string;
  86367. /**
  86368. * Returns the string "PointParticleEmitter"
  86369. * @returns a string containing the class name
  86370. */
  86371. getClassName(): string;
  86372. /**
  86373. * Serializes the particle system to a JSON object.
  86374. * @returns the JSON object
  86375. */
  86376. serialize(): any;
  86377. /**
  86378. * Parse properties from a JSON object
  86379. * @param serializationObject defines the JSON object
  86380. */
  86381. parse(serializationObject: any): void;
  86382. }
  86383. }
  86384. declare module BABYLON {
  86385. /**
  86386. * Particle emitter emitting particles from the inside of a sphere.
  86387. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86388. */
  86389. export class SphereParticleEmitter implements IParticleEmitterType {
  86390. /**
  86391. * The radius of the emission sphere.
  86392. */
  86393. radius: number;
  86394. /**
  86395. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86396. */
  86397. radiusRange: number;
  86398. /**
  86399. * How much to randomize the particle direction [0-1].
  86400. */
  86401. directionRandomizer: number;
  86402. /**
  86403. * Creates a new instance SphereParticleEmitter
  86404. * @param radius the radius of the emission sphere (1 by default)
  86405. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86406. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86407. */
  86408. constructor(
  86409. /**
  86410. * The radius of the emission sphere.
  86411. */
  86412. radius?: number,
  86413. /**
  86414. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86415. */
  86416. radiusRange?: number,
  86417. /**
  86418. * How much to randomize the particle direction [0-1].
  86419. */
  86420. directionRandomizer?: number);
  86421. /**
  86422. * Called by the particle System when the direction is computed for the created particle.
  86423. * @param worldMatrix is the world matrix of the particle system
  86424. * @param directionToUpdate is the direction vector to update with the result
  86425. * @param particle is the particle we are computed the direction for
  86426. */
  86427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86428. /**
  86429. * Called by the particle System when the position is computed for the created particle.
  86430. * @param worldMatrix is the world matrix of the particle system
  86431. * @param positionToUpdate is the position vector to update with the result
  86432. * @param particle is the particle we are computed the position for
  86433. */
  86434. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86435. /**
  86436. * Clones the current emitter and returns a copy of it
  86437. * @returns the new emitter
  86438. */
  86439. clone(): SphereParticleEmitter;
  86440. /**
  86441. * Called by the GPUParticleSystem to setup the update shader
  86442. * @param effect defines the update shader
  86443. */
  86444. applyToShader(effect: Effect): void;
  86445. /**
  86446. * Returns a string to use to update the GPU particles update shader
  86447. * @returns a string containng the defines string
  86448. */
  86449. getEffectDefines(): string;
  86450. /**
  86451. * Returns the string "SphereParticleEmitter"
  86452. * @returns a string containing the class name
  86453. */
  86454. getClassName(): string;
  86455. /**
  86456. * Serializes the particle system to a JSON object.
  86457. * @returns the JSON object
  86458. */
  86459. serialize(): any;
  86460. /**
  86461. * Parse properties from a JSON object
  86462. * @param serializationObject defines the JSON object
  86463. */
  86464. parse(serializationObject: any): void;
  86465. }
  86466. /**
  86467. * Particle emitter emitting particles from the inside of a sphere.
  86468. * It emits the particles randomly between two vectors.
  86469. */
  86470. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86471. /**
  86472. * The min limit of the emission direction.
  86473. */
  86474. direction1: Vector3;
  86475. /**
  86476. * The max limit of the emission direction.
  86477. */
  86478. direction2: Vector3;
  86479. /**
  86480. * Creates a new instance SphereDirectedParticleEmitter
  86481. * @param radius the radius of the emission sphere (1 by default)
  86482. * @param direction1 the min limit of the emission direction (up vector by default)
  86483. * @param direction2 the max limit of the emission direction (up vector by default)
  86484. */
  86485. constructor(radius?: number,
  86486. /**
  86487. * The min limit of the emission direction.
  86488. */
  86489. direction1?: Vector3,
  86490. /**
  86491. * The max limit of the emission direction.
  86492. */
  86493. direction2?: Vector3);
  86494. /**
  86495. * Called by the particle System when the direction is computed for the created particle.
  86496. * @param worldMatrix is the world matrix of the particle system
  86497. * @param directionToUpdate is the direction vector to update with the result
  86498. * @param particle is the particle we are computed the direction for
  86499. */
  86500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86501. /**
  86502. * Clones the current emitter and returns a copy of it
  86503. * @returns the new emitter
  86504. */
  86505. clone(): SphereDirectedParticleEmitter;
  86506. /**
  86507. * Called by the GPUParticleSystem to setup the update shader
  86508. * @param effect defines the update shader
  86509. */
  86510. applyToShader(effect: Effect): void;
  86511. /**
  86512. * Returns a string to use to update the GPU particles update shader
  86513. * @returns a string containng the defines string
  86514. */
  86515. getEffectDefines(): string;
  86516. /**
  86517. * Returns the string "SphereDirectedParticleEmitter"
  86518. * @returns a string containing the class name
  86519. */
  86520. getClassName(): string;
  86521. /**
  86522. * Serializes the particle system to a JSON object.
  86523. * @returns the JSON object
  86524. */
  86525. serialize(): any;
  86526. /**
  86527. * Parse properties from a JSON object
  86528. * @param serializationObject defines the JSON object
  86529. */
  86530. parse(serializationObject: any): void;
  86531. }
  86532. }
  86533. declare module BABYLON {
  86534. /**
  86535. * Interface representing a particle system in Babylon.js.
  86536. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86537. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86538. */
  86539. export interface IParticleSystem {
  86540. /**
  86541. * List of animations used by the particle system.
  86542. */
  86543. animations: Animation[];
  86544. /**
  86545. * The id of the Particle system.
  86546. */
  86547. id: string;
  86548. /**
  86549. * The name of the Particle system.
  86550. */
  86551. name: string;
  86552. /**
  86553. * The emitter represents the Mesh or position we are attaching the particle system to.
  86554. */
  86555. emitter: Nullable<AbstractMesh | Vector3>;
  86556. /**
  86557. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86558. */
  86559. isBillboardBased: boolean;
  86560. /**
  86561. * The rendering group used by the Particle system to chose when to render.
  86562. */
  86563. renderingGroupId: number;
  86564. /**
  86565. * The layer mask we are rendering the particles through.
  86566. */
  86567. layerMask: number;
  86568. /**
  86569. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86570. */
  86571. updateSpeed: number;
  86572. /**
  86573. * The amount of time the particle system is running (depends of the overall update speed).
  86574. */
  86575. targetStopDuration: number;
  86576. /**
  86577. * The texture used to render each particle. (this can be a spritesheet)
  86578. */
  86579. particleTexture: Nullable<Texture>;
  86580. /**
  86581. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86582. */
  86583. blendMode: number;
  86584. /**
  86585. * Minimum life time of emitting particles.
  86586. */
  86587. minLifeTime: number;
  86588. /**
  86589. * Maximum life time of emitting particles.
  86590. */
  86591. maxLifeTime: number;
  86592. /**
  86593. * Minimum Size of emitting particles.
  86594. */
  86595. minSize: number;
  86596. /**
  86597. * Maximum Size of emitting particles.
  86598. */
  86599. maxSize: number;
  86600. /**
  86601. * Minimum scale of emitting particles on X axis.
  86602. */
  86603. minScaleX: number;
  86604. /**
  86605. * Maximum scale of emitting particles on X axis.
  86606. */
  86607. maxScaleX: number;
  86608. /**
  86609. * Minimum scale of emitting particles on Y axis.
  86610. */
  86611. minScaleY: number;
  86612. /**
  86613. * Maximum scale of emitting particles on Y axis.
  86614. */
  86615. maxScaleY: number;
  86616. /**
  86617. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86618. */
  86619. color1: Color4;
  86620. /**
  86621. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86622. */
  86623. color2: Color4;
  86624. /**
  86625. * Color the particle will have at the end of its lifetime.
  86626. */
  86627. colorDead: Color4;
  86628. /**
  86629. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86630. */
  86631. emitRate: number;
  86632. /**
  86633. * You can use gravity if you want to give an orientation to your particles.
  86634. */
  86635. gravity: Vector3;
  86636. /**
  86637. * Minimum power of emitting particles.
  86638. */
  86639. minEmitPower: number;
  86640. /**
  86641. * Maximum power of emitting particles.
  86642. */
  86643. maxEmitPower: number;
  86644. /**
  86645. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86646. */
  86647. minAngularSpeed: number;
  86648. /**
  86649. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86650. */
  86651. maxAngularSpeed: number;
  86652. /**
  86653. * Gets or sets the minimal initial rotation in radians.
  86654. */
  86655. minInitialRotation: number;
  86656. /**
  86657. * Gets or sets the maximal initial rotation in radians.
  86658. */
  86659. maxInitialRotation: number;
  86660. /**
  86661. * The particle emitter type defines the emitter used by the particle system.
  86662. * It can be for example box, sphere, or cone...
  86663. */
  86664. particleEmitterType: Nullable<IParticleEmitterType>;
  86665. /**
  86666. * Defines the delay in milliseconds before starting the system (0 by default)
  86667. */
  86668. startDelay: number;
  86669. /**
  86670. * 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
  86671. */
  86672. preWarmCycles: number;
  86673. /**
  86674. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86675. */
  86676. preWarmStepOffset: number;
  86677. /**
  86678. * 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)
  86679. */
  86680. spriteCellChangeSpeed: number;
  86681. /**
  86682. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86683. */
  86684. startSpriteCellID: number;
  86685. /**
  86686. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86687. */
  86688. endSpriteCellID: number;
  86689. /**
  86690. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86691. */
  86692. spriteCellWidth: number;
  86693. /**
  86694. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86695. */
  86696. spriteCellHeight: number;
  86697. /**
  86698. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86699. */
  86700. spriteRandomStartCell: boolean;
  86701. /**
  86702. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86703. */
  86704. isAnimationSheetEnabled: boolean;
  86705. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86706. translationPivot: Vector2;
  86707. /**
  86708. * Gets or sets a texture used to add random noise to particle positions
  86709. */
  86710. noiseTexture: Nullable<BaseTexture>;
  86711. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86712. noiseStrength: Vector3;
  86713. /**
  86714. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86715. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86716. */
  86717. billboardMode: number;
  86718. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86719. limitVelocityDamping: number;
  86720. /**
  86721. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86722. */
  86723. beginAnimationOnStart: boolean;
  86724. /**
  86725. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86726. */
  86727. beginAnimationFrom: number;
  86728. /**
  86729. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86730. */
  86731. beginAnimationTo: number;
  86732. /**
  86733. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86734. */
  86735. beginAnimationLoop: boolean;
  86736. /**
  86737. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86738. */
  86739. disposeOnStop: boolean;
  86740. /**
  86741. * Gets the maximum number of particles active at the same time.
  86742. * @returns The max number of active particles.
  86743. */
  86744. getCapacity(): number;
  86745. /**
  86746. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86747. * @returns True if it has been started, otherwise false.
  86748. */
  86749. isStarted(): boolean;
  86750. /**
  86751. * Animates the particle system for this frame.
  86752. */
  86753. animate(): void;
  86754. /**
  86755. * Renders the particle system in its current state.
  86756. * @returns the current number of particles
  86757. */
  86758. render(): number;
  86759. /**
  86760. * Dispose the particle system and frees its associated resources.
  86761. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86762. */
  86763. dispose(disposeTexture?: boolean): void;
  86764. /**
  86765. * Clones the particle system.
  86766. * @param name The name of the cloned object
  86767. * @param newEmitter The new emitter to use
  86768. * @returns the cloned particle system
  86769. */
  86770. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86771. /**
  86772. * Serializes the particle system to a JSON object.
  86773. * @returns the JSON object
  86774. */
  86775. serialize(): any;
  86776. /**
  86777. * Rebuild the particle system
  86778. */
  86779. rebuild(): void;
  86780. /**
  86781. * Starts the particle system and begins to emit
  86782. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86783. */
  86784. start(delay?: number): void;
  86785. /**
  86786. * Stops the particle system.
  86787. */
  86788. stop(): void;
  86789. /**
  86790. * Remove all active particles
  86791. */
  86792. reset(): void;
  86793. /**
  86794. * Is this system ready to be used/rendered
  86795. * @return true if the system is ready
  86796. */
  86797. isReady(): boolean;
  86798. /**
  86799. * Adds a new color gradient
  86800. * @param gradient defines the gradient to use (between 0 and 1)
  86801. * @param color1 defines the color to affect to the specified gradient
  86802. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86803. * @returns the current particle system
  86804. */
  86805. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86806. /**
  86807. * Remove a specific color gradient
  86808. * @param gradient defines the gradient to remove
  86809. * @returns the current particle system
  86810. */
  86811. removeColorGradient(gradient: number): IParticleSystem;
  86812. /**
  86813. * Adds a new size gradient
  86814. * @param gradient defines the gradient to use (between 0 and 1)
  86815. * @param factor defines the size factor to affect to the specified gradient
  86816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86817. * @returns the current particle system
  86818. */
  86819. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86820. /**
  86821. * Remove a specific size gradient
  86822. * @param gradient defines the gradient to remove
  86823. * @returns the current particle system
  86824. */
  86825. removeSizeGradient(gradient: number): IParticleSystem;
  86826. /**
  86827. * Gets the current list of color gradients.
  86828. * You must use addColorGradient and removeColorGradient to udpate this list
  86829. * @returns the list of color gradients
  86830. */
  86831. getColorGradients(): Nullable<Array<ColorGradient>>;
  86832. /**
  86833. * Gets the current list of size gradients.
  86834. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86835. * @returns the list of size gradients
  86836. */
  86837. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86838. /**
  86839. * Gets the current list of angular speed gradients.
  86840. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86841. * @returns the list of angular speed gradients
  86842. */
  86843. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86844. /**
  86845. * Adds a new angular speed gradient
  86846. * @param gradient defines the gradient to use (between 0 and 1)
  86847. * @param factor defines the angular speed to affect to the specified gradient
  86848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86849. * @returns the current particle system
  86850. */
  86851. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86852. /**
  86853. * Remove a specific angular speed gradient
  86854. * @param gradient defines the gradient to remove
  86855. * @returns the current particle system
  86856. */
  86857. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86858. /**
  86859. * Gets the current list of velocity gradients.
  86860. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86861. * @returns the list of velocity gradients
  86862. */
  86863. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86864. /**
  86865. * Adds a new velocity gradient
  86866. * @param gradient defines the gradient to use (between 0 and 1)
  86867. * @param factor defines the velocity to affect to the specified gradient
  86868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86869. * @returns the current particle system
  86870. */
  86871. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86872. /**
  86873. * Remove a specific velocity gradient
  86874. * @param gradient defines the gradient to remove
  86875. * @returns the current particle system
  86876. */
  86877. removeVelocityGradient(gradient: number): IParticleSystem;
  86878. /**
  86879. * Gets the current list of limit velocity gradients.
  86880. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86881. * @returns the list of limit velocity gradients
  86882. */
  86883. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86884. /**
  86885. * Adds a new limit velocity gradient
  86886. * @param gradient defines the gradient to use (between 0 and 1)
  86887. * @param factor defines the limit velocity to affect to the specified gradient
  86888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86889. * @returns the current particle system
  86890. */
  86891. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86892. /**
  86893. * Remove a specific limit velocity gradient
  86894. * @param gradient defines the gradient to remove
  86895. * @returns the current particle system
  86896. */
  86897. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86898. /**
  86899. * Adds a new drag gradient
  86900. * @param gradient defines the gradient to use (between 0 and 1)
  86901. * @param factor defines the drag to affect to the specified gradient
  86902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86903. * @returns the current particle system
  86904. */
  86905. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86906. /**
  86907. * Remove a specific drag gradient
  86908. * @param gradient defines the gradient to remove
  86909. * @returns the current particle system
  86910. */
  86911. removeDragGradient(gradient: number): IParticleSystem;
  86912. /**
  86913. * Gets the current list of drag gradients.
  86914. * You must use addDragGradient and removeDragGradient to udpate this list
  86915. * @returns the list of drag gradients
  86916. */
  86917. getDragGradients(): Nullable<Array<FactorGradient>>;
  86918. /**
  86919. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86920. * @param gradient defines the gradient to use (between 0 and 1)
  86921. * @param factor defines the emit rate to affect to the specified gradient
  86922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86923. * @returns the current particle system
  86924. */
  86925. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86926. /**
  86927. * Remove a specific emit rate gradient
  86928. * @param gradient defines the gradient to remove
  86929. * @returns the current particle system
  86930. */
  86931. removeEmitRateGradient(gradient: number): IParticleSystem;
  86932. /**
  86933. * Gets the current list of emit rate gradients.
  86934. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86935. * @returns the list of emit rate gradients
  86936. */
  86937. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86938. /**
  86939. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86940. * @param gradient defines the gradient to use (between 0 and 1)
  86941. * @param factor defines the start size to affect to the specified gradient
  86942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86943. * @returns the current particle system
  86944. */
  86945. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86946. /**
  86947. * Remove a specific start size gradient
  86948. * @param gradient defines the gradient to remove
  86949. * @returns the current particle system
  86950. */
  86951. removeStartSizeGradient(gradient: number): IParticleSystem;
  86952. /**
  86953. * Gets the current list of start size gradients.
  86954. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86955. * @returns the list of start size gradients
  86956. */
  86957. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86958. /**
  86959. * Adds a new life time gradient
  86960. * @param gradient defines the gradient to use (between 0 and 1)
  86961. * @param factor defines the life time factor to affect to the specified gradient
  86962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86963. * @returns the current particle system
  86964. */
  86965. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86966. /**
  86967. * Remove a specific life time gradient
  86968. * @param gradient defines the gradient to remove
  86969. * @returns the current particle system
  86970. */
  86971. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86972. /**
  86973. * Gets the current list of life time gradients.
  86974. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86975. * @returns the list of life time gradients
  86976. */
  86977. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86978. /**
  86979. * Gets the current list of color gradients.
  86980. * You must use addColorGradient and removeColorGradient to udpate this list
  86981. * @returns the list of color gradients
  86982. */
  86983. getColorGradients(): Nullable<Array<ColorGradient>>;
  86984. /**
  86985. * Adds a new ramp gradient used to remap particle colors
  86986. * @param gradient defines the gradient to use (between 0 and 1)
  86987. * @param color defines the color to affect to the specified gradient
  86988. * @returns the current particle system
  86989. */
  86990. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86991. /**
  86992. * Gets the current list of ramp gradients.
  86993. * You must use addRampGradient and removeRampGradient to udpate this list
  86994. * @returns the list of ramp gradients
  86995. */
  86996. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86997. /** Gets or sets a boolean indicating that ramp gradients must be used
  86998. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86999. */
  87000. useRampGradients: boolean;
  87001. /**
  87002. * Adds a new color remap gradient
  87003. * @param gradient defines the gradient to use (between 0 and 1)
  87004. * @param min defines the color remap minimal range
  87005. * @param max defines the color remap maximal range
  87006. * @returns the current particle system
  87007. */
  87008. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87009. /**
  87010. * Gets the current list of color remap gradients.
  87011. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87012. * @returns the list of color remap gradients
  87013. */
  87014. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87015. /**
  87016. * Adds a new alpha remap gradient
  87017. * @param gradient defines the gradient to use (between 0 and 1)
  87018. * @param min defines the alpha remap minimal range
  87019. * @param max defines the alpha remap maximal range
  87020. * @returns the current particle system
  87021. */
  87022. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87023. /**
  87024. * Gets the current list of alpha remap gradients.
  87025. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87026. * @returns the list of alpha remap gradients
  87027. */
  87028. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87029. /**
  87030. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87031. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87032. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87033. * @returns the emitter
  87034. */
  87035. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87036. /**
  87037. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87038. * @param radius The radius of the hemisphere to emit from
  87039. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87040. * @returns the emitter
  87041. */
  87042. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87043. /**
  87044. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87045. * @param radius The radius of the sphere to emit from
  87046. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87047. * @returns the emitter
  87048. */
  87049. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87050. /**
  87051. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87052. * @param radius The radius of the sphere to emit from
  87053. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87054. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87055. * @returns the emitter
  87056. */
  87057. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87058. /**
  87059. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87060. * @param radius The radius of the emission cylinder
  87061. * @param height The height of the emission cylinder
  87062. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87063. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87064. * @returns the emitter
  87065. */
  87066. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87067. /**
  87068. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87069. * @param radius The radius of the cylinder to emit from
  87070. * @param height The height of the emission cylinder
  87071. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87072. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87073. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87074. * @returns the emitter
  87075. */
  87076. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87077. /**
  87078. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87079. * @param radius The radius of the cone to emit from
  87080. * @param angle The base angle of the cone
  87081. * @returns the emitter
  87082. */
  87083. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87084. /**
  87085. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87086. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87087. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87088. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87089. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87090. * @returns the emitter
  87091. */
  87092. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87093. /**
  87094. * Get hosting scene
  87095. * @returns the scene
  87096. */
  87097. getScene(): Scene;
  87098. }
  87099. }
  87100. declare module BABYLON {
  87101. /**
  87102. * Creates an instance based on a source mesh.
  87103. */
  87104. export class InstancedMesh extends AbstractMesh {
  87105. private _sourceMesh;
  87106. private _currentLOD;
  87107. /** @hidden */
  87108. _indexInSourceMeshInstanceArray: number;
  87109. constructor(name: string, source: Mesh);
  87110. /**
  87111. * Returns the string "InstancedMesh".
  87112. */
  87113. getClassName(): string;
  87114. /** Gets the list of lights affecting that mesh */
  87115. readonly lightSources: Light[];
  87116. _resyncLightSources(): void;
  87117. _resyncLighSource(light: Light): void;
  87118. _removeLightSource(light: Light, dispose: boolean): void;
  87119. /**
  87120. * If the source mesh receives shadows
  87121. */
  87122. readonly receiveShadows: boolean;
  87123. /**
  87124. * The material of the source mesh
  87125. */
  87126. readonly material: Nullable<Material>;
  87127. /**
  87128. * Visibility of the source mesh
  87129. */
  87130. readonly visibility: number;
  87131. /**
  87132. * Skeleton of the source mesh
  87133. */
  87134. readonly skeleton: Nullable<Skeleton>;
  87135. /**
  87136. * Rendering ground id of the source mesh
  87137. */
  87138. renderingGroupId: number;
  87139. /**
  87140. * Returns the total number of vertices (integer).
  87141. */
  87142. getTotalVertices(): number;
  87143. /**
  87144. * Returns a positive integer : the total number of indices in this mesh geometry.
  87145. * @returns the numner of indices or zero if the mesh has no geometry.
  87146. */
  87147. getTotalIndices(): number;
  87148. /**
  87149. * The source mesh of the instance
  87150. */
  87151. readonly sourceMesh: Mesh;
  87152. /**
  87153. * Is this node ready to be used/rendered
  87154. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87155. * @return {boolean} is it ready
  87156. */
  87157. isReady(completeCheck?: boolean): boolean;
  87158. /**
  87159. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87160. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87161. * @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.
  87162. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87163. */
  87164. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87165. /**
  87166. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87167. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87168. * The `data` are either a numeric array either a Float32Array.
  87169. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87170. * 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).
  87171. * Note that a new underlying VertexBuffer object is created each call.
  87172. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87173. *
  87174. * Possible `kind` values :
  87175. * - VertexBuffer.PositionKind
  87176. * - VertexBuffer.UVKind
  87177. * - VertexBuffer.UV2Kind
  87178. * - VertexBuffer.UV3Kind
  87179. * - VertexBuffer.UV4Kind
  87180. * - VertexBuffer.UV5Kind
  87181. * - VertexBuffer.UV6Kind
  87182. * - VertexBuffer.ColorKind
  87183. * - VertexBuffer.MatricesIndicesKind
  87184. * - VertexBuffer.MatricesIndicesExtraKind
  87185. * - VertexBuffer.MatricesWeightsKind
  87186. * - VertexBuffer.MatricesWeightsExtraKind
  87187. *
  87188. * Returns the Mesh.
  87189. */
  87190. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87191. /**
  87192. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87193. * If the mesh has no geometry, it is simply returned as it is.
  87194. * The `data` are either a numeric array either a Float32Array.
  87195. * No new underlying VertexBuffer object is created.
  87196. * 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.
  87197. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87198. *
  87199. * Possible `kind` values :
  87200. * - VertexBuffer.PositionKind
  87201. * - VertexBuffer.UVKind
  87202. * - VertexBuffer.UV2Kind
  87203. * - VertexBuffer.UV3Kind
  87204. * - VertexBuffer.UV4Kind
  87205. * - VertexBuffer.UV5Kind
  87206. * - VertexBuffer.UV6Kind
  87207. * - VertexBuffer.ColorKind
  87208. * - VertexBuffer.MatricesIndicesKind
  87209. * - VertexBuffer.MatricesIndicesExtraKind
  87210. * - VertexBuffer.MatricesWeightsKind
  87211. * - VertexBuffer.MatricesWeightsExtraKind
  87212. *
  87213. * Returns the Mesh.
  87214. */
  87215. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87216. /**
  87217. * Sets the mesh indices.
  87218. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87219. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87220. * This method creates a new index buffer each call.
  87221. * Returns the Mesh.
  87222. */
  87223. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87224. /**
  87225. * Boolean : True if the mesh owns the requested kind of data.
  87226. */
  87227. isVerticesDataPresent(kind: string): boolean;
  87228. /**
  87229. * Returns an array of indices (IndicesArray).
  87230. */
  87231. getIndices(): Nullable<IndicesArray>;
  87232. readonly _positions: Nullable<Vector3[]>;
  87233. /**
  87234. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87235. * This means the mesh underlying bounding box and sphere are recomputed.
  87236. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87237. * @returns the current mesh
  87238. */
  87239. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87240. /** @hidden */
  87241. _preActivate(): InstancedMesh;
  87242. /** @hidden */
  87243. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87244. /** @hidden */
  87245. _postActivate(): void;
  87246. getWorldMatrix(): Matrix;
  87247. readonly isAnInstance: boolean;
  87248. /**
  87249. * Returns the current associated LOD AbstractMesh.
  87250. */
  87251. getLOD(camera: Camera): AbstractMesh;
  87252. /** @hidden */
  87253. _syncSubMeshes(): InstancedMesh;
  87254. /** @hidden */
  87255. _generatePointsArray(): boolean;
  87256. /**
  87257. * Creates a new InstancedMesh from the current mesh.
  87258. * - name (string) : the cloned mesh name
  87259. * - newParent (optional Node) : the optional Node to parent the clone to.
  87260. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87261. *
  87262. * Returns the clone.
  87263. */
  87264. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87265. /**
  87266. * Disposes the InstancedMesh.
  87267. * Returns nothing.
  87268. */
  87269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87270. }
  87271. interface Mesh {
  87272. /**
  87273. * Register a custom buffer that will be instanced
  87274. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87275. * @param kind defines the buffer kind
  87276. * @param stride defines the stride in floats
  87277. */
  87278. registerInstancedBuffer(kind: string, stride: number): void;
  87279. /** @hidden */
  87280. _userInstancedBuffersStorage: {
  87281. data: {
  87282. [key: string]: Float32Array;
  87283. };
  87284. sizes: {
  87285. [key: string]: number;
  87286. };
  87287. vertexBuffers: {
  87288. [key: string]: Nullable<VertexBuffer>;
  87289. };
  87290. strides: {
  87291. [key: string]: number;
  87292. };
  87293. };
  87294. }
  87295. interface AbstractMesh {
  87296. /**
  87297. * Object used to store instanced buffers defined by user
  87298. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87299. */
  87300. instancedBuffers: {
  87301. [key: string]: any;
  87302. };
  87303. }
  87304. }
  87305. declare module BABYLON {
  87306. /**
  87307. * Defines the options associated with the creation of a shader material.
  87308. */
  87309. export interface IShaderMaterialOptions {
  87310. /**
  87311. * Does the material work in alpha blend mode
  87312. */
  87313. needAlphaBlending: boolean;
  87314. /**
  87315. * Does the material work in alpha test mode
  87316. */
  87317. needAlphaTesting: boolean;
  87318. /**
  87319. * The list of attribute names used in the shader
  87320. */
  87321. attributes: string[];
  87322. /**
  87323. * The list of unifrom names used in the shader
  87324. */
  87325. uniforms: string[];
  87326. /**
  87327. * The list of UBO names used in the shader
  87328. */
  87329. uniformBuffers: string[];
  87330. /**
  87331. * The list of sampler names used in the shader
  87332. */
  87333. samplers: string[];
  87334. /**
  87335. * The list of defines used in the shader
  87336. */
  87337. defines: string[];
  87338. }
  87339. /**
  87340. * 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.
  87341. *
  87342. * This returned material effects how the mesh will look based on the code in the shaders.
  87343. *
  87344. * @see http://doc.babylonjs.com/how_to/shader_material
  87345. */
  87346. export class ShaderMaterial extends Material {
  87347. private _shaderPath;
  87348. private _options;
  87349. private _textures;
  87350. private _textureArrays;
  87351. private _floats;
  87352. private _ints;
  87353. private _floatsArrays;
  87354. private _colors3;
  87355. private _colors3Arrays;
  87356. private _colors4;
  87357. private _colors4Arrays;
  87358. private _vectors2;
  87359. private _vectors3;
  87360. private _vectors4;
  87361. private _matrices;
  87362. private _matrixArrays;
  87363. private _matrices3x3;
  87364. private _matrices2x2;
  87365. private _vectors2Arrays;
  87366. private _vectors3Arrays;
  87367. private _vectors4Arrays;
  87368. private _cachedWorldViewMatrix;
  87369. private _cachedWorldViewProjectionMatrix;
  87370. private _renderId;
  87371. /**
  87372. * Instantiate a new shader material.
  87373. * 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.
  87374. * This returned material effects how the mesh will look based on the code in the shaders.
  87375. * @see http://doc.babylonjs.com/how_to/shader_material
  87376. * @param name Define the name of the material in the scene
  87377. * @param scene Define the scene the material belongs to
  87378. * @param shaderPath Defines the route to the shader code in one of three ways:
  87379. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87380. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87381. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87382. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87383. * @param options Define the options used to create the shader
  87384. */
  87385. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87386. /**
  87387. * Gets the shader path used to define the shader code
  87388. * It can be modified to trigger a new compilation
  87389. */
  87390. /**
  87391. * Sets the shader path used to define the shader code
  87392. * It can be modified to trigger a new compilation
  87393. */
  87394. shaderPath: any;
  87395. /**
  87396. * Gets the options used to compile the shader.
  87397. * They can be modified to trigger a new compilation
  87398. */
  87399. readonly options: IShaderMaterialOptions;
  87400. /**
  87401. * Gets the current class name of the material e.g. "ShaderMaterial"
  87402. * Mainly use in serialization.
  87403. * @returns the class name
  87404. */
  87405. getClassName(): string;
  87406. /**
  87407. * Specifies if the material will require alpha blending
  87408. * @returns a boolean specifying if alpha blending is needed
  87409. */
  87410. needAlphaBlending(): boolean;
  87411. /**
  87412. * Specifies if this material should be rendered in alpha test mode
  87413. * @returns a boolean specifying if an alpha test is needed.
  87414. */
  87415. needAlphaTesting(): boolean;
  87416. private _checkUniform;
  87417. /**
  87418. * Set a texture in the shader.
  87419. * @param name Define the name of the uniform samplers as defined in the shader
  87420. * @param texture Define the texture to bind to this sampler
  87421. * @return the material itself allowing "fluent" like uniform updates
  87422. */
  87423. setTexture(name: string, texture: Texture): ShaderMaterial;
  87424. /**
  87425. * Set a texture array in the shader.
  87426. * @param name Define the name of the uniform sampler array as defined in the shader
  87427. * @param textures Define the list of textures to bind to this sampler
  87428. * @return the material itself allowing "fluent" like uniform updates
  87429. */
  87430. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87431. /**
  87432. * Set a float in the shader.
  87433. * @param name Define the name of the uniform as defined in the shader
  87434. * @param value Define the value to give to the uniform
  87435. * @return the material itself allowing "fluent" like uniform updates
  87436. */
  87437. setFloat(name: string, value: number): ShaderMaterial;
  87438. /**
  87439. * Set a int in the shader.
  87440. * @param name Define the name of the uniform as defined in the shader
  87441. * @param value Define the value to give to the uniform
  87442. * @return the material itself allowing "fluent" like uniform updates
  87443. */
  87444. setInt(name: string, value: number): ShaderMaterial;
  87445. /**
  87446. * Set an array of floats in the shader.
  87447. * @param name Define the name of the uniform as defined in the shader
  87448. * @param value Define the value to give to the uniform
  87449. * @return the material itself allowing "fluent" like uniform updates
  87450. */
  87451. setFloats(name: string, value: number[]): ShaderMaterial;
  87452. /**
  87453. * Set a vec3 in the shader from a Color3.
  87454. * @param name Define the name of the uniform as defined in the shader
  87455. * @param value Define the value to give to the uniform
  87456. * @return the material itself allowing "fluent" like uniform updates
  87457. */
  87458. setColor3(name: string, value: Color3): ShaderMaterial;
  87459. /**
  87460. * Set a vec3 array in the shader from a Color3 array.
  87461. * @param name Define the name of the uniform as defined in the shader
  87462. * @param value Define the value to give to the uniform
  87463. * @return the material itself allowing "fluent" like uniform updates
  87464. */
  87465. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87466. /**
  87467. * Set a vec4 in the shader from a Color4.
  87468. * @param name Define the name of the uniform as defined in the shader
  87469. * @param value Define the value to give to the uniform
  87470. * @return the material itself allowing "fluent" like uniform updates
  87471. */
  87472. setColor4(name: string, value: Color4): ShaderMaterial;
  87473. /**
  87474. * Set a vec4 array in the shader from a Color4 array.
  87475. * @param name Define the name of the uniform as defined in the shader
  87476. * @param value Define the value to give to the uniform
  87477. * @return the material itself allowing "fluent" like uniform updates
  87478. */
  87479. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87480. /**
  87481. * Set a vec2 in the shader from a Vector2.
  87482. * @param name Define the name of the uniform as defined in the shader
  87483. * @param value Define the value to give to the uniform
  87484. * @return the material itself allowing "fluent" like uniform updates
  87485. */
  87486. setVector2(name: string, value: Vector2): ShaderMaterial;
  87487. /**
  87488. * Set a vec3 in the shader from a Vector3.
  87489. * @param name Define the name of the uniform as defined in the shader
  87490. * @param value Define the value to give to the uniform
  87491. * @return the material itself allowing "fluent" like uniform updates
  87492. */
  87493. setVector3(name: string, value: Vector3): ShaderMaterial;
  87494. /**
  87495. * Set a vec4 in the shader from a Vector4.
  87496. * @param name Define the name of the uniform as defined in the shader
  87497. * @param value Define the value to give to the uniform
  87498. * @return the material itself allowing "fluent" like uniform updates
  87499. */
  87500. setVector4(name: string, value: Vector4): ShaderMaterial;
  87501. /**
  87502. * Set a mat4 in the shader from a Matrix.
  87503. * @param name Define the name of the uniform as defined in the shader
  87504. * @param value Define the value to give to the uniform
  87505. * @return the material itself allowing "fluent" like uniform updates
  87506. */
  87507. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87508. /**
  87509. * Set a float32Array in the shader from a matrix array.
  87510. * @param name Define the name of the uniform as defined in the shader
  87511. * @param value Define the value to give to the uniform
  87512. * @return the material itself allowing "fluent" like uniform updates
  87513. */
  87514. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87515. /**
  87516. * Set a mat3 in the shader from a Float32Array.
  87517. * @param name Define the name of the uniform as defined in the shader
  87518. * @param value Define the value to give to the uniform
  87519. * @return the material itself allowing "fluent" like uniform updates
  87520. */
  87521. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87522. /**
  87523. * Set a mat2 in the shader from a Float32Array.
  87524. * @param name Define the name of the uniform as defined in the shader
  87525. * @param value Define the value to give to the uniform
  87526. * @return the material itself allowing "fluent" like uniform updates
  87527. */
  87528. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87529. /**
  87530. * Set a vec2 array in the shader from a number array.
  87531. * @param name Define the name of the uniform as defined in the shader
  87532. * @param value Define the value to give to the uniform
  87533. * @return the material itself allowing "fluent" like uniform updates
  87534. */
  87535. setArray2(name: string, value: number[]): ShaderMaterial;
  87536. /**
  87537. * Set a vec3 array in the shader from a number array.
  87538. * @param name Define the name of the uniform as defined in the shader
  87539. * @param value Define the value to give to the uniform
  87540. * @return the material itself allowing "fluent" like uniform updates
  87541. */
  87542. setArray3(name: string, value: number[]): ShaderMaterial;
  87543. /**
  87544. * Set a vec4 array in the shader from a number array.
  87545. * @param name Define the name of the uniform as defined in the shader
  87546. * @param value Define the value to give to the uniform
  87547. * @return the material itself allowing "fluent" like uniform updates
  87548. */
  87549. setArray4(name: string, value: number[]): ShaderMaterial;
  87550. private _checkCache;
  87551. /**
  87552. * Specifies that the submesh is ready to be used
  87553. * @param mesh defines the mesh to check
  87554. * @param subMesh defines which submesh to check
  87555. * @param useInstances specifies that instances should be used
  87556. * @returns a boolean indicating that the submesh is ready or not
  87557. */
  87558. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87559. /**
  87560. * Checks if the material is ready to render the requested mesh
  87561. * @param mesh Define the mesh to render
  87562. * @param useInstances Define whether or not the material is used with instances
  87563. * @returns true if ready, otherwise false
  87564. */
  87565. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87566. /**
  87567. * Binds the world matrix to the material
  87568. * @param world defines the world transformation matrix
  87569. */
  87570. bindOnlyWorldMatrix(world: Matrix): void;
  87571. /**
  87572. * Binds the material to the mesh
  87573. * @param world defines the world transformation matrix
  87574. * @param mesh defines the mesh to bind the material to
  87575. */
  87576. bind(world: Matrix, mesh?: Mesh): void;
  87577. /**
  87578. * Gets the active textures from the material
  87579. * @returns an array of textures
  87580. */
  87581. getActiveTextures(): BaseTexture[];
  87582. /**
  87583. * Specifies if the material uses a texture
  87584. * @param texture defines the texture to check against the material
  87585. * @returns a boolean specifying if the material uses the texture
  87586. */
  87587. hasTexture(texture: BaseTexture): boolean;
  87588. /**
  87589. * Makes a duplicate of the material, and gives it a new name
  87590. * @param name defines the new name for the duplicated material
  87591. * @returns the cloned material
  87592. */
  87593. clone(name: string): ShaderMaterial;
  87594. /**
  87595. * Disposes the material
  87596. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87597. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87598. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87599. */
  87600. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87601. /**
  87602. * Serializes this material in a JSON representation
  87603. * @returns the serialized material object
  87604. */
  87605. serialize(): any;
  87606. /**
  87607. * Creates a shader material from parsed shader material data
  87608. * @param source defines the JSON represnetation of the material
  87609. * @param scene defines the hosting scene
  87610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87611. * @returns a new material
  87612. */
  87613. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87614. }
  87615. }
  87616. declare module BABYLON {
  87617. /** @hidden */
  87618. export var colorPixelShader: {
  87619. name: string;
  87620. shader: string;
  87621. };
  87622. }
  87623. declare module BABYLON {
  87624. /** @hidden */
  87625. export var colorVertexShader: {
  87626. name: string;
  87627. shader: string;
  87628. };
  87629. }
  87630. declare module BABYLON {
  87631. /**
  87632. * Line mesh
  87633. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87634. */
  87635. export class LinesMesh extends Mesh {
  87636. /**
  87637. * If vertex color should be applied to the mesh
  87638. */
  87639. readonly useVertexColor?: boolean | undefined;
  87640. /**
  87641. * If vertex alpha should be applied to the mesh
  87642. */
  87643. readonly useVertexAlpha?: boolean | undefined;
  87644. /**
  87645. * Color of the line (Default: White)
  87646. */
  87647. color: Color3;
  87648. /**
  87649. * Alpha of the line (Default: 1)
  87650. */
  87651. alpha: number;
  87652. /**
  87653. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87654. * This margin is expressed in world space coordinates, so its value may vary.
  87655. * Default value is 0.1
  87656. */
  87657. intersectionThreshold: number;
  87658. private _colorShader;
  87659. private color4;
  87660. /**
  87661. * Creates a new LinesMesh
  87662. * @param name defines the name
  87663. * @param scene defines the hosting scene
  87664. * @param parent defines the parent mesh if any
  87665. * @param source defines the optional source LinesMesh used to clone data from
  87666. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87667. * When false, achieved by calling a clone(), also passing False.
  87668. * This will make creation of children, recursive.
  87669. * @param useVertexColor defines if this LinesMesh supports vertex color
  87670. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87671. */
  87672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87673. /**
  87674. * If vertex color should be applied to the mesh
  87675. */
  87676. useVertexColor?: boolean | undefined,
  87677. /**
  87678. * If vertex alpha should be applied to the mesh
  87679. */
  87680. useVertexAlpha?: boolean | undefined);
  87681. private _addClipPlaneDefine;
  87682. private _removeClipPlaneDefine;
  87683. isReady(): boolean;
  87684. /**
  87685. * Returns the string "LineMesh"
  87686. */
  87687. getClassName(): string;
  87688. /**
  87689. * @hidden
  87690. */
  87691. /**
  87692. * @hidden
  87693. */
  87694. material: Material;
  87695. /**
  87696. * @hidden
  87697. */
  87698. readonly checkCollisions: boolean;
  87699. /** @hidden */
  87700. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87701. /** @hidden */
  87702. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87703. /**
  87704. * Disposes of the line mesh
  87705. * @param doNotRecurse If children should be disposed
  87706. */
  87707. dispose(doNotRecurse?: boolean): void;
  87708. /**
  87709. * Returns a new LineMesh object cloned from the current one.
  87710. */
  87711. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87712. /**
  87713. * Creates a new InstancedLinesMesh object from the mesh model.
  87714. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87715. * @param name defines the name of the new instance
  87716. * @returns a new InstancedLinesMesh
  87717. */
  87718. createInstance(name: string): InstancedLinesMesh;
  87719. }
  87720. /**
  87721. * Creates an instance based on a source LinesMesh
  87722. */
  87723. export class InstancedLinesMesh extends InstancedMesh {
  87724. /**
  87725. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87726. * This margin is expressed in world space coordinates, so its value may vary.
  87727. * Initilized with the intersectionThreshold value of the source LinesMesh
  87728. */
  87729. intersectionThreshold: number;
  87730. constructor(name: string, source: LinesMesh);
  87731. /**
  87732. * Returns the string "InstancedLinesMesh".
  87733. */
  87734. getClassName(): string;
  87735. }
  87736. }
  87737. declare module BABYLON {
  87738. /** @hidden */
  87739. export var linePixelShader: {
  87740. name: string;
  87741. shader: string;
  87742. };
  87743. }
  87744. declare module BABYLON {
  87745. /** @hidden */
  87746. export var lineVertexShader: {
  87747. name: string;
  87748. shader: string;
  87749. };
  87750. }
  87751. declare module BABYLON {
  87752. interface AbstractMesh {
  87753. /**
  87754. * Gets the edgesRenderer associated with the mesh
  87755. */
  87756. edgesRenderer: Nullable<EdgesRenderer>;
  87757. }
  87758. interface LinesMesh {
  87759. /**
  87760. * Enables the edge rendering mode on the mesh.
  87761. * This mode makes the mesh edges visible
  87762. * @param epsilon defines the maximal distance between two angles to detect a face
  87763. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87764. * @returns the currentAbstractMesh
  87765. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87766. */
  87767. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87768. }
  87769. interface InstancedLinesMesh {
  87770. /**
  87771. * Enables the edge rendering mode on the mesh.
  87772. * This mode makes the mesh edges visible
  87773. * @param epsilon defines the maximal distance between two angles to detect a face
  87774. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87775. * @returns the current InstancedLinesMesh
  87776. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87777. */
  87778. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87779. }
  87780. /**
  87781. * Defines the minimum contract an Edges renderer should follow.
  87782. */
  87783. export interface IEdgesRenderer extends IDisposable {
  87784. /**
  87785. * Gets or sets a boolean indicating if the edgesRenderer is active
  87786. */
  87787. isEnabled: boolean;
  87788. /**
  87789. * Renders the edges of the attached mesh,
  87790. */
  87791. render(): void;
  87792. /**
  87793. * Checks wether or not the edges renderer is ready to render.
  87794. * @return true if ready, otherwise false.
  87795. */
  87796. isReady(): boolean;
  87797. }
  87798. /**
  87799. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87800. */
  87801. export class EdgesRenderer implements IEdgesRenderer {
  87802. /**
  87803. * Define the size of the edges with an orthographic camera
  87804. */
  87805. edgesWidthScalerForOrthographic: number;
  87806. /**
  87807. * Define the size of the edges with a perspective camera
  87808. */
  87809. edgesWidthScalerForPerspective: number;
  87810. protected _source: AbstractMesh;
  87811. protected _linesPositions: number[];
  87812. protected _linesNormals: number[];
  87813. protected _linesIndices: number[];
  87814. protected _epsilon: number;
  87815. protected _indicesCount: number;
  87816. protected _lineShader: ShaderMaterial;
  87817. protected _ib: DataBuffer;
  87818. protected _buffers: {
  87819. [key: string]: Nullable<VertexBuffer>;
  87820. };
  87821. protected _checkVerticesInsteadOfIndices: boolean;
  87822. private _meshRebuildObserver;
  87823. private _meshDisposeObserver;
  87824. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87825. isEnabled: boolean;
  87826. /**
  87827. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87828. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87829. * @param source Mesh used to create edges
  87830. * @param epsilon sum of angles in adjacency to check for edge
  87831. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87832. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87833. */
  87834. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87835. protected _prepareRessources(): void;
  87836. /** @hidden */
  87837. _rebuild(): void;
  87838. /**
  87839. * Releases the required resources for the edges renderer
  87840. */
  87841. dispose(): void;
  87842. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87843. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87844. /**
  87845. * Checks if the pair of p0 and p1 is en edge
  87846. * @param faceIndex
  87847. * @param edge
  87848. * @param faceNormals
  87849. * @param p0
  87850. * @param p1
  87851. * @private
  87852. */
  87853. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87854. /**
  87855. * push line into the position, normal and index buffer
  87856. * @protected
  87857. */
  87858. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87859. /**
  87860. * Generates lines edges from adjacencjes
  87861. * @private
  87862. */
  87863. _generateEdgesLines(): void;
  87864. /**
  87865. * Checks wether or not the edges renderer is ready to render.
  87866. * @return true if ready, otherwise false.
  87867. */
  87868. isReady(): boolean;
  87869. /**
  87870. * Renders the edges of the attached mesh,
  87871. */
  87872. render(): void;
  87873. }
  87874. /**
  87875. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87876. */
  87877. export class LineEdgesRenderer extends EdgesRenderer {
  87878. /**
  87879. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87880. * @param source LineMesh used to generate edges
  87881. * @param epsilon not important (specified angle for edge detection)
  87882. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87883. */
  87884. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87885. /**
  87886. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87887. */
  87888. _generateEdgesLines(): void;
  87889. }
  87890. }
  87891. declare module BABYLON {
  87892. /**
  87893. * This represents the object necessary to create a rendering group.
  87894. * This is exclusively used and created by the rendering manager.
  87895. * To modify the behavior, you use the available helpers in your scene or meshes.
  87896. * @hidden
  87897. */
  87898. export class RenderingGroup {
  87899. index: number;
  87900. private static _zeroVector;
  87901. private _scene;
  87902. private _opaqueSubMeshes;
  87903. private _transparentSubMeshes;
  87904. private _alphaTestSubMeshes;
  87905. private _depthOnlySubMeshes;
  87906. private _particleSystems;
  87907. private _spriteManagers;
  87908. private _opaqueSortCompareFn;
  87909. private _alphaTestSortCompareFn;
  87910. private _transparentSortCompareFn;
  87911. private _renderOpaque;
  87912. private _renderAlphaTest;
  87913. private _renderTransparent;
  87914. /** @hidden */
  87915. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87916. onBeforeTransparentRendering: () => void;
  87917. /**
  87918. * Set the opaque sort comparison function.
  87919. * If null the sub meshes will be render in the order they were created
  87920. */
  87921. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87922. /**
  87923. * Set the alpha test sort comparison function.
  87924. * If null the sub meshes will be render in the order they were created
  87925. */
  87926. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87927. /**
  87928. * Set the transparent sort comparison function.
  87929. * If null the sub meshes will be render in the order they were created
  87930. */
  87931. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87932. /**
  87933. * Creates a new rendering group.
  87934. * @param index The rendering group index
  87935. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87936. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87937. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87938. */
  87939. 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>);
  87940. /**
  87941. * Render all the sub meshes contained in the group.
  87942. * @param customRenderFunction Used to override the default render behaviour of the group.
  87943. * @returns true if rendered some submeshes.
  87944. */
  87945. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87946. /**
  87947. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87948. * @param subMeshes The submeshes to render
  87949. */
  87950. private renderOpaqueSorted;
  87951. /**
  87952. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87953. * @param subMeshes The submeshes to render
  87954. */
  87955. private renderAlphaTestSorted;
  87956. /**
  87957. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87958. * @param subMeshes The submeshes to render
  87959. */
  87960. private renderTransparentSorted;
  87961. /**
  87962. * Renders the submeshes in a specified order.
  87963. * @param subMeshes The submeshes to sort before render
  87964. * @param sortCompareFn The comparison function use to sort
  87965. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87966. * @param transparent Specifies to activate blending if true
  87967. */
  87968. private static renderSorted;
  87969. /**
  87970. * Renders the submeshes in the order they were dispatched (no sort applied).
  87971. * @param subMeshes The submeshes to render
  87972. */
  87973. private static renderUnsorted;
  87974. /**
  87975. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87976. * are rendered back to front if in the same alpha index.
  87977. *
  87978. * @param a The first submesh
  87979. * @param b The second submesh
  87980. * @returns The result of the comparison
  87981. */
  87982. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87983. /**
  87984. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87985. * are rendered back to front.
  87986. *
  87987. * @param a The first submesh
  87988. * @param b The second submesh
  87989. * @returns The result of the comparison
  87990. */
  87991. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87992. /**
  87993. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87994. * are rendered front to back (prevent overdraw).
  87995. *
  87996. * @param a The first submesh
  87997. * @param b The second submesh
  87998. * @returns The result of the comparison
  87999. */
  88000. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88001. /**
  88002. * Resets the different lists of submeshes to prepare a new frame.
  88003. */
  88004. prepare(): void;
  88005. dispose(): void;
  88006. /**
  88007. * Inserts the submesh in its correct queue depending on its material.
  88008. * @param subMesh The submesh to dispatch
  88009. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88010. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88011. */
  88012. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88013. dispatchSprites(spriteManager: ISpriteManager): void;
  88014. dispatchParticles(particleSystem: IParticleSystem): void;
  88015. private _renderParticles;
  88016. private _renderSprites;
  88017. }
  88018. }
  88019. declare module BABYLON {
  88020. /**
  88021. * Interface describing the different options available in the rendering manager
  88022. * regarding Auto Clear between groups.
  88023. */
  88024. export interface IRenderingManagerAutoClearSetup {
  88025. /**
  88026. * Defines whether or not autoclear is enable.
  88027. */
  88028. autoClear: boolean;
  88029. /**
  88030. * Defines whether or not to autoclear the depth buffer.
  88031. */
  88032. depth: boolean;
  88033. /**
  88034. * Defines whether or not to autoclear the stencil buffer.
  88035. */
  88036. stencil: boolean;
  88037. }
  88038. /**
  88039. * This class is used by the onRenderingGroupObservable
  88040. */
  88041. export class RenderingGroupInfo {
  88042. /**
  88043. * The Scene that being rendered
  88044. */
  88045. scene: Scene;
  88046. /**
  88047. * The camera currently used for the rendering pass
  88048. */
  88049. camera: Nullable<Camera>;
  88050. /**
  88051. * The ID of the renderingGroup being processed
  88052. */
  88053. renderingGroupId: number;
  88054. }
  88055. /**
  88056. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88057. * It is enable to manage the different groups as well as the different necessary sort functions.
  88058. * This should not be used directly aside of the few static configurations
  88059. */
  88060. export class RenderingManager {
  88061. /**
  88062. * The max id used for rendering groups (not included)
  88063. */
  88064. static MAX_RENDERINGGROUPS: number;
  88065. /**
  88066. * The min id used for rendering groups (included)
  88067. */
  88068. static MIN_RENDERINGGROUPS: number;
  88069. /**
  88070. * Used to globally prevent autoclearing scenes.
  88071. */
  88072. static AUTOCLEAR: boolean;
  88073. /**
  88074. * @hidden
  88075. */
  88076. _useSceneAutoClearSetup: boolean;
  88077. private _scene;
  88078. private _renderingGroups;
  88079. private _depthStencilBufferAlreadyCleaned;
  88080. private _autoClearDepthStencil;
  88081. private _customOpaqueSortCompareFn;
  88082. private _customAlphaTestSortCompareFn;
  88083. private _customTransparentSortCompareFn;
  88084. private _renderingGroupInfo;
  88085. /**
  88086. * Instantiates a new rendering group for a particular scene
  88087. * @param scene Defines the scene the groups belongs to
  88088. */
  88089. constructor(scene: Scene);
  88090. private _clearDepthStencilBuffer;
  88091. /**
  88092. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88093. * @hidden
  88094. */
  88095. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88096. /**
  88097. * Resets the different information of the group to prepare a new frame
  88098. * @hidden
  88099. */
  88100. reset(): void;
  88101. /**
  88102. * Dispose and release the group and its associated resources.
  88103. * @hidden
  88104. */
  88105. dispose(): void;
  88106. /**
  88107. * Clear the info related to rendering groups preventing retention points during dispose.
  88108. */
  88109. freeRenderingGroups(): void;
  88110. private _prepareRenderingGroup;
  88111. /**
  88112. * Add a sprite manager to the rendering manager in order to render it this frame.
  88113. * @param spriteManager Define the sprite manager to render
  88114. */
  88115. dispatchSprites(spriteManager: ISpriteManager): void;
  88116. /**
  88117. * Add a particle system to the rendering manager in order to render it this frame.
  88118. * @param particleSystem Define the particle system to render
  88119. */
  88120. dispatchParticles(particleSystem: IParticleSystem): void;
  88121. /**
  88122. * Add a submesh to the manager in order to render it this frame
  88123. * @param subMesh The submesh to dispatch
  88124. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88125. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88126. */
  88127. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88128. /**
  88129. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88130. * This allowed control for front to back rendering or reversly depending of the special needs.
  88131. *
  88132. * @param renderingGroupId The rendering group id corresponding to its index
  88133. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88134. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88135. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88136. */
  88137. 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;
  88138. /**
  88139. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88140. *
  88141. * @param renderingGroupId The rendering group id corresponding to its index
  88142. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88143. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88144. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88145. */
  88146. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88147. /**
  88148. * Gets the current auto clear configuration for one rendering group of the rendering
  88149. * manager.
  88150. * @param index the rendering group index to get the information for
  88151. * @returns The auto clear setup for the requested rendering group
  88152. */
  88153. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88154. }
  88155. }
  88156. declare module BABYLON {
  88157. /**
  88158. * This Helps creating a texture that will be created from a camera in your scene.
  88159. * It is basically a dynamic texture that could be used to create special effects for instance.
  88160. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88161. */
  88162. export class RenderTargetTexture extends Texture {
  88163. isCube: boolean;
  88164. /**
  88165. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88166. */
  88167. static readonly REFRESHRATE_RENDER_ONCE: number;
  88168. /**
  88169. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88170. */
  88171. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88172. /**
  88173. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88174. * the central point of your effect and can save a lot of performances.
  88175. */
  88176. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88177. /**
  88178. * Use this predicate to dynamically define the list of mesh you want to render.
  88179. * If set, the renderList property will be overwritten.
  88180. */
  88181. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88182. private _renderList;
  88183. /**
  88184. * Use this list to define the list of mesh you want to render.
  88185. */
  88186. renderList: Nullable<Array<AbstractMesh>>;
  88187. private _hookArray;
  88188. /**
  88189. * Define if particles should be rendered in your texture.
  88190. */
  88191. renderParticles: boolean;
  88192. /**
  88193. * Define if sprites should be rendered in your texture.
  88194. */
  88195. renderSprites: boolean;
  88196. /**
  88197. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88198. */
  88199. coordinatesMode: number;
  88200. /**
  88201. * Define the camera used to render the texture.
  88202. */
  88203. activeCamera: Nullable<Camera>;
  88204. /**
  88205. * Override the render function of the texture with your own one.
  88206. */
  88207. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88208. /**
  88209. * Define if camera post processes should be use while rendering the texture.
  88210. */
  88211. useCameraPostProcesses: boolean;
  88212. /**
  88213. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88214. */
  88215. ignoreCameraViewport: boolean;
  88216. private _postProcessManager;
  88217. private _postProcesses;
  88218. private _resizeObserver;
  88219. /**
  88220. * An event triggered when the texture is unbind.
  88221. */
  88222. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88223. /**
  88224. * An event triggered when the texture is unbind.
  88225. */
  88226. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88227. private _onAfterUnbindObserver;
  88228. /**
  88229. * Set a after unbind callback in the texture.
  88230. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88231. */
  88232. onAfterUnbind: () => void;
  88233. /**
  88234. * An event triggered before rendering the texture
  88235. */
  88236. onBeforeRenderObservable: Observable<number>;
  88237. private _onBeforeRenderObserver;
  88238. /**
  88239. * Set a before render callback in the texture.
  88240. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88241. */
  88242. onBeforeRender: (faceIndex: number) => void;
  88243. /**
  88244. * An event triggered after rendering the texture
  88245. */
  88246. onAfterRenderObservable: Observable<number>;
  88247. private _onAfterRenderObserver;
  88248. /**
  88249. * Set a after render callback in the texture.
  88250. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88251. */
  88252. onAfterRender: (faceIndex: number) => void;
  88253. /**
  88254. * An event triggered after the texture clear
  88255. */
  88256. onClearObservable: Observable<Engine>;
  88257. private _onClearObserver;
  88258. /**
  88259. * Set a clear callback in the texture.
  88260. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88261. */
  88262. onClear: (Engine: Engine) => void;
  88263. /**
  88264. * An event triggered when the texture is resized.
  88265. */
  88266. onResizeObservable: Observable<RenderTargetTexture>;
  88267. /**
  88268. * Define the clear color of the Render Target if it should be different from the scene.
  88269. */
  88270. clearColor: Color4;
  88271. protected _size: number | {
  88272. width: number;
  88273. height: number;
  88274. };
  88275. protected _initialSizeParameter: number | {
  88276. width: number;
  88277. height: number;
  88278. } | {
  88279. ratio: number;
  88280. };
  88281. protected _sizeRatio: Nullable<number>;
  88282. /** @hidden */
  88283. _generateMipMaps: boolean;
  88284. protected _renderingManager: RenderingManager;
  88285. /** @hidden */
  88286. _waitingRenderList: string[];
  88287. protected _doNotChangeAspectRatio: boolean;
  88288. protected _currentRefreshId: number;
  88289. protected _refreshRate: number;
  88290. protected _textureMatrix: Matrix;
  88291. protected _samples: number;
  88292. protected _renderTargetOptions: RenderTargetCreationOptions;
  88293. /**
  88294. * Gets render target creation options that were used.
  88295. */
  88296. readonly renderTargetOptions: RenderTargetCreationOptions;
  88297. protected _engine: Engine;
  88298. protected _onRatioRescale(): void;
  88299. /**
  88300. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88301. * It must define where the camera used to render the texture is set
  88302. */
  88303. boundingBoxPosition: Vector3;
  88304. private _boundingBoxSize;
  88305. /**
  88306. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88307. * When defined, the cubemap will switch to local mode
  88308. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88309. * @example https://www.babylonjs-playground.com/#RNASML
  88310. */
  88311. boundingBoxSize: Vector3;
  88312. /**
  88313. * In case the RTT has been created with a depth texture, get the associated
  88314. * depth texture.
  88315. * Otherwise, return null.
  88316. */
  88317. depthStencilTexture: Nullable<InternalTexture>;
  88318. /**
  88319. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88320. * or used a shadow, depth texture...
  88321. * @param name The friendly name of the texture
  88322. * @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)
  88323. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88324. * @param generateMipMaps True if mip maps need to be generated after render.
  88325. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88326. * @param type The type of the buffer in the RTT (int, half float, float...)
  88327. * @param isCube True if a cube texture needs to be created
  88328. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88329. * @param generateDepthBuffer True to generate a depth buffer
  88330. * @param generateStencilBuffer True to generate a stencil buffer
  88331. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88332. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88333. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88334. */
  88335. constructor(name: string, size: number | {
  88336. width: number;
  88337. height: number;
  88338. } | {
  88339. ratio: number;
  88340. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88341. /**
  88342. * Creates a depth stencil texture.
  88343. * This is only available in WebGL 2 or with the depth texture extension available.
  88344. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88345. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88346. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88347. */
  88348. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88349. private _processSizeParameter;
  88350. /**
  88351. * Define the number of samples to use in case of MSAA.
  88352. * It defaults to one meaning no MSAA has been enabled.
  88353. */
  88354. samples: number;
  88355. /**
  88356. * Resets the refresh counter of the texture and start bak from scratch.
  88357. * Could be useful to regenerate the texture if it is setup to render only once.
  88358. */
  88359. resetRefreshCounter(): void;
  88360. /**
  88361. * Define the refresh rate of the texture or the rendering frequency.
  88362. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88363. */
  88364. refreshRate: number;
  88365. /**
  88366. * Adds a post process to the render target rendering passes.
  88367. * @param postProcess define the post process to add
  88368. */
  88369. addPostProcess(postProcess: PostProcess): void;
  88370. /**
  88371. * Clear all the post processes attached to the render target
  88372. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88373. */
  88374. clearPostProcesses(dispose?: boolean): void;
  88375. /**
  88376. * Remove one of the post process from the list of attached post processes to the texture
  88377. * @param postProcess define the post process to remove from the list
  88378. */
  88379. removePostProcess(postProcess: PostProcess): void;
  88380. /** @hidden */
  88381. _shouldRender(): boolean;
  88382. /**
  88383. * Gets the actual render size of the texture.
  88384. * @returns the width of the render size
  88385. */
  88386. getRenderSize(): number;
  88387. /**
  88388. * Gets the actual render width of the texture.
  88389. * @returns the width of the render size
  88390. */
  88391. getRenderWidth(): number;
  88392. /**
  88393. * Gets the actual render height of the texture.
  88394. * @returns the height of the render size
  88395. */
  88396. getRenderHeight(): number;
  88397. /**
  88398. * Get if the texture can be rescaled or not.
  88399. */
  88400. readonly canRescale: boolean;
  88401. /**
  88402. * Resize the texture using a ratio.
  88403. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88404. */
  88405. scale(ratio: number): void;
  88406. /**
  88407. * Get the texture reflection matrix used to rotate/transform the reflection.
  88408. * @returns the reflection matrix
  88409. */
  88410. getReflectionTextureMatrix(): Matrix;
  88411. /**
  88412. * Resize the texture to a new desired size.
  88413. * Be carrefull as it will recreate all the data in the new texture.
  88414. * @param size Define the new size. It can be:
  88415. * - a number for squared texture,
  88416. * - an object containing { width: number, height: number }
  88417. * - or an object containing a ratio { ratio: number }
  88418. */
  88419. resize(size: number | {
  88420. width: number;
  88421. height: number;
  88422. } | {
  88423. ratio: number;
  88424. }): void;
  88425. /**
  88426. * Renders all the objects from the render list into the texture.
  88427. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88428. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88429. */
  88430. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88431. private _bestReflectionRenderTargetDimension;
  88432. /**
  88433. * @hidden
  88434. * @param faceIndex face index to bind to if this is a cubetexture
  88435. */
  88436. _bindFrameBuffer(faceIndex?: number): void;
  88437. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88438. private renderToTarget;
  88439. /**
  88440. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88441. * This allowed control for front to back rendering or reversly depending of the special needs.
  88442. *
  88443. * @param renderingGroupId The rendering group id corresponding to its index
  88444. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88445. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88446. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88447. */
  88448. 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;
  88449. /**
  88450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88451. *
  88452. * @param renderingGroupId The rendering group id corresponding to its index
  88453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88454. */
  88455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88456. /**
  88457. * Clones the texture.
  88458. * @returns the cloned texture
  88459. */
  88460. clone(): RenderTargetTexture;
  88461. /**
  88462. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88463. * @returns The JSON representation of the texture
  88464. */
  88465. serialize(): any;
  88466. /**
  88467. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88468. */
  88469. disposeFramebufferObjects(): void;
  88470. /**
  88471. * Dispose the texture and release its associated resources.
  88472. */
  88473. dispose(): void;
  88474. /** @hidden */
  88475. _rebuild(): void;
  88476. /**
  88477. * Clear the info related to rendering groups preventing retention point in material dispose.
  88478. */
  88479. freeRenderingGroups(): void;
  88480. /**
  88481. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88482. * @returns the view count
  88483. */
  88484. getViewCount(): number;
  88485. }
  88486. }
  88487. declare module BABYLON {
  88488. /**
  88489. * Options for compiling materials.
  88490. */
  88491. export interface IMaterialCompilationOptions {
  88492. /**
  88493. * Defines whether clip planes are enabled.
  88494. */
  88495. clipPlane: boolean;
  88496. /**
  88497. * Defines whether instances are enabled.
  88498. */
  88499. useInstances: boolean;
  88500. }
  88501. /**
  88502. * Base class for the main features of a material in Babylon.js
  88503. */
  88504. export class Material implements IAnimatable {
  88505. /**
  88506. * Returns the triangle fill mode
  88507. */
  88508. static readonly TriangleFillMode: number;
  88509. /**
  88510. * Returns the wireframe mode
  88511. */
  88512. static readonly WireFrameFillMode: number;
  88513. /**
  88514. * Returns the point fill mode
  88515. */
  88516. static readonly PointFillMode: number;
  88517. /**
  88518. * Returns the point list draw mode
  88519. */
  88520. static readonly PointListDrawMode: number;
  88521. /**
  88522. * Returns the line list draw mode
  88523. */
  88524. static readonly LineListDrawMode: number;
  88525. /**
  88526. * Returns the line loop draw mode
  88527. */
  88528. static readonly LineLoopDrawMode: number;
  88529. /**
  88530. * Returns the line strip draw mode
  88531. */
  88532. static readonly LineStripDrawMode: number;
  88533. /**
  88534. * Returns the triangle strip draw mode
  88535. */
  88536. static readonly TriangleStripDrawMode: number;
  88537. /**
  88538. * Returns the triangle fan draw mode
  88539. */
  88540. static readonly TriangleFanDrawMode: number;
  88541. /**
  88542. * Stores the clock-wise side orientation
  88543. */
  88544. static readonly ClockWiseSideOrientation: number;
  88545. /**
  88546. * Stores the counter clock-wise side orientation
  88547. */
  88548. static readonly CounterClockWiseSideOrientation: number;
  88549. /**
  88550. * The dirty texture flag value
  88551. */
  88552. static readonly TextureDirtyFlag: number;
  88553. /**
  88554. * The dirty light flag value
  88555. */
  88556. static readonly LightDirtyFlag: number;
  88557. /**
  88558. * The dirty fresnel flag value
  88559. */
  88560. static readonly FresnelDirtyFlag: number;
  88561. /**
  88562. * The dirty attribute flag value
  88563. */
  88564. static readonly AttributesDirtyFlag: number;
  88565. /**
  88566. * The dirty misc flag value
  88567. */
  88568. static readonly MiscDirtyFlag: number;
  88569. /**
  88570. * The all dirty flag value
  88571. */
  88572. static readonly AllDirtyFlag: number;
  88573. /**
  88574. * The ID of the material
  88575. */
  88576. id: string;
  88577. /**
  88578. * Gets or sets the unique id of the material
  88579. */
  88580. uniqueId: number;
  88581. /**
  88582. * The name of the material
  88583. */
  88584. name: string;
  88585. /**
  88586. * Gets or sets user defined metadata
  88587. */
  88588. metadata: any;
  88589. /**
  88590. * For internal use only. Please do not use.
  88591. */
  88592. reservedDataStore: any;
  88593. /**
  88594. * Specifies if the ready state should be checked on each call
  88595. */
  88596. checkReadyOnEveryCall: boolean;
  88597. /**
  88598. * Specifies if the ready state should be checked once
  88599. */
  88600. checkReadyOnlyOnce: boolean;
  88601. /**
  88602. * The state of the material
  88603. */
  88604. state: string;
  88605. /**
  88606. * The alpha value of the material
  88607. */
  88608. protected _alpha: number;
  88609. /**
  88610. * List of inspectable custom properties (used by the Inspector)
  88611. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88612. */
  88613. inspectableCustomProperties: IInspectable[];
  88614. /**
  88615. * Sets the alpha value of the material
  88616. */
  88617. /**
  88618. * Gets the alpha value of the material
  88619. */
  88620. alpha: number;
  88621. /**
  88622. * Specifies if back face culling is enabled
  88623. */
  88624. protected _backFaceCulling: boolean;
  88625. /**
  88626. * Sets the back-face culling state
  88627. */
  88628. /**
  88629. * Gets the back-face culling state
  88630. */
  88631. backFaceCulling: boolean;
  88632. /**
  88633. * Stores the value for side orientation
  88634. */
  88635. sideOrientation: number;
  88636. /**
  88637. * Callback triggered when the material is compiled
  88638. */
  88639. onCompiled: Nullable<(effect: Effect) => void>;
  88640. /**
  88641. * Callback triggered when an error occurs
  88642. */
  88643. onError: Nullable<(effect: Effect, errors: string) => void>;
  88644. /**
  88645. * Callback triggered to get the render target textures
  88646. */
  88647. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88648. /**
  88649. * Gets a boolean indicating that current material needs to register RTT
  88650. */
  88651. readonly hasRenderTargetTextures: boolean;
  88652. /**
  88653. * Specifies if the material should be serialized
  88654. */
  88655. doNotSerialize: boolean;
  88656. /**
  88657. * @hidden
  88658. */
  88659. _storeEffectOnSubMeshes: boolean;
  88660. /**
  88661. * Stores the animations for the material
  88662. */
  88663. animations: Nullable<Array<Animation>>;
  88664. /**
  88665. * An event triggered when the material is disposed
  88666. */
  88667. onDisposeObservable: Observable<Material>;
  88668. /**
  88669. * An observer which watches for dispose events
  88670. */
  88671. private _onDisposeObserver;
  88672. private _onUnBindObservable;
  88673. /**
  88674. * Called during a dispose event
  88675. */
  88676. onDispose: () => void;
  88677. private _onBindObservable;
  88678. /**
  88679. * An event triggered when the material is bound
  88680. */
  88681. readonly onBindObservable: Observable<AbstractMesh>;
  88682. /**
  88683. * An observer which watches for bind events
  88684. */
  88685. private _onBindObserver;
  88686. /**
  88687. * Called during a bind event
  88688. */
  88689. onBind: (Mesh: AbstractMesh) => void;
  88690. /**
  88691. * An event triggered when the material is unbound
  88692. */
  88693. readonly onUnBindObservable: Observable<Material>;
  88694. /**
  88695. * Stores the value of the alpha mode
  88696. */
  88697. private _alphaMode;
  88698. /**
  88699. * Sets the value of the alpha mode.
  88700. *
  88701. * | Value | Type | Description |
  88702. * | --- | --- | --- |
  88703. * | 0 | ALPHA_DISABLE | |
  88704. * | 1 | ALPHA_ADD | |
  88705. * | 2 | ALPHA_COMBINE | |
  88706. * | 3 | ALPHA_SUBTRACT | |
  88707. * | 4 | ALPHA_MULTIPLY | |
  88708. * | 5 | ALPHA_MAXIMIZED | |
  88709. * | 6 | ALPHA_ONEONE | |
  88710. * | 7 | ALPHA_PREMULTIPLIED | |
  88711. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88712. * | 9 | ALPHA_INTERPOLATE | |
  88713. * | 10 | ALPHA_SCREENMODE | |
  88714. *
  88715. */
  88716. /**
  88717. * Gets the value of the alpha mode
  88718. */
  88719. alphaMode: number;
  88720. /**
  88721. * Stores the state of the need depth pre-pass value
  88722. */
  88723. private _needDepthPrePass;
  88724. /**
  88725. * Sets the need depth pre-pass value
  88726. */
  88727. /**
  88728. * Gets the depth pre-pass value
  88729. */
  88730. needDepthPrePass: boolean;
  88731. /**
  88732. * Specifies if depth writing should be disabled
  88733. */
  88734. disableDepthWrite: boolean;
  88735. /**
  88736. * Specifies if depth writing should be forced
  88737. */
  88738. forceDepthWrite: boolean;
  88739. /**
  88740. * Specifies if there should be a separate pass for culling
  88741. */
  88742. separateCullingPass: boolean;
  88743. /**
  88744. * Stores the state specifing if fog should be enabled
  88745. */
  88746. private _fogEnabled;
  88747. /**
  88748. * Sets the state for enabling fog
  88749. */
  88750. /**
  88751. * Gets the value of the fog enabled state
  88752. */
  88753. fogEnabled: boolean;
  88754. /**
  88755. * Stores the size of points
  88756. */
  88757. pointSize: number;
  88758. /**
  88759. * Stores the z offset value
  88760. */
  88761. zOffset: number;
  88762. /**
  88763. * Gets a value specifying if wireframe mode is enabled
  88764. */
  88765. /**
  88766. * Sets the state of wireframe mode
  88767. */
  88768. wireframe: boolean;
  88769. /**
  88770. * Gets the value specifying if point clouds are enabled
  88771. */
  88772. /**
  88773. * Sets the state of point cloud mode
  88774. */
  88775. pointsCloud: boolean;
  88776. /**
  88777. * Gets the material fill mode
  88778. */
  88779. /**
  88780. * Sets the material fill mode
  88781. */
  88782. fillMode: number;
  88783. /**
  88784. * @hidden
  88785. * Stores the effects for the material
  88786. */
  88787. _effect: Nullable<Effect>;
  88788. /**
  88789. * @hidden
  88790. * Specifies if the material was previously ready
  88791. */
  88792. _wasPreviouslyReady: boolean;
  88793. /**
  88794. * Specifies if uniform buffers should be used
  88795. */
  88796. private _useUBO;
  88797. /**
  88798. * Stores a reference to the scene
  88799. */
  88800. private _scene;
  88801. /**
  88802. * Stores the fill mode state
  88803. */
  88804. private _fillMode;
  88805. /**
  88806. * Specifies if the depth write state should be cached
  88807. */
  88808. private _cachedDepthWriteState;
  88809. /**
  88810. * Stores the uniform buffer
  88811. */
  88812. protected _uniformBuffer: UniformBuffer;
  88813. /** @hidden */
  88814. _indexInSceneMaterialArray: number;
  88815. /** @hidden */
  88816. meshMap: Nullable<{
  88817. [id: string]: AbstractMesh | undefined;
  88818. }>;
  88819. /**
  88820. * Creates a material instance
  88821. * @param name defines the name of the material
  88822. * @param scene defines the scene to reference
  88823. * @param doNotAdd specifies if the material should be added to the scene
  88824. */
  88825. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88826. /**
  88827. * Returns a string representation of the current material
  88828. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88829. * @returns a string with material information
  88830. */
  88831. toString(fullDetails?: boolean): string;
  88832. /**
  88833. * Gets the class name of the material
  88834. * @returns a string with the class name of the material
  88835. */
  88836. getClassName(): string;
  88837. /**
  88838. * Specifies if updates for the material been locked
  88839. */
  88840. readonly isFrozen: boolean;
  88841. /**
  88842. * Locks updates for the material
  88843. */
  88844. freeze(): void;
  88845. /**
  88846. * Unlocks updates for the material
  88847. */
  88848. unfreeze(): void;
  88849. /**
  88850. * Specifies if the material is ready to be used
  88851. * @param mesh defines the mesh to check
  88852. * @param useInstances specifies if instances should be used
  88853. * @returns a boolean indicating if the material is ready to be used
  88854. */
  88855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88856. /**
  88857. * Specifies that the submesh is ready to be used
  88858. * @param mesh defines the mesh to check
  88859. * @param subMesh defines which submesh to check
  88860. * @param useInstances specifies that instances should be used
  88861. * @returns a boolean indicating that the submesh is ready or not
  88862. */
  88863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88864. /**
  88865. * Returns the material effect
  88866. * @returns the effect associated with the material
  88867. */
  88868. getEffect(): Nullable<Effect>;
  88869. /**
  88870. * Returns the current scene
  88871. * @returns a Scene
  88872. */
  88873. getScene(): Scene;
  88874. /**
  88875. * Specifies if the material will require alpha blending
  88876. * @returns a boolean specifying if alpha blending is needed
  88877. */
  88878. needAlphaBlending(): boolean;
  88879. /**
  88880. * Specifies if the mesh will require alpha blending
  88881. * @param mesh defines the mesh to check
  88882. * @returns a boolean specifying if alpha blending is needed for the mesh
  88883. */
  88884. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88885. /**
  88886. * Specifies if this material should be rendered in alpha test mode
  88887. * @returns a boolean specifying if an alpha test is needed.
  88888. */
  88889. needAlphaTesting(): boolean;
  88890. /**
  88891. * Gets the texture used for the alpha test
  88892. * @returns the texture to use for alpha testing
  88893. */
  88894. getAlphaTestTexture(): Nullable<BaseTexture>;
  88895. /**
  88896. * Marks the material to indicate that it needs to be re-calculated
  88897. */
  88898. markDirty(): void;
  88899. /** @hidden */
  88900. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88901. /**
  88902. * Binds the material to the mesh
  88903. * @param world defines the world transformation matrix
  88904. * @param mesh defines the mesh to bind the material to
  88905. */
  88906. bind(world: Matrix, mesh?: Mesh): void;
  88907. /**
  88908. * Binds the submesh to the material
  88909. * @param world defines the world transformation matrix
  88910. * @param mesh defines the mesh containing the submesh
  88911. * @param subMesh defines the submesh to bind the material to
  88912. */
  88913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88914. /**
  88915. * Binds the world matrix to the material
  88916. * @param world defines the world transformation matrix
  88917. */
  88918. bindOnlyWorldMatrix(world: Matrix): void;
  88919. /**
  88920. * Binds the scene's uniform buffer to the effect.
  88921. * @param effect defines the effect to bind to the scene uniform buffer
  88922. * @param sceneUbo defines the uniform buffer storing scene data
  88923. */
  88924. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88925. /**
  88926. * Binds the view matrix to the effect
  88927. * @param effect defines the effect to bind the view matrix to
  88928. */
  88929. bindView(effect: Effect): void;
  88930. /**
  88931. * Binds the view projection matrix to the effect
  88932. * @param effect defines the effect to bind the view projection matrix to
  88933. */
  88934. bindViewProjection(effect: Effect): void;
  88935. /**
  88936. * Specifies if material alpha testing should be turned on for the mesh
  88937. * @param mesh defines the mesh to check
  88938. */
  88939. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88940. /**
  88941. * Processes to execute after binding the material to a mesh
  88942. * @param mesh defines the rendered mesh
  88943. */
  88944. protected _afterBind(mesh?: Mesh): void;
  88945. /**
  88946. * Unbinds the material from the mesh
  88947. */
  88948. unbind(): void;
  88949. /**
  88950. * Gets the active textures from the material
  88951. * @returns an array of textures
  88952. */
  88953. getActiveTextures(): BaseTexture[];
  88954. /**
  88955. * Specifies if the material uses a texture
  88956. * @param texture defines the texture to check against the material
  88957. * @returns a boolean specifying if the material uses the texture
  88958. */
  88959. hasTexture(texture: BaseTexture): boolean;
  88960. /**
  88961. * Makes a duplicate of the material, and gives it a new name
  88962. * @param name defines the new name for the duplicated material
  88963. * @returns the cloned material
  88964. */
  88965. clone(name: string): Nullable<Material>;
  88966. /**
  88967. * Gets the meshes bound to the material
  88968. * @returns an array of meshes bound to the material
  88969. */
  88970. getBindedMeshes(): AbstractMesh[];
  88971. /**
  88972. * Force shader compilation
  88973. * @param mesh defines the mesh associated with this material
  88974. * @param onCompiled defines a function to execute once the material is compiled
  88975. * @param options defines the options to configure the compilation
  88976. * @param onError defines a function to execute if the material fails compiling
  88977. */
  88978. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88979. /**
  88980. * Force shader compilation
  88981. * @param mesh defines the mesh that will use this material
  88982. * @param options defines additional options for compiling the shaders
  88983. * @returns a promise that resolves when the compilation completes
  88984. */
  88985. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88986. private static readonly _AllDirtyCallBack;
  88987. private static readonly _ImageProcessingDirtyCallBack;
  88988. private static readonly _TextureDirtyCallBack;
  88989. private static readonly _FresnelDirtyCallBack;
  88990. private static readonly _MiscDirtyCallBack;
  88991. private static readonly _LightsDirtyCallBack;
  88992. private static readonly _AttributeDirtyCallBack;
  88993. private static _FresnelAndMiscDirtyCallBack;
  88994. private static _TextureAndMiscDirtyCallBack;
  88995. private static readonly _DirtyCallbackArray;
  88996. private static readonly _RunDirtyCallBacks;
  88997. /**
  88998. * Marks a define in the material to indicate that it needs to be re-computed
  88999. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89000. */
  89001. markAsDirty(flag: number): void;
  89002. /**
  89003. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89004. * @param func defines a function which checks material defines against the submeshes
  89005. */
  89006. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89007. /**
  89008. * Indicates that we need to re-calculated for all submeshes
  89009. */
  89010. protected _markAllSubMeshesAsAllDirty(): void;
  89011. /**
  89012. * Indicates that image processing needs to be re-calculated for all submeshes
  89013. */
  89014. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89015. /**
  89016. * Indicates that textures need to be re-calculated for all submeshes
  89017. */
  89018. protected _markAllSubMeshesAsTexturesDirty(): void;
  89019. /**
  89020. * Indicates that fresnel needs to be re-calculated for all submeshes
  89021. */
  89022. protected _markAllSubMeshesAsFresnelDirty(): void;
  89023. /**
  89024. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89025. */
  89026. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89027. /**
  89028. * Indicates that lights need to be re-calculated for all submeshes
  89029. */
  89030. protected _markAllSubMeshesAsLightsDirty(): void;
  89031. /**
  89032. * Indicates that attributes need to be re-calculated for all submeshes
  89033. */
  89034. protected _markAllSubMeshesAsAttributesDirty(): void;
  89035. /**
  89036. * Indicates that misc needs to be re-calculated for all submeshes
  89037. */
  89038. protected _markAllSubMeshesAsMiscDirty(): void;
  89039. /**
  89040. * Indicates that textures and misc need to be re-calculated for all submeshes
  89041. */
  89042. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89043. /**
  89044. * Disposes the material
  89045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89047. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89048. */
  89049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89050. /** @hidden */
  89051. private releaseVertexArrayObject;
  89052. /**
  89053. * Serializes this material
  89054. * @returns the serialized material object
  89055. */
  89056. serialize(): any;
  89057. /**
  89058. * Creates a material from parsed material data
  89059. * @param parsedMaterial defines parsed material data
  89060. * @param scene defines the hosting scene
  89061. * @param rootUrl defines the root URL to use to load textures
  89062. * @returns a new material
  89063. */
  89064. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89065. }
  89066. }
  89067. declare module BABYLON {
  89068. /**
  89069. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89070. * separate meshes. This can be use to improve performances.
  89071. * @see http://doc.babylonjs.com/how_to/multi_materials
  89072. */
  89073. export class MultiMaterial extends Material {
  89074. private _subMaterials;
  89075. /**
  89076. * Gets or Sets the list of Materials used within the multi material.
  89077. * They need to be ordered according to the submeshes order in the associated mesh
  89078. */
  89079. subMaterials: Nullable<Material>[];
  89080. /**
  89081. * Function used to align with Node.getChildren()
  89082. * @returns the list of Materials used within the multi material
  89083. */
  89084. getChildren(): Nullable<Material>[];
  89085. /**
  89086. * Instantiates a new Multi Material
  89087. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89088. * separate meshes. This can be use to improve performances.
  89089. * @see http://doc.babylonjs.com/how_to/multi_materials
  89090. * @param name Define the name in the scene
  89091. * @param scene Define the scene the material belongs to
  89092. */
  89093. constructor(name: string, scene: Scene);
  89094. private _hookArray;
  89095. /**
  89096. * Get one of the submaterial by its index in the submaterials array
  89097. * @param index The index to look the sub material at
  89098. * @returns The Material if the index has been defined
  89099. */
  89100. getSubMaterial(index: number): Nullable<Material>;
  89101. /**
  89102. * Get the list of active textures for the whole sub materials list.
  89103. * @returns All the textures that will be used during the rendering
  89104. */
  89105. getActiveTextures(): BaseTexture[];
  89106. /**
  89107. * Gets the current class name of the material e.g. "MultiMaterial"
  89108. * Mainly use in serialization.
  89109. * @returns the class name
  89110. */
  89111. getClassName(): string;
  89112. /**
  89113. * Checks if the material is ready to render the requested sub mesh
  89114. * @param mesh Define the mesh the submesh belongs to
  89115. * @param subMesh Define the sub mesh to look readyness for
  89116. * @param useInstances Define whether or not the material is used with instances
  89117. * @returns true if ready, otherwise false
  89118. */
  89119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89120. /**
  89121. * Clones the current material and its related sub materials
  89122. * @param name Define the name of the newly cloned material
  89123. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89124. * @returns the cloned material
  89125. */
  89126. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89127. /**
  89128. * Serializes the materials into a JSON representation.
  89129. * @returns the JSON representation
  89130. */
  89131. serialize(): any;
  89132. /**
  89133. * Dispose the material and release its associated resources
  89134. * @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)
  89135. * @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)
  89136. * @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)
  89137. */
  89138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89139. /**
  89140. * Creates a MultiMaterial from parsed MultiMaterial data.
  89141. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89142. * @param scene defines the hosting scene
  89143. * @returns a new MultiMaterial
  89144. */
  89145. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89146. }
  89147. }
  89148. declare module BABYLON {
  89149. /**
  89150. * Base class for submeshes
  89151. */
  89152. export class BaseSubMesh {
  89153. /** @hidden */
  89154. _materialDefines: Nullable<MaterialDefines>;
  89155. /** @hidden */
  89156. _materialEffect: Nullable<Effect>;
  89157. /**
  89158. * Gets associated effect
  89159. */
  89160. readonly effect: Nullable<Effect>;
  89161. /**
  89162. * Sets associated effect (effect used to render this submesh)
  89163. * @param effect defines the effect to associate with
  89164. * @param defines defines the set of defines used to compile this effect
  89165. */
  89166. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89167. }
  89168. /**
  89169. * Defines a subdivision inside a mesh
  89170. */
  89171. export class SubMesh extends BaseSubMesh implements ICullable {
  89172. /** the material index to use */
  89173. materialIndex: number;
  89174. /** vertex index start */
  89175. verticesStart: number;
  89176. /** vertices count */
  89177. verticesCount: number;
  89178. /** index start */
  89179. indexStart: number;
  89180. /** indices count */
  89181. indexCount: number;
  89182. /** @hidden */
  89183. _linesIndexCount: number;
  89184. private _mesh;
  89185. private _renderingMesh;
  89186. private _boundingInfo;
  89187. private _linesIndexBuffer;
  89188. /** @hidden */
  89189. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89190. /** @hidden */
  89191. _trianglePlanes: Plane[];
  89192. /** @hidden */
  89193. _lastColliderTransformMatrix: Nullable<Matrix>;
  89194. /** @hidden */
  89195. _renderId: number;
  89196. /** @hidden */
  89197. _alphaIndex: number;
  89198. /** @hidden */
  89199. _distanceToCamera: number;
  89200. /** @hidden */
  89201. _id: number;
  89202. private _currentMaterial;
  89203. /**
  89204. * Add a new submesh to a mesh
  89205. * @param materialIndex defines the material index to use
  89206. * @param verticesStart defines vertex index start
  89207. * @param verticesCount defines vertices count
  89208. * @param indexStart defines index start
  89209. * @param indexCount defines indices count
  89210. * @param mesh defines the parent mesh
  89211. * @param renderingMesh defines an optional rendering mesh
  89212. * @param createBoundingBox defines if bounding box should be created for this submesh
  89213. * @returns the new submesh
  89214. */
  89215. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89216. /**
  89217. * Creates a new submesh
  89218. * @param materialIndex defines the material index to use
  89219. * @param verticesStart defines vertex index start
  89220. * @param verticesCount defines vertices count
  89221. * @param indexStart defines index start
  89222. * @param indexCount defines indices count
  89223. * @param mesh defines the parent mesh
  89224. * @param renderingMesh defines an optional rendering mesh
  89225. * @param createBoundingBox defines if bounding box should be created for this submesh
  89226. */
  89227. constructor(
  89228. /** the material index to use */
  89229. materialIndex: number,
  89230. /** vertex index start */
  89231. verticesStart: number,
  89232. /** vertices count */
  89233. verticesCount: number,
  89234. /** index start */
  89235. indexStart: number,
  89236. /** indices count */
  89237. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89238. /**
  89239. * Returns true if this submesh covers the entire parent mesh
  89240. * @ignorenaming
  89241. */
  89242. readonly IsGlobal: boolean;
  89243. /**
  89244. * Returns the submesh BoudingInfo object
  89245. * @returns current bounding info (or mesh's one if the submesh is global)
  89246. */
  89247. getBoundingInfo(): BoundingInfo;
  89248. /**
  89249. * Sets the submesh BoundingInfo
  89250. * @param boundingInfo defines the new bounding info to use
  89251. * @returns the SubMesh
  89252. */
  89253. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89254. /**
  89255. * Returns the mesh of the current submesh
  89256. * @return the parent mesh
  89257. */
  89258. getMesh(): AbstractMesh;
  89259. /**
  89260. * Returns the rendering mesh of the submesh
  89261. * @returns the rendering mesh (could be different from parent mesh)
  89262. */
  89263. getRenderingMesh(): Mesh;
  89264. /**
  89265. * Returns the submesh material
  89266. * @returns null or the current material
  89267. */
  89268. getMaterial(): Nullable<Material>;
  89269. /**
  89270. * Sets a new updated BoundingInfo object to the submesh
  89271. * @param data defines an optional position array to use to determine the bounding info
  89272. * @returns the SubMesh
  89273. */
  89274. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89275. /** @hidden */
  89276. _checkCollision(collider: Collider): boolean;
  89277. /**
  89278. * Updates the submesh BoundingInfo
  89279. * @param world defines the world matrix to use to update the bounding info
  89280. * @returns the submesh
  89281. */
  89282. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89283. /**
  89284. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89285. * @param frustumPlanes defines the frustum planes
  89286. * @returns true if the submesh is intersecting with the frustum
  89287. */
  89288. isInFrustum(frustumPlanes: Plane[]): boolean;
  89289. /**
  89290. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89291. * @param frustumPlanes defines the frustum planes
  89292. * @returns true if the submesh is inside the frustum
  89293. */
  89294. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89295. /**
  89296. * Renders the submesh
  89297. * @param enableAlphaMode defines if alpha needs to be used
  89298. * @returns the submesh
  89299. */
  89300. render(enableAlphaMode: boolean): SubMesh;
  89301. /**
  89302. * @hidden
  89303. */
  89304. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89305. /**
  89306. * Checks if the submesh intersects with a ray
  89307. * @param ray defines the ray to test
  89308. * @returns true is the passed ray intersects the submesh bounding box
  89309. */
  89310. canIntersects(ray: Ray): boolean;
  89311. /**
  89312. * Intersects current submesh with a ray
  89313. * @param ray defines the ray to test
  89314. * @param positions defines mesh's positions array
  89315. * @param indices defines mesh's indices array
  89316. * @param fastCheck defines if only bounding info should be used
  89317. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89318. * @returns intersection info or null if no intersection
  89319. */
  89320. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89321. /** @hidden */
  89322. private _intersectLines;
  89323. /** @hidden */
  89324. private _intersectUnIndexedLines;
  89325. /** @hidden */
  89326. private _intersectTriangles;
  89327. /** @hidden */
  89328. private _intersectUnIndexedTriangles;
  89329. /** @hidden */
  89330. _rebuild(): void;
  89331. /**
  89332. * Creates a new submesh from the passed mesh
  89333. * @param newMesh defines the new hosting mesh
  89334. * @param newRenderingMesh defines an optional rendering mesh
  89335. * @returns the new submesh
  89336. */
  89337. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89338. /**
  89339. * Release associated resources
  89340. */
  89341. dispose(): void;
  89342. /**
  89343. * Gets the class name
  89344. * @returns the string "SubMesh".
  89345. */
  89346. getClassName(): string;
  89347. /**
  89348. * Creates a new submesh from indices data
  89349. * @param materialIndex the index of the main mesh material
  89350. * @param startIndex the index where to start the copy in the mesh indices array
  89351. * @param indexCount the number of indices to copy then from the startIndex
  89352. * @param mesh the main mesh to create the submesh from
  89353. * @param renderingMesh the optional rendering mesh
  89354. * @returns a new submesh
  89355. */
  89356. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89357. }
  89358. }
  89359. declare module BABYLON {
  89360. /**
  89361. * Class used to represent data loading progression
  89362. */
  89363. export class SceneLoaderFlags {
  89364. private static _ForceFullSceneLoadingForIncremental;
  89365. private static _ShowLoadingScreen;
  89366. private static _CleanBoneMatrixWeights;
  89367. private static _loggingLevel;
  89368. /**
  89369. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89370. */
  89371. static ForceFullSceneLoadingForIncremental: boolean;
  89372. /**
  89373. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89374. */
  89375. static ShowLoadingScreen: boolean;
  89376. /**
  89377. * Defines the current logging level (while loading the scene)
  89378. * @ignorenaming
  89379. */
  89380. static loggingLevel: number;
  89381. /**
  89382. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89383. */
  89384. static CleanBoneMatrixWeights: boolean;
  89385. }
  89386. }
  89387. declare module BABYLON {
  89388. /**
  89389. * Class used to store geometry data (vertex buffers + index buffer)
  89390. */
  89391. export class Geometry implements IGetSetVerticesData {
  89392. /**
  89393. * Gets or sets the ID of the geometry
  89394. */
  89395. id: string;
  89396. /**
  89397. * Gets or sets the unique ID of the geometry
  89398. */
  89399. uniqueId: number;
  89400. /**
  89401. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89402. */
  89403. delayLoadState: number;
  89404. /**
  89405. * Gets the file containing the data to load when running in delay load state
  89406. */
  89407. delayLoadingFile: Nullable<string>;
  89408. /**
  89409. * Callback called when the geometry is updated
  89410. */
  89411. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89412. private _scene;
  89413. private _engine;
  89414. private _meshes;
  89415. private _totalVertices;
  89416. /** @hidden */
  89417. _indices: IndicesArray;
  89418. /** @hidden */
  89419. _vertexBuffers: {
  89420. [key: string]: VertexBuffer;
  89421. };
  89422. private _isDisposed;
  89423. private _extend;
  89424. private _boundingBias;
  89425. /** @hidden */
  89426. _delayInfo: Array<string>;
  89427. private _indexBuffer;
  89428. private _indexBufferIsUpdatable;
  89429. /** @hidden */
  89430. _boundingInfo: Nullable<BoundingInfo>;
  89431. /** @hidden */
  89432. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89433. /** @hidden */
  89434. _softwareSkinningFrameId: number;
  89435. private _vertexArrayObjects;
  89436. private _updatable;
  89437. /** @hidden */
  89438. _positions: Nullable<Vector3[]>;
  89439. /**
  89440. * 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
  89441. */
  89442. /**
  89443. * 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
  89444. */
  89445. boundingBias: Vector2;
  89446. /**
  89447. * Static function used to attach a new empty geometry to a mesh
  89448. * @param mesh defines the mesh to attach the geometry to
  89449. * @returns the new Geometry
  89450. */
  89451. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89452. /**
  89453. * Creates a new geometry
  89454. * @param id defines the unique ID
  89455. * @param scene defines the hosting scene
  89456. * @param vertexData defines the VertexData used to get geometry data
  89457. * @param updatable defines if geometry must be updatable (false by default)
  89458. * @param mesh defines the mesh that will be associated with the geometry
  89459. */
  89460. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89461. /**
  89462. * Gets the current extend of the geometry
  89463. */
  89464. readonly extend: {
  89465. minimum: Vector3;
  89466. maximum: Vector3;
  89467. };
  89468. /**
  89469. * Gets the hosting scene
  89470. * @returns the hosting Scene
  89471. */
  89472. getScene(): Scene;
  89473. /**
  89474. * Gets the hosting engine
  89475. * @returns the hosting Engine
  89476. */
  89477. getEngine(): Engine;
  89478. /**
  89479. * Defines if the geometry is ready to use
  89480. * @returns true if the geometry is ready to be used
  89481. */
  89482. isReady(): boolean;
  89483. /**
  89484. * Gets a value indicating that the geometry should not be serialized
  89485. */
  89486. readonly doNotSerialize: boolean;
  89487. /** @hidden */
  89488. _rebuild(): void;
  89489. /**
  89490. * Affects all geometry data in one call
  89491. * @param vertexData defines the geometry data
  89492. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89493. */
  89494. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89495. /**
  89496. * Set specific vertex data
  89497. * @param kind defines the data kind (Position, normal, etc...)
  89498. * @param data defines the vertex data to use
  89499. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89500. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89501. */
  89502. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89503. /**
  89504. * Removes a specific vertex data
  89505. * @param kind defines the data kind (Position, normal, etc...)
  89506. */
  89507. removeVerticesData(kind: string): void;
  89508. /**
  89509. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89510. * @param buffer defines the vertex buffer to use
  89511. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89512. */
  89513. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89514. /**
  89515. * Update a specific vertex buffer
  89516. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89517. * It will do nothing if the buffer is not updatable
  89518. * @param kind defines the data kind (Position, normal, etc...)
  89519. * @param data defines the data to use
  89520. * @param offset defines the offset in the target buffer where to store the data
  89521. * @param useBytes set to true if the offset is in bytes
  89522. */
  89523. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89524. /**
  89525. * Update a specific vertex buffer
  89526. * This function will create a new buffer if the current one is not updatable
  89527. * @param kind defines the data kind (Position, normal, etc...)
  89528. * @param data defines the data to use
  89529. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89530. */
  89531. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89532. private _updateBoundingInfo;
  89533. /** @hidden */
  89534. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89535. /**
  89536. * Gets total number of vertices
  89537. * @returns the total number of vertices
  89538. */
  89539. getTotalVertices(): number;
  89540. /**
  89541. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89542. * @param kind defines the data kind (Position, normal, etc...)
  89543. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89544. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89545. * @returns a float array containing vertex data
  89546. */
  89547. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89548. /**
  89549. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89550. * @param kind defines the data kind (Position, normal, etc...)
  89551. * @returns true if the vertex buffer with the specified kind is updatable
  89552. */
  89553. isVertexBufferUpdatable(kind: string): boolean;
  89554. /**
  89555. * Gets a specific vertex buffer
  89556. * @param kind defines the data kind (Position, normal, etc...)
  89557. * @returns a VertexBuffer
  89558. */
  89559. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89560. /**
  89561. * Returns all vertex buffers
  89562. * @return an object holding all vertex buffers indexed by kind
  89563. */
  89564. getVertexBuffers(): Nullable<{
  89565. [key: string]: VertexBuffer;
  89566. }>;
  89567. /**
  89568. * Gets a boolean indicating if specific vertex buffer is present
  89569. * @param kind defines the data kind (Position, normal, etc...)
  89570. * @returns true if data is present
  89571. */
  89572. isVerticesDataPresent(kind: string): boolean;
  89573. /**
  89574. * Gets a list of all attached data kinds (Position, normal, etc...)
  89575. * @returns a list of string containing all kinds
  89576. */
  89577. getVerticesDataKinds(): string[];
  89578. /**
  89579. * Update index buffer
  89580. * @param indices defines the indices to store in the index buffer
  89581. * @param offset defines the offset in the target buffer where to store the data
  89582. * @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)
  89583. */
  89584. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89585. /**
  89586. * Creates a new index buffer
  89587. * @param indices defines the indices to store in the index buffer
  89588. * @param totalVertices defines the total number of vertices (could be null)
  89589. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89590. */
  89591. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89592. /**
  89593. * Return the total number of indices
  89594. * @returns the total number of indices
  89595. */
  89596. getTotalIndices(): number;
  89597. /**
  89598. * Gets the index buffer array
  89599. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89600. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89601. * @returns the index buffer array
  89602. */
  89603. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89604. /**
  89605. * Gets the index buffer
  89606. * @return the index buffer
  89607. */
  89608. getIndexBuffer(): Nullable<DataBuffer>;
  89609. /** @hidden */
  89610. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89611. /**
  89612. * Release the associated resources for a specific mesh
  89613. * @param mesh defines the source mesh
  89614. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89615. */
  89616. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89617. /**
  89618. * Apply current geometry to a given mesh
  89619. * @param mesh defines the mesh to apply geometry to
  89620. */
  89621. applyToMesh(mesh: Mesh): void;
  89622. private _updateExtend;
  89623. private _applyToMesh;
  89624. private notifyUpdate;
  89625. /**
  89626. * Load the geometry if it was flagged as delay loaded
  89627. * @param scene defines the hosting scene
  89628. * @param onLoaded defines a callback called when the geometry is loaded
  89629. */
  89630. load(scene: Scene, onLoaded?: () => void): void;
  89631. private _queueLoad;
  89632. /**
  89633. * Invert the geometry to move from a right handed system to a left handed one.
  89634. */
  89635. toLeftHanded(): void;
  89636. /** @hidden */
  89637. _resetPointsArrayCache(): void;
  89638. /** @hidden */
  89639. _generatePointsArray(): boolean;
  89640. /**
  89641. * Gets a value indicating if the geometry is disposed
  89642. * @returns true if the geometry was disposed
  89643. */
  89644. isDisposed(): boolean;
  89645. private _disposeVertexArrayObjects;
  89646. /**
  89647. * Free all associated resources
  89648. */
  89649. dispose(): void;
  89650. /**
  89651. * Clone the current geometry into a new geometry
  89652. * @param id defines the unique ID of the new geometry
  89653. * @returns a new geometry object
  89654. */
  89655. copy(id: string): Geometry;
  89656. /**
  89657. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89658. * @return a JSON representation of the current geometry data (without the vertices data)
  89659. */
  89660. serialize(): any;
  89661. private toNumberArray;
  89662. /**
  89663. * Serialize all vertices data into a JSON oject
  89664. * @returns a JSON representation of the current geometry data
  89665. */
  89666. serializeVerticeData(): any;
  89667. /**
  89668. * Extracts a clone of a mesh geometry
  89669. * @param mesh defines the source mesh
  89670. * @param id defines the unique ID of the new geometry object
  89671. * @returns the new geometry object
  89672. */
  89673. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89674. /**
  89675. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89676. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89677. * Be aware Math.random() could cause collisions, but:
  89678. * "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"
  89679. * @returns a string containing a new GUID
  89680. */
  89681. static RandomId(): string;
  89682. /** @hidden */
  89683. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89684. private static _CleanMatricesWeights;
  89685. /**
  89686. * Create a new geometry from persisted data (Using .babylon file format)
  89687. * @param parsedVertexData defines the persisted data
  89688. * @param scene defines the hosting scene
  89689. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89690. * @returns the new geometry object
  89691. */
  89692. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89693. }
  89694. }
  89695. declare module BABYLON {
  89696. /**
  89697. * Define an interface for all classes that will get and set the data on vertices
  89698. */
  89699. export interface IGetSetVerticesData {
  89700. /**
  89701. * Gets a boolean indicating if specific vertex data is present
  89702. * @param kind defines the vertex data kind to use
  89703. * @returns true is data kind is present
  89704. */
  89705. isVerticesDataPresent(kind: string): boolean;
  89706. /**
  89707. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89708. * @param kind defines the data kind (Position, normal, etc...)
  89709. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89711. * @returns a float array containing vertex data
  89712. */
  89713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89714. /**
  89715. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89716. * @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.
  89717. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89718. * @returns the indices array or an empty array if the mesh has no geometry
  89719. */
  89720. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89721. /**
  89722. * Set specific vertex data
  89723. * @param kind defines the data kind (Position, normal, etc...)
  89724. * @param data defines the vertex data to use
  89725. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89726. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89727. */
  89728. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89729. /**
  89730. * Update a specific associated vertex buffer
  89731. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89732. * - VertexBuffer.PositionKind
  89733. * - VertexBuffer.UVKind
  89734. * - VertexBuffer.UV2Kind
  89735. * - VertexBuffer.UV3Kind
  89736. * - VertexBuffer.UV4Kind
  89737. * - VertexBuffer.UV5Kind
  89738. * - VertexBuffer.UV6Kind
  89739. * - VertexBuffer.ColorKind
  89740. * - VertexBuffer.MatricesIndicesKind
  89741. * - VertexBuffer.MatricesIndicesExtraKind
  89742. * - VertexBuffer.MatricesWeightsKind
  89743. * - VertexBuffer.MatricesWeightsExtraKind
  89744. * @param data defines the data source
  89745. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89746. * @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)
  89747. */
  89748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89749. /**
  89750. * Creates a new index buffer
  89751. * @param indices defines the indices to store in the index buffer
  89752. * @param totalVertices defines the total number of vertices (could be null)
  89753. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89754. */
  89755. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89756. }
  89757. /**
  89758. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89759. */
  89760. export class VertexData {
  89761. /**
  89762. * Mesh side orientation : usually the external or front surface
  89763. */
  89764. static readonly FRONTSIDE: number;
  89765. /**
  89766. * Mesh side orientation : usually the internal or back surface
  89767. */
  89768. static readonly BACKSIDE: number;
  89769. /**
  89770. * Mesh side orientation : both internal and external or front and back surfaces
  89771. */
  89772. static readonly DOUBLESIDE: number;
  89773. /**
  89774. * Mesh side orientation : by default, `FRONTSIDE`
  89775. */
  89776. static readonly DEFAULTSIDE: number;
  89777. /**
  89778. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89779. */
  89780. positions: Nullable<FloatArray>;
  89781. /**
  89782. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89783. */
  89784. normals: Nullable<FloatArray>;
  89785. /**
  89786. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89787. */
  89788. tangents: Nullable<FloatArray>;
  89789. /**
  89790. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89791. */
  89792. uvs: Nullable<FloatArray>;
  89793. /**
  89794. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89795. */
  89796. uvs2: Nullable<FloatArray>;
  89797. /**
  89798. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89799. */
  89800. uvs3: Nullable<FloatArray>;
  89801. /**
  89802. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89803. */
  89804. uvs4: Nullable<FloatArray>;
  89805. /**
  89806. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89807. */
  89808. uvs5: Nullable<FloatArray>;
  89809. /**
  89810. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89811. */
  89812. uvs6: Nullable<FloatArray>;
  89813. /**
  89814. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89815. */
  89816. colors: Nullable<FloatArray>;
  89817. /**
  89818. * 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).
  89819. */
  89820. matricesIndices: Nullable<FloatArray>;
  89821. /**
  89822. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89823. */
  89824. matricesWeights: Nullable<FloatArray>;
  89825. /**
  89826. * An array extending the number of possible indices
  89827. */
  89828. matricesIndicesExtra: Nullable<FloatArray>;
  89829. /**
  89830. * An array extending the number of possible weights when the number of indices is extended
  89831. */
  89832. matricesWeightsExtra: Nullable<FloatArray>;
  89833. /**
  89834. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89835. */
  89836. indices: Nullable<IndicesArray>;
  89837. /**
  89838. * Uses the passed data array to set the set the values for the specified kind of data
  89839. * @param data a linear array of floating numbers
  89840. * @param kind the type of data that is being set, eg positions, colors etc
  89841. */
  89842. set(data: FloatArray, kind: string): void;
  89843. /**
  89844. * Associates the vertexData to the passed Mesh.
  89845. * Sets it as updatable or not (default `false`)
  89846. * @param mesh the mesh the vertexData is applied to
  89847. * @param updatable when used and having the value true allows new data to update the vertexData
  89848. * @returns the VertexData
  89849. */
  89850. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89851. /**
  89852. * Associates the vertexData to the passed Geometry.
  89853. * Sets it as updatable or not (default `false`)
  89854. * @param geometry the geometry the vertexData is applied to
  89855. * @param updatable when used and having the value true allows new data to update the vertexData
  89856. * @returns VertexData
  89857. */
  89858. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89859. /**
  89860. * Updates the associated mesh
  89861. * @param mesh the mesh to be updated
  89862. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89863. * @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
  89864. * @returns VertexData
  89865. */
  89866. updateMesh(mesh: Mesh): VertexData;
  89867. /**
  89868. * Updates the associated geometry
  89869. * @param geometry the geometry to be updated
  89870. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89871. * @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
  89872. * @returns VertexData.
  89873. */
  89874. updateGeometry(geometry: Geometry): VertexData;
  89875. private _applyTo;
  89876. private _update;
  89877. /**
  89878. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89879. * @param matrix the transforming matrix
  89880. * @returns the VertexData
  89881. */
  89882. transform(matrix: Matrix): VertexData;
  89883. /**
  89884. * Merges the passed VertexData into the current one
  89885. * @param other the VertexData to be merged into the current one
  89886. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89887. * @returns the modified VertexData
  89888. */
  89889. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89890. private _mergeElement;
  89891. private _validate;
  89892. /**
  89893. * Serializes the VertexData
  89894. * @returns a serialized object
  89895. */
  89896. serialize(): any;
  89897. /**
  89898. * Extracts the vertexData from a mesh
  89899. * @param mesh the mesh from which to extract the VertexData
  89900. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89901. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89902. * @returns the object VertexData associated to the passed mesh
  89903. */
  89904. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89905. /**
  89906. * Extracts the vertexData from the geometry
  89907. * @param geometry the geometry from which to extract the VertexData
  89908. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89909. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89910. * @returns the object VertexData associated to the passed mesh
  89911. */
  89912. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89913. private static _ExtractFrom;
  89914. /**
  89915. * Creates the VertexData for a Ribbon
  89916. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89917. * * pathArray array of paths, each of which an array of successive Vector3
  89918. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89919. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89920. * * 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
  89921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89922. * * 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)
  89923. * * 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)
  89924. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89925. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89926. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89927. * @returns the VertexData of the ribbon
  89928. */
  89929. static CreateRibbon(options: {
  89930. pathArray: Vector3[][];
  89931. closeArray?: boolean;
  89932. closePath?: boolean;
  89933. offset?: number;
  89934. sideOrientation?: number;
  89935. frontUVs?: Vector4;
  89936. backUVs?: Vector4;
  89937. invertUV?: boolean;
  89938. uvs?: Vector2[];
  89939. colors?: Color4[];
  89940. }): VertexData;
  89941. /**
  89942. * Creates the VertexData for a box
  89943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89944. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89945. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89946. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89947. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89948. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89949. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89951. * * 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)
  89952. * * 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)
  89953. * @returns the VertexData of the box
  89954. */
  89955. static CreateBox(options: {
  89956. size?: number;
  89957. width?: number;
  89958. height?: number;
  89959. depth?: number;
  89960. faceUV?: Vector4[];
  89961. faceColors?: Color4[];
  89962. sideOrientation?: number;
  89963. frontUVs?: Vector4;
  89964. backUVs?: Vector4;
  89965. }): VertexData;
  89966. /**
  89967. * Creates the VertexData for a tiled box
  89968. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89969. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89970. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89971. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89973. * @returns the VertexData of the box
  89974. */
  89975. static CreateTiledBox(options: {
  89976. pattern?: number;
  89977. width?: number;
  89978. height?: number;
  89979. depth?: number;
  89980. tileSize?: number;
  89981. tileWidth?: number;
  89982. tileHeight?: number;
  89983. alignHorizontal?: number;
  89984. alignVertical?: number;
  89985. faceUV?: Vector4[];
  89986. faceColors?: Color4[];
  89987. sideOrientation?: number;
  89988. }): VertexData;
  89989. /**
  89990. * Creates the VertexData for a tiled plane
  89991. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89992. * * pattern a limited pattern arrangement depending on the number
  89993. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89994. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89995. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89997. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  89998. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  89999. * @returns the VertexData of the tiled plane
  90000. */
  90001. static CreateTiledPlane(options: {
  90002. pattern?: number;
  90003. tileSize?: number;
  90004. tileWidth?: number;
  90005. tileHeight?: number;
  90006. size?: number;
  90007. width?: number;
  90008. height?: number;
  90009. alignHorizontal?: number;
  90010. alignVertical?: number;
  90011. sideOrientation?: number;
  90012. frontUVs?: Vector4;
  90013. backUVs?: Vector4;
  90014. }): VertexData;
  90015. /**
  90016. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90018. * * segments sets the number of horizontal strips optional, default 32
  90019. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90020. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90021. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90022. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90023. * * 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
  90024. * * 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
  90025. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90026. * * 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)
  90027. * * 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)
  90028. * @returns the VertexData of the ellipsoid
  90029. */
  90030. static CreateSphere(options: {
  90031. segments?: number;
  90032. diameter?: number;
  90033. diameterX?: number;
  90034. diameterY?: number;
  90035. diameterZ?: number;
  90036. arc?: number;
  90037. slice?: number;
  90038. sideOrientation?: number;
  90039. frontUVs?: Vector4;
  90040. backUVs?: Vector4;
  90041. }): VertexData;
  90042. /**
  90043. * Creates the VertexData for a cylinder, cone or prism
  90044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90045. * * height sets the height (y direction) of the cylinder, optional, default 2
  90046. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90047. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90048. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90049. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90050. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90051. * * 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
  90052. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90053. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90054. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90055. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90057. * * 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)
  90058. * * 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)
  90059. * @returns the VertexData of the cylinder, cone or prism
  90060. */
  90061. static CreateCylinder(options: {
  90062. height?: number;
  90063. diameterTop?: number;
  90064. diameterBottom?: number;
  90065. diameter?: number;
  90066. tessellation?: number;
  90067. subdivisions?: number;
  90068. arc?: number;
  90069. faceColors?: Color4[];
  90070. faceUV?: Vector4[];
  90071. hasRings?: boolean;
  90072. enclose?: boolean;
  90073. sideOrientation?: number;
  90074. frontUVs?: Vector4;
  90075. backUVs?: Vector4;
  90076. }): VertexData;
  90077. /**
  90078. * Creates the VertexData for a torus
  90079. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90080. * * diameter the diameter of the torus, optional default 1
  90081. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90082. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90084. * * 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)
  90085. * * 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)
  90086. * @returns the VertexData of the torus
  90087. */
  90088. static CreateTorus(options: {
  90089. diameter?: number;
  90090. thickness?: number;
  90091. tessellation?: number;
  90092. sideOrientation?: number;
  90093. frontUVs?: Vector4;
  90094. backUVs?: Vector4;
  90095. }): VertexData;
  90096. /**
  90097. * Creates the VertexData of the LineSystem
  90098. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90099. * - lines an array of lines, each line being an array of successive Vector3
  90100. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90101. * @returns the VertexData of the LineSystem
  90102. */
  90103. static CreateLineSystem(options: {
  90104. lines: Vector3[][];
  90105. colors?: Nullable<Color4[][]>;
  90106. }): VertexData;
  90107. /**
  90108. * Create the VertexData for a DashedLines
  90109. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90110. * - points an array successive Vector3
  90111. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90112. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90113. * - dashNb the intended total number of dashes, optional, default 200
  90114. * @returns the VertexData for the DashedLines
  90115. */
  90116. static CreateDashedLines(options: {
  90117. points: Vector3[];
  90118. dashSize?: number;
  90119. gapSize?: number;
  90120. dashNb?: number;
  90121. }): VertexData;
  90122. /**
  90123. * Creates the VertexData for a Ground
  90124. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90125. * - width the width (x direction) of the ground, optional, default 1
  90126. * - height the height (z direction) of the ground, optional, default 1
  90127. * - subdivisions the number of subdivisions per side, optional, default 1
  90128. * @returns the VertexData of the Ground
  90129. */
  90130. static CreateGround(options: {
  90131. width?: number;
  90132. height?: number;
  90133. subdivisions?: number;
  90134. subdivisionsX?: number;
  90135. subdivisionsY?: number;
  90136. }): VertexData;
  90137. /**
  90138. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90139. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90140. * * xmin the ground minimum X coordinate, optional, default -1
  90141. * * zmin the ground minimum Z coordinate, optional, default -1
  90142. * * xmax the ground maximum X coordinate, optional, default 1
  90143. * * zmax the ground maximum Z coordinate, optional, default 1
  90144. * * 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}
  90145. * * 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}
  90146. * @returns the VertexData of the TiledGround
  90147. */
  90148. static CreateTiledGround(options: {
  90149. xmin: number;
  90150. zmin: number;
  90151. xmax: number;
  90152. zmax: number;
  90153. subdivisions?: {
  90154. w: number;
  90155. h: number;
  90156. };
  90157. precision?: {
  90158. w: number;
  90159. h: number;
  90160. };
  90161. }): VertexData;
  90162. /**
  90163. * Creates the VertexData of the Ground designed from a heightmap
  90164. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90165. * * width the width (x direction) of the ground
  90166. * * height the height (z direction) of the ground
  90167. * * subdivisions the number of subdivisions per side
  90168. * * minHeight the minimum altitude on the ground, optional, default 0
  90169. * * maxHeight the maximum altitude on the ground, optional default 1
  90170. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90171. * * buffer the array holding the image color data
  90172. * * bufferWidth the width of image
  90173. * * bufferHeight the height of image
  90174. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90175. * @returns the VertexData of the Ground designed from a heightmap
  90176. */
  90177. static CreateGroundFromHeightMap(options: {
  90178. width: number;
  90179. height: number;
  90180. subdivisions: number;
  90181. minHeight: number;
  90182. maxHeight: number;
  90183. colorFilter: Color3;
  90184. buffer: Uint8Array;
  90185. bufferWidth: number;
  90186. bufferHeight: number;
  90187. alphaFilter: number;
  90188. }): VertexData;
  90189. /**
  90190. * Creates the VertexData for a Plane
  90191. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90192. * * size sets the width and height of the plane to the value of size, optional default 1
  90193. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90194. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90196. * * 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)
  90197. * * 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)
  90198. * @returns the VertexData of the box
  90199. */
  90200. static CreatePlane(options: {
  90201. size?: number;
  90202. width?: number;
  90203. height?: number;
  90204. sideOrientation?: number;
  90205. frontUVs?: Vector4;
  90206. backUVs?: Vector4;
  90207. }): VertexData;
  90208. /**
  90209. * Creates the VertexData of the Disc or regular Polygon
  90210. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90211. * * radius the radius of the disc, optional default 0.5
  90212. * * tessellation the number of polygon sides, optional, default 64
  90213. * * 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
  90214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90215. * * 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)
  90216. * * 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)
  90217. * @returns the VertexData of the box
  90218. */
  90219. static CreateDisc(options: {
  90220. radius?: number;
  90221. tessellation?: number;
  90222. arc?: number;
  90223. sideOrientation?: number;
  90224. frontUVs?: Vector4;
  90225. backUVs?: Vector4;
  90226. }): VertexData;
  90227. /**
  90228. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90229. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90230. * @param polygon a mesh built from polygonTriangulation.build()
  90231. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90232. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90233. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90234. * @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)
  90235. * @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)
  90236. * @returns the VertexData of the Polygon
  90237. */
  90238. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90239. /**
  90240. * Creates the VertexData of the IcoSphere
  90241. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90242. * * radius the radius of the IcoSphere, optional default 1
  90243. * * radiusX allows stretching in the x direction, optional, default radius
  90244. * * radiusY allows stretching in the y direction, optional, default radius
  90245. * * radiusZ allows stretching in the z direction, optional, default radius
  90246. * * flat when true creates a flat shaded mesh, optional, default true
  90247. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90249. * * 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)
  90250. * * 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)
  90251. * @returns the VertexData of the IcoSphere
  90252. */
  90253. static CreateIcoSphere(options: {
  90254. radius?: number;
  90255. radiusX?: number;
  90256. radiusY?: number;
  90257. radiusZ?: number;
  90258. flat?: boolean;
  90259. subdivisions?: number;
  90260. sideOrientation?: number;
  90261. frontUVs?: Vector4;
  90262. backUVs?: Vector4;
  90263. }): VertexData;
  90264. /**
  90265. * Creates the VertexData for a Polyhedron
  90266. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90267. * * type provided types are:
  90268. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90269. * * 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)
  90270. * * size the size of the IcoSphere, optional default 1
  90271. * * sizeX allows stretching in the x direction, optional, default size
  90272. * * sizeY allows stretching in the y direction, optional, default size
  90273. * * sizeZ allows stretching in the z direction, optional, default size
  90274. * * 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
  90275. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90276. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90277. * * flat when true creates a flat shaded mesh, optional, default true
  90278. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90280. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  90281. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  90282. * @returns the VertexData of the Polyhedron
  90283. */
  90284. static CreatePolyhedron(options: {
  90285. type?: number;
  90286. size?: number;
  90287. sizeX?: number;
  90288. sizeY?: number;
  90289. sizeZ?: number;
  90290. custom?: any;
  90291. faceUV?: Vector4[];
  90292. faceColors?: Color4[];
  90293. flat?: boolean;
  90294. sideOrientation?: number;
  90295. frontUVs?: Vector4;
  90296. backUVs?: Vector4;
  90297. }): VertexData;
  90298. /**
  90299. * Creates the VertexData for a TorusKnot
  90300. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90301. * * radius the radius of the torus knot, optional, default 2
  90302. * * tube the thickness of the tube, optional, default 0.5
  90303. * * radialSegments the number of sides on each tube segments, optional, default 32
  90304. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90305. * * p the number of windings around the z axis, optional, default 2
  90306. * * q the number of windings around the x axis, optional, default 3
  90307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90308. * * 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)
  90309. * * 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)
  90310. * @returns the VertexData of the Torus Knot
  90311. */
  90312. static CreateTorusKnot(options: {
  90313. radius?: number;
  90314. tube?: number;
  90315. radialSegments?: number;
  90316. tubularSegments?: number;
  90317. p?: number;
  90318. q?: number;
  90319. sideOrientation?: number;
  90320. frontUVs?: Vector4;
  90321. backUVs?: Vector4;
  90322. }): VertexData;
  90323. /**
  90324. * Compute normals for given positions and indices
  90325. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90326. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90327. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90328. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90329. * * facetNormals : optional array of facet normals (vector3)
  90330. * * facetPositions : optional array of facet positions (vector3)
  90331. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90332. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90333. * * bInfo : optional bounding info, required for facetPartitioning computation
  90334. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90335. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90336. * * useRightHandedSystem: optional boolean to for right handed system computation
  90337. * * depthSort : optional boolean to enable the facet depth sort computation
  90338. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90339. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90340. */
  90341. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90342. facetNormals?: any;
  90343. facetPositions?: any;
  90344. facetPartitioning?: any;
  90345. ratio?: number;
  90346. bInfo?: any;
  90347. bbSize?: Vector3;
  90348. subDiv?: any;
  90349. useRightHandedSystem?: boolean;
  90350. depthSort?: boolean;
  90351. distanceTo?: Vector3;
  90352. depthSortedFacets?: any;
  90353. }): void;
  90354. /** @hidden */
  90355. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90356. /**
  90357. * Applies VertexData created from the imported parameters to the geometry
  90358. * @param parsedVertexData the parsed data from an imported file
  90359. * @param geometry the geometry to apply the VertexData to
  90360. */
  90361. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90362. }
  90363. }
  90364. declare module BABYLON {
  90365. /**
  90366. * Defines a target to use with MorphTargetManager
  90367. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90368. */
  90369. export class MorphTarget implements IAnimatable {
  90370. /** defines the name of the target */
  90371. name: string;
  90372. /**
  90373. * Gets or sets the list of animations
  90374. */
  90375. animations: Animation[];
  90376. private _scene;
  90377. private _positions;
  90378. private _normals;
  90379. private _tangents;
  90380. private _uvs;
  90381. private _influence;
  90382. private _uniqueId;
  90383. /**
  90384. * Observable raised when the influence changes
  90385. */
  90386. onInfluenceChanged: Observable<boolean>;
  90387. /** @hidden */
  90388. _onDataLayoutChanged: Observable<void>;
  90389. /**
  90390. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90391. */
  90392. influence: number;
  90393. /**
  90394. * Gets or sets the id of the morph Target
  90395. */
  90396. id: string;
  90397. private _animationPropertiesOverride;
  90398. /**
  90399. * Gets or sets the animation properties override
  90400. */
  90401. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90402. /**
  90403. * Creates a new MorphTarget
  90404. * @param name defines the name of the target
  90405. * @param influence defines the influence to use
  90406. * @param scene defines the scene the morphtarget belongs to
  90407. */
  90408. constructor(
  90409. /** defines the name of the target */
  90410. name: string, influence?: number, scene?: Nullable<Scene>);
  90411. /**
  90412. * Gets the unique ID of this manager
  90413. */
  90414. readonly uniqueId: number;
  90415. /**
  90416. * Gets a boolean defining if the target contains position data
  90417. */
  90418. readonly hasPositions: boolean;
  90419. /**
  90420. * Gets a boolean defining if the target contains normal data
  90421. */
  90422. readonly hasNormals: boolean;
  90423. /**
  90424. * Gets a boolean defining if the target contains tangent data
  90425. */
  90426. readonly hasTangents: boolean;
  90427. /**
  90428. * Gets a boolean defining if the target contains texture coordinates data
  90429. */
  90430. readonly hasUVs: boolean;
  90431. /**
  90432. * Affects position data to this target
  90433. * @param data defines the position data to use
  90434. */
  90435. setPositions(data: Nullable<FloatArray>): void;
  90436. /**
  90437. * Gets the position data stored in this target
  90438. * @returns a FloatArray containing the position data (or null if not present)
  90439. */
  90440. getPositions(): Nullable<FloatArray>;
  90441. /**
  90442. * Affects normal data to this target
  90443. * @param data defines the normal data to use
  90444. */
  90445. setNormals(data: Nullable<FloatArray>): void;
  90446. /**
  90447. * Gets the normal data stored in this target
  90448. * @returns a FloatArray containing the normal data (or null if not present)
  90449. */
  90450. getNormals(): Nullable<FloatArray>;
  90451. /**
  90452. * Affects tangent data to this target
  90453. * @param data defines the tangent data to use
  90454. */
  90455. setTangents(data: Nullable<FloatArray>): void;
  90456. /**
  90457. * Gets the tangent data stored in this target
  90458. * @returns a FloatArray containing the tangent data (or null if not present)
  90459. */
  90460. getTangents(): Nullable<FloatArray>;
  90461. /**
  90462. * Affects texture coordinates data to this target
  90463. * @param data defines the texture coordinates data to use
  90464. */
  90465. setUVs(data: Nullable<FloatArray>): void;
  90466. /**
  90467. * Gets the texture coordinates data stored in this target
  90468. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90469. */
  90470. getUVs(): Nullable<FloatArray>;
  90471. /**
  90472. * Clone the current target
  90473. * @returns a new MorphTarget
  90474. */
  90475. clone(): MorphTarget;
  90476. /**
  90477. * Serializes the current target into a Serialization object
  90478. * @returns the serialized object
  90479. */
  90480. serialize(): any;
  90481. /**
  90482. * Returns the string "MorphTarget"
  90483. * @returns "MorphTarget"
  90484. */
  90485. getClassName(): string;
  90486. /**
  90487. * Creates a new target from serialized data
  90488. * @param serializationObject defines the serialized data to use
  90489. * @returns a new MorphTarget
  90490. */
  90491. static Parse(serializationObject: any): MorphTarget;
  90492. /**
  90493. * Creates a MorphTarget from mesh data
  90494. * @param mesh defines the source mesh
  90495. * @param name defines the name to use for the new target
  90496. * @param influence defines the influence to attach to the target
  90497. * @returns a new MorphTarget
  90498. */
  90499. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90500. }
  90501. }
  90502. declare module BABYLON {
  90503. /**
  90504. * This class is used to deform meshes using morphing between different targets
  90505. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90506. */
  90507. export class MorphTargetManager {
  90508. private _targets;
  90509. private _targetInfluenceChangedObservers;
  90510. private _targetDataLayoutChangedObservers;
  90511. private _activeTargets;
  90512. private _scene;
  90513. private _influences;
  90514. private _supportsNormals;
  90515. private _supportsTangents;
  90516. private _supportsUVs;
  90517. private _vertexCount;
  90518. private _uniqueId;
  90519. private _tempInfluences;
  90520. /**
  90521. * Gets or sets a boolean indicating if normals must be morphed
  90522. */
  90523. enableNormalMorphing: boolean;
  90524. /**
  90525. * Gets or sets a boolean indicating if tangents must be morphed
  90526. */
  90527. enableTangentMorphing: boolean;
  90528. /**
  90529. * Gets or sets a boolean indicating if UV must be morphed
  90530. */
  90531. enableUVMorphing: boolean;
  90532. /**
  90533. * Creates a new MorphTargetManager
  90534. * @param scene defines the current scene
  90535. */
  90536. constructor(scene?: Nullable<Scene>);
  90537. /**
  90538. * Gets the unique ID of this manager
  90539. */
  90540. readonly uniqueId: number;
  90541. /**
  90542. * Gets the number of vertices handled by this manager
  90543. */
  90544. readonly vertexCount: number;
  90545. /**
  90546. * Gets a boolean indicating if this manager supports morphing of normals
  90547. */
  90548. readonly supportsNormals: boolean;
  90549. /**
  90550. * Gets a boolean indicating if this manager supports morphing of tangents
  90551. */
  90552. readonly supportsTangents: boolean;
  90553. /**
  90554. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90555. */
  90556. readonly supportsUVs: boolean;
  90557. /**
  90558. * Gets the number of targets stored in this manager
  90559. */
  90560. readonly numTargets: number;
  90561. /**
  90562. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90563. */
  90564. readonly numInfluencers: number;
  90565. /**
  90566. * Gets the list of influences (one per target)
  90567. */
  90568. readonly influences: Float32Array;
  90569. /**
  90570. * Gets the active target at specified index. An active target is a target with an influence > 0
  90571. * @param index defines the index to check
  90572. * @returns the requested target
  90573. */
  90574. getActiveTarget(index: number): MorphTarget;
  90575. /**
  90576. * Gets the target at specified index
  90577. * @param index defines the index to check
  90578. * @returns the requested target
  90579. */
  90580. getTarget(index: number): MorphTarget;
  90581. /**
  90582. * Add a new target to this manager
  90583. * @param target defines the target to add
  90584. */
  90585. addTarget(target: MorphTarget): void;
  90586. /**
  90587. * Removes a target from the manager
  90588. * @param target defines the target to remove
  90589. */
  90590. removeTarget(target: MorphTarget): void;
  90591. /**
  90592. * Clone the current manager
  90593. * @returns a new MorphTargetManager
  90594. */
  90595. clone(): MorphTargetManager;
  90596. /**
  90597. * Serializes the current manager into a Serialization object
  90598. * @returns the serialized object
  90599. */
  90600. serialize(): any;
  90601. private _syncActiveTargets;
  90602. /**
  90603. * Syncrhonize the targets with all the meshes using this morph target manager
  90604. */
  90605. synchronize(): void;
  90606. /**
  90607. * Creates a new MorphTargetManager from serialized data
  90608. * @param serializationObject defines the serialized data
  90609. * @param scene defines the hosting scene
  90610. * @returns the new MorphTargetManager
  90611. */
  90612. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90613. }
  90614. }
  90615. declare module BABYLON {
  90616. /**
  90617. * Class used to represent a specific level of detail of a mesh
  90618. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90619. */
  90620. export class MeshLODLevel {
  90621. /** Defines the distance where this level should start being displayed */
  90622. distance: number;
  90623. /** Defines the mesh to use to render this level */
  90624. mesh: Nullable<Mesh>;
  90625. /**
  90626. * Creates a new LOD level
  90627. * @param distance defines the distance where this level should star being displayed
  90628. * @param mesh defines the mesh to use to render this level
  90629. */
  90630. constructor(
  90631. /** Defines the distance where this level should start being displayed */
  90632. distance: number,
  90633. /** Defines the mesh to use to render this level */
  90634. mesh: Nullable<Mesh>);
  90635. }
  90636. }
  90637. declare module BABYLON {
  90638. /**
  90639. * Mesh representing the gorund
  90640. */
  90641. export class GroundMesh extends Mesh {
  90642. /** If octree should be generated */
  90643. generateOctree: boolean;
  90644. private _heightQuads;
  90645. /** @hidden */
  90646. _subdivisionsX: number;
  90647. /** @hidden */
  90648. _subdivisionsY: number;
  90649. /** @hidden */
  90650. _width: number;
  90651. /** @hidden */
  90652. _height: number;
  90653. /** @hidden */
  90654. _minX: number;
  90655. /** @hidden */
  90656. _maxX: number;
  90657. /** @hidden */
  90658. _minZ: number;
  90659. /** @hidden */
  90660. _maxZ: number;
  90661. constructor(name: string, scene: Scene);
  90662. /**
  90663. * "GroundMesh"
  90664. * @returns "GroundMesh"
  90665. */
  90666. getClassName(): string;
  90667. /**
  90668. * The minimum of x and y subdivisions
  90669. */
  90670. readonly subdivisions: number;
  90671. /**
  90672. * X subdivisions
  90673. */
  90674. readonly subdivisionsX: number;
  90675. /**
  90676. * Y subdivisions
  90677. */
  90678. readonly subdivisionsY: number;
  90679. /**
  90680. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90681. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90682. * @param chunksCount the number of subdivisions for x and y
  90683. * @param octreeBlocksSize (Default: 32)
  90684. */
  90685. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90686. /**
  90687. * Returns a height (y) value in the Worl system :
  90688. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90689. * @param x x coordinate
  90690. * @param z z coordinate
  90691. * @returns the ground y position if (x, z) are outside the ground surface.
  90692. */
  90693. getHeightAtCoordinates(x: number, z: number): number;
  90694. /**
  90695. * Returns a normalized vector (Vector3) orthogonal to the ground
  90696. * at the ground coordinates (x, z) expressed in the World system.
  90697. * @param x x coordinate
  90698. * @param z z coordinate
  90699. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90700. */
  90701. getNormalAtCoordinates(x: number, z: number): Vector3;
  90702. /**
  90703. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90704. * at the ground coordinates (x, z) expressed in the World system.
  90705. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90706. * @param x x coordinate
  90707. * @param z z coordinate
  90708. * @param ref vector to store the result
  90709. * @returns the GroundMesh.
  90710. */
  90711. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90712. /**
  90713. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90714. * if the ground has been updated.
  90715. * This can be used in the render loop.
  90716. * @returns the GroundMesh.
  90717. */
  90718. updateCoordinateHeights(): GroundMesh;
  90719. private _getFacetAt;
  90720. private _initHeightQuads;
  90721. private _computeHeightQuads;
  90722. /**
  90723. * Serializes this ground mesh
  90724. * @param serializationObject object to write serialization to
  90725. */
  90726. serialize(serializationObject: any): void;
  90727. /**
  90728. * Parses a serialized ground mesh
  90729. * @param parsedMesh the serialized mesh
  90730. * @param scene the scene to create the ground mesh in
  90731. * @returns the created ground mesh
  90732. */
  90733. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90734. }
  90735. }
  90736. declare module BABYLON {
  90737. /**
  90738. * Interface for Physics-Joint data
  90739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90740. */
  90741. export interface PhysicsJointData {
  90742. /**
  90743. * The main pivot of the joint
  90744. */
  90745. mainPivot?: Vector3;
  90746. /**
  90747. * The connected pivot of the joint
  90748. */
  90749. connectedPivot?: Vector3;
  90750. /**
  90751. * The main axis of the joint
  90752. */
  90753. mainAxis?: Vector3;
  90754. /**
  90755. * The connected axis of the joint
  90756. */
  90757. connectedAxis?: Vector3;
  90758. /**
  90759. * The collision of the joint
  90760. */
  90761. collision?: boolean;
  90762. /**
  90763. * Native Oimo/Cannon/Energy data
  90764. */
  90765. nativeParams?: any;
  90766. }
  90767. /**
  90768. * This is a holder class for the physics joint created by the physics plugin
  90769. * It holds a set of functions to control the underlying joint
  90770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90771. */
  90772. export class PhysicsJoint {
  90773. /**
  90774. * The type of the physics joint
  90775. */
  90776. type: number;
  90777. /**
  90778. * The data for the physics joint
  90779. */
  90780. jointData: PhysicsJointData;
  90781. private _physicsJoint;
  90782. protected _physicsPlugin: IPhysicsEnginePlugin;
  90783. /**
  90784. * Initializes the physics joint
  90785. * @param type The type of the physics joint
  90786. * @param jointData The data for the physics joint
  90787. */
  90788. constructor(
  90789. /**
  90790. * The type of the physics joint
  90791. */
  90792. type: number,
  90793. /**
  90794. * The data for the physics joint
  90795. */
  90796. jointData: PhysicsJointData);
  90797. /**
  90798. * Gets the physics joint
  90799. */
  90800. /**
  90801. * Sets the physics joint
  90802. */
  90803. physicsJoint: any;
  90804. /**
  90805. * Sets the physics plugin
  90806. */
  90807. physicsPlugin: IPhysicsEnginePlugin;
  90808. /**
  90809. * Execute a function that is physics-plugin specific.
  90810. * @param {Function} func the function that will be executed.
  90811. * It accepts two parameters: the physics world and the physics joint
  90812. */
  90813. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90814. /**
  90815. * Distance-Joint type
  90816. */
  90817. static DistanceJoint: number;
  90818. /**
  90819. * Hinge-Joint type
  90820. */
  90821. static HingeJoint: number;
  90822. /**
  90823. * Ball-and-Socket joint type
  90824. */
  90825. static BallAndSocketJoint: number;
  90826. /**
  90827. * Wheel-Joint type
  90828. */
  90829. static WheelJoint: number;
  90830. /**
  90831. * Slider-Joint type
  90832. */
  90833. static SliderJoint: number;
  90834. /**
  90835. * Prismatic-Joint type
  90836. */
  90837. static PrismaticJoint: number;
  90838. /**
  90839. * Universal-Joint type
  90840. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90841. */
  90842. static UniversalJoint: number;
  90843. /**
  90844. * Hinge-Joint 2 type
  90845. */
  90846. static Hinge2Joint: number;
  90847. /**
  90848. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90849. */
  90850. static PointToPointJoint: number;
  90851. /**
  90852. * Spring-Joint type
  90853. */
  90854. static SpringJoint: number;
  90855. /**
  90856. * Lock-Joint type
  90857. */
  90858. static LockJoint: number;
  90859. }
  90860. /**
  90861. * A class representing a physics distance joint
  90862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90863. */
  90864. export class DistanceJoint extends PhysicsJoint {
  90865. /**
  90866. *
  90867. * @param jointData The data for the Distance-Joint
  90868. */
  90869. constructor(jointData: DistanceJointData);
  90870. /**
  90871. * Update the predefined distance.
  90872. * @param maxDistance The maximum preferred distance
  90873. * @param minDistance The minimum preferred distance
  90874. */
  90875. updateDistance(maxDistance: number, minDistance?: number): void;
  90876. }
  90877. /**
  90878. * Represents a Motor-Enabled Joint
  90879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90880. */
  90881. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90882. /**
  90883. * Initializes the Motor-Enabled Joint
  90884. * @param type The type of the joint
  90885. * @param jointData The physica joint data for the joint
  90886. */
  90887. constructor(type: number, jointData: PhysicsJointData);
  90888. /**
  90889. * Set the motor values.
  90890. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90891. * @param force the force to apply
  90892. * @param maxForce max force for this motor.
  90893. */
  90894. setMotor(force?: number, maxForce?: number): void;
  90895. /**
  90896. * Set the motor's limits.
  90897. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90898. * @param upperLimit The upper limit of the motor
  90899. * @param lowerLimit The lower limit of the motor
  90900. */
  90901. setLimit(upperLimit: number, lowerLimit?: number): void;
  90902. }
  90903. /**
  90904. * This class represents a single physics Hinge-Joint
  90905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90906. */
  90907. export class HingeJoint extends MotorEnabledJoint {
  90908. /**
  90909. * Initializes the Hinge-Joint
  90910. * @param jointData The joint data for the Hinge-Joint
  90911. */
  90912. constructor(jointData: PhysicsJointData);
  90913. /**
  90914. * Set the motor values.
  90915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90916. * @param {number} force the force to apply
  90917. * @param {number} maxForce max force for this motor.
  90918. */
  90919. setMotor(force?: number, maxForce?: number): void;
  90920. /**
  90921. * Set the motor's limits.
  90922. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90923. * @param upperLimit The upper limit of the motor
  90924. * @param lowerLimit The lower limit of the motor
  90925. */
  90926. setLimit(upperLimit: number, lowerLimit?: number): void;
  90927. }
  90928. /**
  90929. * This class represents a dual hinge physics joint (same as wheel joint)
  90930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90931. */
  90932. export class Hinge2Joint extends MotorEnabledJoint {
  90933. /**
  90934. * Initializes the Hinge2-Joint
  90935. * @param jointData The joint data for the Hinge2-Joint
  90936. */
  90937. constructor(jointData: PhysicsJointData);
  90938. /**
  90939. * Set the motor values.
  90940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90941. * @param {number} targetSpeed the speed the motor is to reach
  90942. * @param {number} maxForce max force for this motor.
  90943. * @param {motorIndex} the motor's index, 0 or 1.
  90944. */
  90945. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90946. /**
  90947. * Set the motor limits.
  90948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90949. * @param {number} upperLimit the upper limit
  90950. * @param {number} lowerLimit lower limit
  90951. * @param {motorIndex} the motor's index, 0 or 1.
  90952. */
  90953. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90954. }
  90955. /**
  90956. * Interface for a motor enabled joint
  90957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90958. */
  90959. export interface IMotorEnabledJoint {
  90960. /**
  90961. * Physics joint
  90962. */
  90963. physicsJoint: any;
  90964. /**
  90965. * Sets the motor of the motor-enabled joint
  90966. * @param force The force of the motor
  90967. * @param maxForce The maximum force of the motor
  90968. * @param motorIndex The index of the motor
  90969. */
  90970. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90971. /**
  90972. * Sets the limit of the motor
  90973. * @param upperLimit The upper limit of the motor
  90974. * @param lowerLimit The lower limit of the motor
  90975. * @param motorIndex The index of the motor
  90976. */
  90977. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90978. }
  90979. /**
  90980. * Joint data for a Distance-Joint
  90981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90982. */
  90983. export interface DistanceJointData extends PhysicsJointData {
  90984. /**
  90985. * Max distance the 2 joint objects can be apart
  90986. */
  90987. maxDistance: number;
  90988. }
  90989. /**
  90990. * Joint data from a spring joint
  90991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90992. */
  90993. export interface SpringJointData extends PhysicsJointData {
  90994. /**
  90995. * Length of the spring
  90996. */
  90997. length: number;
  90998. /**
  90999. * Stiffness of the spring
  91000. */
  91001. stiffness: number;
  91002. /**
  91003. * Damping of the spring
  91004. */
  91005. damping: number;
  91006. /** this callback will be called when applying the force to the impostors. */
  91007. forceApplicationCallback: () => void;
  91008. }
  91009. }
  91010. declare module BABYLON {
  91011. /**
  91012. * Holds the data for the raycast result
  91013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91014. */
  91015. export class PhysicsRaycastResult {
  91016. private _hasHit;
  91017. private _hitDistance;
  91018. private _hitNormalWorld;
  91019. private _hitPointWorld;
  91020. private _rayFromWorld;
  91021. private _rayToWorld;
  91022. /**
  91023. * Gets if there was a hit
  91024. */
  91025. readonly hasHit: boolean;
  91026. /**
  91027. * Gets the distance from the hit
  91028. */
  91029. readonly hitDistance: number;
  91030. /**
  91031. * Gets the hit normal/direction in the world
  91032. */
  91033. readonly hitNormalWorld: Vector3;
  91034. /**
  91035. * Gets the hit point in the world
  91036. */
  91037. readonly hitPointWorld: Vector3;
  91038. /**
  91039. * Gets the ray "start point" of the ray in the world
  91040. */
  91041. readonly rayFromWorld: Vector3;
  91042. /**
  91043. * Gets the ray "end point" of the ray in the world
  91044. */
  91045. readonly rayToWorld: Vector3;
  91046. /**
  91047. * Sets the hit data (normal & point in world space)
  91048. * @param hitNormalWorld defines the normal in world space
  91049. * @param hitPointWorld defines the point in world space
  91050. */
  91051. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91052. /**
  91053. * Sets the distance from the start point to the hit point
  91054. * @param distance
  91055. */
  91056. setHitDistance(distance: number): void;
  91057. /**
  91058. * Calculates the distance manually
  91059. */
  91060. calculateHitDistance(): void;
  91061. /**
  91062. * Resets all the values to default
  91063. * @param from The from point on world space
  91064. * @param to The to point on world space
  91065. */
  91066. reset(from?: Vector3, to?: Vector3): void;
  91067. }
  91068. /**
  91069. * Interface for the size containing width and height
  91070. */
  91071. interface IXYZ {
  91072. /**
  91073. * X
  91074. */
  91075. x: number;
  91076. /**
  91077. * Y
  91078. */
  91079. y: number;
  91080. /**
  91081. * Z
  91082. */
  91083. z: number;
  91084. }
  91085. }
  91086. declare module BABYLON {
  91087. /**
  91088. * Interface used to describe a physics joint
  91089. */
  91090. export interface PhysicsImpostorJoint {
  91091. /** Defines the main impostor to which the joint is linked */
  91092. mainImpostor: PhysicsImpostor;
  91093. /** Defines the impostor that is connected to the main impostor using this joint */
  91094. connectedImpostor: PhysicsImpostor;
  91095. /** Defines the joint itself */
  91096. joint: PhysicsJoint;
  91097. }
  91098. /** @hidden */
  91099. export interface IPhysicsEnginePlugin {
  91100. world: any;
  91101. name: string;
  91102. setGravity(gravity: Vector3): void;
  91103. setTimeStep(timeStep: number): void;
  91104. getTimeStep(): number;
  91105. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91106. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91107. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91108. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91109. removePhysicsBody(impostor: PhysicsImpostor): void;
  91110. generateJoint(joint: PhysicsImpostorJoint): void;
  91111. removeJoint(joint: PhysicsImpostorJoint): void;
  91112. isSupported(): boolean;
  91113. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91114. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91115. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91116. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91117. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91118. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91119. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91120. getBodyMass(impostor: PhysicsImpostor): number;
  91121. getBodyFriction(impostor: PhysicsImpostor): number;
  91122. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91123. getBodyRestitution(impostor: PhysicsImpostor): number;
  91124. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91125. getBodyPressure?(impostor: PhysicsImpostor): number;
  91126. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91127. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91128. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91129. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91130. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91131. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91132. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91133. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91134. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91135. sleepBody(impostor: PhysicsImpostor): void;
  91136. wakeUpBody(impostor: PhysicsImpostor): void;
  91137. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91138. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91139. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91140. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91141. getRadius(impostor: PhysicsImpostor): number;
  91142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91143. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91144. dispose(): void;
  91145. }
  91146. /**
  91147. * Interface used to define a physics engine
  91148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91149. */
  91150. export interface IPhysicsEngine {
  91151. /**
  91152. * Gets the gravity vector used by the simulation
  91153. */
  91154. gravity: Vector3;
  91155. /**
  91156. * Sets the gravity vector used by the simulation
  91157. * @param gravity defines the gravity vector to use
  91158. */
  91159. setGravity(gravity: Vector3): void;
  91160. /**
  91161. * Set the time step of the physics engine.
  91162. * Default is 1/60.
  91163. * To slow it down, enter 1/600 for example.
  91164. * To speed it up, 1/30
  91165. * @param newTimeStep the new timestep to apply to this world.
  91166. */
  91167. setTimeStep(newTimeStep: number): void;
  91168. /**
  91169. * Get the time step of the physics engine.
  91170. * @returns the current time step
  91171. */
  91172. getTimeStep(): number;
  91173. /**
  91174. * Release all resources
  91175. */
  91176. dispose(): void;
  91177. /**
  91178. * Gets the name of the current physics plugin
  91179. * @returns the name of the plugin
  91180. */
  91181. getPhysicsPluginName(): string;
  91182. /**
  91183. * Adding a new impostor for the impostor tracking.
  91184. * This will be done by the impostor itself.
  91185. * @param impostor the impostor to add
  91186. */
  91187. addImpostor(impostor: PhysicsImpostor): void;
  91188. /**
  91189. * Remove an impostor from the engine.
  91190. * This impostor and its mesh will not longer be updated by the physics engine.
  91191. * @param impostor the impostor to remove
  91192. */
  91193. removeImpostor(impostor: PhysicsImpostor): void;
  91194. /**
  91195. * Add a joint to the physics engine
  91196. * @param mainImpostor defines the main impostor to which the joint is added.
  91197. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91198. * @param joint defines the joint that will connect both impostors.
  91199. */
  91200. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91201. /**
  91202. * Removes a joint from the simulation
  91203. * @param mainImpostor defines the impostor used with the joint
  91204. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91205. * @param joint defines the joint to remove
  91206. */
  91207. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91208. /**
  91209. * Gets the current plugin used to run the simulation
  91210. * @returns current plugin
  91211. */
  91212. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91213. /**
  91214. * Gets the list of physic impostors
  91215. * @returns an array of PhysicsImpostor
  91216. */
  91217. getImpostors(): Array<PhysicsImpostor>;
  91218. /**
  91219. * Gets the impostor for a physics enabled object
  91220. * @param object defines the object impersonated by the impostor
  91221. * @returns the PhysicsImpostor or null if not found
  91222. */
  91223. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91224. /**
  91225. * Gets the impostor for a physics body object
  91226. * @param body defines physics body used by the impostor
  91227. * @returns the PhysicsImpostor or null if not found
  91228. */
  91229. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91230. /**
  91231. * Does a raycast in the physics world
  91232. * @param from when should the ray start?
  91233. * @param to when should the ray end?
  91234. * @returns PhysicsRaycastResult
  91235. */
  91236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91237. /**
  91238. * Called by the scene. No need to call it.
  91239. * @param delta defines the timespam between frames
  91240. */
  91241. _step(delta: number): void;
  91242. }
  91243. }
  91244. declare module BABYLON {
  91245. /**
  91246. * The interface for the physics imposter parameters
  91247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91248. */
  91249. export interface PhysicsImpostorParameters {
  91250. /**
  91251. * The mass of the physics imposter
  91252. */
  91253. mass: number;
  91254. /**
  91255. * The friction of the physics imposter
  91256. */
  91257. friction?: number;
  91258. /**
  91259. * The coefficient of restitution of the physics imposter
  91260. */
  91261. restitution?: number;
  91262. /**
  91263. * The native options of the physics imposter
  91264. */
  91265. nativeOptions?: any;
  91266. /**
  91267. * Specifies if the parent should be ignored
  91268. */
  91269. ignoreParent?: boolean;
  91270. /**
  91271. * Specifies if bi-directional transformations should be disabled
  91272. */
  91273. disableBidirectionalTransformation?: boolean;
  91274. /**
  91275. * The pressure inside the physics imposter, soft object only
  91276. */
  91277. pressure?: number;
  91278. /**
  91279. * The stiffness the physics imposter, soft object only
  91280. */
  91281. stiffness?: number;
  91282. /**
  91283. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91284. */
  91285. velocityIterations?: number;
  91286. /**
  91287. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91288. */
  91289. positionIterations?: number;
  91290. /**
  91291. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91292. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91293. * Add to fix multiple points
  91294. */
  91295. fixedPoints?: number;
  91296. /**
  91297. * The collision margin around a soft object
  91298. */
  91299. margin?: number;
  91300. /**
  91301. * The collision margin around a soft object
  91302. */
  91303. damping?: number;
  91304. /**
  91305. * The path for a rope based on an extrusion
  91306. */
  91307. path?: any;
  91308. /**
  91309. * The shape of an extrusion used for a rope based on an extrusion
  91310. */
  91311. shape?: any;
  91312. }
  91313. /**
  91314. * Interface for a physics-enabled object
  91315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91316. */
  91317. export interface IPhysicsEnabledObject {
  91318. /**
  91319. * The position of the physics-enabled object
  91320. */
  91321. position: Vector3;
  91322. /**
  91323. * The rotation of the physics-enabled object
  91324. */
  91325. rotationQuaternion: Nullable<Quaternion>;
  91326. /**
  91327. * The scale of the physics-enabled object
  91328. */
  91329. scaling: Vector3;
  91330. /**
  91331. * The rotation of the physics-enabled object
  91332. */
  91333. rotation?: Vector3;
  91334. /**
  91335. * The parent of the physics-enabled object
  91336. */
  91337. parent?: any;
  91338. /**
  91339. * The bounding info of the physics-enabled object
  91340. * @returns The bounding info of the physics-enabled object
  91341. */
  91342. getBoundingInfo(): BoundingInfo;
  91343. /**
  91344. * Computes the world matrix
  91345. * @param force Specifies if the world matrix should be computed by force
  91346. * @returns A world matrix
  91347. */
  91348. computeWorldMatrix(force: boolean): Matrix;
  91349. /**
  91350. * Gets the world matrix
  91351. * @returns A world matrix
  91352. */
  91353. getWorldMatrix?(): Matrix;
  91354. /**
  91355. * Gets the child meshes
  91356. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91357. * @returns An array of abstract meshes
  91358. */
  91359. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91360. /**
  91361. * Gets the vertex data
  91362. * @param kind The type of vertex data
  91363. * @returns A nullable array of numbers, or a float32 array
  91364. */
  91365. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91366. /**
  91367. * Gets the indices from the mesh
  91368. * @returns A nullable array of index arrays
  91369. */
  91370. getIndices?(): Nullable<IndicesArray>;
  91371. /**
  91372. * Gets the scene from the mesh
  91373. * @returns the indices array or null
  91374. */
  91375. getScene?(): Scene;
  91376. /**
  91377. * Gets the absolute position from the mesh
  91378. * @returns the absolute position
  91379. */
  91380. getAbsolutePosition(): Vector3;
  91381. /**
  91382. * Gets the absolute pivot point from the mesh
  91383. * @returns the absolute pivot point
  91384. */
  91385. getAbsolutePivotPoint(): Vector3;
  91386. /**
  91387. * Rotates the mesh
  91388. * @param axis The axis of rotation
  91389. * @param amount The amount of rotation
  91390. * @param space The space of the rotation
  91391. * @returns The rotation transform node
  91392. */
  91393. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91394. /**
  91395. * Translates the mesh
  91396. * @param axis The axis of translation
  91397. * @param distance The distance of translation
  91398. * @param space The space of the translation
  91399. * @returns The transform node
  91400. */
  91401. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91402. /**
  91403. * Sets the absolute position of the mesh
  91404. * @param absolutePosition The absolute position of the mesh
  91405. * @returns The transform node
  91406. */
  91407. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91408. /**
  91409. * Gets the class name of the mesh
  91410. * @returns The class name
  91411. */
  91412. getClassName(): string;
  91413. }
  91414. /**
  91415. * Represents a physics imposter
  91416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91417. */
  91418. export class PhysicsImpostor {
  91419. /**
  91420. * The physics-enabled object used as the physics imposter
  91421. */
  91422. object: IPhysicsEnabledObject;
  91423. /**
  91424. * The type of the physics imposter
  91425. */
  91426. type: number;
  91427. private _options;
  91428. private _scene?;
  91429. /**
  91430. * The default object size of the imposter
  91431. */
  91432. static DEFAULT_OBJECT_SIZE: Vector3;
  91433. /**
  91434. * The identity quaternion of the imposter
  91435. */
  91436. static IDENTITY_QUATERNION: Quaternion;
  91437. /** @hidden */
  91438. _pluginData: any;
  91439. private _physicsEngine;
  91440. private _physicsBody;
  91441. private _bodyUpdateRequired;
  91442. private _onBeforePhysicsStepCallbacks;
  91443. private _onAfterPhysicsStepCallbacks;
  91444. /** @hidden */
  91445. _onPhysicsCollideCallbacks: Array<{
  91446. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91447. otherImpostors: Array<PhysicsImpostor>;
  91448. }>;
  91449. private _deltaPosition;
  91450. private _deltaRotation;
  91451. private _deltaRotationConjugated;
  91452. /** @hidden */
  91453. _isFromLine: boolean;
  91454. private _parent;
  91455. private _isDisposed;
  91456. private static _tmpVecs;
  91457. private static _tmpQuat;
  91458. /**
  91459. * Specifies if the physics imposter is disposed
  91460. */
  91461. readonly isDisposed: boolean;
  91462. /**
  91463. * Gets the mass of the physics imposter
  91464. */
  91465. mass: number;
  91466. /**
  91467. * Gets the coefficient of friction
  91468. */
  91469. /**
  91470. * Sets the coefficient of friction
  91471. */
  91472. friction: number;
  91473. /**
  91474. * Gets the coefficient of restitution
  91475. */
  91476. /**
  91477. * Sets the coefficient of restitution
  91478. */
  91479. restitution: number;
  91480. /**
  91481. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91482. */
  91483. /**
  91484. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91485. */
  91486. pressure: number;
  91487. /**
  91488. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91489. */
  91490. /**
  91491. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91492. */
  91493. stiffness: number;
  91494. /**
  91495. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91496. */
  91497. /**
  91498. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91499. */
  91500. velocityIterations: number;
  91501. /**
  91502. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91503. */
  91504. /**
  91505. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91506. */
  91507. positionIterations: number;
  91508. /**
  91509. * The unique id of the physics imposter
  91510. * set by the physics engine when adding this impostor to the array
  91511. */
  91512. uniqueId: number;
  91513. /**
  91514. * @hidden
  91515. */
  91516. soft: boolean;
  91517. /**
  91518. * @hidden
  91519. */
  91520. segments: number;
  91521. private _joints;
  91522. /**
  91523. * Initializes the physics imposter
  91524. * @param object The physics-enabled object used as the physics imposter
  91525. * @param type The type of the physics imposter
  91526. * @param _options The options for the physics imposter
  91527. * @param _scene The Babylon scene
  91528. */
  91529. constructor(
  91530. /**
  91531. * The physics-enabled object used as the physics imposter
  91532. */
  91533. object: IPhysicsEnabledObject,
  91534. /**
  91535. * The type of the physics imposter
  91536. */
  91537. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91538. /**
  91539. * This function will completly initialize this impostor.
  91540. * It will create a new body - but only if this mesh has no parent.
  91541. * If it has, this impostor will not be used other than to define the impostor
  91542. * of the child mesh.
  91543. * @hidden
  91544. */
  91545. _init(): void;
  91546. private _getPhysicsParent;
  91547. /**
  91548. * Should a new body be generated.
  91549. * @returns boolean specifying if body initialization is required
  91550. */
  91551. isBodyInitRequired(): boolean;
  91552. /**
  91553. * Sets the updated scaling
  91554. * @param updated Specifies if the scaling is updated
  91555. */
  91556. setScalingUpdated(): void;
  91557. /**
  91558. * Force a regeneration of this or the parent's impostor's body.
  91559. * Use under cautious - This will remove all joints already implemented.
  91560. */
  91561. forceUpdate(): void;
  91562. /**
  91563. * Gets the body that holds this impostor. Either its own, or its parent.
  91564. */
  91565. /**
  91566. * Set the physics body. Used mainly by the physics engine/plugin
  91567. */
  91568. physicsBody: any;
  91569. /**
  91570. * Get the parent of the physics imposter
  91571. * @returns Physics imposter or null
  91572. */
  91573. /**
  91574. * Sets the parent of the physics imposter
  91575. */
  91576. parent: Nullable<PhysicsImpostor>;
  91577. /**
  91578. * Resets the update flags
  91579. */
  91580. resetUpdateFlags(): void;
  91581. /**
  91582. * Gets the object extend size
  91583. * @returns the object extend size
  91584. */
  91585. getObjectExtendSize(): Vector3;
  91586. /**
  91587. * Gets the object center
  91588. * @returns The object center
  91589. */
  91590. getObjectCenter(): Vector3;
  91591. /**
  91592. * Get a specific parametes from the options parameter
  91593. * @param paramName The object parameter name
  91594. * @returns The object parameter
  91595. */
  91596. getParam(paramName: string): any;
  91597. /**
  91598. * Sets a specific parameter in the options given to the physics plugin
  91599. * @param paramName The parameter name
  91600. * @param value The value of the parameter
  91601. */
  91602. setParam(paramName: string, value: number): void;
  91603. /**
  91604. * Specifically change the body's mass option. Won't recreate the physics body object
  91605. * @param mass The mass of the physics imposter
  91606. */
  91607. setMass(mass: number): void;
  91608. /**
  91609. * Gets the linear velocity
  91610. * @returns linear velocity or null
  91611. */
  91612. getLinearVelocity(): Nullable<Vector3>;
  91613. /**
  91614. * Sets the linear velocity
  91615. * @param velocity linear velocity or null
  91616. */
  91617. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91618. /**
  91619. * Gets the angular velocity
  91620. * @returns angular velocity or null
  91621. */
  91622. getAngularVelocity(): Nullable<Vector3>;
  91623. /**
  91624. * Sets the angular velocity
  91625. * @param velocity The velocity or null
  91626. */
  91627. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91628. /**
  91629. * Execute a function with the physics plugin native code
  91630. * Provide a function the will have two variables - the world object and the physics body object
  91631. * @param func The function to execute with the physics plugin native code
  91632. */
  91633. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91634. /**
  91635. * Register a function that will be executed before the physics world is stepping forward
  91636. * @param func The function to execute before the physics world is stepped forward
  91637. */
  91638. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91639. /**
  91640. * Unregister a function that will be executed before the physics world is stepping forward
  91641. * @param func The function to execute before the physics world is stepped forward
  91642. */
  91643. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91644. /**
  91645. * Register a function that will be executed after the physics step
  91646. * @param func The function to execute after physics step
  91647. */
  91648. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91649. /**
  91650. * Unregisters a function that will be executed after the physics step
  91651. * @param func The function to execute after physics step
  91652. */
  91653. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91654. /**
  91655. * register a function that will be executed when this impostor collides against a different body
  91656. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91657. * @param func Callback that is executed on collision
  91658. */
  91659. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91660. /**
  91661. * Unregisters the physics imposter on contact
  91662. * @param collideAgainst The physics object to collide against
  91663. * @param func Callback to execute on collision
  91664. */
  91665. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91666. private _tmpQuat;
  91667. private _tmpQuat2;
  91668. /**
  91669. * Get the parent rotation
  91670. * @returns The parent rotation
  91671. */
  91672. getParentsRotation(): Quaternion;
  91673. /**
  91674. * this function is executed by the physics engine.
  91675. */
  91676. beforeStep: () => void;
  91677. /**
  91678. * this function is executed by the physics engine
  91679. */
  91680. afterStep: () => void;
  91681. /**
  91682. * Legacy collision detection event support
  91683. */
  91684. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91685. /**
  91686. * event and body object due to cannon's event-based architecture.
  91687. */
  91688. onCollide: (e: {
  91689. body: any;
  91690. }) => void;
  91691. /**
  91692. * Apply a force
  91693. * @param force The force to apply
  91694. * @param contactPoint The contact point for the force
  91695. * @returns The physics imposter
  91696. */
  91697. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91698. /**
  91699. * Apply an impulse
  91700. * @param force The impulse force
  91701. * @param contactPoint The contact point for the impulse force
  91702. * @returns The physics imposter
  91703. */
  91704. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91705. /**
  91706. * A help function to create a joint
  91707. * @param otherImpostor A physics imposter used to create a joint
  91708. * @param jointType The type of joint
  91709. * @param jointData The data for the joint
  91710. * @returns The physics imposter
  91711. */
  91712. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91713. /**
  91714. * Add a joint to this impostor with a different impostor
  91715. * @param otherImpostor A physics imposter used to add a joint
  91716. * @param joint The joint to add
  91717. * @returns The physics imposter
  91718. */
  91719. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91720. /**
  91721. * Add an anchor to a cloth impostor
  91722. * @param otherImpostor rigid impostor to anchor to
  91723. * @param width ratio across width from 0 to 1
  91724. * @param height ratio up height from 0 to 1
  91725. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91726. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91727. * @returns impostor the soft imposter
  91728. */
  91729. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91730. /**
  91731. * Add a hook to a rope impostor
  91732. * @param otherImpostor rigid impostor to anchor to
  91733. * @param length ratio across rope from 0 to 1
  91734. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91735. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91736. * @returns impostor the rope imposter
  91737. */
  91738. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91739. /**
  91740. * Will keep this body still, in a sleep mode.
  91741. * @returns the physics imposter
  91742. */
  91743. sleep(): PhysicsImpostor;
  91744. /**
  91745. * Wake the body up.
  91746. * @returns The physics imposter
  91747. */
  91748. wakeUp(): PhysicsImpostor;
  91749. /**
  91750. * Clones the physics imposter
  91751. * @param newObject The physics imposter clones to this physics-enabled object
  91752. * @returns A nullable physics imposter
  91753. */
  91754. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91755. /**
  91756. * Disposes the physics imposter
  91757. */
  91758. dispose(): void;
  91759. /**
  91760. * Sets the delta position
  91761. * @param position The delta position amount
  91762. */
  91763. setDeltaPosition(position: Vector3): void;
  91764. /**
  91765. * Sets the delta rotation
  91766. * @param rotation The delta rotation amount
  91767. */
  91768. setDeltaRotation(rotation: Quaternion): void;
  91769. /**
  91770. * Gets the box size of the physics imposter and stores the result in the input parameter
  91771. * @param result Stores the box size
  91772. * @returns The physics imposter
  91773. */
  91774. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91775. /**
  91776. * Gets the radius of the physics imposter
  91777. * @returns Radius of the physics imposter
  91778. */
  91779. getRadius(): number;
  91780. /**
  91781. * Sync a bone with this impostor
  91782. * @param bone The bone to sync to the impostor.
  91783. * @param boneMesh The mesh that the bone is influencing.
  91784. * @param jointPivot The pivot of the joint / bone in local space.
  91785. * @param distToJoint Optional distance from the impostor to the joint.
  91786. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91787. */
  91788. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91789. /**
  91790. * Sync impostor to a bone
  91791. * @param bone The bone that the impostor will be synced to.
  91792. * @param boneMesh The mesh that the bone is influencing.
  91793. * @param jointPivot The pivot of the joint / bone in local space.
  91794. * @param distToJoint Optional distance from the impostor to the joint.
  91795. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91796. * @param boneAxis Optional vector3 axis the bone is aligned with
  91797. */
  91798. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91799. /**
  91800. * No-Imposter type
  91801. */
  91802. static NoImpostor: number;
  91803. /**
  91804. * Sphere-Imposter type
  91805. */
  91806. static SphereImpostor: number;
  91807. /**
  91808. * Box-Imposter type
  91809. */
  91810. static BoxImpostor: number;
  91811. /**
  91812. * Plane-Imposter type
  91813. */
  91814. static PlaneImpostor: number;
  91815. /**
  91816. * Mesh-imposter type
  91817. */
  91818. static MeshImpostor: number;
  91819. /**
  91820. * Capsule-Impostor type (Ammo.js plugin only)
  91821. */
  91822. static CapsuleImpostor: number;
  91823. /**
  91824. * Cylinder-Imposter type
  91825. */
  91826. static CylinderImpostor: number;
  91827. /**
  91828. * Particle-Imposter type
  91829. */
  91830. static ParticleImpostor: number;
  91831. /**
  91832. * Heightmap-Imposter type
  91833. */
  91834. static HeightmapImpostor: number;
  91835. /**
  91836. * ConvexHull-Impostor type (Ammo.js plugin only)
  91837. */
  91838. static ConvexHullImpostor: number;
  91839. /**
  91840. * Rope-Imposter type
  91841. */
  91842. static RopeImpostor: number;
  91843. /**
  91844. * Cloth-Imposter type
  91845. */
  91846. static ClothImpostor: number;
  91847. /**
  91848. * Softbody-Imposter type
  91849. */
  91850. static SoftbodyImpostor: number;
  91851. }
  91852. }
  91853. declare module BABYLON {
  91854. /**
  91855. * @hidden
  91856. **/
  91857. export class _CreationDataStorage {
  91858. closePath?: boolean;
  91859. closeArray?: boolean;
  91860. idx: number[];
  91861. dashSize: number;
  91862. gapSize: number;
  91863. path3D: Path3D;
  91864. pathArray: Vector3[][];
  91865. arc: number;
  91866. radius: number;
  91867. cap: number;
  91868. tessellation: number;
  91869. }
  91870. /**
  91871. * @hidden
  91872. **/
  91873. class _InstanceDataStorage {
  91874. visibleInstances: any;
  91875. batchCache: _InstancesBatch;
  91876. instancesBufferSize: number;
  91877. instancesBuffer: Nullable<Buffer>;
  91878. instancesData: Float32Array;
  91879. overridenInstanceCount: number;
  91880. isFrozen: boolean;
  91881. previousBatch: Nullable<_InstancesBatch>;
  91882. hardwareInstancedRendering: boolean;
  91883. sideOrientation: number;
  91884. manualUpdate: boolean;
  91885. }
  91886. /**
  91887. * @hidden
  91888. **/
  91889. export class _InstancesBatch {
  91890. mustReturn: boolean;
  91891. visibleInstances: Nullable<InstancedMesh[]>[];
  91892. renderSelf: boolean[];
  91893. hardwareInstancedRendering: boolean[];
  91894. }
  91895. /**
  91896. * Class used to represent renderable models
  91897. */
  91898. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91899. /**
  91900. * Mesh side orientation : usually the external or front surface
  91901. */
  91902. static readonly FRONTSIDE: number;
  91903. /**
  91904. * Mesh side orientation : usually the internal or back surface
  91905. */
  91906. static readonly BACKSIDE: number;
  91907. /**
  91908. * Mesh side orientation : both internal and external or front and back surfaces
  91909. */
  91910. static readonly DOUBLESIDE: number;
  91911. /**
  91912. * Mesh side orientation : by default, `FRONTSIDE`
  91913. */
  91914. static readonly DEFAULTSIDE: number;
  91915. /**
  91916. * Mesh cap setting : no cap
  91917. */
  91918. static readonly NO_CAP: number;
  91919. /**
  91920. * Mesh cap setting : one cap at the beginning of the mesh
  91921. */
  91922. static readonly CAP_START: number;
  91923. /**
  91924. * Mesh cap setting : one cap at the end of the mesh
  91925. */
  91926. static readonly CAP_END: number;
  91927. /**
  91928. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91929. */
  91930. static readonly CAP_ALL: number;
  91931. /**
  91932. * Mesh pattern setting : no flip or rotate
  91933. */
  91934. static readonly NO_FLIP: number;
  91935. /**
  91936. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91937. */
  91938. static readonly FLIP_TILE: number;
  91939. /**
  91940. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91941. */
  91942. static readonly ROTATE_TILE: number;
  91943. /**
  91944. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91945. */
  91946. static readonly FLIP_ROW: number;
  91947. /**
  91948. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91949. */
  91950. static readonly ROTATE_ROW: number;
  91951. /**
  91952. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91953. */
  91954. static readonly FLIP_N_ROTATE_TILE: number;
  91955. /**
  91956. * Mesh pattern setting : rotate pattern and rotate
  91957. */
  91958. static readonly FLIP_N_ROTATE_ROW: number;
  91959. /**
  91960. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91961. */
  91962. static readonly CENTER: number;
  91963. /**
  91964. * Mesh tile positioning : part tiles on left
  91965. */
  91966. static readonly LEFT: number;
  91967. /**
  91968. * Mesh tile positioning : part tiles on right
  91969. */
  91970. static readonly RIGHT: number;
  91971. /**
  91972. * Mesh tile positioning : part tiles on top
  91973. */
  91974. static readonly TOP: number;
  91975. /**
  91976. * Mesh tile positioning : part tiles on bottom
  91977. */
  91978. static readonly BOTTOM: number;
  91979. /**
  91980. * Gets the default side orientation.
  91981. * @param orientation the orientation to value to attempt to get
  91982. * @returns the default orientation
  91983. * @hidden
  91984. */
  91985. static _GetDefaultSideOrientation(orientation?: number): number;
  91986. private _internalMeshDataInfo;
  91987. /**
  91988. * An event triggered before rendering the mesh
  91989. */
  91990. readonly onBeforeRenderObservable: Observable<Mesh>;
  91991. /**
  91992. * An event triggered before binding the mesh
  91993. */
  91994. readonly onBeforeBindObservable: Observable<Mesh>;
  91995. /**
  91996. * An event triggered after rendering the mesh
  91997. */
  91998. readonly onAfterRenderObservable: Observable<Mesh>;
  91999. /**
  92000. * An event triggered before drawing the mesh
  92001. */
  92002. readonly onBeforeDrawObservable: Observable<Mesh>;
  92003. private _onBeforeDrawObserver;
  92004. /**
  92005. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92006. */
  92007. onBeforeDraw: () => void;
  92008. readonly hasInstances: boolean;
  92009. /**
  92010. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92011. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92012. */
  92013. delayLoadState: number;
  92014. /**
  92015. * Gets the list of instances created from this mesh
  92016. * it is not supposed to be modified manually.
  92017. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92018. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92019. */
  92020. instances: InstancedMesh[];
  92021. /**
  92022. * Gets the file containing delay loading data for this mesh
  92023. */
  92024. delayLoadingFile: string;
  92025. /** @hidden */
  92026. _binaryInfo: any;
  92027. /**
  92028. * User defined function used to change how LOD level selection is done
  92029. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92030. */
  92031. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92032. /**
  92033. * Gets or sets the morph target manager
  92034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92035. */
  92036. morphTargetManager: Nullable<MorphTargetManager>;
  92037. /** @hidden */
  92038. _creationDataStorage: Nullable<_CreationDataStorage>;
  92039. /** @hidden */
  92040. _geometry: Nullable<Geometry>;
  92041. /** @hidden */
  92042. _delayInfo: Array<string>;
  92043. /** @hidden */
  92044. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92045. /** @hidden */
  92046. _instanceDataStorage: _InstanceDataStorage;
  92047. private _effectiveMaterial;
  92048. /** @hidden */
  92049. _shouldGenerateFlatShading: boolean;
  92050. /** @hidden */
  92051. _originalBuilderSideOrientation: number;
  92052. /**
  92053. * Use this property to change the original side orientation defined at construction time
  92054. */
  92055. overrideMaterialSideOrientation: Nullable<number>;
  92056. /**
  92057. * Gets the source mesh (the one used to clone this one from)
  92058. */
  92059. readonly source: Nullable<Mesh>;
  92060. /**
  92061. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92062. */
  92063. isUnIndexed: boolean;
  92064. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92065. readonly worldMatrixInstancedBuffer: Float32Array;
  92066. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92067. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92068. /**
  92069. * @constructor
  92070. * @param name The value used by scene.getMeshByName() to do a lookup.
  92071. * @param scene The scene to add this mesh to.
  92072. * @param parent The parent of this mesh, if it has one
  92073. * @param source An optional Mesh from which geometry is shared, cloned.
  92074. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92075. * When false, achieved by calling a clone(), also passing False.
  92076. * This will make creation of children, recursive.
  92077. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92078. */
  92079. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92080. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92081. doNotInstantiate: boolean;
  92082. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92083. /**
  92084. * Gets the class name
  92085. * @returns the string "Mesh".
  92086. */
  92087. getClassName(): string;
  92088. /** @hidden */
  92089. readonly _isMesh: boolean;
  92090. /**
  92091. * Returns a description of this mesh
  92092. * @param fullDetails define if full details about this mesh must be used
  92093. * @returns a descriptive string representing this mesh
  92094. */
  92095. toString(fullDetails?: boolean): string;
  92096. /** @hidden */
  92097. _unBindEffect(): void;
  92098. /**
  92099. * Gets a boolean indicating if this mesh has LOD
  92100. */
  92101. readonly hasLODLevels: boolean;
  92102. /**
  92103. * Gets the list of MeshLODLevel associated with the current mesh
  92104. * @returns an array of MeshLODLevel
  92105. */
  92106. getLODLevels(): MeshLODLevel[];
  92107. private _sortLODLevels;
  92108. /**
  92109. * Add a mesh as LOD level triggered at the given distance.
  92110. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92111. * @param distance The distance from the center of the object to show this level
  92112. * @param mesh The mesh to be added as LOD level (can be null)
  92113. * @return This mesh (for chaining)
  92114. */
  92115. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92116. /**
  92117. * Returns the LOD level mesh at the passed distance or null if not found.
  92118. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92119. * @param distance The distance from the center of the object to show this level
  92120. * @returns a Mesh or `null`
  92121. */
  92122. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92123. /**
  92124. * Remove a mesh from the LOD array
  92125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92126. * @param mesh defines the mesh to be removed
  92127. * @return This mesh (for chaining)
  92128. */
  92129. removeLODLevel(mesh: Mesh): Mesh;
  92130. /**
  92131. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92132. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92133. * @param camera defines the camera to use to compute distance
  92134. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92135. * @return This mesh (for chaining)
  92136. */
  92137. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92138. /**
  92139. * Gets the mesh internal Geometry object
  92140. */
  92141. readonly geometry: Nullable<Geometry>;
  92142. /**
  92143. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92144. * @returns the total number of vertices
  92145. */
  92146. getTotalVertices(): number;
  92147. /**
  92148. * Returns the content of an associated vertex buffer
  92149. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92150. * - VertexBuffer.PositionKind
  92151. * - VertexBuffer.UVKind
  92152. * - VertexBuffer.UV2Kind
  92153. * - VertexBuffer.UV3Kind
  92154. * - VertexBuffer.UV4Kind
  92155. * - VertexBuffer.UV5Kind
  92156. * - VertexBuffer.UV6Kind
  92157. * - VertexBuffer.ColorKind
  92158. * - VertexBuffer.MatricesIndicesKind
  92159. * - VertexBuffer.MatricesIndicesExtraKind
  92160. * - VertexBuffer.MatricesWeightsKind
  92161. * - VertexBuffer.MatricesWeightsExtraKind
  92162. * @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
  92163. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92164. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92165. */
  92166. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92167. /**
  92168. * Returns the mesh VertexBuffer object from the requested `kind`
  92169. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92170. * - VertexBuffer.PositionKind
  92171. * - VertexBuffer.NormalKind
  92172. * - VertexBuffer.UVKind
  92173. * - VertexBuffer.UV2Kind
  92174. * - VertexBuffer.UV3Kind
  92175. * - VertexBuffer.UV4Kind
  92176. * - VertexBuffer.UV5Kind
  92177. * - VertexBuffer.UV6Kind
  92178. * - VertexBuffer.ColorKind
  92179. * - VertexBuffer.MatricesIndicesKind
  92180. * - VertexBuffer.MatricesIndicesExtraKind
  92181. * - VertexBuffer.MatricesWeightsKind
  92182. * - VertexBuffer.MatricesWeightsExtraKind
  92183. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92184. */
  92185. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92186. /**
  92187. * Tests if a specific vertex buffer is associated with this mesh
  92188. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92189. * - VertexBuffer.PositionKind
  92190. * - VertexBuffer.NormalKind
  92191. * - VertexBuffer.UVKind
  92192. * - VertexBuffer.UV2Kind
  92193. * - VertexBuffer.UV3Kind
  92194. * - VertexBuffer.UV4Kind
  92195. * - VertexBuffer.UV5Kind
  92196. * - VertexBuffer.UV6Kind
  92197. * - VertexBuffer.ColorKind
  92198. * - VertexBuffer.MatricesIndicesKind
  92199. * - VertexBuffer.MatricesIndicesExtraKind
  92200. * - VertexBuffer.MatricesWeightsKind
  92201. * - VertexBuffer.MatricesWeightsExtraKind
  92202. * @returns a boolean
  92203. */
  92204. isVerticesDataPresent(kind: string): boolean;
  92205. /**
  92206. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92207. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92208. * - VertexBuffer.PositionKind
  92209. * - VertexBuffer.UVKind
  92210. * - VertexBuffer.UV2Kind
  92211. * - VertexBuffer.UV3Kind
  92212. * - VertexBuffer.UV4Kind
  92213. * - VertexBuffer.UV5Kind
  92214. * - VertexBuffer.UV6Kind
  92215. * - VertexBuffer.ColorKind
  92216. * - VertexBuffer.MatricesIndicesKind
  92217. * - VertexBuffer.MatricesIndicesExtraKind
  92218. * - VertexBuffer.MatricesWeightsKind
  92219. * - VertexBuffer.MatricesWeightsExtraKind
  92220. * @returns a boolean
  92221. */
  92222. isVertexBufferUpdatable(kind: string): boolean;
  92223. /**
  92224. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92226. * - VertexBuffer.PositionKind
  92227. * - VertexBuffer.NormalKind
  92228. * - VertexBuffer.UVKind
  92229. * - VertexBuffer.UV2Kind
  92230. * - VertexBuffer.UV3Kind
  92231. * - VertexBuffer.UV4Kind
  92232. * - VertexBuffer.UV5Kind
  92233. * - VertexBuffer.UV6Kind
  92234. * - VertexBuffer.ColorKind
  92235. * - VertexBuffer.MatricesIndicesKind
  92236. * - VertexBuffer.MatricesIndicesExtraKind
  92237. * - VertexBuffer.MatricesWeightsKind
  92238. * - VertexBuffer.MatricesWeightsExtraKind
  92239. * @returns an array of strings
  92240. */
  92241. getVerticesDataKinds(): string[];
  92242. /**
  92243. * Returns a positive integer : the total number of indices in this mesh geometry.
  92244. * @returns the numner of indices or zero if the mesh has no geometry.
  92245. */
  92246. getTotalIndices(): number;
  92247. /**
  92248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92249. * @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.
  92250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92251. * @returns the indices array or an empty array if the mesh has no geometry
  92252. */
  92253. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92254. readonly isBlocked: boolean;
  92255. /**
  92256. * Determine if the current mesh is ready to be rendered
  92257. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92258. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92259. * @returns true if all associated assets are ready (material, textures, shaders)
  92260. */
  92261. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92262. /**
  92263. * 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.
  92264. */
  92265. readonly areNormalsFrozen: boolean;
  92266. /**
  92267. * 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.
  92268. * @returns the current mesh
  92269. */
  92270. freezeNormals(): Mesh;
  92271. /**
  92272. * 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
  92273. * @returns the current mesh
  92274. */
  92275. unfreezeNormals(): Mesh;
  92276. /**
  92277. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92278. */
  92279. overridenInstanceCount: number;
  92280. /** @hidden */
  92281. _preActivate(): Mesh;
  92282. /** @hidden */
  92283. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92284. /** @hidden */
  92285. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92286. /**
  92287. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92288. * This means the mesh underlying bounding box and sphere are recomputed.
  92289. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92290. * @returns the current mesh
  92291. */
  92292. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92293. /** @hidden */
  92294. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92295. /**
  92296. * This function will subdivide the mesh into multiple submeshes
  92297. * @param count defines the expected number of submeshes
  92298. */
  92299. subdivide(count: number): void;
  92300. /**
  92301. * Copy a FloatArray into a specific associated vertex buffer
  92302. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92303. * - VertexBuffer.PositionKind
  92304. * - VertexBuffer.UVKind
  92305. * - VertexBuffer.UV2Kind
  92306. * - VertexBuffer.UV3Kind
  92307. * - VertexBuffer.UV4Kind
  92308. * - VertexBuffer.UV5Kind
  92309. * - VertexBuffer.UV6Kind
  92310. * - VertexBuffer.ColorKind
  92311. * - VertexBuffer.MatricesIndicesKind
  92312. * - VertexBuffer.MatricesIndicesExtraKind
  92313. * - VertexBuffer.MatricesWeightsKind
  92314. * - VertexBuffer.MatricesWeightsExtraKind
  92315. * @param data defines the data source
  92316. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92317. * @param stride defines the data stride size (can be null)
  92318. * @returns the current mesh
  92319. */
  92320. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92321. /**
  92322. * Delete a vertex buffer associated with this mesh
  92323. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92324. * - VertexBuffer.PositionKind
  92325. * - VertexBuffer.UVKind
  92326. * - VertexBuffer.UV2Kind
  92327. * - VertexBuffer.UV3Kind
  92328. * - VertexBuffer.UV4Kind
  92329. * - VertexBuffer.UV5Kind
  92330. * - VertexBuffer.UV6Kind
  92331. * - VertexBuffer.ColorKind
  92332. * - VertexBuffer.MatricesIndicesKind
  92333. * - VertexBuffer.MatricesIndicesExtraKind
  92334. * - VertexBuffer.MatricesWeightsKind
  92335. * - VertexBuffer.MatricesWeightsExtraKind
  92336. */
  92337. removeVerticesData(kind: string): void;
  92338. /**
  92339. * Flags an associated vertex buffer as updatable
  92340. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92341. * - VertexBuffer.PositionKind
  92342. * - VertexBuffer.UVKind
  92343. * - VertexBuffer.UV2Kind
  92344. * - VertexBuffer.UV3Kind
  92345. * - VertexBuffer.UV4Kind
  92346. * - VertexBuffer.UV5Kind
  92347. * - VertexBuffer.UV6Kind
  92348. * - VertexBuffer.ColorKind
  92349. * - VertexBuffer.MatricesIndicesKind
  92350. * - VertexBuffer.MatricesIndicesExtraKind
  92351. * - VertexBuffer.MatricesWeightsKind
  92352. * - VertexBuffer.MatricesWeightsExtraKind
  92353. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92354. */
  92355. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92356. /**
  92357. * Sets the mesh global Vertex Buffer
  92358. * @param buffer defines the buffer to use
  92359. * @returns the current mesh
  92360. */
  92361. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92362. /**
  92363. * Update a specific associated vertex buffer
  92364. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92365. * - VertexBuffer.PositionKind
  92366. * - VertexBuffer.UVKind
  92367. * - VertexBuffer.UV2Kind
  92368. * - VertexBuffer.UV3Kind
  92369. * - VertexBuffer.UV4Kind
  92370. * - VertexBuffer.UV5Kind
  92371. * - VertexBuffer.UV6Kind
  92372. * - VertexBuffer.ColorKind
  92373. * - VertexBuffer.MatricesIndicesKind
  92374. * - VertexBuffer.MatricesIndicesExtraKind
  92375. * - VertexBuffer.MatricesWeightsKind
  92376. * - VertexBuffer.MatricesWeightsExtraKind
  92377. * @param data defines the data source
  92378. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92379. * @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)
  92380. * @returns the current mesh
  92381. */
  92382. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92383. /**
  92384. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92385. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92386. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92387. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92388. * @returns the current mesh
  92389. */
  92390. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92391. /**
  92392. * Creates a un-shared specific occurence of the geometry for the mesh.
  92393. * @returns the current mesh
  92394. */
  92395. makeGeometryUnique(): Mesh;
  92396. /**
  92397. * Set the index buffer of this mesh
  92398. * @param indices defines the source data
  92399. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92400. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92401. * @returns the current mesh
  92402. */
  92403. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92404. /**
  92405. * Update the current index buffer
  92406. * @param indices defines the source data
  92407. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92408. * @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)
  92409. * @returns the current mesh
  92410. */
  92411. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92412. /**
  92413. * Invert the geometry to move from a right handed system to a left handed one.
  92414. * @returns the current mesh
  92415. */
  92416. toLeftHanded(): Mesh;
  92417. /** @hidden */
  92418. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92419. /** @hidden */
  92420. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92421. /**
  92422. * Registers for this mesh a javascript function called just before the rendering process
  92423. * @param func defines the function to call before rendering this mesh
  92424. * @returns the current mesh
  92425. */
  92426. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92427. /**
  92428. * Disposes a previously registered javascript function called before the rendering
  92429. * @param func defines the function to remove
  92430. * @returns the current mesh
  92431. */
  92432. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92433. /**
  92434. * Registers for this mesh a javascript function called just after the rendering is complete
  92435. * @param func defines the function to call after rendering this mesh
  92436. * @returns the current mesh
  92437. */
  92438. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92439. /**
  92440. * Disposes a previously registered javascript function called after the rendering.
  92441. * @param func defines the function to remove
  92442. * @returns the current mesh
  92443. */
  92444. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92445. /** @hidden */
  92446. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  92447. /** @hidden */
  92448. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92449. /** @hidden */
  92450. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92451. /** @hidden */
  92452. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92453. /** @hidden */
  92454. _rebuild(): void;
  92455. /** @hidden */
  92456. _freeze(): void;
  92457. /** @hidden */
  92458. _unFreeze(): void;
  92459. /**
  92460. * 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
  92461. * @param subMesh defines the subMesh to render
  92462. * @param enableAlphaMode defines if alpha mode can be changed
  92463. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92464. * @returns the current mesh
  92465. */
  92466. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92467. private _onBeforeDraw;
  92468. /**
  92469. * Renormalize the mesh and patch it up if there are no weights
  92470. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92471. * However in the case of zero weights then we set just a single influence to 1.
  92472. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92473. */
  92474. cleanMatrixWeights(): void;
  92475. private normalizeSkinFourWeights;
  92476. private normalizeSkinWeightsAndExtra;
  92477. /**
  92478. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92479. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92480. * the user know there was an issue with importing the mesh
  92481. * @returns a validation object with skinned, valid and report string
  92482. */
  92483. validateSkinning(): {
  92484. skinned: boolean;
  92485. valid: boolean;
  92486. report: string;
  92487. };
  92488. /** @hidden */
  92489. _checkDelayState(): Mesh;
  92490. private _queueLoad;
  92491. /**
  92492. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92493. * A mesh is in the frustum if its bounding box intersects the frustum
  92494. * @param frustumPlanes defines the frustum to test
  92495. * @returns true if the mesh is in the frustum planes
  92496. */
  92497. isInFrustum(frustumPlanes: Plane[]): boolean;
  92498. /**
  92499. * Sets the mesh material by the material or multiMaterial `id` property
  92500. * @param id is a string identifying the material or the multiMaterial
  92501. * @returns the current mesh
  92502. */
  92503. setMaterialByID(id: string): Mesh;
  92504. /**
  92505. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92506. * @returns an array of IAnimatable
  92507. */
  92508. getAnimatables(): IAnimatable[];
  92509. /**
  92510. * Modifies the mesh geometry according to the passed transformation matrix.
  92511. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92512. * The mesh normals are modified using the same transformation.
  92513. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92514. * @param transform defines the transform matrix to use
  92515. * @see http://doc.babylonjs.com/resources/baking_transformations
  92516. * @returns the current mesh
  92517. */
  92518. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92519. /**
  92520. * Modifies the mesh geometry according to its own current World Matrix.
  92521. * The mesh World Matrix is then reset.
  92522. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92523. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92524. * @see http://doc.babylonjs.com/resources/baking_transformations
  92525. * @returns the current mesh
  92526. */
  92527. bakeCurrentTransformIntoVertices(): Mesh;
  92528. /** @hidden */
  92529. readonly _positions: Nullable<Vector3[]>;
  92530. /** @hidden */
  92531. _resetPointsArrayCache(): Mesh;
  92532. /** @hidden */
  92533. _generatePointsArray(): boolean;
  92534. /**
  92535. * Returns a new Mesh object generated from the current mesh properties.
  92536. * This method must not get confused with createInstance()
  92537. * @param name is a string, the name given to the new mesh
  92538. * @param newParent can be any Node object (default `null`)
  92539. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92540. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92541. * @returns a new mesh
  92542. */
  92543. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92544. /**
  92545. * Releases resources associated with this mesh.
  92546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92548. */
  92549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92550. /** @hidden */
  92551. _disposeInstanceSpecificData(): void;
  92552. /**
  92553. * Modifies the mesh geometry according to a displacement map.
  92554. * 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.
  92555. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92556. * @param url is a string, the URL from the image file is to be downloaded.
  92557. * @param minHeight is the lower limit of the displacement.
  92558. * @param maxHeight is the upper limit of the displacement.
  92559. * @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.
  92560. * @param uvOffset is an optional vector2 used to offset UV.
  92561. * @param uvScale is an optional vector2 used to scale UV.
  92562. * @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.
  92563. * @returns the Mesh.
  92564. */
  92565. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92566. /**
  92567. * Modifies the mesh geometry according to a displacementMap buffer.
  92568. * 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.
  92569. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92570. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92571. * @param heightMapWidth is the width of the buffer image.
  92572. * @param heightMapHeight is the height of the buffer image.
  92573. * @param minHeight is the lower limit of the displacement.
  92574. * @param maxHeight is the upper limit of the displacement.
  92575. * @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.
  92576. * @param uvOffset is an optional vector2 used to offset UV.
  92577. * @param uvScale is an optional vector2 used to scale UV.
  92578. * @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.
  92579. * @returns the Mesh.
  92580. */
  92581. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92582. /**
  92583. * Modify the mesh to get a flat shading rendering.
  92584. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92585. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92586. * @returns current mesh
  92587. */
  92588. convertToFlatShadedMesh(): Mesh;
  92589. /**
  92590. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92591. * In other words, more vertices, no more indices and a single bigger VBO.
  92592. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92593. * @returns current mesh
  92594. */
  92595. convertToUnIndexedMesh(): Mesh;
  92596. /**
  92597. * Inverses facet orientations.
  92598. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92599. * @param flipNormals will also inverts the normals
  92600. * @returns current mesh
  92601. */
  92602. flipFaces(flipNormals?: boolean): Mesh;
  92603. /**
  92604. * Increase the number of facets and hence vertices in a mesh
  92605. * Vertex normals are interpolated from existing vertex normals
  92606. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92607. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92608. */
  92609. increaseVertices(numberPerEdge: number): void;
  92610. /**
  92611. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92612. * This will undo any application of covertToFlatShadedMesh
  92613. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92614. */
  92615. forceSharedVertices(): void;
  92616. /** @hidden */
  92617. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92618. /** @hidden */
  92619. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92620. /**
  92621. * Creates a new InstancedMesh object from the mesh model.
  92622. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92623. * @param name defines the name of the new instance
  92624. * @returns a new InstancedMesh
  92625. */
  92626. createInstance(name: string): InstancedMesh;
  92627. /**
  92628. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92629. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92630. * @returns the current mesh
  92631. */
  92632. synchronizeInstances(): Mesh;
  92633. /**
  92634. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92635. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92636. * This should be used together with the simplification to avoid disappearing triangles.
  92637. * @param successCallback an optional success callback to be called after the optimization finished.
  92638. * @returns the current mesh
  92639. */
  92640. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92641. /**
  92642. * Serialize current mesh
  92643. * @param serializationObject defines the object which will receive the serialization data
  92644. */
  92645. serialize(serializationObject: any): void;
  92646. /** @hidden */
  92647. _syncGeometryWithMorphTargetManager(): void;
  92648. /** @hidden */
  92649. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92650. /**
  92651. * Returns a new Mesh object parsed from the source provided.
  92652. * @param parsedMesh is the source
  92653. * @param scene defines the hosting scene
  92654. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92655. * @returns a new Mesh
  92656. */
  92657. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92658. /**
  92659. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92660. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92661. * @param name defines the name of the mesh to create
  92662. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92663. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92664. * @param closePath creates a seam between the first and the last points of each path of the path array
  92665. * @param offset is taken in account only if the `pathArray` is containing a single path
  92666. * @param scene defines the hosting scene
  92667. * @param updatable defines if the mesh must be flagged as updatable
  92668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92669. * @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)
  92670. * @returns a new Mesh
  92671. */
  92672. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92673. /**
  92674. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92675. * @param name defines the name of the mesh to create
  92676. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92677. * @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
  92678. * @param scene defines the hosting scene
  92679. * @param updatable defines if the mesh must be flagged as updatable
  92680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92681. * @returns a new Mesh
  92682. */
  92683. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92684. /**
  92685. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92686. * @param name defines the name of the mesh to create
  92687. * @param size sets the size (float) of each box side (default 1)
  92688. * @param scene defines the hosting scene
  92689. * @param updatable defines if the mesh must be flagged as updatable
  92690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92691. * @returns a new Mesh
  92692. */
  92693. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92694. /**
  92695. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92696. * @param name defines the name of the mesh to create
  92697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92699. * @param scene defines the hosting scene
  92700. * @param updatable defines if the mesh must be flagged as updatable
  92701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92702. * @returns a new Mesh
  92703. */
  92704. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92705. /**
  92706. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92707. * @param name defines the name of the mesh to create
  92708. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92709. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92710. * @param scene defines the hosting scene
  92711. * @returns a new Mesh
  92712. */
  92713. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92714. /**
  92715. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92716. * @param name defines the name of the mesh to create
  92717. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92718. * @param diameterTop set the top cap diameter (floats, default 1)
  92719. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92720. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92721. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92722. * @param scene defines the hosting scene
  92723. * @param updatable defines if the mesh must be flagged as updatable
  92724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92725. * @returns a new Mesh
  92726. */
  92727. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92728. /**
  92729. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92730. * @param name defines the name of the mesh to create
  92731. * @param diameter sets the diameter size (float) of the torus (default 1)
  92732. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92733. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92734. * @param scene defines the hosting scene
  92735. * @param updatable defines if the mesh must be flagged as updatable
  92736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92737. * @returns a new Mesh
  92738. */
  92739. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92740. /**
  92741. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92742. * @param name defines the name of the mesh to create
  92743. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92744. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92745. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92746. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92747. * @param p the number of windings on X axis (positive integers, default 2)
  92748. * @param q the number of windings on Y axis (positive integers, default 3)
  92749. * @param scene defines the hosting scene
  92750. * @param updatable defines if the mesh must be flagged as updatable
  92751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92752. * @returns a new Mesh
  92753. */
  92754. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92755. /**
  92756. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92757. * @param name defines the name of the mesh to create
  92758. * @param points is an array successive Vector3
  92759. * @param scene defines the hosting scene
  92760. * @param updatable defines if the mesh must be flagged as updatable
  92761. * @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).
  92762. * @returns a new Mesh
  92763. */
  92764. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92765. /**
  92766. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92767. * @param name defines the name of the mesh to create
  92768. * @param points is an array successive Vector3
  92769. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92770. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92771. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92772. * @param scene defines the hosting scene
  92773. * @param updatable defines if the mesh must be flagged as updatable
  92774. * @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)
  92775. * @returns a new Mesh
  92776. */
  92777. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92778. /**
  92779. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92781. * 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.
  92782. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92783. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92784. * Remember you can only change the shape positions, not their number when updating a polygon.
  92785. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92786. * @param name defines the name of the mesh to create
  92787. * @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
  92788. * @param scene defines the hosting scene
  92789. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92790. * @param updatable defines if the mesh must be flagged as updatable
  92791. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92792. * @param earcutInjection can be used to inject your own earcut reference
  92793. * @returns a new Mesh
  92794. */
  92795. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92796. /**
  92797. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92798. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92799. * @param name defines the name of the mesh to create
  92800. * @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
  92801. * @param depth defines the height of extrusion
  92802. * @param scene defines the hosting scene
  92803. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92804. * @param updatable defines if the mesh must be flagged as updatable
  92805. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92806. * @param earcutInjection can be used to inject your own earcut reference
  92807. * @returns a new Mesh
  92808. */
  92809. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92810. /**
  92811. * Creates an extruded shape mesh.
  92812. * 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
  92813. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92814. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92815. * @param name defines the name of the mesh to create
  92816. * @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
  92817. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92818. * @param scale is the value to scale the shape
  92819. * @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
  92820. * @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
  92821. * @param scene defines the hosting scene
  92822. * @param updatable defines if the mesh must be flagged as updatable
  92823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92824. * @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)
  92825. * @returns a new Mesh
  92826. */
  92827. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92828. /**
  92829. * Creates an custom extruded shape mesh.
  92830. * The custom extrusion is a parametric shape.
  92831. * It has no predefined shape. Its final shape will depend on the input parameters.
  92832. * Please consider using the same method from the MeshBuilder class instead
  92833. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92834. * @param name defines the name of the mesh to create
  92835. * @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
  92836. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92837. * @param scaleFunction is a custom Javascript function called on each path point
  92838. * @param rotationFunction is a custom Javascript function called on each path point
  92839. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92840. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92841. * @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
  92842. * @param scene defines the hosting scene
  92843. * @param updatable defines if the mesh must be flagged as updatable
  92844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92845. * @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)
  92846. * @returns a new Mesh
  92847. */
  92848. 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;
  92849. /**
  92850. * Creates lathe mesh.
  92851. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92852. * Please consider using the same method from the MeshBuilder class instead
  92853. * @param name defines the name of the mesh to create
  92854. * @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
  92855. * @param radius is the radius value of the lathe
  92856. * @param tessellation is the side number of the lathe.
  92857. * @param scene defines the hosting scene
  92858. * @param updatable defines if the mesh must be flagged as updatable
  92859. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92860. * @returns a new Mesh
  92861. */
  92862. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92863. /**
  92864. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92865. * @param name defines the name of the mesh to create
  92866. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92867. * @param scene defines the hosting scene
  92868. * @param updatable defines if the mesh must be flagged as updatable
  92869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92870. * @returns a new Mesh
  92871. */
  92872. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92873. /**
  92874. * Creates a ground mesh.
  92875. * Please consider using the same method from the MeshBuilder class instead
  92876. * @param name defines the name of the mesh to create
  92877. * @param width set the width of the ground
  92878. * @param height set the height of the ground
  92879. * @param subdivisions sets the number of subdivisions per side
  92880. * @param scene defines the hosting scene
  92881. * @param updatable defines if the mesh must be flagged as updatable
  92882. * @returns a new Mesh
  92883. */
  92884. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92885. /**
  92886. * Creates a tiled ground mesh.
  92887. * Please consider using the same method from the MeshBuilder class instead
  92888. * @param name defines the name of the mesh to create
  92889. * @param xmin set the ground minimum X coordinate
  92890. * @param zmin set the ground minimum Y coordinate
  92891. * @param xmax set the ground maximum X coordinate
  92892. * @param zmax set the ground maximum Z coordinate
  92893. * @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
  92894. * @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
  92895. * @param scene defines the hosting scene
  92896. * @param updatable defines if the mesh must be flagged as updatable
  92897. * @returns a new Mesh
  92898. */
  92899. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92900. w: number;
  92901. h: number;
  92902. }, precision: {
  92903. w: number;
  92904. h: number;
  92905. }, scene: Scene, updatable?: boolean): Mesh;
  92906. /**
  92907. * Creates a ground mesh from a height map.
  92908. * Please consider using the same method from the MeshBuilder class instead
  92909. * @see http://doc.babylonjs.com/babylon101/height_map
  92910. * @param name defines the name of the mesh to create
  92911. * @param url sets the URL of the height map image resource
  92912. * @param width set the ground width size
  92913. * @param height set the ground height size
  92914. * @param subdivisions sets the number of subdivision per side
  92915. * @param minHeight is the minimum altitude on the ground
  92916. * @param maxHeight is the maximum altitude on the ground
  92917. * @param scene defines the hosting scene
  92918. * @param updatable defines if the mesh must be flagged as updatable
  92919. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92920. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92921. * @returns a new Mesh
  92922. */
  92923. 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;
  92924. /**
  92925. * Creates a tube mesh.
  92926. * The tube is a parametric shape.
  92927. * It has no predefined shape. Its final shape will depend on the input parameters.
  92928. * Please consider using the same method from the MeshBuilder class instead
  92929. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92930. * @param name defines the name of the mesh to create
  92931. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92932. * @param radius sets the tube radius size
  92933. * @param tessellation is the number of sides on the tubular surface
  92934. * @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
  92935. * @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
  92936. * @param scene defines the hosting scene
  92937. * @param updatable defines if the mesh must be flagged as updatable
  92938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92939. * @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)
  92940. * @returns a new Mesh
  92941. */
  92942. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92943. (i: number, distance: number): number;
  92944. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92945. /**
  92946. * Creates a polyhedron mesh.
  92947. * Please consider using the same method from the MeshBuilder class instead.
  92948. * * 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
  92949. * * The parameter `size` (positive float, default 1) sets the polygon size
  92950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92951. * * 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`
  92952. * * 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
  92953. * * 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)`)
  92954. * * 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
  92955. * * 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
  92956. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92957. * * If you create a double-sided mesh, you can choose what parts of 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
  92958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92959. * @param name defines the name of the mesh to create
  92960. * @param options defines the options used to create the mesh
  92961. * @param scene defines the hosting scene
  92962. * @returns a new Mesh
  92963. */
  92964. static CreatePolyhedron(name: string, options: {
  92965. type?: number;
  92966. size?: number;
  92967. sizeX?: number;
  92968. sizeY?: number;
  92969. sizeZ?: number;
  92970. custom?: any;
  92971. faceUV?: Vector4[];
  92972. faceColors?: Color4[];
  92973. updatable?: boolean;
  92974. sideOrientation?: number;
  92975. }, scene: Scene): Mesh;
  92976. /**
  92977. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92978. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92979. * * 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`)
  92980. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92981. * * 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
  92982. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92983. * * If you create a double-sided mesh, you can choose what parts of 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
  92984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92985. * @param name defines the name of the mesh
  92986. * @param options defines the options used to create the mesh
  92987. * @param scene defines the hosting scene
  92988. * @returns a new Mesh
  92989. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92990. */
  92991. static CreateIcoSphere(name: string, options: {
  92992. radius?: number;
  92993. flat?: boolean;
  92994. subdivisions?: number;
  92995. sideOrientation?: number;
  92996. updatable?: boolean;
  92997. }, scene: Scene): Mesh;
  92998. /**
  92999. * Creates a decal mesh.
  93000. * Please consider using the same method from the MeshBuilder class instead.
  93001. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93002. * @param name defines the name of the mesh
  93003. * @param sourceMesh defines the mesh receiving the decal
  93004. * @param position sets the position of the decal in world coordinates
  93005. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93006. * @param size sets the decal scaling
  93007. * @param angle sets the angle to rotate the decal
  93008. * @returns a new Mesh
  93009. */
  93010. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93011. /**
  93012. * Prepare internal position array for software CPU skinning
  93013. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93014. */
  93015. setPositionsForCPUSkinning(): Float32Array;
  93016. /**
  93017. * Prepare internal normal array for software CPU skinning
  93018. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93019. */
  93020. setNormalsForCPUSkinning(): Float32Array;
  93021. /**
  93022. * Updates the vertex buffer by applying transformation from the bones
  93023. * @param skeleton defines the skeleton to apply to current mesh
  93024. * @returns the current mesh
  93025. */
  93026. applySkeleton(skeleton: Skeleton): Mesh;
  93027. /**
  93028. * 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
  93029. * @param meshes defines the list of meshes to scan
  93030. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93031. */
  93032. static MinMax(meshes: AbstractMesh[]): {
  93033. min: Vector3;
  93034. max: Vector3;
  93035. };
  93036. /**
  93037. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93038. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93039. * @returns a vector3
  93040. */
  93041. static Center(meshesOrMinMaxVector: {
  93042. min: Vector3;
  93043. max: Vector3;
  93044. } | AbstractMesh[]): Vector3;
  93045. /**
  93046. * Merge the array of meshes into a single mesh for performance reasons.
  93047. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93048. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93049. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93050. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93051. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93052. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93053. * @returns a new mesh
  93054. */
  93055. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93056. /** @hidden */
  93057. addInstance(instance: InstancedMesh): void;
  93058. /** @hidden */
  93059. removeInstance(instance: InstancedMesh): void;
  93060. }
  93061. }
  93062. declare module BABYLON {
  93063. /**
  93064. * This is the base class of all the camera used in the application.
  93065. * @see http://doc.babylonjs.com/features/cameras
  93066. */
  93067. export class Camera extends Node {
  93068. /** @hidden */
  93069. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93070. /**
  93071. * This is the default projection mode used by the cameras.
  93072. * It helps recreating a feeling of perspective and better appreciate depth.
  93073. * This is the best way to simulate real life cameras.
  93074. */
  93075. static readonly PERSPECTIVE_CAMERA: number;
  93076. /**
  93077. * This helps creating camera with an orthographic mode.
  93078. * 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.
  93079. */
  93080. static readonly ORTHOGRAPHIC_CAMERA: number;
  93081. /**
  93082. * This is the default FOV mode for perspective cameras.
  93083. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93084. */
  93085. static readonly FOVMODE_VERTICAL_FIXED: number;
  93086. /**
  93087. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93088. */
  93089. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93090. /**
  93091. * This specifies ther is no need for a camera rig.
  93092. * Basically only one eye is rendered corresponding to the camera.
  93093. */
  93094. static readonly RIG_MODE_NONE: number;
  93095. /**
  93096. * Simulates a camera Rig with one blue eye and one red eye.
  93097. * This can be use with 3d blue and red glasses.
  93098. */
  93099. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93100. /**
  93101. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93102. */
  93103. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93104. /**
  93105. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93106. */
  93107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93108. /**
  93109. * Defines that both eyes of the camera will be rendered over under each other.
  93110. */
  93111. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93112. /**
  93113. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93114. */
  93115. static readonly RIG_MODE_VR: number;
  93116. /**
  93117. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93118. */
  93119. static readonly RIG_MODE_WEBVR: number;
  93120. /**
  93121. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93122. */
  93123. static readonly RIG_MODE_CUSTOM: number;
  93124. /**
  93125. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93126. */
  93127. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93128. /**
  93129. * Define the input manager associated with the camera.
  93130. */
  93131. inputs: CameraInputsManager<Camera>;
  93132. /** @hidden */
  93133. _position: Vector3;
  93134. /**
  93135. * Define the current local position of the camera in the scene
  93136. */
  93137. position: Vector3;
  93138. /**
  93139. * The vector the camera should consider as up.
  93140. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93141. */
  93142. upVector: Vector3;
  93143. /**
  93144. * Define the current limit on the left side for an orthographic camera
  93145. * In scene unit
  93146. */
  93147. orthoLeft: Nullable<number>;
  93148. /**
  93149. * Define the current limit on the right side for an orthographic camera
  93150. * In scene unit
  93151. */
  93152. orthoRight: Nullable<number>;
  93153. /**
  93154. * Define the current limit on the bottom side for an orthographic camera
  93155. * In scene unit
  93156. */
  93157. orthoBottom: Nullable<number>;
  93158. /**
  93159. * Define the current limit on the top side for an orthographic camera
  93160. * In scene unit
  93161. */
  93162. orthoTop: Nullable<number>;
  93163. /**
  93164. * Field Of View is set in Radians. (default is 0.8)
  93165. */
  93166. fov: number;
  93167. /**
  93168. * Define the minimum distance the camera can see from.
  93169. * This is important to note that the depth buffer are not infinite and the closer it starts
  93170. * the more your scene might encounter depth fighting issue.
  93171. */
  93172. minZ: number;
  93173. /**
  93174. * Define the maximum distance the camera can see to.
  93175. * This is important to note that the depth buffer are not infinite and the further it end
  93176. * the more your scene might encounter depth fighting issue.
  93177. */
  93178. maxZ: number;
  93179. /**
  93180. * Define the default inertia of the camera.
  93181. * This helps giving a smooth feeling to the camera movement.
  93182. */
  93183. inertia: number;
  93184. /**
  93185. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93186. */
  93187. mode: number;
  93188. /**
  93189. * Define wether the camera is intermediate.
  93190. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93191. */
  93192. isIntermediate: boolean;
  93193. /**
  93194. * Define the viewport of the camera.
  93195. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93196. */
  93197. viewport: Viewport;
  93198. /**
  93199. * Restricts the camera to viewing objects with the same layerMask.
  93200. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93201. */
  93202. layerMask: number;
  93203. /**
  93204. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93205. */
  93206. fovMode: number;
  93207. /**
  93208. * Rig mode of the camera.
  93209. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93210. * This is normally controlled byt the camera themselves as internal use.
  93211. */
  93212. cameraRigMode: number;
  93213. /**
  93214. * Defines the distance between both "eyes" in case of a RIG
  93215. */
  93216. interaxialDistance: number;
  93217. /**
  93218. * Defines if stereoscopic rendering is done side by side or over under.
  93219. */
  93220. isStereoscopicSideBySide: boolean;
  93221. /**
  93222. * 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
  93223. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93224. * else in the scene. (Eg. security camera)
  93225. *
  93226. * 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)
  93227. */
  93228. customRenderTargets: RenderTargetTexture[];
  93229. /**
  93230. * When set, the camera will render to this render target instead of the default canvas
  93231. *
  93232. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93233. */
  93234. outputRenderTarget: Nullable<RenderTargetTexture>;
  93235. /**
  93236. * Observable triggered when the camera view matrix has changed.
  93237. */
  93238. onViewMatrixChangedObservable: Observable<Camera>;
  93239. /**
  93240. * Observable triggered when the camera Projection matrix has changed.
  93241. */
  93242. onProjectionMatrixChangedObservable: Observable<Camera>;
  93243. /**
  93244. * Observable triggered when the inputs have been processed.
  93245. */
  93246. onAfterCheckInputsObservable: Observable<Camera>;
  93247. /**
  93248. * Observable triggered when reset has been called and applied to the camera.
  93249. */
  93250. onRestoreStateObservable: Observable<Camera>;
  93251. /** @hidden */
  93252. _cameraRigParams: any;
  93253. /** @hidden */
  93254. _rigCameras: Camera[];
  93255. /** @hidden */
  93256. _rigPostProcess: Nullable<PostProcess>;
  93257. protected _webvrViewMatrix: Matrix;
  93258. /** @hidden */
  93259. _skipRendering: boolean;
  93260. /** @hidden */
  93261. _projectionMatrix: Matrix;
  93262. /** @hidden */
  93263. _postProcesses: Nullable<PostProcess>[];
  93264. /** @hidden */
  93265. _activeMeshes: SmartArray<AbstractMesh>;
  93266. protected _globalPosition: Vector3;
  93267. /** @hidden */
  93268. _computedViewMatrix: Matrix;
  93269. private _doNotComputeProjectionMatrix;
  93270. private _transformMatrix;
  93271. private _frustumPlanes;
  93272. private _refreshFrustumPlanes;
  93273. private _storedFov;
  93274. private _stateStored;
  93275. /**
  93276. * Instantiates a new camera object.
  93277. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93278. * @see http://doc.babylonjs.com/features/cameras
  93279. * @param name Defines the name of the camera in the scene
  93280. * @param position Defines the position of the camera
  93281. * @param scene Defines the scene the camera belongs too
  93282. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93283. */
  93284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93285. /**
  93286. * Store current camera state (fov, position, etc..)
  93287. * @returns the camera
  93288. */
  93289. storeState(): Camera;
  93290. /**
  93291. * Restores the camera state values if it has been stored. You must call storeState() first
  93292. */
  93293. protected _restoreStateValues(): boolean;
  93294. /**
  93295. * Restored camera state. You must call storeState() first.
  93296. * @returns true if restored and false otherwise
  93297. */
  93298. restoreState(): boolean;
  93299. /**
  93300. * Gets the class name of the camera.
  93301. * @returns the class name
  93302. */
  93303. getClassName(): string;
  93304. /** @hidden */
  93305. readonly _isCamera: boolean;
  93306. /**
  93307. * Gets a string representation of the camera useful for debug purpose.
  93308. * @param fullDetails Defines that a more verboe level of logging is required
  93309. * @returns the string representation
  93310. */
  93311. toString(fullDetails?: boolean): string;
  93312. /**
  93313. * Gets the current world space position of the camera.
  93314. */
  93315. readonly globalPosition: Vector3;
  93316. /**
  93317. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93318. * @returns the active meshe list
  93319. */
  93320. getActiveMeshes(): SmartArray<AbstractMesh>;
  93321. /**
  93322. * Check wether a mesh is part of the current active mesh list of the camera
  93323. * @param mesh Defines the mesh to check
  93324. * @returns true if active, false otherwise
  93325. */
  93326. isActiveMesh(mesh: Mesh): boolean;
  93327. /**
  93328. * Is this camera ready to be used/rendered
  93329. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93330. * @return true if the camera is ready
  93331. */
  93332. isReady(completeCheck?: boolean): boolean;
  93333. /** @hidden */
  93334. _initCache(): void;
  93335. /** @hidden */
  93336. _updateCache(ignoreParentClass?: boolean): void;
  93337. /** @hidden */
  93338. _isSynchronized(): boolean;
  93339. /** @hidden */
  93340. _isSynchronizedViewMatrix(): boolean;
  93341. /** @hidden */
  93342. _isSynchronizedProjectionMatrix(): boolean;
  93343. /**
  93344. * Attach the input controls to a specific dom element to get the input from.
  93345. * @param element Defines the element the controls should be listened from
  93346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93347. */
  93348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93349. /**
  93350. * Detach the current controls from the specified dom element.
  93351. * @param element Defines the element to stop listening the inputs from
  93352. */
  93353. detachControl(element: HTMLElement): void;
  93354. /**
  93355. * Update the camera state according to the different inputs gathered during the frame.
  93356. */
  93357. update(): void;
  93358. /** @hidden */
  93359. _checkInputs(): void;
  93360. /** @hidden */
  93361. readonly rigCameras: Camera[];
  93362. /**
  93363. * Gets the post process used by the rig cameras
  93364. */
  93365. readonly rigPostProcess: Nullable<PostProcess>;
  93366. /**
  93367. * Internal, gets the first post proces.
  93368. * @returns the first post process to be run on this camera.
  93369. */
  93370. _getFirstPostProcess(): Nullable<PostProcess>;
  93371. private _cascadePostProcessesToRigCams;
  93372. /**
  93373. * Attach a post process to the camera.
  93374. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93375. * @param postProcess The post process to attach to the camera
  93376. * @param insertAt The position of the post process in case several of them are in use in the scene
  93377. * @returns the position the post process has been inserted at
  93378. */
  93379. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93380. /**
  93381. * Detach a post process to the camera.
  93382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93383. * @param postProcess The post process to detach from the camera
  93384. */
  93385. detachPostProcess(postProcess: PostProcess): void;
  93386. /**
  93387. * Gets the current world matrix of the camera
  93388. */
  93389. getWorldMatrix(): Matrix;
  93390. /** @hidden */
  93391. _getViewMatrix(): Matrix;
  93392. /**
  93393. * Gets the current view matrix of the camera.
  93394. * @param force forces the camera to recompute the matrix without looking at the cached state
  93395. * @returns the view matrix
  93396. */
  93397. getViewMatrix(force?: boolean): Matrix;
  93398. /**
  93399. * Freeze the projection matrix.
  93400. * It will prevent the cache check of the camera projection compute and can speed up perf
  93401. * if no parameter of the camera are meant to change
  93402. * @param projection Defines manually a projection if necessary
  93403. */
  93404. freezeProjectionMatrix(projection?: Matrix): void;
  93405. /**
  93406. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93407. */
  93408. unfreezeProjectionMatrix(): void;
  93409. /**
  93410. * Gets the current projection matrix of the camera.
  93411. * @param force forces the camera to recompute the matrix without looking at the cached state
  93412. * @returns the projection matrix
  93413. */
  93414. getProjectionMatrix(force?: boolean): Matrix;
  93415. /**
  93416. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93417. * @returns a Matrix
  93418. */
  93419. getTransformationMatrix(): Matrix;
  93420. private _updateFrustumPlanes;
  93421. /**
  93422. * Checks if a cullable object (mesh...) is in the camera frustum
  93423. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93424. * @param target The object to check
  93425. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93426. * @returns true if the object is in frustum otherwise false
  93427. */
  93428. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93429. /**
  93430. * Checks if a cullable object (mesh...) is in the camera frustum
  93431. * Unlike isInFrustum this cheks the full bounding box
  93432. * @param target The object to check
  93433. * @returns true if the object is in frustum otherwise false
  93434. */
  93435. isCompletelyInFrustum(target: ICullable): boolean;
  93436. /**
  93437. * Gets a ray in the forward direction from the camera.
  93438. * @param length Defines the length of the ray to create
  93439. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93440. * @param origin Defines the start point of the ray which defaults to the camera position
  93441. * @returns the forward ray
  93442. */
  93443. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93444. /**
  93445. * Releases resources associated with this node.
  93446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93448. */
  93449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93450. /** @hidden */
  93451. _isLeftCamera: boolean;
  93452. /**
  93453. * Gets the left camera of a rig setup in case of Rigged Camera
  93454. */
  93455. readonly isLeftCamera: boolean;
  93456. /** @hidden */
  93457. _isRightCamera: boolean;
  93458. /**
  93459. * Gets the right camera of a rig setup in case of Rigged Camera
  93460. */
  93461. readonly isRightCamera: boolean;
  93462. /**
  93463. * Gets the left camera of a rig setup in case of Rigged Camera
  93464. */
  93465. readonly leftCamera: Nullable<FreeCamera>;
  93466. /**
  93467. * Gets the right camera of a rig setup in case of Rigged Camera
  93468. */
  93469. readonly rightCamera: Nullable<FreeCamera>;
  93470. /**
  93471. * Gets the left camera target of a rig setup in case of Rigged Camera
  93472. * @returns the target position
  93473. */
  93474. getLeftTarget(): Nullable<Vector3>;
  93475. /**
  93476. * Gets the right camera target of a rig setup in case of Rigged Camera
  93477. * @returns the target position
  93478. */
  93479. getRightTarget(): Nullable<Vector3>;
  93480. /**
  93481. * @hidden
  93482. */
  93483. setCameraRigMode(mode: number, rigParams: any): void;
  93484. /** @hidden */
  93485. static _setStereoscopicRigMode(camera: Camera): void;
  93486. /** @hidden */
  93487. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93488. /** @hidden */
  93489. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93490. /** @hidden */
  93491. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93492. /** @hidden */
  93493. _getVRProjectionMatrix(): Matrix;
  93494. protected _updateCameraRotationMatrix(): void;
  93495. protected _updateWebVRCameraRotationMatrix(): void;
  93496. /**
  93497. * This function MUST be overwritten by the different WebVR cameras available.
  93498. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93499. * @hidden
  93500. */
  93501. _getWebVRProjectionMatrix(): Matrix;
  93502. /**
  93503. * This function MUST be overwritten by the different WebVR cameras available.
  93504. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93505. * @hidden
  93506. */
  93507. _getWebVRViewMatrix(): Matrix;
  93508. /** @hidden */
  93509. setCameraRigParameter(name: string, value: any): void;
  93510. /**
  93511. * needs to be overridden by children so sub has required properties to be copied
  93512. * @hidden
  93513. */
  93514. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93515. /**
  93516. * May need to be overridden by children
  93517. * @hidden
  93518. */
  93519. _updateRigCameras(): void;
  93520. /** @hidden */
  93521. _setupInputs(): void;
  93522. /**
  93523. * Serialiaze the camera setup to a json represention
  93524. * @returns the JSON representation
  93525. */
  93526. serialize(): any;
  93527. /**
  93528. * Clones the current camera.
  93529. * @param name The cloned camera name
  93530. * @returns the cloned camera
  93531. */
  93532. clone(name: string): Camera;
  93533. /**
  93534. * Gets the direction of the camera relative to a given local axis.
  93535. * @param localAxis Defines the reference axis to provide a relative direction.
  93536. * @return the direction
  93537. */
  93538. getDirection(localAxis: Vector3): Vector3;
  93539. /**
  93540. * Returns the current camera absolute rotation
  93541. */
  93542. readonly absoluteRotation: Quaternion;
  93543. /**
  93544. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93545. * @param localAxis Defines the reference axis to provide a relative direction.
  93546. * @param result Defines the vector to store the result in
  93547. */
  93548. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93549. /**
  93550. * Gets a camera constructor for a given camera type
  93551. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93552. * @param name The name of the camera the result will be able to instantiate
  93553. * @param scene The scene the result will construct the camera in
  93554. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93555. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93556. * @returns a factory method to construc the camera
  93557. */
  93558. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93559. /**
  93560. * Compute the world matrix of the camera.
  93561. * @returns the camera world matrix
  93562. */
  93563. computeWorldMatrix(): Matrix;
  93564. /**
  93565. * Parse a JSON and creates the camera from the parsed information
  93566. * @param parsedCamera The JSON to parse
  93567. * @param scene The scene to instantiate the camera in
  93568. * @returns the newly constructed camera
  93569. */
  93570. static Parse(parsedCamera: any, scene: Scene): Camera;
  93571. }
  93572. }
  93573. declare module BABYLON {
  93574. /**
  93575. * Class containing static functions to help procedurally build meshes
  93576. */
  93577. export class DiscBuilder {
  93578. /**
  93579. * Creates a plane polygonal mesh. By default, this is a disc
  93580. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93581. * * 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
  93582. * * 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
  93583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93586. * @param name defines the name of the mesh
  93587. * @param options defines the options used to create the mesh
  93588. * @param scene defines the hosting scene
  93589. * @returns the plane polygonal mesh
  93590. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93591. */
  93592. static CreateDisc(name: string, options: {
  93593. radius?: number;
  93594. tessellation?: number;
  93595. arc?: number;
  93596. updatable?: boolean;
  93597. sideOrientation?: number;
  93598. frontUVs?: Vector4;
  93599. backUVs?: Vector4;
  93600. }, scene?: Nullable<Scene>): Mesh;
  93601. }
  93602. }
  93603. declare module BABYLON {
  93604. /**
  93605. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93606. *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.
  93607. * The SPS is also a particle system. It provides some methods to manage the particles.
  93608. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93609. *
  93610. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93611. */
  93612. export class SolidParticleSystem implements IDisposable {
  93613. /**
  93614. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93615. * Example : var p = SPS.particles[i];
  93616. */
  93617. particles: SolidParticle[];
  93618. /**
  93619. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93620. */
  93621. nbParticles: number;
  93622. /**
  93623. * If the particles must ever face the camera (default false). Useful for planar particles.
  93624. */
  93625. billboard: boolean;
  93626. /**
  93627. * Recompute normals when adding a shape
  93628. */
  93629. recomputeNormals: boolean;
  93630. /**
  93631. * This a counter ofr your own usage. It's not set by any SPS functions.
  93632. */
  93633. counter: number;
  93634. /**
  93635. * The SPS name. This name is also given to the underlying mesh.
  93636. */
  93637. name: string;
  93638. /**
  93639. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93640. */
  93641. mesh: Mesh;
  93642. /**
  93643. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93644. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93645. */
  93646. vars: any;
  93647. /**
  93648. * This array is populated when the SPS is set as 'pickable'.
  93649. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93650. * Each element of this array is an object `{idx: int, faceId: int}`.
  93651. * `idx` is the picked particle index in the `SPS.particles` array
  93652. * `faceId` is the picked face index counted within this particle.
  93653. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93654. */
  93655. pickedParticles: {
  93656. idx: number;
  93657. faceId: number;
  93658. }[];
  93659. /**
  93660. * This array is populated when `enableDepthSort` is set to true.
  93661. * Each element of this array is an instance of the class DepthSortedParticle.
  93662. */
  93663. depthSortedParticles: DepthSortedParticle[];
  93664. /**
  93665. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93666. * @hidden
  93667. */
  93668. _bSphereOnly: boolean;
  93669. /**
  93670. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93671. * @hidden
  93672. */
  93673. _bSphereRadiusFactor: number;
  93674. private _scene;
  93675. private _positions;
  93676. private _indices;
  93677. private _normals;
  93678. private _colors;
  93679. private _uvs;
  93680. private _indices32;
  93681. private _positions32;
  93682. private _normals32;
  93683. private _fixedNormal32;
  93684. private _colors32;
  93685. private _uvs32;
  93686. private _index;
  93687. private _updatable;
  93688. private _pickable;
  93689. private _isVisibilityBoxLocked;
  93690. private _alwaysVisible;
  93691. private _depthSort;
  93692. private _expandable;
  93693. private _shapeCounter;
  93694. private _copy;
  93695. private _color;
  93696. private _computeParticleColor;
  93697. private _computeParticleTexture;
  93698. private _computeParticleRotation;
  93699. private _computeParticleVertex;
  93700. private _computeBoundingBox;
  93701. private _depthSortParticles;
  93702. private _camera;
  93703. private _mustUnrotateFixedNormals;
  93704. private _particlesIntersect;
  93705. private _needs32Bits;
  93706. private _isNotBuilt;
  93707. private _lastParticleId;
  93708. private _idxOfId;
  93709. /**
  93710. * Creates a SPS (Solid Particle System) object.
  93711. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93712. * @param scene (Scene) is the scene in which the SPS is added.
  93713. * @param options defines the options of the sps e.g.
  93714. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93715. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93716. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93717. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93718. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93719. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93720. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93721. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93722. */
  93723. constructor(name: string, scene: Scene, options?: {
  93724. updatable?: boolean;
  93725. isPickable?: boolean;
  93726. enableDepthSort?: boolean;
  93727. particleIntersection?: boolean;
  93728. boundingSphereOnly?: boolean;
  93729. bSphereRadiusFactor?: number;
  93730. expandable?: boolean;
  93731. });
  93732. /**
  93733. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93734. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93735. * @returns the created mesh
  93736. */
  93737. buildMesh(): Mesh;
  93738. /**
  93739. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93740. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93741. * Thus the particles generated from `digest()` have their property `position` set yet.
  93742. * @param mesh ( Mesh ) is the mesh to be digested
  93743. * @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
  93744. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93745. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93746. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93747. * @returns the current SPS
  93748. */
  93749. digest(mesh: Mesh, options?: {
  93750. facetNb?: number;
  93751. number?: number;
  93752. delta?: number;
  93753. storage?: [];
  93754. }): SolidParticleSystem;
  93755. /**
  93756. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  93757. * @hidden
  93758. */
  93759. private _unrotateFixedNormals;
  93760. /**
  93761. * Resets the temporary working copy particle
  93762. * @hidden
  93763. */
  93764. private _resetCopy;
  93765. /**
  93766. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  93767. * @param p the current index in the positions array to be updated
  93768. * @param shape a Vector3 array, the shape geometry
  93769. * @param positions the positions array to be updated
  93770. * @param meshInd the shape indices array
  93771. * @param indices the indices array to be updated
  93772. * @param meshUV the shape uv array
  93773. * @param uvs the uv array to be updated
  93774. * @param meshCol the shape color array
  93775. * @param colors the color array to be updated
  93776. * @param meshNor the shape normals array
  93777. * @param normals the normals array to be updated
  93778. * @param idx the particle index
  93779. * @param idxInShape the particle index in its shape
  93780. * @param options the addShape() method passed options
  93781. * @hidden
  93782. */
  93783. private _meshBuilder;
  93784. /**
  93785. * Returns a shape Vector3 array from positions float array
  93786. * @param positions float array
  93787. * @returns a vector3 array
  93788. * @hidden
  93789. */
  93790. private _posToShape;
  93791. /**
  93792. * Returns a shapeUV array from a float uvs (array deep copy)
  93793. * @param uvs as a float array
  93794. * @returns a shapeUV array
  93795. * @hidden
  93796. */
  93797. private _uvsToShapeUV;
  93798. /**
  93799. * Adds a new particle object in the particles array
  93800. * @param idx particle index in particles array
  93801. * @param id particle id
  93802. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  93803. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  93804. * @param model particle ModelShape object
  93805. * @param shapeId model shape identifier
  93806. * @param idxInShape index of the particle in the current model
  93807. * @param bInfo model bounding info object
  93808. * @param storage target storage array, if any
  93809. * @hidden
  93810. */
  93811. private _addParticle;
  93812. /**
  93813. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93814. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93815. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93816. * @param nb (positive integer) the number of particles to be created from this model
  93817. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93818. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93819. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  93820. * @returns the number of shapes in the system
  93821. */
  93822. addShape(mesh: Mesh, nb: number, options?: {
  93823. positionFunction?: any;
  93824. vertexFunction?: any;
  93825. storage?: [];
  93826. }): number;
  93827. /**
  93828. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  93829. * @hidden
  93830. */
  93831. private _rebuildParticle;
  93832. /**
  93833. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93834. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  93835. * @returns the SPS.
  93836. */
  93837. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93838. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93839. * Returns an array with the removed particles.
  93840. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  93841. * The SPS can't be empty so at least one particle needs to remain in place.
  93842. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93843. * @param start index of the first particle to remove
  93844. * @param end index of the last particle to remove (included)
  93845. * @returns an array populated with the removed particles
  93846. */
  93847. removeParticles(start: number, end: number): SolidParticle[];
  93848. /**
  93849. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  93850. * @param solidParticleArray an array populated with Solid Particles objects
  93851. * @returns the SPS
  93852. */
  93853. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  93854. /**
  93855. * Creates a new particle and modifies the SPS mesh geometry :
  93856. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  93857. * - calls _addParticle() to populate the particle array
  93858. * factorized code from addShape() and insertParticlesFromArray()
  93859. * @param idx particle index in the particles array
  93860. * @param i particle index in its shape
  93861. * @param modelShape particle ModelShape object
  93862. * @param shape shape vertex array
  93863. * @param meshInd shape indices array
  93864. * @param meshUV shape uv array
  93865. * @param meshCol shape color array
  93866. * @param meshNor shape normals array
  93867. * @param bbInfo shape bounding info
  93868. * @param storage target particle storage
  93869. * @options addShape() passed options
  93870. * @hidden
  93871. */
  93872. private _insertNewParticle;
  93873. /**
  93874. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93875. * This method calls `updateParticle()` for each particle of the SPS.
  93876. * For an animated SPS, it is usually called within the render loop.
  93877. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  93878. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93879. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93880. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93881. * @returns the SPS.
  93882. */
  93883. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93884. /**
  93885. * Disposes the SPS.
  93886. */
  93887. dispose(): void;
  93888. /**
  93889. * Returns a SolidParticle object from its identifier : particle.id
  93890. * @param id (integer) the particle Id
  93891. * @returns the searched particle or null if not found in the SPS.
  93892. */
  93893. getParticleById(id: number): Nullable<SolidParticle>;
  93894. /**
  93895. * Returns a new array populated with the particles having the passed shapeId.
  93896. * @param shapeId (integer) the shape identifier
  93897. * @returns a new solid particle array
  93898. */
  93899. getParticlesByShapeId(shapeId: number): SolidParticle[];
  93900. /**
  93901. * Populates the passed array "ref" with the particles having the passed shapeId.
  93902. * @param shapeId the shape identifier
  93903. * @returns the SPS
  93904. * @param ref
  93905. */
  93906. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  93907. /**
  93908. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93909. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93910. * @returns the SPS.
  93911. */
  93912. refreshVisibleSize(): SolidParticleSystem;
  93913. /**
  93914. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93915. * @param size the size (float) of the visibility box
  93916. * note : this doesn't lock the SPS mesh bounding box.
  93917. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93918. */
  93919. setVisibilityBox(size: number): void;
  93920. /**
  93921. * Gets whether the SPS as always visible or not
  93922. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93923. */
  93924. /**
  93925. * Sets the SPS as always visible or not
  93926. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93927. */
  93928. isAlwaysVisible: boolean;
  93929. /**
  93930. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93931. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93932. */
  93933. /**
  93934. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93935. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93936. */
  93937. isVisibilityBoxLocked: boolean;
  93938. /**
  93939. * Tells to `setParticles()` to compute the particle rotations or not.
  93940. * Default value : true. The SPS is faster when it's set to false.
  93941. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93942. */
  93943. /**
  93944. * Gets if `setParticles()` computes the particle rotations or not.
  93945. * Default value : true. The SPS is faster when it's set to false.
  93946. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93947. */
  93948. computeParticleRotation: boolean;
  93949. /**
  93950. * Tells to `setParticles()` to compute the particle colors or not.
  93951. * Default value : true. The SPS is faster when it's set to false.
  93952. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93953. */
  93954. /**
  93955. * Gets if `setParticles()` computes the particle colors or not.
  93956. * Default value : true. The SPS is faster when it's set to false.
  93957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93958. */
  93959. computeParticleColor: boolean;
  93960. /**
  93961. * Gets if `setParticles()` computes the particle textures or not.
  93962. * Default value : true. The SPS is faster when it's set to false.
  93963. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93964. */
  93965. computeParticleTexture: boolean;
  93966. /**
  93967. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93968. * Default value : false. The SPS is faster when it's set to false.
  93969. * Note : the particle custom vertex positions aren't stored values.
  93970. */
  93971. /**
  93972. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93973. * Default value : false. The SPS is faster when it's set to false.
  93974. * Note : the particle custom vertex positions aren't stored values.
  93975. */
  93976. computeParticleVertex: boolean;
  93977. /**
  93978. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93979. */
  93980. /**
  93981. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93982. */
  93983. computeBoundingBox: boolean;
  93984. /**
  93985. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93986. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93987. * Default : `true`
  93988. */
  93989. /**
  93990. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93991. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93992. * Default : `true`
  93993. */
  93994. depthSortParticles: boolean;
  93995. /**
  93996. * Gets if the SPS is created as expandable at construction time.
  93997. * Default : `false`
  93998. */
  93999. readonly expandable: boolean;
  94000. /**
  94001. * This function does nothing. It may be overwritten to set all the particle first values.
  94002. * The SPS doesn't call this function, you may have to call it by your own.
  94003. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94004. */
  94005. initParticles(): void;
  94006. /**
  94007. * This function does nothing. It may be overwritten to recycle a particle.
  94008. * The SPS doesn't call this function, you may have to call it by your own.
  94009. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94010. * @param particle The particle to recycle
  94011. * @returns the recycled particle
  94012. */
  94013. recycleParticle(particle: SolidParticle): SolidParticle;
  94014. /**
  94015. * Updates a particle : this function should be overwritten by the user.
  94016. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94018. * @example : just set a particle position or velocity and recycle conditions
  94019. * @param particle The particle to update
  94020. * @returns the updated particle
  94021. */
  94022. updateParticle(particle: SolidParticle): SolidParticle;
  94023. /**
  94024. * Updates a vertex of a particle : it can be overwritten by the user.
  94025. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94026. * @param particle the current particle
  94027. * @param vertex the current index of the current particle
  94028. * @param pt the index of the current vertex in the particle shape
  94029. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94030. * @example : just set a vertex particle position
  94031. * @returns the updated vertex
  94032. */
  94033. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94034. /**
  94035. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94036. * This does nothing and may be overwritten by the user.
  94037. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94038. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94039. * @param update the boolean update value actually passed to setParticles()
  94040. */
  94041. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94042. /**
  94043. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94044. * This will be passed three parameters.
  94045. * This does nothing and may be overwritten by the user.
  94046. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94047. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94048. * @param update the boolean update value actually passed to setParticles()
  94049. */
  94050. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94051. }
  94052. }
  94053. declare module BABYLON {
  94054. /**
  94055. * Represents one particle of a solid particle system.
  94056. */
  94057. export class SolidParticle {
  94058. /**
  94059. * particle global index
  94060. */
  94061. idx: number;
  94062. /**
  94063. * particle identifier
  94064. */
  94065. id: number;
  94066. /**
  94067. * The color of the particle
  94068. */
  94069. color: Nullable<Color4>;
  94070. /**
  94071. * The world space position of the particle.
  94072. */
  94073. position: Vector3;
  94074. /**
  94075. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94076. */
  94077. rotation: Vector3;
  94078. /**
  94079. * The world space rotation quaternion of the particle.
  94080. */
  94081. rotationQuaternion: Nullable<Quaternion>;
  94082. /**
  94083. * The scaling of the particle.
  94084. */
  94085. scaling: Vector3;
  94086. /**
  94087. * The uvs of the particle.
  94088. */
  94089. uvs: Vector4;
  94090. /**
  94091. * The current speed of the particle.
  94092. */
  94093. velocity: Vector3;
  94094. /**
  94095. * The pivot point in the particle local space.
  94096. */
  94097. pivot: Vector3;
  94098. /**
  94099. * Must the particle be translated from its pivot point in its local space ?
  94100. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94101. * Default : false
  94102. */
  94103. translateFromPivot: boolean;
  94104. /**
  94105. * Is the particle active or not ?
  94106. */
  94107. alive: boolean;
  94108. /**
  94109. * Is the particle visible or not ?
  94110. */
  94111. isVisible: boolean;
  94112. /**
  94113. * Index of this particle in the global "positions" array (Internal use)
  94114. * @hidden
  94115. */
  94116. _pos: number;
  94117. /**
  94118. * @hidden Index of this particle in the global "indices" array (Internal use)
  94119. */
  94120. _ind: number;
  94121. /**
  94122. * @hidden ModelShape of this particle (Internal use)
  94123. */
  94124. _model: ModelShape;
  94125. /**
  94126. * ModelShape id of this particle
  94127. */
  94128. shapeId: number;
  94129. /**
  94130. * Index of the particle in its shape id
  94131. */
  94132. idxInShape: number;
  94133. /**
  94134. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94135. */
  94136. _modelBoundingInfo: BoundingInfo;
  94137. /**
  94138. * @hidden Particle BoundingInfo object (Internal use)
  94139. */
  94140. _boundingInfo: BoundingInfo;
  94141. /**
  94142. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94143. */
  94144. _sps: SolidParticleSystem;
  94145. /**
  94146. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94147. */
  94148. _stillInvisible: boolean;
  94149. /**
  94150. * @hidden Last computed particle rotation matrix
  94151. */
  94152. _rotationMatrix: number[];
  94153. /**
  94154. * Parent particle Id, if any.
  94155. * Default null.
  94156. */
  94157. parentId: Nullable<number>;
  94158. /**
  94159. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94160. * The possible values are :
  94161. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94162. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94164. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94165. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94166. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94167. * */
  94168. cullingStrategy: number;
  94169. /**
  94170. * @hidden Internal global position in the SPS.
  94171. */
  94172. _globalPosition: Vector3;
  94173. /**
  94174. * Creates a Solid Particle object.
  94175. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94176. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94177. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94178. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94179. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94180. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94181. * @param shapeId (integer) is the model shape identifier in the SPS.
  94182. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94183. * @param sps defines the sps it is associated to
  94184. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94185. */
  94186. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94187. /**
  94188. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94189. * @param target the particle target
  94190. * @returns the current particle
  94191. */
  94192. copyToRef(target: SolidParticle): SolidParticle;
  94193. /**
  94194. * Legacy support, changed scale to scaling
  94195. */
  94196. /**
  94197. * Legacy support, changed scale to scaling
  94198. */
  94199. scale: Vector3;
  94200. /**
  94201. * Legacy support, changed quaternion to rotationQuaternion
  94202. */
  94203. /**
  94204. * Legacy support, changed quaternion to rotationQuaternion
  94205. */
  94206. quaternion: Nullable<Quaternion>;
  94207. /**
  94208. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94209. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94210. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94211. * @returns true if it intersects
  94212. */
  94213. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94214. /**
  94215. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94216. * A particle is in the frustum if its bounding box intersects the frustum
  94217. * @param frustumPlanes defines the frustum to test
  94218. * @returns true if the particle is in the frustum planes
  94219. */
  94220. isInFrustum(frustumPlanes: Plane[]): boolean;
  94221. /**
  94222. * get the rotation matrix of the particle
  94223. * @hidden
  94224. */
  94225. getRotationMatrix(m: Matrix): void;
  94226. }
  94227. /**
  94228. * Represents the shape of the model used by one particle of a solid particle system.
  94229. * SPS internal tool, don't use it manually.
  94230. */
  94231. export class ModelShape {
  94232. /**
  94233. * The shape id
  94234. * @hidden
  94235. */
  94236. shapeID: number;
  94237. /**
  94238. * flat array of model positions (internal use)
  94239. * @hidden
  94240. */
  94241. _shape: Vector3[];
  94242. /**
  94243. * flat array of model UVs (internal use)
  94244. * @hidden
  94245. */
  94246. _shapeUV: number[];
  94247. /**
  94248. * color array of the model
  94249. * @hidden
  94250. */
  94251. _shapeColors: number[];
  94252. /**
  94253. * indices array of the model
  94254. * @hidden
  94255. */
  94256. _indices: number[];
  94257. /**
  94258. * normals array of the model
  94259. * @hidden
  94260. */
  94261. _normals: number[];
  94262. /**
  94263. * length of the shape in the model indices array (internal use)
  94264. * @hidden
  94265. */
  94266. _indicesLength: number;
  94267. /**
  94268. * Custom position function (internal use)
  94269. * @hidden
  94270. */
  94271. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94272. /**
  94273. * Custom vertex function (internal use)
  94274. * @hidden
  94275. */
  94276. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94277. /**
  94278. * 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.
  94279. * SPS internal tool, don't use it manually.
  94280. * @hidden
  94281. */
  94282. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  94283. }
  94284. /**
  94285. * Represents a Depth Sorted Particle in the solid particle system.
  94286. */
  94287. export class DepthSortedParticle {
  94288. /**
  94289. * Index of the particle in the "indices" array
  94290. */
  94291. ind: number;
  94292. /**
  94293. * Length of the particle shape in the "indices" array
  94294. */
  94295. indicesLength: number;
  94296. /**
  94297. * Squared distance from the particle to the camera
  94298. */
  94299. sqDistance: number;
  94300. }
  94301. }
  94302. declare module BABYLON {
  94303. /**
  94304. * @hidden
  94305. */
  94306. export class _MeshCollisionData {
  94307. _checkCollisions: boolean;
  94308. _collisionMask: number;
  94309. _collisionGroup: number;
  94310. _collider: Nullable<Collider>;
  94311. _oldPositionForCollisions: Vector3;
  94312. _diffPositionForCollisions: Vector3;
  94313. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94314. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94315. }
  94316. }
  94317. declare module BABYLON {
  94318. /** @hidden */
  94319. class _FacetDataStorage {
  94320. facetPositions: Vector3[];
  94321. facetNormals: Vector3[];
  94322. facetPartitioning: number[][];
  94323. facetNb: number;
  94324. partitioningSubdivisions: number;
  94325. partitioningBBoxRatio: number;
  94326. facetDataEnabled: boolean;
  94327. facetParameters: any;
  94328. bbSize: Vector3;
  94329. subDiv: {
  94330. max: number;
  94331. X: number;
  94332. Y: number;
  94333. Z: number;
  94334. };
  94335. facetDepthSort: boolean;
  94336. facetDepthSortEnabled: boolean;
  94337. depthSortedIndices: IndicesArray;
  94338. depthSortedFacets: {
  94339. ind: number;
  94340. sqDistance: number;
  94341. }[];
  94342. facetDepthSortFunction: (f1: {
  94343. ind: number;
  94344. sqDistance: number;
  94345. }, f2: {
  94346. ind: number;
  94347. sqDistance: number;
  94348. }) => number;
  94349. facetDepthSortFrom: Vector3;
  94350. facetDepthSortOrigin: Vector3;
  94351. invertedMatrix: Matrix;
  94352. }
  94353. /**
  94354. * @hidden
  94355. **/
  94356. class _InternalAbstractMeshDataInfo {
  94357. _hasVertexAlpha: boolean;
  94358. _useVertexColors: boolean;
  94359. _numBoneInfluencers: number;
  94360. _applyFog: boolean;
  94361. _receiveShadows: boolean;
  94362. _facetData: _FacetDataStorage;
  94363. _visibility: number;
  94364. _skeleton: Nullable<Skeleton>;
  94365. _layerMask: number;
  94366. _computeBonesUsingShaders: boolean;
  94367. _isActive: boolean;
  94368. _onlyForInstances: boolean;
  94369. _isActiveIntermediate: boolean;
  94370. _onlyForInstancesIntermediate: boolean;
  94371. _actAsRegularMesh: boolean;
  94372. }
  94373. /**
  94374. * Class used to store all common mesh properties
  94375. */
  94376. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94377. /** No occlusion */
  94378. static OCCLUSION_TYPE_NONE: number;
  94379. /** Occlusion set to optimisitic */
  94380. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94381. /** Occlusion set to strict */
  94382. static OCCLUSION_TYPE_STRICT: number;
  94383. /** Use an accurante occlusion algorithm */
  94384. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94385. /** Use a conservative occlusion algorithm */
  94386. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94387. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94388. * Test order :
  94389. * Is the bounding sphere outside the frustum ?
  94390. * If not, are the bounding box vertices outside the frustum ?
  94391. * It not, then the cullable object is in the frustum.
  94392. */
  94393. static readonly CULLINGSTRATEGY_STANDARD: number;
  94394. /** Culling strategy : Bounding Sphere Only.
  94395. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94396. * It's also less accurate than the standard because some not visible objects can still be selected.
  94397. * Test : is the bounding sphere outside the frustum ?
  94398. * If not, then the cullable object is in the frustum.
  94399. */
  94400. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94401. /** Culling strategy : Optimistic Inclusion.
  94402. * This in an inclusion test first, then the standard exclusion test.
  94403. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94404. * 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.
  94405. * Anyway, it's as accurate as the standard strategy.
  94406. * Test :
  94407. * Is the cullable object bounding sphere center in the frustum ?
  94408. * If not, apply the default culling strategy.
  94409. */
  94410. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94411. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94412. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94413. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94414. * 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.
  94415. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94416. * Test :
  94417. * Is the cullable object bounding sphere center in the frustum ?
  94418. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94419. */
  94420. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94421. /**
  94422. * No billboard
  94423. */
  94424. static readonly BILLBOARDMODE_NONE: number;
  94425. /** Billboard on X axis */
  94426. static readonly BILLBOARDMODE_X: number;
  94427. /** Billboard on Y axis */
  94428. static readonly BILLBOARDMODE_Y: number;
  94429. /** Billboard on Z axis */
  94430. static readonly BILLBOARDMODE_Z: number;
  94431. /** Billboard on all axes */
  94432. static readonly BILLBOARDMODE_ALL: number;
  94433. /** Billboard on using position instead of orientation */
  94434. static readonly BILLBOARDMODE_USE_POSITION: number;
  94435. /** @hidden */
  94436. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94437. /**
  94438. * The culling strategy to use to check whether the mesh must be rendered or not.
  94439. * This value can be changed at any time and will be used on the next render mesh selection.
  94440. * The possible values are :
  94441. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94442. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94443. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94444. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94445. * Please read each static variable documentation to get details about the culling process.
  94446. * */
  94447. cullingStrategy: number;
  94448. /**
  94449. * Gets the number of facets in the mesh
  94450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94451. */
  94452. readonly facetNb: number;
  94453. /**
  94454. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94456. */
  94457. partitioningSubdivisions: number;
  94458. /**
  94459. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94460. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94462. */
  94463. partitioningBBoxRatio: number;
  94464. /**
  94465. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94466. * Works only for updatable meshes.
  94467. * Doesn't work with multi-materials
  94468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94469. */
  94470. mustDepthSortFacets: boolean;
  94471. /**
  94472. * The location (Vector3) where the facet depth sort must be computed from.
  94473. * By default, the active camera position.
  94474. * Used only when facet depth sort is enabled
  94475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94476. */
  94477. facetDepthSortFrom: Vector3;
  94478. /**
  94479. * gets a boolean indicating if facetData is enabled
  94480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94481. */
  94482. readonly isFacetDataEnabled: boolean;
  94483. /** @hidden */
  94484. _updateNonUniformScalingState(value: boolean): boolean;
  94485. /**
  94486. * An event triggered when this mesh collides with another one
  94487. */
  94488. onCollideObservable: Observable<AbstractMesh>;
  94489. /** Set a function to call when this mesh collides with another one */
  94490. onCollide: () => void;
  94491. /**
  94492. * An event triggered when the collision's position changes
  94493. */
  94494. onCollisionPositionChangeObservable: Observable<Vector3>;
  94495. /** Set a function to call when the collision's position changes */
  94496. onCollisionPositionChange: () => void;
  94497. /**
  94498. * An event triggered when material is changed
  94499. */
  94500. onMaterialChangedObservable: Observable<AbstractMesh>;
  94501. /**
  94502. * Gets or sets the orientation for POV movement & rotation
  94503. */
  94504. definedFacingForward: boolean;
  94505. /** @hidden */
  94506. _occlusionQuery: Nullable<WebGLQuery>;
  94507. /** @hidden */
  94508. _renderingGroup: Nullable<RenderingGroup>;
  94509. /**
  94510. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94511. */
  94512. /**
  94513. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94514. */
  94515. visibility: number;
  94516. /** Gets or sets the alpha index used to sort transparent meshes
  94517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94518. */
  94519. alphaIndex: number;
  94520. /**
  94521. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94522. */
  94523. isVisible: boolean;
  94524. /**
  94525. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94526. */
  94527. isPickable: boolean;
  94528. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94529. showSubMeshesBoundingBox: boolean;
  94530. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94532. */
  94533. isBlocker: boolean;
  94534. /**
  94535. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94536. */
  94537. enablePointerMoveEvents: boolean;
  94538. /**
  94539. * Specifies the rendering group id for this mesh (0 by default)
  94540. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94541. */
  94542. renderingGroupId: number;
  94543. private _material;
  94544. /** Gets or sets current material */
  94545. material: Nullable<Material>;
  94546. /**
  94547. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94548. * @see http://doc.babylonjs.com/babylon101/shadows
  94549. */
  94550. receiveShadows: boolean;
  94551. /** Defines color to use when rendering outline */
  94552. outlineColor: Color3;
  94553. /** Define width to use when rendering outline */
  94554. outlineWidth: number;
  94555. /** Defines color to use when rendering overlay */
  94556. overlayColor: Color3;
  94557. /** Defines alpha to use when rendering overlay */
  94558. overlayAlpha: number;
  94559. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94560. hasVertexAlpha: boolean;
  94561. /** 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) */
  94562. useVertexColors: boolean;
  94563. /**
  94564. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94565. */
  94566. computeBonesUsingShaders: boolean;
  94567. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94568. numBoneInfluencers: number;
  94569. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94570. applyFog: boolean;
  94571. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94572. useOctreeForRenderingSelection: boolean;
  94573. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94574. useOctreeForPicking: boolean;
  94575. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94576. useOctreeForCollisions: boolean;
  94577. /**
  94578. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94579. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94580. */
  94581. layerMask: number;
  94582. /**
  94583. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94584. */
  94585. alwaysSelectAsActiveMesh: boolean;
  94586. /**
  94587. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94588. */
  94589. doNotSyncBoundingInfo: boolean;
  94590. /**
  94591. * Gets or sets the current action manager
  94592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94593. */
  94594. actionManager: Nullable<AbstractActionManager>;
  94595. private _meshCollisionData;
  94596. /**
  94597. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94599. */
  94600. ellipsoid: Vector3;
  94601. /**
  94602. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94604. */
  94605. ellipsoidOffset: Vector3;
  94606. /**
  94607. * Gets or sets a collision mask used to mask collisions (default is -1).
  94608. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94609. */
  94610. collisionMask: number;
  94611. /**
  94612. * Gets or sets the current collision group mask (-1 by default).
  94613. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94614. */
  94615. collisionGroup: number;
  94616. /**
  94617. * Defines edge width used when edgesRenderer is enabled
  94618. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94619. */
  94620. edgesWidth: number;
  94621. /**
  94622. * Defines edge color used when edgesRenderer is enabled
  94623. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94624. */
  94625. edgesColor: Color4;
  94626. /** @hidden */
  94627. _edgesRenderer: Nullable<IEdgesRenderer>;
  94628. /** @hidden */
  94629. _masterMesh: Nullable<AbstractMesh>;
  94630. /** @hidden */
  94631. _boundingInfo: Nullable<BoundingInfo>;
  94632. /** @hidden */
  94633. _renderId: number;
  94634. /**
  94635. * Gets or sets the list of subMeshes
  94636. * @see http://doc.babylonjs.com/how_to/multi_materials
  94637. */
  94638. subMeshes: SubMesh[];
  94639. /** @hidden */
  94640. _intersectionsInProgress: AbstractMesh[];
  94641. /** @hidden */
  94642. _unIndexed: boolean;
  94643. /** @hidden */
  94644. _lightSources: Light[];
  94645. /** Gets the list of lights affecting that mesh */
  94646. readonly lightSources: Light[];
  94647. /** @hidden */
  94648. readonly _positions: Nullable<Vector3[]>;
  94649. /** @hidden */
  94650. _waitingData: {
  94651. lods: Nullable<any>;
  94652. actions: Nullable<any>;
  94653. freezeWorldMatrix: Nullable<boolean>;
  94654. };
  94655. /** @hidden */
  94656. _bonesTransformMatrices: Nullable<Float32Array>;
  94657. /** @hidden */
  94658. _transformMatrixTexture: Nullable<RawTexture>;
  94659. /**
  94660. * Gets or sets a skeleton to apply skining transformations
  94661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94662. */
  94663. skeleton: Nullable<Skeleton>;
  94664. /**
  94665. * An event triggered when the mesh is rebuilt.
  94666. */
  94667. onRebuildObservable: Observable<AbstractMesh>;
  94668. /**
  94669. * Creates a new AbstractMesh
  94670. * @param name defines the name of the mesh
  94671. * @param scene defines the hosting scene
  94672. */
  94673. constructor(name: string, scene?: Nullable<Scene>);
  94674. /**
  94675. * Returns the string "AbstractMesh"
  94676. * @returns "AbstractMesh"
  94677. */
  94678. getClassName(): string;
  94679. /**
  94680. * Gets a string representation of the current mesh
  94681. * @param fullDetails defines a boolean indicating if full details must be included
  94682. * @returns a string representation of the current mesh
  94683. */
  94684. toString(fullDetails?: boolean): string;
  94685. /**
  94686. * @hidden
  94687. */
  94688. protected _getEffectiveParent(): Nullable<Node>;
  94689. /** @hidden */
  94690. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94691. /** @hidden */
  94692. _rebuild(): void;
  94693. /** @hidden */
  94694. _resyncLightSources(): void;
  94695. /** @hidden */
  94696. _resyncLighSource(light: Light): void;
  94697. /** @hidden */
  94698. _unBindEffect(): void;
  94699. /** @hidden */
  94700. _removeLightSource(light: Light, dispose: boolean): void;
  94701. private _markSubMeshesAsDirty;
  94702. /** @hidden */
  94703. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94704. /** @hidden */
  94705. _markSubMeshesAsAttributesDirty(): void;
  94706. /** @hidden */
  94707. _markSubMeshesAsMiscDirty(): void;
  94708. /**
  94709. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94710. */
  94711. scaling: Vector3;
  94712. /**
  94713. * Returns true if the mesh is blocked. Implemented by child classes
  94714. */
  94715. readonly isBlocked: boolean;
  94716. /**
  94717. * Returns the mesh itself by default. Implemented by child classes
  94718. * @param camera defines the camera to use to pick the right LOD level
  94719. * @returns the currentAbstractMesh
  94720. */
  94721. getLOD(camera: Camera): Nullable<AbstractMesh>;
  94722. /**
  94723. * Returns 0 by default. Implemented by child classes
  94724. * @returns an integer
  94725. */
  94726. getTotalVertices(): number;
  94727. /**
  94728. * Returns a positive integer : the total number of indices in this mesh geometry.
  94729. * @returns the numner of indices or zero if the mesh has no geometry.
  94730. */
  94731. getTotalIndices(): number;
  94732. /**
  94733. * Returns null by default. Implemented by child classes
  94734. * @returns null
  94735. */
  94736. getIndices(): Nullable<IndicesArray>;
  94737. /**
  94738. * Returns the array of the requested vertex data kind. Implemented by child classes
  94739. * @param kind defines the vertex data kind to use
  94740. * @returns null
  94741. */
  94742. getVerticesData(kind: string): Nullable<FloatArray>;
  94743. /**
  94744. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94745. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94746. * Note that a new underlying VertexBuffer object is created each call.
  94747. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94748. * @param kind defines vertex data kind:
  94749. * * VertexBuffer.PositionKind
  94750. * * VertexBuffer.UVKind
  94751. * * VertexBuffer.UV2Kind
  94752. * * VertexBuffer.UV3Kind
  94753. * * VertexBuffer.UV4Kind
  94754. * * VertexBuffer.UV5Kind
  94755. * * VertexBuffer.UV6Kind
  94756. * * VertexBuffer.ColorKind
  94757. * * VertexBuffer.MatricesIndicesKind
  94758. * * VertexBuffer.MatricesIndicesExtraKind
  94759. * * VertexBuffer.MatricesWeightsKind
  94760. * * VertexBuffer.MatricesWeightsExtraKind
  94761. * @param data defines the data source
  94762. * @param updatable defines if the data must be flagged as updatable (or static)
  94763. * @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
  94764. * @returns the current mesh
  94765. */
  94766. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94767. /**
  94768. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94769. * If the mesh has no geometry, it is simply returned as it is.
  94770. * @param kind defines vertex data kind:
  94771. * * VertexBuffer.PositionKind
  94772. * * VertexBuffer.UVKind
  94773. * * VertexBuffer.UV2Kind
  94774. * * VertexBuffer.UV3Kind
  94775. * * VertexBuffer.UV4Kind
  94776. * * VertexBuffer.UV5Kind
  94777. * * VertexBuffer.UV6Kind
  94778. * * VertexBuffer.ColorKind
  94779. * * VertexBuffer.MatricesIndicesKind
  94780. * * VertexBuffer.MatricesIndicesExtraKind
  94781. * * VertexBuffer.MatricesWeightsKind
  94782. * * VertexBuffer.MatricesWeightsExtraKind
  94783. * @param data defines the data source
  94784. * @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
  94785. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94786. * @returns the current mesh
  94787. */
  94788. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94789. /**
  94790. * Sets the mesh indices,
  94791. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94792. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94793. * @param totalVertices Defines the total number of vertices
  94794. * @returns the current mesh
  94795. */
  94796. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94797. /**
  94798. * Gets a boolean indicating if specific vertex data is present
  94799. * @param kind defines the vertex data kind to use
  94800. * @returns true is data kind is present
  94801. */
  94802. isVerticesDataPresent(kind: string): boolean;
  94803. /**
  94804. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94805. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94806. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94807. * @returns a BoundingInfo
  94808. */
  94809. getBoundingInfo(): BoundingInfo;
  94810. /**
  94811. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94812. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94813. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94814. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94815. * @returns the current mesh
  94816. */
  94817. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94818. /**
  94819. * Overwrite the current bounding info
  94820. * @param boundingInfo defines the new bounding info
  94821. * @returns the current mesh
  94822. */
  94823. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94824. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94825. readonly useBones: boolean;
  94826. /** @hidden */
  94827. _preActivate(): void;
  94828. /** @hidden */
  94829. _preActivateForIntermediateRendering(renderId: number): void;
  94830. /** @hidden */
  94831. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94832. /** @hidden */
  94833. _postActivate(): void;
  94834. /** @hidden */
  94835. _freeze(): void;
  94836. /** @hidden */
  94837. _unFreeze(): void;
  94838. /**
  94839. * Gets the current world matrix
  94840. * @returns a Matrix
  94841. */
  94842. getWorldMatrix(): Matrix;
  94843. /** @hidden */
  94844. _getWorldMatrixDeterminant(): number;
  94845. /**
  94846. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94847. */
  94848. readonly isAnInstance: boolean;
  94849. /**
  94850. * Gets a boolean indicating if this mesh has instances
  94851. */
  94852. readonly hasInstances: boolean;
  94853. /**
  94854. * Perform relative position change from the point of view of behind the front of the mesh.
  94855. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94856. * Supports definition of mesh facing forward or backward
  94857. * @param amountRight defines the distance on the right axis
  94858. * @param amountUp defines the distance on the up axis
  94859. * @param amountForward defines the distance on the forward axis
  94860. * @returns the current mesh
  94861. */
  94862. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94863. /**
  94864. * Calculate relative position change from the point of view of behind the front of the mesh.
  94865. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94866. * Supports definition of mesh facing forward or backward
  94867. * @param amountRight defines the distance on the right axis
  94868. * @param amountUp defines the distance on the up axis
  94869. * @param amountForward defines the distance on the forward axis
  94870. * @returns the new displacement vector
  94871. */
  94872. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94873. /**
  94874. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94875. * Supports definition of mesh facing forward or backward
  94876. * @param flipBack defines the flip
  94877. * @param twirlClockwise defines the twirl
  94878. * @param tiltRight defines the tilt
  94879. * @returns the current mesh
  94880. */
  94881. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94882. /**
  94883. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94884. * Supports definition of mesh facing forward or backward.
  94885. * @param flipBack defines the flip
  94886. * @param twirlClockwise defines the twirl
  94887. * @param tiltRight defines the tilt
  94888. * @returns the new rotation vector
  94889. */
  94890. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94891. /**
  94892. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94893. * This means the mesh underlying bounding box and sphere are recomputed.
  94894. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94895. * @returns the current mesh
  94896. */
  94897. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94898. /** @hidden */
  94899. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94900. /** @hidden */
  94901. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94902. /** @hidden */
  94903. _updateBoundingInfo(): AbstractMesh;
  94904. /** @hidden */
  94905. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94906. /** @hidden */
  94907. protected _afterComputeWorldMatrix(): void;
  94908. /** @hidden */
  94909. readonly _effectiveMesh: AbstractMesh;
  94910. /**
  94911. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94912. * A mesh is in the frustum if its bounding box intersects the frustum
  94913. * @param frustumPlanes defines the frustum to test
  94914. * @returns true if the mesh is in the frustum planes
  94915. */
  94916. isInFrustum(frustumPlanes: Plane[]): boolean;
  94917. /**
  94918. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94919. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94920. * @param frustumPlanes defines the frustum to test
  94921. * @returns true if the mesh is completely in the frustum planes
  94922. */
  94923. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94924. /**
  94925. * True if the mesh intersects another mesh or a SolidParticle object
  94926. * @param mesh defines a target mesh or SolidParticle to test
  94927. * @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)
  94928. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94929. * @returns true if there is an intersection
  94930. */
  94931. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94932. /**
  94933. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94934. * @param point defines the point to test
  94935. * @returns true if there is an intersection
  94936. */
  94937. intersectsPoint(point: Vector3): boolean;
  94938. /**
  94939. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94940. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94941. */
  94942. checkCollisions: boolean;
  94943. /**
  94944. * Gets Collider object used to compute collisions (not physics)
  94945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94946. */
  94947. readonly collider: Nullable<Collider>;
  94948. /**
  94949. * Move the mesh using collision engine
  94950. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94951. * @param displacement defines the requested displacement vector
  94952. * @returns the current mesh
  94953. */
  94954. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94955. private _onCollisionPositionChange;
  94956. /** @hidden */
  94957. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94958. /** @hidden */
  94959. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94960. /** @hidden */
  94961. _checkCollision(collider: Collider): AbstractMesh;
  94962. /** @hidden */
  94963. _generatePointsArray(): boolean;
  94964. /**
  94965. * Checks if the passed Ray intersects with the mesh
  94966. * @param ray defines the ray to use
  94967. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94968. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94969. * @returns the picking info
  94970. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94971. */
  94972. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94973. /**
  94974. * Clones the current mesh
  94975. * @param name defines the mesh name
  94976. * @param newParent defines the new mesh parent
  94977. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94978. * @returns the new mesh
  94979. */
  94980. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94981. /**
  94982. * Disposes all the submeshes of the current meshnp
  94983. * @returns the current mesh
  94984. */
  94985. releaseSubMeshes(): AbstractMesh;
  94986. /**
  94987. * Releases resources associated with this abstract mesh.
  94988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94990. */
  94991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94992. /**
  94993. * Adds the passed mesh as a child to the current mesh
  94994. * @param mesh defines the child mesh
  94995. * @returns the current mesh
  94996. */
  94997. addChild(mesh: AbstractMesh): AbstractMesh;
  94998. /**
  94999. * Removes the passed mesh from the current mesh children list
  95000. * @param mesh defines the child mesh
  95001. * @returns the current mesh
  95002. */
  95003. removeChild(mesh: AbstractMesh): AbstractMesh;
  95004. /** @hidden */
  95005. private _initFacetData;
  95006. /**
  95007. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95008. * This method can be called within the render loop.
  95009. * 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
  95010. * @returns the current mesh
  95011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95012. */
  95013. updateFacetData(): AbstractMesh;
  95014. /**
  95015. * Returns the facetLocalNormals array.
  95016. * The normals are expressed in the mesh local spac
  95017. * @returns an array of Vector3
  95018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95019. */
  95020. getFacetLocalNormals(): Vector3[];
  95021. /**
  95022. * Returns the facetLocalPositions array.
  95023. * The facet positions are expressed in the mesh local space
  95024. * @returns an array of Vector3
  95025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95026. */
  95027. getFacetLocalPositions(): Vector3[];
  95028. /**
  95029. * Returns the facetLocalPartioning array
  95030. * @returns an array of array of numbers
  95031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95032. */
  95033. getFacetLocalPartitioning(): number[][];
  95034. /**
  95035. * Returns the i-th facet position in the world system.
  95036. * This method allocates a new Vector3 per call
  95037. * @param i defines the facet index
  95038. * @returns a new Vector3
  95039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95040. */
  95041. getFacetPosition(i: number): Vector3;
  95042. /**
  95043. * Sets the reference Vector3 with the i-th facet position in the world system
  95044. * @param i defines the facet index
  95045. * @param ref defines the target vector
  95046. * @returns the current mesh
  95047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95048. */
  95049. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95050. /**
  95051. * Returns the i-th facet normal in the world system.
  95052. * This method allocates a new Vector3 per call
  95053. * @param i defines the facet index
  95054. * @returns a new Vector3
  95055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95056. */
  95057. getFacetNormal(i: number): Vector3;
  95058. /**
  95059. * Sets the reference Vector3 with the i-th facet normal in the world system
  95060. * @param i defines the facet index
  95061. * @param ref defines the target vector
  95062. * @returns the current mesh
  95063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95064. */
  95065. getFacetNormalToRef(i: number, ref: Vector3): this;
  95066. /**
  95067. * 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)
  95068. * @param x defines x coordinate
  95069. * @param y defines y coordinate
  95070. * @param z defines z coordinate
  95071. * @returns the array of facet indexes
  95072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95073. */
  95074. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95075. /**
  95076. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95077. * @param projected sets as the (x,y,z) world projection on the facet
  95078. * @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
  95079. * @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
  95080. * @param x defines x coordinate
  95081. * @param y defines y coordinate
  95082. * @param z defines z coordinate
  95083. * @returns the face index if found (or null instead)
  95084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95085. */
  95086. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95087. /**
  95088. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95089. * @param projected sets as the (x,y,z) local projection on the facet
  95090. * @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
  95091. * @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
  95092. * @param x defines x coordinate
  95093. * @param y defines y coordinate
  95094. * @param z defines z coordinate
  95095. * @returns the face index if found (or null instead)
  95096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95097. */
  95098. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95099. /**
  95100. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95101. * @returns the parameters
  95102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95103. */
  95104. getFacetDataParameters(): any;
  95105. /**
  95106. * Disables the feature FacetData and frees the related memory
  95107. * @returns the current mesh
  95108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95109. */
  95110. disableFacetData(): AbstractMesh;
  95111. /**
  95112. * Updates the AbstractMesh indices array
  95113. * @param indices defines the data source
  95114. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95115. * @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)
  95116. * @returns the current mesh
  95117. */
  95118. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95119. /**
  95120. * Creates new normals data for the mesh
  95121. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95122. * @returns the current mesh
  95123. */
  95124. createNormals(updatable: boolean): AbstractMesh;
  95125. /**
  95126. * Align the mesh with a normal
  95127. * @param normal defines the normal to use
  95128. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95129. * @returns the current mesh
  95130. */
  95131. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95132. /** @hidden */
  95133. _checkOcclusionQuery(): boolean;
  95134. /**
  95135. * Disables the mesh edge rendering mode
  95136. * @returns the currentAbstractMesh
  95137. */
  95138. disableEdgesRendering(): AbstractMesh;
  95139. /**
  95140. * Enables the edge rendering mode on the mesh.
  95141. * This mode makes the mesh edges visible
  95142. * @param epsilon defines the maximal distance between two angles to detect a face
  95143. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95144. * @returns the currentAbstractMesh
  95145. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95146. */
  95147. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95148. }
  95149. }
  95150. declare module BABYLON {
  95151. /**
  95152. * Interface used to define ActionEvent
  95153. */
  95154. export interface IActionEvent {
  95155. /** The mesh or sprite that triggered the action */
  95156. source: any;
  95157. /** The X mouse cursor position at the time of the event */
  95158. pointerX: number;
  95159. /** The Y mouse cursor position at the time of the event */
  95160. pointerY: number;
  95161. /** The mesh that is currently pointed at (can be null) */
  95162. meshUnderPointer: Nullable<AbstractMesh>;
  95163. /** the original (browser) event that triggered the ActionEvent */
  95164. sourceEvent?: any;
  95165. /** additional data for the event */
  95166. additionalData?: any;
  95167. }
  95168. /**
  95169. * ActionEvent is the event being sent when an action is triggered.
  95170. */
  95171. export class ActionEvent implements IActionEvent {
  95172. /** The mesh or sprite that triggered the action */
  95173. source: any;
  95174. /** The X mouse cursor position at the time of the event */
  95175. pointerX: number;
  95176. /** The Y mouse cursor position at the time of the event */
  95177. pointerY: number;
  95178. /** The mesh that is currently pointed at (can be null) */
  95179. meshUnderPointer: Nullable<AbstractMesh>;
  95180. /** the original (browser) event that triggered the ActionEvent */
  95181. sourceEvent?: any;
  95182. /** additional data for the event */
  95183. additionalData?: any;
  95184. /**
  95185. * Creates a new ActionEvent
  95186. * @param source The mesh or sprite that triggered the action
  95187. * @param pointerX The X mouse cursor position at the time of the event
  95188. * @param pointerY The Y mouse cursor position at the time of the event
  95189. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95190. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95191. * @param additionalData additional data for the event
  95192. */
  95193. constructor(
  95194. /** The mesh or sprite that triggered the action */
  95195. source: any,
  95196. /** The X mouse cursor position at the time of the event */
  95197. pointerX: number,
  95198. /** The Y mouse cursor position at the time of the event */
  95199. pointerY: number,
  95200. /** The mesh that is currently pointed at (can be null) */
  95201. meshUnderPointer: Nullable<AbstractMesh>,
  95202. /** the original (browser) event that triggered the ActionEvent */
  95203. sourceEvent?: any,
  95204. /** additional data for the event */
  95205. additionalData?: any);
  95206. /**
  95207. * Helper function to auto-create an ActionEvent from a source mesh.
  95208. * @param source The source mesh that triggered the event
  95209. * @param evt The original (browser) event
  95210. * @param additionalData additional data for the event
  95211. * @returns the new ActionEvent
  95212. */
  95213. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95214. /**
  95215. * Helper function to auto-create an ActionEvent from a source sprite
  95216. * @param source The source sprite that triggered the event
  95217. * @param scene Scene associated with the sprite
  95218. * @param evt The original (browser) event
  95219. * @param additionalData additional data for the event
  95220. * @returns the new ActionEvent
  95221. */
  95222. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95223. /**
  95224. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95225. * @param scene the scene where the event occurred
  95226. * @param evt The original (browser) event
  95227. * @returns the new ActionEvent
  95228. */
  95229. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95230. /**
  95231. * Helper function to auto-create an ActionEvent from a primitive
  95232. * @param prim defines the target primitive
  95233. * @param pointerPos defines the pointer position
  95234. * @param evt The original (browser) event
  95235. * @param additionalData additional data for the event
  95236. * @returns the new ActionEvent
  95237. */
  95238. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95239. }
  95240. }
  95241. declare module BABYLON {
  95242. /**
  95243. * Abstract class used to decouple action Manager from scene and meshes.
  95244. * Do not instantiate.
  95245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95246. */
  95247. export abstract class AbstractActionManager implements IDisposable {
  95248. /** Gets the list of active triggers */
  95249. static Triggers: {
  95250. [key: string]: number;
  95251. };
  95252. /** Gets the cursor to use when hovering items */
  95253. hoverCursor: string;
  95254. /** Gets the list of actions */
  95255. actions: IAction[];
  95256. /**
  95257. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95258. */
  95259. isRecursive: boolean;
  95260. /**
  95261. * Releases all associated resources
  95262. */
  95263. abstract dispose(): void;
  95264. /**
  95265. * Does this action manager has pointer triggers
  95266. */
  95267. abstract readonly hasPointerTriggers: boolean;
  95268. /**
  95269. * Does this action manager has pick triggers
  95270. */
  95271. abstract readonly hasPickTriggers: boolean;
  95272. /**
  95273. * Process a specific trigger
  95274. * @param trigger defines the trigger to process
  95275. * @param evt defines the event details to be processed
  95276. */
  95277. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95278. /**
  95279. * Does this action manager handles actions of any of the given triggers
  95280. * @param triggers defines the triggers to be tested
  95281. * @return a boolean indicating whether one (or more) of the triggers is handled
  95282. */
  95283. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95284. /**
  95285. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95286. * speed.
  95287. * @param triggerA defines the trigger to be tested
  95288. * @param triggerB defines the trigger to be tested
  95289. * @return a boolean indicating whether one (or more) of the triggers is handled
  95290. */
  95291. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95292. /**
  95293. * Does this action manager handles actions of a given trigger
  95294. * @param trigger defines the trigger to be tested
  95295. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95296. * @return whether the trigger is handled
  95297. */
  95298. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95299. /**
  95300. * Serialize this manager to a JSON object
  95301. * @param name defines the property name to store this manager
  95302. * @returns a JSON representation of this manager
  95303. */
  95304. abstract serialize(name: string): any;
  95305. /**
  95306. * Registers an action to this action manager
  95307. * @param action defines the action to be registered
  95308. * @return the action amended (prepared) after registration
  95309. */
  95310. abstract registerAction(action: IAction): Nullable<IAction>;
  95311. /**
  95312. * Unregisters an action to this action manager
  95313. * @param action defines the action to be unregistered
  95314. * @return a boolean indicating whether the action has been unregistered
  95315. */
  95316. abstract unregisterAction(action: IAction): Boolean;
  95317. /**
  95318. * Does exist one action manager with at least one trigger
  95319. **/
  95320. static readonly HasTriggers: boolean;
  95321. /**
  95322. * Does exist one action manager with at least one pick trigger
  95323. **/
  95324. static readonly HasPickTriggers: boolean;
  95325. /**
  95326. * Does exist one action manager that handles actions of a given trigger
  95327. * @param trigger defines the trigger to be tested
  95328. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95329. **/
  95330. static HasSpecificTrigger(trigger: number): boolean;
  95331. }
  95332. }
  95333. declare module BABYLON {
  95334. /**
  95335. * Defines how a node can be built from a string name.
  95336. */
  95337. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95338. /**
  95339. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95340. */
  95341. export class Node implements IBehaviorAware<Node> {
  95342. /** @hidden */
  95343. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95344. private static _NodeConstructors;
  95345. /**
  95346. * Add a new node constructor
  95347. * @param type defines the type name of the node to construct
  95348. * @param constructorFunc defines the constructor function
  95349. */
  95350. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95351. /**
  95352. * Returns a node constructor based on type name
  95353. * @param type defines the type name
  95354. * @param name defines the new node name
  95355. * @param scene defines the hosting scene
  95356. * @param options defines optional options to transmit to constructors
  95357. * @returns the new constructor or null
  95358. */
  95359. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95360. /**
  95361. * Gets or sets the name of the node
  95362. */
  95363. name: string;
  95364. /**
  95365. * Gets or sets the id of the node
  95366. */
  95367. id: string;
  95368. /**
  95369. * Gets or sets the unique id of the node
  95370. */
  95371. uniqueId: number;
  95372. /**
  95373. * Gets or sets a string used to store user defined state for the node
  95374. */
  95375. state: string;
  95376. /**
  95377. * Gets or sets an object used to store user defined information for the node
  95378. */
  95379. metadata: any;
  95380. /**
  95381. * For internal use only. Please do not use.
  95382. */
  95383. reservedDataStore: any;
  95384. /**
  95385. * List of inspectable custom properties (used by the Inspector)
  95386. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95387. */
  95388. inspectableCustomProperties: IInspectable[];
  95389. private _doNotSerialize;
  95390. /**
  95391. * Gets or sets a boolean used to define if the node must be serialized
  95392. */
  95393. doNotSerialize: boolean;
  95394. /** @hidden */
  95395. _isDisposed: boolean;
  95396. /**
  95397. * Gets a list of Animations associated with the node
  95398. */
  95399. animations: Animation[];
  95400. protected _ranges: {
  95401. [name: string]: Nullable<AnimationRange>;
  95402. };
  95403. /**
  95404. * Callback raised when the node is ready to be used
  95405. */
  95406. onReady: Nullable<(node: Node) => void>;
  95407. private _isEnabled;
  95408. private _isParentEnabled;
  95409. private _isReady;
  95410. /** @hidden */
  95411. _currentRenderId: number;
  95412. private _parentUpdateId;
  95413. /** @hidden */
  95414. _childUpdateId: number;
  95415. /** @hidden */
  95416. _waitingParentId: Nullable<string>;
  95417. /** @hidden */
  95418. _scene: Scene;
  95419. /** @hidden */
  95420. _cache: any;
  95421. private _parentNode;
  95422. private _children;
  95423. /** @hidden */
  95424. _worldMatrix: Matrix;
  95425. /** @hidden */
  95426. _worldMatrixDeterminant: number;
  95427. /** @hidden */
  95428. _worldMatrixDeterminantIsDirty: boolean;
  95429. /** @hidden */
  95430. private _sceneRootNodesIndex;
  95431. /**
  95432. * Gets a boolean indicating if the node has been disposed
  95433. * @returns true if the node was disposed
  95434. */
  95435. isDisposed(): boolean;
  95436. /**
  95437. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95438. * @see https://doc.babylonjs.com/how_to/parenting
  95439. */
  95440. parent: Nullable<Node>;
  95441. /** @hidden */
  95442. _addToSceneRootNodes(): void;
  95443. /** @hidden */
  95444. _removeFromSceneRootNodes(): void;
  95445. private _animationPropertiesOverride;
  95446. /**
  95447. * Gets or sets the animation properties override
  95448. */
  95449. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95450. /**
  95451. * Gets a string idenfifying the name of the class
  95452. * @returns "Node" string
  95453. */
  95454. getClassName(): string;
  95455. /** @hidden */
  95456. readonly _isNode: boolean;
  95457. /**
  95458. * An event triggered when the mesh is disposed
  95459. */
  95460. onDisposeObservable: Observable<Node>;
  95461. private _onDisposeObserver;
  95462. /**
  95463. * Sets a callback that will be raised when the node will be disposed
  95464. */
  95465. onDispose: () => void;
  95466. /**
  95467. * Creates a new Node
  95468. * @param name the name and id to be given to this node
  95469. * @param scene the scene this node will be added to
  95470. */
  95471. constructor(name: string, scene?: Nullable<Scene>);
  95472. /**
  95473. * Gets the scene of the node
  95474. * @returns a scene
  95475. */
  95476. getScene(): Scene;
  95477. /**
  95478. * Gets the engine of the node
  95479. * @returns a Engine
  95480. */
  95481. getEngine(): Engine;
  95482. private _behaviors;
  95483. /**
  95484. * Attach a behavior to the node
  95485. * @see http://doc.babylonjs.com/features/behaviour
  95486. * @param behavior defines the behavior to attach
  95487. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95488. * @returns the current Node
  95489. */
  95490. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95491. /**
  95492. * Remove an attached behavior
  95493. * @see http://doc.babylonjs.com/features/behaviour
  95494. * @param behavior defines the behavior to attach
  95495. * @returns the current Node
  95496. */
  95497. removeBehavior(behavior: Behavior<Node>): Node;
  95498. /**
  95499. * Gets the list of attached behaviors
  95500. * @see http://doc.babylonjs.com/features/behaviour
  95501. */
  95502. readonly behaviors: Behavior<Node>[];
  95503. /**
  95504. * Gets an attached behavior by name
  95505. * @param name defines the name of the behavior to look for
  95506. * @see http://doc.babylonjs.com/features/behaviour
  95507. * @returns null if behavior was not found else the requested behavior
  95508. */
  95509. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95510. /**
  95511. * Returns the latest update of the World matrix
  95512. * @returns a Matrix
  95513. */
  95514. getWorldMatrix(): Matrix;
  95515. /** @hidden */
  95516. _getWorldMatrixDeterminant(): number;
  95517. /**
  95518. * Returns directly the latest state of the mesh World matrix.
  95519. * A Matrix is returned.
  95520. */
  95521. readonly worldMatrixFromCache: Matrix;
  95522. /** @hidden */
  95523. _initCache(): void;
  95524. /** @hidden */
  95525. updateCache(force?: boolean): void;
  95526. /** @hidden */
  95527. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95528. /** @hidden */
  95529. _updateCache(ignoreParentClass?: boolean): void;
  95530. /** @hidden */
  95531. _isSynchronized(): boolean;
  95532. /** @hidden */
  95533. _markSyncedWithParent(): void;
  95534. /** @hidden */
  95535. isSynchronizedWithParent(): boolean;
  95536. /** @hidden */
  95537. isSynchronized(): boolean;
  95538. /**
  95539. * Is this node ready to be used/rendered
  95540. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95541. * @return true if the node is ready
  95542. */
  95543. isReady(completeCheck?: boolean): boolean;
  95544. /**
  95545. * Is this node enabled?
  95546. * 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
  95547. * @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
  95548. * @return whether this node (and its parent) is enabled
  95549. */
  95550. isEnabled(checkAncestors?: boolean): boolean;
  95551. /** @hidden */
  95552. protected _syncParentEnabledState(): void;
  95553. /**
  95554. * Set the enabled state of this node
  95555. * @param value defines the new enabled state
  95556. */
  95557. setEnabled(value: boolean): void;
  95558. /**
  95559. * Is this node a descendant of the given node?
  95560. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95561. * @param ancestor defines the parent node to inspect
  95562. * @returns a boolean indicating if this node is a descendant of the given node
  95563. */
  95564. isDescendantOf(ancestor: Node): boolean;
  95565. /** @hidden */
  95566. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95567. /**
  95568. * Will return all nodes that have this node as ascendant
  95569. * @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
  95570. * @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
  95571. * @return all children nodes of all types
  95572. */
  95573. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95574. /**
  95575. * Get all child-meshes of this node
  95576. * @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)
  95577. * @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
  95578. * @returns an array of AbstractMesh
  95579. */
  95580. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95581. /**
  95582. * Get all direct children of this node
  95583. * @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
  95584. * @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)
  95585. * @returns an array of Node
  95586. */
  95587. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95588. /** @hidden */
  95589. _setReady(state: boolean): void;
  95590. /**
  95591. * Get an animation by name
  95592. * @param name defines the name of the animation to look for
  95593. * @returns null if not found else the requested animation
  95594. */
  95595. getAnimationByName(name: string): Nullable<Animation>;
  95596. /**
  95597. * Creates an animation range for this node
  95598. * @param name defines the name of the range
  95599. * @param from defines the starting key
  95600. * @param to defines the end key
  95601. */
  95602. createAnimationRange(name: string, from: number, to: number): void;
  95603. /**
  95604. * Delete a specific animation range
  95605. * @param name defines the name of the range to delete
  95606. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95607. */
  95608. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95609. /**
  95610. * Get an animation range by name
  95611. * @param name defines the name of the animation range to look for
  95612. * @returns null if not found else the requested animation range
  95613. */
  95614. getAnimationRange(name: string): Nullable<AnimationRange>;
  95615. /**
  95616. * Gets the list of all animation ranges defined on this node
  95617. * @returns an array
  95618. */
  95619. getAnimationRanges(): Nullable<AnimationRange>[];
  95620. /**
  95621. * Will start the animation sequence
  95622. * @param name defines the range frames for animation sequence
  95623. * @param loop defines if the animation should loop (false by default)
  95624. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95625. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95626. * @returns the object created for this animation. If range does not exist, it will return null
  95627. */
  95628. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95629. /**
  95630. * Serialize animation ranges into a JSON compatible object
  95631. * @returns serialization object
  95632. */
  95633. serializeAnimationRanges(): any;
  95634. /**
  95635. * Computes the world matrix of the node
  95636. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95637. * @returns the world matrix
  95638. */
  95639. computeWorldMatrix(force?: boolean): Matrix;
  95640. /**
  95641. * Releases resources associated with this node.
  95642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95644. */
  95645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95646. /**
  95647. * Parse animation range data from a serialization object and store them into a given node
  95648. * @param node defines where to store the animation ranges
  95649. * @param parsedNode defines the serialization object to read data from
  95650. * @param scene defines the hosting scene
  95651. */
  95652. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95653. /**
  95654. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95655. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95656. * @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
  95657. * @returns the new bounding vectors
  95658. */
  95659. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95660. min: Vector3;
  95661. max: Vector3;
  95662. };
  95663. }
  95664. }
  95665. declare module BABYLON {
  95666. /**
  95667. * @hidden
  95668. */
  95669. export class _IAnimationState {
  95670. key: number;
  95671. repeatCount: number;
  95672. workValue?: any;
  95673. loopMode?: number;
  95674. offsetValue?: any;
  95675. highLimitValue?: any;
  95676. }
  95677. /**
  95678. * Class used to store any kind of animation
  95679. */
  95680. export class Animation {
  95681. /**Name of the animation */
  95682. name: string;
  95683. /**Property to animate */
  95684. targetProperty: string;
  95685. /**The frames per second of the animation */
  95686. framePerSecond: number;
  95687. /**The data type of the animation */
  95688. dataType: number;
  95689. /**The loop mode of the animation */
  95690. loopMode?: number | undefined;
  95691. /**Specifies if blending should be enabled */
  95692. enableBlending?: boolean | undefined;
  95693. /**
  95694. * Use matrix interpolation instead of using direct key value when animating matrices
  95695. */
  95696. static AllowMatricesInterpolation: boolean;
  95697. /**
  95698. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95699. */
  95700. static AllowMatrixDecomposeForInterpolation: boolean;
  95701. /**
  95702. * Stores the key frames of the animation
  95703. */
  95704. private _keys;
  95705. /**
  95706. * Stores the easing function of the animation
  95707. */
  95708. private _easingFunction;
  95709. /**
  95710. * @hidden Internal use only
  95711. */
  95712. _runtimeAnimations: RuntimeAnimation[];
  95713. /**
  95714. * The set of event that will be linked to this animation
  95715. */
  95716. private _events;
  95717. /**
  95718. * Stores an array of target property paths
  95719. */
  95720. targetPropertyPath: string[];
  95721. /**
  95722. * Stores the blending speed of the animation
  95723. */
  95724. blendingSpeed: number;
  95725. /**
  95726. * Stores the animation ranges for the animation
  95727. */
  95728. private _ranges;
  95729. /**
  95730. * @hidden Internal use
  95731. */
  95732. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  95733. /**
  95734. * Sets up an animation
  95735. * @param property The property to animate
  95736. * @param animationType The animation type to apply
  95737. * @param framePerSecond The frames per second of the animation
  95738. * @param easingFunction The easing function used in the animation
  95739. * @returns The created animation
  95740. */
  95741. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  95742. /**
  95743. * Create and start an animation on a node
  95744. * @param name defines the name of the global animation that will be run on all nodes
  95745. * @param node defines the root node where the animation will take place
  95746. * @param targetProperty defines property to animate
  95747. * @param framePerSecond defines the number of frame per second yo use
  95748. * @param totalFrame defines the number of frames in total
  95749. * @param from defines the initial value
  95750. * @param to defines the final value
  95751. * @param loopMode defines which loop mode you want to use (off by default)
  95752. * @param easingFunction defines the easing function to use (linear by default)
  95753. * @param onAnimationEnd defines the callback to call when animation end
  95754. * @returns the animatable created for this animation
  95755. */
  95756. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95757. /**
  95758. * Create and start an animation on a node and its descendants
  95759. * @param name defines the name of the global animation that will be run on all nodes
  95760. * @param node defines the root node where the animation will take place
  95761. * @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
  95762. * @param targetProperty defines property to animate
  95763. * @param framePerSecond defines the number of frame per second to use
  95764. * @param totalFrame defines the number of frames in total
  95765. * @param from defines the initial value
  95766. * @param to defines the final value
  95767. * @param loopMode defines which loop mode you want to use (off by default)
  95768. * @param easingFunction defines the easing function to use (linear by default)
  95769. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95770. * @returns the list of animatables created for all nodes
  95771. * @example https://www.babylonjs-playground.com/#MH0VLI
  95772. */
  95773. 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[]>;
  95774. /**
  95775. * Creates a new animation, merges it with the existing animations and starts it
  95776. * @param name Name of the animation
  95777. * @param node Node which contains the scene that begins the animations
  95778. * @param targetProperty Specifies which property to animate
  95779. * @param framePerSecond The frames per second of the animation
  95780. * @param totalFrame The total number of frames
  95781. * @param from The frame at the beginning of the animation
  95782. * @param to The frame at the end of the animation
  95783. * @param loopMode Specifies the loop mode of the animation
  95784. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95785. * @param onAnimationEnd Callback to run once the animation is complete
  95786. * @returns Nullable animation
  95787. */
  95788. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95789. /**
  95790. * Transition property of an host to the target Value
  95791. * @param property The property to transition
  95792. * @param targetValue The target Value of the property
  95793. * @param host The object where the property to animate belongs
  95794. * @param scene Scene used to run the animation
  95795. * @param frameRate Framerate (in frame/s) to use
  95796. * @param transition The transition type we want to use
  95797. * @param duration The duration of the animation, in milliseconds
  95798. * @param onAnimationEnd Callback trigger at the end of the animation
  95799. * @returns Nullable animation
  95800. */
  95801. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95802. /**
  95803. * Return the array of runtime animations currently using this animation
  95804. */
  95805. readonly runtimeAnimations: RuntimeAnimation[];
  95806. /**
  95807. * Specifies if any of the runtime animations are currently running
  95808. */
  95809. readonly hasRunningRuntimeAnimations: boolean;
  95810. /**
  95811. * Initializes the animation
  95812. * @param name Name of the animation
  95813. * @param targetProperty Property to animate
  95814. * @param framePerSecond The frames per second of the animation
  95815. * @param dataType The data type of the animation
  95816. * @param loopMode The loop mode of the animation
  95817. * @param enableBlending Specifies if blending should be enabled
  95818. */
  95819. constructor(
  95820. /**Name of the animation */
  95821. name: string,
  95822. /**Property to animate */
  95823. targetProperty: string,
  95824. /**The frames per second of the animation */
  95825. framePerSecond: number,
  95826. /**The data type of the animation */
  95827. dataType: number,
  95828. /**The loop mode of the animation */
  95829. loopMode?: number | undefined,
  95830. /**Specifies if blending should be enabled */
  95831. enableBlending?: boolean | undefined);
  95832. /**
  95833. * Converts the animation to a string
  95834. * @param fullDetails support for multiple levels of logging within scene loading
  95835. * @returns String form of the animation
  95836. */
  95837. toString(fullDetails?: boolean): string;
  95838. /**
  95839. * Add an event to this animation
  95840. * @param event Event to add
  95841. */
  95842. addEvent(event: AnimationEvent): void;
  95843. /**
  95844. * Remove all events found at the given frame
  95845. * @param frame The frame to remove events from
  95846. */
  95847. removeEvents(frame: number): void;
  95848. /**
  95849. * Retrieves all the events from the animation
  95850. * @returns Events from the animation
  95851. */
  95852. getEvents(): AnimationEvent[];
  95853. /**
  95854. * Creates an animation range
  95855. * @param name Name of the animation range
  95856. * @param from Starting frame of the animation range
  95857. * @param to Ending frame of the animation
  95858. */
  95859. createRange(name: string, from: number, to: number): void;
  95860. /**
  95861. * Deletes an animation range by name
  95862. * @param name Name of the animation range to delete
  95863. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95864. */
  95865. deleteRange(name: string, deleteFrames?: boolean): void;
  95866. /**
  95867. * Gets the animation range by name, or null if not defined
  95868. * @param name Name of the animation range
  95869. * @returns Nullable animation range
  95870. */
  95871. getRange(name: string): Nullable<AnimationRange>;
  95872. /**
  95873. * Gets the key frames from the animation
  95874. * @returns The key frames of the animation
  95875. */
  95876. getKeys(): Array<IAnimationKey>;
  95877. /**
  95878. * Gets the highest frame rate of the animation
  95879. * @returns Highest frame rate of the animation
  95880. */
  95881. getHighestFrame(): number;
  95882. /**
  95883. * Gets the easing function of the animation
  95884. * @returns Easing function of the animation
  95885. */
  95886. getEasingFunction(): IEasingFunction;
  95887. /**
  95888. * Sets the easing function of the animation
  95889. * @param easingFunction A custom mathematical formula for animation
  95890. */
  95891. setEasingFunction(easingFunction: EasingFunction): void;
  95892. /**
  95893. * Interpolates a scalar linearly
  95894. * @param startValue Start value of the animation curve
  95895. * @param endValue End value of the animation curve
  95896. * @param gradient Scalar amount to interpolate
  95897. * @returns Interpolated scalar value
  95898. */
  95899. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95900. /**
  95901. * Interpolates a scalar cubically
  95902. * @param startValue Start value of the animation curve
  95903. * @param outTangent End tangent of the animation
  95904. * @param endValue End value of the animation curve
  95905. * @param inTangent Start tangent of the animation curve
  95906. * @param gradient Scalar amount to interpolate
  95907. * @returns Interpolated scalar value
  95908. */
  95909. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95910. /**
  95911. * Interpolates a quaternion using a spherical linear interpolation
  95912. * @param startValue Start value of the animation curve
  95913. * @param endValue End value of the animation curve
  95914. * @param gradient Scalar amount to interpolate
  95915. * @returns Interpolated quaternion value
  95916. */
  95917. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95918. /**
  95919. * Interpolates a quaternion cubically
  95920. * @param startValue Start value of the animation curve
  95921. * @param outTangent End tangent of the animation curve
  95922. * @param endValue End value of the animation curve
  95923. * @param inTangent Start tangent of the animation curve
  95924. * @param gradient Scalar amount to interpolate
  95925. * @returns Interpolated quaternion value
  95926. */
  95927. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95928. /**
  95929. * Interpolates a Vector3 linearl
  95930. * @param startValue Start value of the animation curve
  95931. * @param endValue End value of the animation curve
  95932. * @param gradient Scalar amount to interpolate
  95933. * @returns Interpolated scalar value
  95934. */
  95935. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95936. /**
  95937. * Interpolates a Vector3 cubically
  95938. * @param startValue Start value of the animation curve
  95939. * @param outTangent End tangent of the animation
  95940. * @param endValue End value of the animation curve
  95941. * @param inTangent Start tangent of the animation curve
  95942. * @param gradient Scalar amount to interpolate
  95943. * @returns InterpolatedVector3 value
  95944. */
  95945. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95946. /**
  95947. * Interpolates a Vector2 linearly
  95948. * @param startValue Start value of the animation curve
  95949. * @param endValue End value of the animation curve
  95950. * @param gradient Scalar amount to interpolate
  95951. * @returns Interpolated Vector2 value
  95952. */
  95953. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95954. /**
  95955. * Interpolates a Vector2 cubically
  95956. * @param startValue Start value of the animation curve
  95957. * @param outTangent End tangent of the animation
  95958. * @param endValue End value of the animation curve
  95959. * @param inTangent Start tangent of the animation curve
  95960. * @param gradient Scalar amount to interpolate
  95961. * @returns Interpolated Vector2 value
  95962. */
  95963. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95964. /**
  95965. * Interpolates a size linearly
  95966. * @param startValue Start value of the animation curve
  95967. * @param endValue End value of the animation curve
  95968. * @param gradient Scalar amount to interpolate
  95969. * @returns Interpolated Size value
  95970. */
  95971. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95972. /**
  95973. * Interpolates a Color3 linearly
  95974. * @param startValue Start value of the animation curve
  95975. * @param endValue End value of the animation curve
  95976. * @param gradient Scalar amount to interpolate
  95977. * @returns Interpolated Color3 value
  95978. */
  95979. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95980. /**
  95981. * Interpolates a Color4 linearly
  95982. * @param startValue Start value of the animation curve
  95983. * @param endValue End value of the animation curve
  95984. * @param gradient Scalar amount to interpolate
  95985. * @returns Interpolated Color3 value
  95986. */
  95987. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95988. /**
  95989. * @hidden Internal use only
  95990. */
  95991. _getKeyValue(value: any): any;
  95992. /**
  95993. * @hidden Internal use only
  95994. */
  95995. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95996. /**
  95997. * Defines the function to use to interpolate matrices
  95998. * @param startValue defines the start matrix
  95999. * @param endValue defines the end matrix
  96000. * @param gradient defines the gradient between both matrices
  96001. * @param result defines an optional target matrix where to store the interpolation
  96002. * @returns the interpolated matrix
  96003. */
  96004. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96005. /**
  96006. * Makes a copy of the animation
  96007. * @returns Cloned animation
  96008. */
  96009. clone(): Animation;
  96010. /**
  96011. * Sets the key frames of the animation
  96012. * @param values The animation key frames to set
  96013. */
  96014. setKeys(values: Array<IAnimationKey>): void;
  96015. /**
  96016. * Serializes the animation to an object
  96017. * @returns Serialized object
  96018. */
  96019. serialize(): any;
  96020. /**
  96021. * Float animation type
  96022. */
  96023. static readonly ANIMATIONTYPE_FLOAT: number;
  96024. /**
  96025. * Vector3 animation type
  96026. */
  96027. static readonly ANIMATIONTYPE_VECTOR3: number;
  96028. /**
  96029. * Quaternion animation type
  96030. */
  96031. static readonly ANIMATIONTYPE_QUATERNION: number;
  96032. /**
  96033. * Matrix animation type
  96034. */
  96035. static readonly ANIMATIONTYPE_MATRIX: number;
  96036. /**
  96037. * Color3 animation type
  96038. */
  96039. static readonly ANIMATIONTYPE_COLOR3: number;
  96040. /**
  96041. * Color3 animation type
  96042. */
  96043. static readonly ANIMATIONTYPE_COLOR4: number;
  96044. /**
  96045. * Vector2 animation type
  96046. */
  96047. static readonly ANIMATIONTYPE_VECTOR2: number;
  96048. /**
  96049. * Size animation type
  96050. */
  96051. static readonly ANIMATIONTYPE_SIZE: number;
  96052. /**
  96053. * Relative Loop Mode
  96054. */
  96055. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96056. /**
  96057. * Cycle Loop Mode
  96058. */
  96059. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96060. /**
  96061. * Constant Loop Mode
  96062. */
  96063. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96064. /** @hidden */
  96065. static _UniversalLerp(left: any, right: any, amount: number): any;
  96066. /**
  96067. * Parses an animation object and creates an animation
  96068. * @param parsedAnimation Parsed animation object
  96069. * @returns Animation object
  96070. */
  96071. static Parse(parsedAnimation: any): Animation;
  96072. /**
  96073. * Appends the serialized animations from the source animations
  96074. * @param source Source containing the animations
  96075. * @param destination Target to store the animations
  96076. */
  96077. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96078. }
  96079. }
  96080. declare module BABYLON {
  96081. /**
  96082. * Interface containing an array of animations
  96083. */
  96084. export interface IAnimatable {
  96085. /**
  96086. * Array of animations
  96087. */
  96088. animations: Nullable<Array<Animation>>;
  96089. }
  96090. }
  96091. declare module BABYLON {
  96092. /**
  96093. * This represents all the required information to add a fresnel effect on a material:
  96094. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96095. */
  96096. export class FresnelParameters {
  96097. private _isEnabled;
  96098. /**
  96099. * Define if the fresnel effect is enable or not.
  96100. */
  96101. isEnabled: boolean;
  96102. /**
  96103. * Define the color used on edges (grazing angle)
  96104. */
  96105. leftColor: Color3;
  96106. /**
  96107. * Define the color used on center
  96108. */
  96109. rightColor: Color3;
  96110. /**
  96111. * Define bias applied to computed fresnel term
  96112. */
  96113. bias: number;
  96114. /**
  96115. * Defined the power exponent applied to fresnel term
  96116. */
  96117. power: number;
  96118. /**
  96119. * Clones the current fresnel and its valuues
  96120. * @returns a clone fresnel configuration
  96121. */
  96122. clone(): FresnelParameters;
  96123. /**
  96124. * Serializes the current fresnel parameters to a JSON representation.
  96125. * @return the JSON serialization
  96126. */
  96127. serialize(): any;
  96128. /**
  96129. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96130. * @param parsedFresnelParameters Define the JSON representation
  96131. * @returns the parsed parameters
  96132. */
  96133. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96134. }
  96135. }
  96136. declare module BABYLON {
  96137. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96138. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96139. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96140. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96141. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96142. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96143. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96144. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96145. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96146. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96147. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96148. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96149. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96150. /**
  96151. * Decorator used to define property that can be serialized as reference to a camera
  96152. * @param sourceName defines the name of the property to decorate
  96153. */
  96154. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96155. /**
  96156. * Class used to help serialization objects
  96157. */
  96158. export class SerializationHelper {
  96159. /** @hidden */
  96160. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96161. /** @hidden */
  96162. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96163. /** @hidden */
  96164. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96165. /** @hidden */
  96166. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96167. /**
  96168. * Appends the serialized animations from the source animations
  96169. * @param source Source containing the animations
  96170. * @param destination Target to store the animations
  96171. */
  96172. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96173. /**
  96174. * Static function used to serialized a specific entity
  96175. * @param entity defines the entity to serialize
  96176. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96177. * @returns a JSON compatible object representing the serialization of the entity
  96178. */
  96179. static Serialize<T>(entity: T, serializationObject?: any): any;
  96180. /**
  96181. * Creates a new entity from a serialization data object
  96182. * @param creationFunction defines a function used to instanciated the new entity
  96183. * @param source defines the source serialization data
  96184. * @param scene defines the hosting scene
  96185. * @param rootUrl defines the root url for resources
  96186. * @returns a new entity
  96187. */
  96188. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96189. /**
  96190. * Clones an object
  96191. * @param creationFunction defines the function used to instanciate the new object
  96192. * @param source defines the source object
  96193. * @returns the cloned object
  96194. */
  96195. static Clone<T>(creationFunction: () => T, source: T): T;
  96196. /**
  96197. * Instanciates a new object based on a source one (some data will be shared between both object)
  96198. * @param creationFunction defines the function used to instanciate the new object
  96199. * @param source defines the source object
  96200. * @returns the new object
  96201. */
  96202. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96203. }
  96204. }
  96205. declare module BABYLON {
  96206. /**
  96207. * Class used to manipulate GUIDs
  96208. */
  96209. export class GUID {
  96210. /**
  96211. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96212. * Be aware Math.random() could cause collisions, but:
  96213. * "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"
  96214. * @returns a pseudo random id
  96215. */
  96216. static RandomId(): string;
  96217. }
  96218. }
  96219. declare module BABYLON {
  96220. /**
  96221. * Base class of all the textures in babylon.
  96222. * It groups all the common properties the materials, post process, lights... might need
  96223. * in order to make a correct use of the texture.
  96224. */
  96225. export class BaseTexture implements IAnimatable {
  96226. /**
  96227. * Default anisotropic filtering level for the application.
  96228. * It is set to 4 as a good tradeoff between perf and quality.
  96229. */
  96230. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96231. /**
  96232. * Gets or sets the unique id of the texture
  96233. */
  96234. uniqueId: number;
  96235. /**
  96236. * Define the name of the texture.
  96237. */
  96238. name: string;
  96239. /**
  96240. * Gets or sets an object used to store user defined information.
  96241. */
  96242. metadata: any;
  96243. /**
  96244. * For internal use only. Please do not use.
  96245. */
  96246. reservedDataStore: any;
  96247. private _hasAlpha;
  96248. /**
  96249. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96250. */
  96251. hasAlpha: boolean;
  96252. /**
  96253. * Defines if the alpha value should be determined via the rgb values.
  96254. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96255. */
  96256. getAlphaFromRGB: boolean;
  96257. /**
  96258. * Intensity or strength of the texture.
  96259. * It is commonly used by materials to fine tune the intensity of the texture
  96260. */
  96261. level: number;
  96262. /**
  96263. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96264. * This is part of the texture as textures usually maps to one uv set.
  96265. */
  96266. coordinatesIndex: number;
  96267. private _coordinatesMode;
  96268. /**
  96269. * How a texture is mapped.
  96270. *
  96271. * | Value | Type | Description |
  96272. * | ----- | ----------------------------------- | ----------- |
  96273. * | 0 | EXPLICIT_MODE | |
  96274. * | 1 | SPHERICAL_MODE | |
  96275. * | 2 | PLANAR_MODE | |
  96276. * | 3 | CUBIC_MODE | |
  96277. * | 4 | PROJECTION_MODE | |
  96278. * | 5 | SKYBOX_MODE | |
  96279. * | 6 | INVCUBIC_MODE | |
  96280. * | 7 | EQUIRECTANGULAR_MODE | |
  96281. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96282. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96283. */
  96284. coordinatesMode: number;
  96285. /**
  96286. * | Value | Type | Description |
  96287. * | ----- | ------------------ | ----------- |
  96288. * | 0 | CLAMP_ADDRESSMODE | |
  96289. * | 1 | WRAP_ADDRESSMODE | |
  96290. * | 2 | MIRROR_ADDRESSMODE | |
  96291. */
  96292. wrapU: number;
  96293. /**
  96294. * | Value | Type | Description |
  96295. * | ----- | ------------------ | ----------- |
  96296. * | 0 | CLAMP_ADDRESSMODE | |
  96297. * | 1 | WRAP_ADDRESSMODE | |
  96298. * | 2 | MIRROR_ADDRESSMODE | |
  96299. */
  96300. wrapV: number;
  96301. /**
  96302. * | Value | Type | Description |
  96303. * | ----- | ------------------ | ----------- |
  96304. * | 0 | CLAMP_ADDRESSMODE | |
  96305. * | 1 | WRAP_ADDRESSMODE | |
  96306. * | 2 | MIRROR_ADDRESSMODE | |
  96307. */
  96308. wrapR: number;
  96309. /**
  96310. * With compliant hardware and browser (supporting anisotropic filtering)
  96311. * this defines the level of anisotropic filtering in the texture.
  96312. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96313. */
  96314. anisotropicFilteringLevel: number;
  96315. /**
  96316. * Define if the texture is a cube texture or if false a 2d texture.
  96317. */
  96318. isCube: boolean;
  96319. /**
  96320. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96321. */
  96322. is3D: boolean;
  96323. /**
  96324. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96325. */
  96326. is2DArray: boolean;
  96327. /**
  96328. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96329. * HDR texture are usually stored in linear space.
  96330. * This only impacts the PBR and Background materials
  96331. */
  96332. gammaSpace: boolean;
  96333. /**
  96334. * Gets or sets whether or not the texture contains RGBD data.
  96335. */
  96336. isRGBD: boolean;
  96337. /**
  96338. * Is Z inverted in the texture (useful in a cube texture).
  96339. */
  96340. invertZ: boolean;
  96341. /**
  96342. * Are mip maps generated for this texture or not.
  96343. */
  96344. readonly noMipmap: boolean;
  96345. /**
  96346. * @hidden
  96347. */
  96348. lodLevelInAlpha: boolean;
  96349. /**
  96350. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96351. */
  96352. lodGenerationOffset: number;
  96353. /**
  96354. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96355. */
  96356. lodGenerationScale: number;
  96357. /**
  96358. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96359. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96360. * average roughness values.
  96361. */
  96362. linearSpecularLOD: boolean;
  96363. /**
  96364. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96365. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96366. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96367. */
  96368. irradianceTexture: Nullable<BaseTexture>;
  96369. /**
  96370. * Define if the texture is a render target.
  96371. */
  96372. isRenderTarget: boolean;
  96373. /**
  96374. * Define the unique id of the texture in the scene.
  96375. */
  96376. readonly uid: string;
  96377. /**
  96378. * Return a string representation of the texture.
  96379. * @returns the texture as a string
  96380. */
  96381. toString(): string;
  96382. /**
  96383. * Get the class name of the texture.
  96384. * @returns "BaseTexture"
  96385. */
  96386. getClassName(): string;
  96387. /**
  96388. * Define the list of animation attached to the texture.
  96389. */
  96390. animations: Animation[];
  96391. /**
  96392. * An event triggered when the texture is disposed.
  96393. */
  96394. onDisposeObservable: Observable<BaseTexture>;
  96395. private _onDisposeObserver;
  96396. /**
  96397. * Callback triggered when the texture has been disposed.
  96398. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96399. */
  96400. onDispose: () => void;
  96401. /**
  96402. * Define the current state of the loading sequence when in delayed load mode.
  96403. */
  96404. delayLoadState: number;
  96405. private _scene;
  96406. /** @hidden */
  96407. _texture: Nullable<InternalTexture>;
  96408. private _uid;
  96409. /**
  96410. * Define if the texture is preventinga material to render or not.
  96411. * If not and the texture is not ready, the engine will use a default black texture instead.
  96412. */
  96413. readonly isBlocking: boolean;
  96414. /**
  96415. * Instantiates a new BaseTexture.
  96416. * Base class of all the textures in babylon.
  96417. * It groups all the common properties the materials, post process, lights... might need
  96418. * in order to make a correct use of the texture.
  96419. * @param scene Define the scene the texture blongs to
  96420. */
  96421. constructor(scene: Nullable<Scene>);
  96422. /**
  96423. * Get the scene the texture belongs to.
  96424. * @returns the scene or null if undefined
  96425. */
  96426. getScene(): Nullable<Scene>;
  96427. /**
  96428. * Get the texture transform matrix used to offset tile the texture for istance.
  96429. * @returns the transformation matrix
  96430. */
  96431. getTextureMatrix(): Matrix;
  96432. /**
  96433. * Get the texture reflection matrix used to rotate/transform the reflection.
  96434. * @returns the reflection matrix
  96435. */
  96436. getReflectionTextureMatrix(): Matrix;
  96437. /**
  96438. * Get the underlying lower level texture from Babylon.
  96439. * @returns the insternal texture
  96440. */
  96441. getInternalTexture(): Nullable<InternalTexture>;
  96442. /**
  96443. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96444. * @returns true if ready or not blocking
  96445. */
  96446. isReadyOrNotBlocking(): boolean;
  96447. /**
  96448. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96449. * @returns true if fully ready
  96450. */
  96451. isReady(): boolean;
  96452. private _cachedSize;
  96453. /**
  96454. * Get the size of the texture.
  96455. * @returns the texture size.
  96456. */
  96457. getSize(): ISize;
  96458. /**
  96459. * Get the base size of the texture.
  96460. * It can be different from the size if the texture has been resized for POT for instance
  96461. * @returns the base size
  96462. */
  96463. getBaseSize(): ISize;
  96464. /**
  96465. * Update the sampling mode of the texture.
  96466. * Default is Trilinear mode.
  96467. *
  96468. * | Value | Type | Description |
  96469. * | ----- | ------------------ | ----------- |
  96470. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96471. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96472. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96473. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96474. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96475. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96476. * | 7 | NEAREST_LINEAR | |
  96477. * | 8 | NEAREST_NEAREST | |
  96478. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96479. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96480. * | 11 | LINEAR_LINEAR | |
  96481. * | 12 | LINEAR_NEAREST | |
  96482. *
  96483. * > _mag_: magnification filter (close to the viewer)
  96484. * > _min_: minification filter (far from the viewer)
  96485. * > _mip_: filter used between mip map levels
  96486. *@param samplingMode Define the new sampling mode of the texture
  96487. */
  96488. updateSamplingMode(samplingMode: number): void;
  96489. /**
  96490. * Scales the texture if is `canRescale()`
  96491. * @param ratio the resize factor we want to use to rescale
  96492. */
  96493. scale(ratio: number): void;
  96494. /**
  96495. * Get if the texture can rescale.
  96496. */
  96497. readonly canRescale: boolean;
  96498. /** @hidden */
  96499. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96500. /** @hidden */
  96501. _rebuild(): void;
  96502. /**
  96503. * Triggers the load sequence in delayed load mode.
  96504. */
  96505. delayLoad(): void;
  96506. /**
  96507. * Clones the texture.
  96508. * @returns the cloned texture
  96509. */
  96510. clone(): Nullable<BaseTexture>;
  96511. /**
  96512. * Get the texture underlying type (INT, FLOAT...)
  96513. */
  96514. readonly textureType: number;
  96515. /**
  96516. * Get the texture underlying format (RGB, RGBA...)
  96517. */
  96518. readonly textureFormat: number;
  96519. /**
  96520. * Indicates that textures need to be re-calculated for all materials
  96521. */
  96522. protected _markAllSubMeshesAsTexturesDirty(): void;
  96523. /**
  96524. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96525. * This will returns an RGBA array buffer containing either in values (0-255) or
  96526. * float values (0-1) depending of the underlying buffer type.
  96527. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96528. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96529. * @param buffer defines a user defined buffer to fill with data (can be null)
  96530. * @returns The Array buffer containing the pixels data.
  96531. */
  96532. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96533. /**
  96534. * Release and destroy the underlying lower level texture aka internalTexture.
  96535. */
  96536. releaseInternalTexture(): void;
  96537. /** @hidden */
  96538. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96539. /** @hidden */
  96540. readonly _lodTextureMid: Nullable<BaseTexture>;
  96541. /** @hidden */
  96542. readonly _lodTextureLow: Nullable<BaseTexture>;
  96543. /**
  96544. * Dispose the texture and release its associated resources.
  96545. */
  96546. dispose(): void;
  96547. /**
  96548. * Serialize the texture into a JSON representation that can be parsed later on.
  96549. * @returns the JSON representation of the texture
  96550. */
  96551. serialize(): any;
  96552. /**
  96553. * Helper function to be called back once a list of texture contains only ready textures.
  96554. * @param textures Define the list of textures to wait for
  96555. * @param callback Define the callback triggered once the entire list will be ready
  96556. */
  96557. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96558. }
  96559. }
  96560. declare module BABYLON {
  96561. /**
  96562. * Options to be used when creating an effect.
  96563. */
  96564. export interface IEffectCreationOptions {
  96565. /**
  96566. * Atrributes that will be used in the shader.
  96567. */
  96568. attributes: string[];
  96569. /**
  96570. * Uniform varible names that will be set in the shader.
  96571. */
  96572. uniformsNames: string[];
  96573. /**
  96574. * Uniform buffer varible names that will be set in the shader.
  96575. */
  96576. uniformBuffersNames: string[];
  96577. /**
  96578. * Sampler texture variable names that will be set in the shader.
  96579. */
  96580. samplers: string[];
  96581. /**
  96582. * Define statements that will be set in the shader.
  96583. */
  96584. defines: any;
  96585. /**
  96586. * Possible fallbacks for this effect to improve performance when needed.
  96587. */
  96588. fallbacks: Nullable<IEffectFallbacks>;
  96589. /**
  96590. * Callback that will be called when the shader is compiled.
  96591. */
  96592. onCompiled: Nullable<(effect: Effect) => void>;
  96593. /**
  96594. * Callback that will be called if an error occurs during shader compilation.
  96595. */
  96596. onError: Nullable<(effect: Effect, errors: string) => void>;
  96597. /**
  96598. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96599. */
  96600. indexParameters?: any;
  96601. /**
  96602. * Max number of lights that can be used in the shader.
  96603. */
  96604. maxSimultaneousLights?: number;
  96605. /**
  96606. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96607. */
  96608. transformFeedbackVaryings?: Nullable<string[]>;
  96609. }
  96610. /**
  96611. * Effect containing vertex and fragment shader that can be executed on an object.
  96612. */
  96613. export class Effect implements IDisposable {
  96614. /**
  96615. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96616. */
  96617. static ShadersRepository: string;
  96618. /**
  96619. * Name of the effect.
  96620. */
  96621. name: any;
  96622. /**
  96623. * String container all the define statements that should be set on the shader.
  96624. */
  96625. defines: string;
  96626. /**
  96627. * Callback that will be called when the shader is compiled.
  96628. */
  96629. onCompiled: Nullable<(effect: Effect) => void>;
  96630. /**
  96631. * Callback that will be called if an error occurs during shader compilation.
  96632. */
  96633. onError: Nullable<(effect: Effect, errors: string) => void>;
  96634. /**
  96635. * Callback that will be called when effect is bound.
  96636. */
  96637. onBind: Nullable<(effect: Effect) => void>;
  96638. /**
  96639. * Unique ID of the effect.
  96640. */
  96641. uniqueId: number;
  96642. /**
  96643. * Observable that will be called when the shader is compiled.
  96644. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96645. */
  96646. onCompileObservable: Observable<Effect>;
  96647. /**
  96648. * Observable that will be called if an error occurs during shader compilation.
  96649. */
  96650. onErrorObservable: Observable<Effect>;
  96651. /** @hidden */
  96652. _onBindObservable: Nullable<Observable<Effect>>;
  96653. /**
  96654. * Observable that will be called when effect is bound.
  96655. */
  96656. readonly onBindObservable: Observable<Effect>;
  96657. /** @hidden */
  96658. _bonesComputationForcedToCPU: boolean;
  96659. private static _uniqueIdSeed;
  96660. private _engine;
  96661. private _uniformBuffersNames;
  96662. private _uniformsNames;
  96663. private _samplerList;
  96664. private _samplers;
  96665. private _isReady;
  96666. private _compilationError;
  96667. private _allFallbacksProcessed;
  96668. private _attributesNames;
  96669. private _attributes;
  96670. private _uniforms;
  96671. /**
  96672. * Key for the effect.
  96673. * @hidden
  96674. */
  96675. _key: string;
  96676. private _indexParameters;
  96677. private _fallbacks;
  96678. private _vertexSourceCode;
  96679. private _fragmentSourceCode;
  96680. private _vertexSourceCodeOverride;
  96681. private _fragmentSourceCodeOverride;
  96682. private _transformFeedbackVaryings;
  96683. /**
  96684. * Compiled shader to webGL program.
  96685. * @hidden
  96686. */
  96687. _pipelineContext: Nullable<IPipelineContext>;
  96688. private _valueCache;
  96689. private static _baseCache;
  96690. /**
  96691. * Instantiates an effect.
  96692. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96693. * @param baseName Name of the effect.
  96694. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96695. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96696. * @param samplers List of sampler variables that will be passed to the shader.
  96697. * @param engine Engine to be used to render the effect
  96698. * @param defines Define statements to be added to the shader.
  96699. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96700. * @param onCompiled Callback that will be called when the shader is compiled.
  96701. * @param onError Callback that will be called if an error occurs during shader compilation.
  96702. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96703. */
  96704. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  96705. private _useFinalCode;
  96706. /**
  96707. * Unique key for this effect
  96708. */
  96709. readonly key: string;
  96710. /**
  96711. * If the effect has been compiled and prepared.
  96712. * @returns if the effect is compiled and prepared.
  96713. */
  96714. isReady(): boolean;
  96715. private _isReadyInternal;
  96716. /**
  96717. * The engine the effect was initialized with.
  96718. * @returns the engine.
  96719. */
  96720. getEngine(): Engine;
  96721. /**
  96722. * The pipeline context for this effect
  96723. * @returns the associated pipeline context
  96724. */
  96725. getPipelineContext(): Nullable<IPipelineContext>;
  96726. /**
  96727. * The set of names of attribute variables for the shader.
  96728. * @returns An array of attribute names.
  96729. */
  96730. getAttributesNames(): string[];
  96731. /**
  96732. * Returns the attribute at the given index.
  96733. * @param index The index of the attribute.
  96734. * @returns The location of the attribute.
  96735. */
  96736. getAttributeLocation(index: number): number;
  96737. /**
  96738. * Returns the attribute based on the name of the variable.
  96739. * @param name of the attribute to look up.
  96740. * @returns the attribute location.
  96741. */
  96742. getAttributeLocationByName(name: string): number;
  96743. /**
  96744. * The number of attributes.
  96745. * @returns the numnber of attributes.
  96746. */
  96747. getAttributesCount(): number;
  96748. /**
  96749. * Gets the index of a uniform variable.
  96750. * @param uniformName of the uniform to look up.
  96751. * @returns the index.
  96752. */
  96753. getUniformIndex(uniformName: string): number;
  96754. /**
  96755. * Returns the attribute based on the name of the variable.
  96756. * @param uniformName of the uniform to look up.
  96757. * @returns the location of the uniform.
  96758. */
  96759. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96760. /**
  96761. * Returns an array of sampler variable names
  96762. * @returns The array of sampler variable neames.
  96763. */
  96764. getSamplers(): string[];
  96765. /**
  96766. * The error from the last compilation.
  96767. * @returns the error string.
  96768. */
  96769. getCompilationError(): string;
  96770. /**
  96771. * Gets a boolean indicating that all fallbacks were used during compilation
  96772. * @returns true if all fallbacks were used
  96773. */
  96774. allFallbacksProcessed(): boolean;
  96775. /**
  96776. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96777. * @param func The callback to be used.
  96778. */
  96779. executeWhenCompiled(func: (effect: Effect) => void): void;
  96780. private _checkIsReady;
  96781. private _loadShader;
  96782. /**
  96783. * Recompiles the webGL program
  96784. * @param vertexSourceCode The source code for the vertex shader.
  96785. * @param fragmentSourceCode The source code for the fragment shader.
  96786. * @param onCompiled Callback called when completed.
  96787. * @param onError Callback called on error.
  96788. * @hidden
  96789. */
  96790. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96791. /**
  96792. * Prepares the effect
  96793. * @hidden
  96794. */
  96795. _prepareEffect(): void;
  96796. private _processCompilationErrors;
  96797. /**
  96798. * Checks if the effect is supported. (Must be called after compilation)
  96799. */
  96800. readonly isSupported: boolean;
  96801. /**
  96802. * Binds a texture to the engine to be used as output of the shader.
  96803. * @param channel Name of the output variable.
  96804. * @param texture Texture to bind.
  96805. * @hidden
  96806. */
  96807. _bindTexture(channel: string, texture: InternalTexture): void;
  96808. /**
  96809. * Sets a texture on the engine to be used in the shader.
  96810. * @param channel Name of the sampler variable.
  96811. * @param texture Texture to set.
  96812. */
  96813. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96814. /**
  96815. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96816. * @param channel Name of the sampler variable.
  96817. * @param texture Texture to set.
  96818. */
  96819. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96820. /**
  96821. * Sets an array of textures on the engine to be used in the shader.
  96822. * @param channel Name of the variable.
  96823. * @param textures Textures to set.
  96824. */
  96825. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96826. /**
  96827. * 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)
  96828. * @param channel Name of the sampler variable.
  96829. * @param postProcess Post process to get the input texture from.
  96830. */
  96831. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96832. /**
  96833. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96834. * 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)
  96835. * @param channel Name of the sampler variable.
  96836. * @param postProcess Post process to get the output texture from.
  96837. */
  96838. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96839. /** @hidden */
  96840. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96841. /** @hidden */
  96842. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96843. /** @hidden */
  96844. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96845. /** @hidden */
  96846. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96847. /**
  96848. * Binds a buffer to a uniform.
  96849. * @param buffer Buffer to bind.
  96850. * @param name Name of the uniform variable to bind to.
  96851. */
  96852. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96853. /**
  96854. * Binds block to a uniform.
  96855. * @param blockName Name of the block to bind.
  96856. * @param index Index to bind.
  96857. */
  96858. bindUniformBlock(blockName: string, index: number): void;
  96859. /**
  96860. * Sets an interger value on a uniform variable.
  96861. * @param uniformName Name of the variable.
  96862. * @param value Value to be set.
  96863. * @returns this effect.
  96864. */
  96865. setInt(uniformName: string, value: number): Effect;
  96866. /**
  96867. * Sets an int array on a uniform variable.
  96868. * @param uniformName Name of the variable.
  96869. * @param array array to be set.
  96870. * @returns this effect.
  96871. */
  96872. setIntArray(uniformName: string, array: Int32Array): Effect;
  96873. /**
  96874. * 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)
  96875. * @param uniformName Name of the variable.
  96876. * @param array array to be set.
  96877. * @returns this effect.
  96878. */
  96879. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96880. /**
  96881. * 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)
  96882. * @param uniformName Name of the variable.
  96883. * @param array array to be set.
  96884. * @returns this effect.
  96885. */
  96886. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96887. /**
  96888. * 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)
  96889. * @param uniformName Name of the variable.
  96890. * @param array array to be set.
  96891. * @returns this effect.
  96892. */
  96893. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96894. /**
  96895. * Sets an float array on a uniform variable.
  96896. * @param uniformName Name of the variable.
  96897. * @param array array to be set.
  96898. * @returns this effect.
  96899. */
  96900. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96901. /**
  96902. * 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)
  96903. * @param uniformName Name of the variable.
  96904. * @param array array to be set.
  96905. * @returns this effect.
  96906. */
  96907. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96908. /**
  96909. * 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)
  96910. * @param uniformName Name of the variable.
  96911. * @param array array to be set.
  96912. * @returns this effect.
  96913. */
  96914. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96915. /**
  96916. * 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)
  96917. * @param uniformName Name of the variable.
  96918. * @param array array to be set.
  96919. * @returns this effect.
  96920. */
  96921. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96922. /**
  96923. * Sets an array on a uniform variable.
  96924. * @param uniformName Name of the variable.
  96925. * @param array array to be set.
  96926. * @returns this effect.
  96927. */
  96928. setArray(uniformName: string, array: number[]): Effect;
  96929. /**
  96930. * 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)
  96931. * @param uniformName Name of the variable.
  96932. * @param array array to be set.
  96933. * @returns this effect.
  96934. */
  96935. setArray2(uniformName: string, array: number[]): Effect;
  96936. /**
  96937. * 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)
  96938. * @param uniformName Name of the variable.
  96939. * @param array array to be set.
  96940. * @returns this effect.
  96941. */
  96942. setArray3(uniformName: string, array: number[]): Effect;
  96943. /**
  96944. * 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)
  96945. * @param uniformName Name of the variable.
  96946. * @param array array to be set.
  96947. * @returns this effect.
  96948. */
  96949. setArray4(uniformName: string, array: number[]): Effect;
  96950. /**
  96951. * Sets matrices on a uniform variable.
  96952. * @param uniformName Name of the variable.
  96953. * @param matrices matrices to be set.
  96954. * @returns this effect.
  96955. */
  96956. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96957. /**
  96958. * Sets matrix on a uniform variable.
  96959. * @param uniformName Name of the variable.
  96960. * @param matrix matrix to be set.
  96961. * @returns this effect.
  96962. */
  96963. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96964. /**
  96965. * 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)
  96966. * @param uniformName Name of the variable.
  96967. * @param matrix matrix to be set.
  96968. * @returns this effect.
  96969. */
  96970. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96971. /**
  96972. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96973. * @param uniformName Name of the variable.
  96974. * @param matrix matrix to be set.
  96975. * @returns this effect.
  96976. */
  96977. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96978. /**
  96979. * Sets a float on a uniform variable.
  96980. * @param uniformName Name of the variable.
  96981. * @param value value to be set.
  96982. * @returns this effect.
  96983. */
  96984. setFloat(uniformName: string, value: number): Effect;
  96985. /**
  96986. * Sets a boolean on a uniform variable.
  96987. * @param uniformName Name of the variable.
  96988. * @param bool value to be set.
  96989. * @returns this effect.
  96990. */
  96991. setBool(uniformName: string, bool: boolean): Effect;
  96992. /**
  96993. * Sets a Vector2 on a uniform variable.
  96994. * @param uniformName Name of the variable.
  96995. * @param vector2 vector2 to be set.
  96996. * @returns this effect.
  96997. */
  96998. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96999. /**
  97000. * Sets a float2 on a uniform variable.
  97001. * @param uniformName Name of the variable.
  97002. * @param x First float in float2.
  97003. * @param y Second float in float2.
  97004. * @returns this effect.
  97005. */
  97006. setFloat2(uniformName: string, x: number, y: number): Effect;
  97007. /**
  97008. * Sets a Vector3 on a uniform variable.
  97009. * @param uniformName Name of the variable.
  97010. * @param vector3 Value to be set.
  97011. * @returns this effect.
  97012. */
  97013. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97014. /**
  97015. * Sets a float3 on a uniform variable.
  97016. * @param uniformName Name of the variable.
  97017. * @param x First float in float3.
  97018. * @param y Second float in float3.
  97019. * @param z Third float in float3.
  97020. * @returns this effect.
  97021. */
  97022. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97023. /**
  97024. * Sets a Vector4 on a uniform variable.
  97025. * @param uniformName Name of the variable.
  97026. * @param vector4 Value to be set.
  97027. * @returns this effect.
  97028. */
  97029. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97030. /**
  97031. * Sets a float4 on a uniform variable.
  97032. * @param uniformName Name of the variable.
  97033. * @param x First float in float4.
  97034. * @param y Second float in float4.
  97035. * @param z Third float in float4.
  97036. * @param w Fourth float in float4.
  97037. * @returns this effect.
  97038. */
  97039. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97040. /**
  97041. * Sets a Color3 on a uniform variable.
  97042. * @param uniformName Name of the variable.
  97043. * @param color3 Value to be set.
  97044. * @returns this effect.
  97045. */
  97046. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97047. /**
  97048. * Sets a Color4 on a uniform variable.
  97049. * @param uniformName Name of the variable.
  97050. * @param color3 Value to be set.
  97051. * @param alpha Alpha value to be set.
  97052. * @returns this effect.
  97053. */
  97054. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97055. /**
  97056. * Sets a Color4 on a uniform variable
  97057. * @param uniformName defines the name of the variable
  97058. * @param color4 defines the value to be set
  97059. * @returns this effect.
  97060. */
  97061. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97062. /** Release all associated resources */
  97063. dispose(): void;
  97064. /**
  97065. * This function will add a new shader to the shader store
  97066. * @param name the name of the shader
  97067. * @param pixelShader optional pixel shader content
  97068. * @param vertexShader optional vertex shader content
  97069. */
  97070. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97071. /**
  97072. * Store of each shader (The can be looked up using effect.key)
  97073. */
  97074. static ShadersStore: {
  97075. [key: string]: string;
  97076. };
  97077. /**
  97078. * Store of each included file for a shader (The can be looked up using effect.key)
  97079. */
  97080. static IncludesShadersStore: {
  97081. [key: string]: string;
  97082. };
  97083. /**
  97084. * Resets the cache of effects.
  97085. */
  97086. static ResetCache(): void;
  97087. }
  97088. }
  97089. declare module BABYLON {
  97090. /**
  97091. * Interface used to describe the capabilities of the engine relatively to the current browser
  97092. */
  97093. export interface EngineCapabilities {
  97094. /** Maximum textures units per fragment shader */
  97095. maxTexturesImageUnits: number;
  97096. /** Maximum texture units per vertex shader */
  97097. maxVertexTextureImageUnits: number;
  97098. /** Maximum textures units in the entire pipeline */
  97099. maxCombinedTexturesImageUnits: number;
  97100. /** Maximum texture size */
  97101. maxTextureSize: number;
  97102. /** Maximum cube texture size */
  97103. maxCubemapTextureSize: number;
  97104. /** Maximum render texture size */
  97105. maxRenderTextureSize: number;
  97106. /** Maximum number of vertex attributes */
  97107. maxVertexAttribs: number;
  97108. /** Maximum number of varyings */
  97109. maxVaryingVectors: number;
  97110. /** Maximum number of uniforms per vertex shader */
  97111. maxVertexUniformVectors: number;
  97112. /** Maximum number of uniforms per fragment shader */
  97113. maxFragmentUniformVectors: number;
  97114. /** Defines if standard derivates (dx/dy) are supported */
  97115. standardDerivatives: boolean;
  97116. /** Defines if s3tc texture compression is supported */
  97117. s3tc?: WEBGL_compressed_texture_s3tc;
  97118. /** Defines if pvrtc texture compression is supported */
  97119. pvrtc: any;
  97120. /** Defines if etc1 texture compression is supported */
  97121. etc1: any;
  97122. /** Defines if etc2 texture compression is supported */
  97123. etc2: any;
  97124. /** Defines if astc texture compression is supported */
  97125. astc: any;
  97126. /** Defines if float textures are supported */
  97127. textureFloat: boolean;
  97128. /** Defines if vertex array objects are supported */
  97129. vertexArrayObject: boolean;
  97130. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97131. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97132. /** Gets the maximum level of anisotropy supported */
  97133. maxAnisotropy: number;
  97134. /** Defines if instancing is supported */
  97135. instancedArrays: boolean;
  97136. /** Defines if 32 bits indices are supported */
  97137. uintIndices: boolean;
  97138. /** Defines if high precision shaders are supported */
  97139. highPrecisionShaderSupported: boolean;
  97140. /** Defines if depth reading in the fragment shader is supported */
  97141. fragmentDepthSupported: boolean;
  97142. /** Defines if float texture linear filtering is supported*/
  97143. textureFloatLinearFiltering: boolean;
  97144. /** Defines if rendering to float textures is supported */
  97145. textureFloatRender: boolean;
  97146. /** Defines if half float textures are supported*/
  97147. textureHalfFloat: boolean;
  97148. /** Defines if half float texture linear filtering is supported*/
  97149. textureHalfFloatLinearFiltering: boolean;
  97150. /** Defines if rendering to half float textures is supported */
  97151. textureHalfFloatRender: boolean;
  97152. /** Defines if textureLOD shader command is supported */
  97153. textureLOD: boolean;
  97154. /** Defines if draw buffers extension is supported */
  97155. drawBuffersExtension: boolean;
  97156. /** Defines if depth textures are supported */
  97157. depthTextureExtension: boolean;
  97158. /** Defines if float color buffer are supported */
  97159. colorBufferFloat: boolean;
  97160. /** Gets disjoint timer query extension (null if not supported) */
  97161. timerQuery?: EXT_disjoint_timer_query;
  97162. /** Defines if timestamp can be used with timer query */
  97163. canUseTimestampForTimerQuery: boolean;
  97164. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97165. multiview?: any;
  97166. /** Function used to let the system compiles shaders in background */
  97167. parallelShaderCompile?: {
  97168. COMPLETION_STATUS_KHR: number;
  97169. };
  97170. /** Max number of texture samples for MSAA */
  97171. maxMSAASamples: number;
  97172. /** Defines if the blend min max extension is supported */
  97173. blendMinMax: boolean;
  97174. }
  97175. }
  97176. declare module BABYLON {
  97177. /**
  97178. * @hidden
  97179. **/
  97180. export class DepthCullingState {
  97181. private _isDepthTestDirty;
  97182. private _isDepthMaskDirty;
  97183. private _isDepthFuncDirty;
  97184. private _isCullFaceDirty;
  97185. private _isCullDirty;
  97186. private _isZOffsetDirty;
  97187. private _isFrontFaceDirty;
  97188. private _depthTest;
  97189. private _depthMask;
  97190. private _depthFunc;
  97191. private _cull;
  97192. private _cullFace;
  97193. private _zOffset;
  97194. private _frontFace;
  97195. /**
  97196. * Initializes the state.
  97197. */
  97198. constructor();
  97199. readonly isDirty: boolean;
  97200. zOffset: number;
  97201. cullFace: Nullable<number>;
  97202. cull: Nullable<boolean>;
  97203. depthFunc: Nullable<number>;
  97204. depthMask: boolean;
  97205. depthTest: boolean;
  97206. frontFace: Nullable<number>;
  97207. reset(): void;
  97208. apply(gl: WebGLRenderingContext): void;
  97209. }
  97210. }
  97211. declare module BABYLON {
  97212. /**
  97213. * @hidden
  97214. **/
  97215. export class StencilState {
  97216. /** 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 */
  97217. static readonly ALWAYS: number;
  97218. /** Passed to stencilOperation to specify that stencil value must be kept */
  97219. static readonly KEEP: number;
  97220. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97221. static readonly REPLACE: number;
  97222. private _isStencilTestDirty;
  97223. private _isStencilMaskDirty;
  97224. private _isStencilFuncDirty;
  97225. private _isStencilOpDirty;
  97226. private _stencilTest;
  97227. private _stencilMask;
  97228. private _stencilFunc;
  97229. private _stencilFuncRef;
  97230. private _stencilFuncMask;
  97231. private _stencilOpStencilFail;
  97232. private _stencilOpDepthFail;
  97233. private _stencilOpStencilDepthPass;
  97234. readonly isDirty: boolean;
  97235. stencilFunc: number;
  97236. stencilFuncRef: number;
  97237. stencilFuncMask: number;
  97238. stencilOpStencilFail: number;
  97239. stencilOpDepthFail: number;
  97240. stencilOpStencilDepthPass: number;
  97241. stencilMask: number;
  97242. stencilTest: boolean;
  97243. constructor();
  97244. reset(): void;
  97245. apply(gl: WebGLRenderingContext): void;
  97246. }
  97247. }
  97248. declare module BABYLON {
  97249. /**
  97250. * @hidden
  97251. **/
  97252. export class AlphaState {
  97253. private _isAlphaBlendDirty;
  97254. private _isBlendFunctionParametersDirty;
  97255. private _isBlendEquationParametersDirty;
  97256. private _isBlendConstantsDirty;
  97257. private _alphaBlend;
  97258. private _blendFunctionParameters;
  97259. private _blendEquationParameters;
  97260. private _blendConstants;
  97261. /**
  97262. * Initializes the state.
  97263. */
  97264. constructor();
  97265. readonly isDirty: boolean;
  97266. alphaBlend: boolean;
  97267. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97268. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97269. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97270. reset(): void;
  97271. apply(gl: WebGLRenderingContext): void;
  97272. }
  97273. }
  97274. declare module BABYLON {
  97275. /** @hidden */
  97276. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97277. attributeProcessor(attribute: string): string;
  97278. varyingProcessor(varying: string, isFragment: boolean): string;
  97279. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97280. }
  97281. }
  97282. declare module BABYLON {
  97283. /**
  97284. * Interface for attribute information associated with buffer instanciation
  97285. */
  97286. export interface InstancingAttributeInfo {
  97287. /**
  97288. * Index/offset of the attribute in the vertex shader
  97289. */
  97290. index: number;
  97291. /**
  97292. * size of the attribute, 1, 2, 3 or 4
  97293. */
  97294. attributeSize: number;
  97295. /**
  97296. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97297. * default is FLOAT
  97298. */
  97299. attributeType: number;
  97300. /**
  97301. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97302. */
  97303. normalized: boolean;
  97304. /**
  97305. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97306. */
  97307. offset: number;
  97308. /**
  97309. * Name of the GLSL attribute, for debugging purpose only
  97310. */
  97311. attributeName: string;
  97312. }
  97313. }
  97314. declare module BABYLON {
  97315. interface ThinEngine {
  97316. /**
  97317. * Update a video texture
  97318. * @param texture defines the texture to update
  97319. * @param video defines the video element to use
  97320. * @param invertY defines if data must be stored with Y axis inverted
  97321. */
  97322. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97323. }
  97324. }
  97325. declare module BABYLON {
  97326. /**
  97327. * Settings for finer control over video usage
  97328. */
  97329. export interface VideoTextureSettings {
  97330. /**
  97331. * Applies `autoplay` to video, if specified
  97332. */
  97333. autoPlay?: boolean;
  97334. /**
  97335. * Applies `loop` to video, if specified
  97336. */
  97337. loop?: boolean;
  97338. /**
  97339. * Automatically updates internal texture from video at every frame in the render loop
  97340. */
  97341. autoUpdateTexture: boolean;
  97342. /**
  97343. * Image src displayed during the video loading or until the user interacts with the video.
  97344. */
  97345. poster?: string;
  97346. }
  97347. /**
  97348. * If you want to display a video in your scene, this is the special texture for that.
  97349. * This special texture works similar to other textures, with the exception of a few parameters.
  97350. * @see https://doc.babylonjs.com/how_to/video_texture
  97351. */
  97352. export class VideoTexture extends Texture {
  97353. /**
  97354. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97355. */
  97356. readonly autoUpdateTexture: boolean;
  97357. /**
  97358. * The video instance used by the texture internally
  97359. */
  97360. readonly video: HTMLVideoElement;
  97361. private _onUserActionRequestedObservable;
  97362. /**
  97363. * Event triggerd when a dom action is required by the user to play the video.
  97364. * This happens due to recent changes in browser policies preventing video to auto start.
  97365. */
  97366. readonly onUserActionRequestedObservable: Observable<Texture>;
  97367. private _generateMipMaps;
  97368. private _engine;
  97369. private _stillImageCaptured;
  97370. private _displayingPosterTexture;
  97371. private _settings;
  97372. private _createInternalTextureOnEvent;
  97373. private _frameId;
  97374. /**
  97375. * Creates a video texture.
  97376. * If you want to display a video in your scene, this is the special texture for that.
  97377. * This special texture works similar to other textures, with the exception of a few parameters.
  97378. * @see https://doc.babylonjs.com/how_to/video_texture
  97379. * @param name optional name, will detect from video source, if not defined
  97380. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97381. * @param scene is obviously the current scene.
  97382. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97383. * @param invertY is false by default but can be used to invert video on Y axis
  97384. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97385. * @param settings allows finer control over video usage
  97386. */
  97387. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97388. private _getName;
  97389. private _getVideo;
  97390. private _createInternalTexture;
  97391. private reset;
  97392. /**
  97393. * @hidden Internal method to initiate `update`.
  97394. */
  97395. _rebuild(): void;
  97396. /**
  97397. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97398. */
  97399. update(): void;
  97400. /**
  97401. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97402. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97403. */
  97404. updateTexture(isVisible: boolean): void;
  97405. protected _updateInternalTexture: () => void;
  97406. /**
  97407. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97408. * @param url New url.
  97409. */
  97410. updateURL(url: string): void;
  97411. /**
  97412. * Dispose the texture and release its associated resources.
  97413. */
  97414. dispose(): void;
  97415. /**
  97416. * Creates a video texture straight from a stream.
  97417. * @param scene Define the scene the texture should be created in
  97418. * @param stream Define the stream the texture should be created from
  97419. * @returns The created video texture as a promise
  97420. */
  97421. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97422. /**
  97423. * Creates a video texture straight from your WebCam video feed.
  97424. * @param scene Define the scene the texture should be created in
  97425. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97426. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97427. * @returns The created video texture as a promise
  97428. */
  97429. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97430. minWidth: number;
  97431. maxWidth: number;
  97432. minHeight: number;
  97433. maxHeight: number;
  97434. deviceId: string;
  97435. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97436. /**
  97437. * Creates a video texture straight from your WebCam video feed.
  97438. * @param scene Define the scene the texture should be created in
  97439. * @param onReady Define a callback to triggered once the texture will be ready
  97440. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97441. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97442. */
  97443. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97444. minWidth: number;
  97445. maxWidth: number;
  97446. minHeight: number;
  97447. maxHeight: number;
  97448. deviceId: string;
  97449. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97450. }
  97451. }
  97452. declare module BABYLON {
  97453. /**
  97454. * Defines the interface used by objects working like Scene
  97455. * @hidden
  97456. */
  97457. interface ISceneLike {
  97458. _addPendingData(data: any): void;
  97459. _removePendingData(data: any): void;
  97460. offlineProvider: IOfflineProvider;
  97461. }
  97462. /** Interface defining initialization parameters for Engine class */
  97463. export interface EngineOptions extends WebGLContextAttributes {
  97464. /**
  97465. * Defines if the engine should no exceed a specified device ratio
  97466. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97467. */
  97468. limitDeviceRatio?: number;
  97469. /**
  97470. * Defines if webvr should be enabled automatically
  97471. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97472. */
  97473. autoEnableWebVR?: boolean;
  97474. /**
  97475. * Defines if webgl2 should be turned off even if supported
  97476. * @see http://doc.babylonjs.com/features/webgl2
  97477. */
  97478. disableWebGL2Support?: boolean;
  97479. /**
  97480. * Defines if webaudio should be initialized as well
  97481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97482. */
  97483. audioEngine?: boolean;
  97484. /**
  97485. * Defines if animations should run using a deterministic lock step
  97486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97487. */
  97488. deterministicLockstep?: boolean;
  97489. /** Defines the maximum steps to use with deterministic lock step mode */
  97490. lockstepMaxSteps?: number;
  97491. /**
  97492. * Defines that engine should ignore context lost events
  97493. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97494. */
  97495. doNotHandleContextLost?: boolean;
  97496. /**
  97497. * Defines that engine should ignore modifying touch action attribute and style
  97498. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97499. */
  97500. doNotHandleTouchAction?: boolean;
  97501. /**
  97502. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97503. */
  97504. useHighPrecisionFloats?: boolean;
  97505. }
  97506. /**
  97507. * The base engine class (root of all engines)
  97508. */
  97509. export class ThinEngine {
  97510. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97511. static ExceptionList: ({
  97512. key: string;
  97513. capture: string;
  97514. captureConstraint: number;
  97515. targets: string[];
  97516. } | {
  97517. key: string;
  97518. capture: null;
  97519. captureConstraint: null;
  97520. targets: string[];
  97521. })[];
  97522. /** @hidden */
  97523. static _TextureLoaders: IInternalTextureLoader[];
  97524. /**
  97525. * Returns the current npm package of the sdk
  97526. */
  97527. static readonly NpmPackage: string;
  97528. /**
  97529. * Returns the current version of the framework
  97530. */
  97531. static readonly Version: string;
  97532. /**
  97533. * Returns a string describing the current engine
  97534. */
  97535. readonly description: string;
  97536. /**
  97537. * Gets or sets the epsilon value used by collision engine
  97538. */
  97539. static CollisionsEpsilon: number;
  97540. /**
  97541. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97542. */
  97543. static ShadersRepository: string;
  97544. /** @hidden */
  97545. _shaderProcessor: IShaderProcessor;
  97546. /**
  97547. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97548. */
  97549. forcePOTTextures: boolean;
  97550. /**
  97551. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97552. */
  97553. isFullscreen: boolean;
  97554. /**
  97555. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97556. */
  97557. cullBackFaces: boolean;
  97558. /**
  97559. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97560. */
  97561. renderEvenInBackground: boolean;
  97562. /**
  97563. * Gets or sets a boolean indicating that cache can be kept between frames
  97564. */
  97565. preventCacheWipeBetweenFrames: boolean;
  97566. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97567. validateShaderPrograms: boolean;
  97568. /**
  97569. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97570. */
  97571. disableUniformBuffers: boolean;
  97572. /** @hidden */
  97573. _uniformBuffers: UniformBuffer[];
  97574. /**
  97575. * Gets a boolean indicating that the engine supports uniform buffers
  97576. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97577. */
  97578. readonly supportsUniformBuffers: boolean;
  97579. /** @hidden */
  97580. _gl: WebGLRenderingContext;
  97581. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97582. protected _windowIsBackground: boolean;
  97583. protected _webGLVersion: number;
  97584. protected _creationOptions: EngineOptions;
  97585. protected _highPrecisionShadersAllowed: boolean;
  97586. /** @hidden */
  97587. readonly _shouldUseHighPrecisionShader: boolean;
  97588. /**
  97589. * Gets a boolean indicating that only power of 2 textures are supported
  97590. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97591. */
  97592. readonly needPOTTextures: boolean;
  97593. /** @hidden */
  97594. _badOS: boolean;
  97595. /** @hidden */
  97596. _badDesktopOS: boolean;
  97597. private _hardwareScalingLevel;
  97598. /** @hidden */
  97599. _caps: EngineCapabilities;
  97600. private _isStencilEnable;
  97601. protected _colorWrite: boolean;
  97602. private _glVersion;
  97603. private _glRenderer;
  97604. private _glVendor;
  97605. /** @hidden */
  97606. _videoTextureSupported: boolean;
  97607. protected _renderingQueueLaunched: boolean;
  97608. protected _activeRenderLoops: (() => void)[];
  97609. /**
  97610. * Observable signaled when a context lost event is raised
  97611. */
  97612. onContextLostObservable: Observable<ThinEngine>;
  97613. /**
  97614. * Observable signaled when a context restored event is raised
  97615. */
  97616. onContextRestoredObservable: Observable<ThinEngine>;
  97617. private _onContextLost;
  97618. private _onContextRestored;
  97619. protected _contextWasLost: boolean;
  97620. /** @hidden */
  97621. _doNotHandleContextLost: boolean;
  97622. /**
  97623. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97625. */
  97626. doNotHandleContextLost: boolean;
  97627. /**
  97628. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97629. */
  97630. disableVertexArrayObjects: boolean;
  97631. /** @hidden */
  97632. protected _depthCullingState: DepthCullingState;
  97633. /** @hidden */
  97634. protected _stencilState: StencilState;
  97635. /** @hidden */
  97636. protected _alphaState: AlphaState;
  97637. /** @hidden */
  97638. _internalTexturesCache: InternalTexture[];
  97639. /** @hidden */
  97640. protected _activeChannel: number;
  97641. private _currentTextureChannel;
  97642. /** @hidden */
  97643. protected _boundTexturesCache: {
  97644. [key: string]: Nullable<InternalTexture>;
  97645. };
  97646. /** @hidden */
  97647. protected _currentEffect: Nullable<Effect>;
  97648. /** @hidden */
  97649. protected _currentProgram: Nullable<WebGLProgram>;
  97650. private _compiledEffects;
  97651. private _vertexAttribArraysEnabled;
  97652. /** @hidden */
  97653. protected _cachedViewport: Nullable<IViewportLike>;
  97654. private _cachedVertexArrayObject;
  97655. /** @hidden */
  97656. protected _cachedVertexBuffers: any;
  97657. /** @hidden */
  97658. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97659. /** @hidden */
  97660. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97661. /** @hidden */
  97662. _currentRenderTarget: Nullable<InternalTexture>;
  97663. private _uintIndicesCurrentlySet;
  97664. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97665. /** @hidden */
  97666. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97667. private _currentBufferPointers;
  97668. private _currentInstanceLocations;
  97669. private _currentInstanceBuffers;
  97670. private _textureUnits;
  97671. /** @hidden */
  97672. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97673. /** @hidden */
  97674. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97675. /** @hidden */
  97676. _boundRenderFunction: any;
  97677. private _vaoRecordInProgress;
  97678. private _mustWipeVertexAttributes;
  97679. private _emptyTexture;
  97680. private _emptyCubeTexture;
  97681. private _emptyTexture3D;
  97682. private _emptyTexture2DArray;
  97683. /** @hidden */
  97684. _frameHandler: number;
  97685. private _nextFreeTextureSlots;
  97686. private _maxSimultaneousTextures;
  97687. private _activeRequests;
  97688. protected _texturesSupported: string[];
  97689. /** @hidden */
  97690. _textureFormatInUse: Nullable<string>;
  97691. protected readonly _supportsHardwareTextureRescaling: boolean;
  97692. /**
  97693. * Gets the list of texture formats supported
  97694. */
  97695. readonly texturesSupported: Array<string>;
  97696. /**
  97697. * Gets the list of texture formats in use
  97698. */
  97699. readonly textureFormatInUse: Nullable<string>;
  97700. /**
  97701. * Gets the current viewport
  97702. */
  97703. readonly currentViewport: Nullable<IViewportLike>;
  97704. /**
  97705. * Gets the default empty texture
  97706. */
  97707. readonly emptyTexture: InternalTexture;
  97708. /**
  97709. * Gets the default empty 3D texture
  97710. */
  97711. readonly emptyTexture3D: InternalTexture;
  97712. /**
  97713. * Gets the default empty 2D array texture
  97714. */
  97715. readonly emptyTexture2DArray: InternalTexture;
  97716. /**
  97717. * Gets the default empty cube texture
  97718. */
  97719. readonly emptyCubeTexture: InternalTexture;
  97720. /**
  97721. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  97722. */
  97723. readonly premultipliedAlpha: boolean;
  97724. /**
  97725. * Observable event triggered before each texture is initialized
  97726. */
  97727. onBeforeTextureInitObservable: Observable<Texture>;
  97728. /**
  97729. * Creates a new engine
  97730. * @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
  97731. * @param antialias defines enable antialiasing (default: false)
  97732. * @param options defines further options to be sent to the getContext() function
  97733. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97734. */
  97735. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97736. private _rebuildInternalTextures;
  97737. private _rebuildEffects;
  97738. /**
  97739. * Gets a boolean indicating if all created effects are ready
  97740. * @returns true if all effects are ready
  97741. */
  97742. areAllEffectsReady(): boolean;
  97743. protected _rebuildBuffers(): void;
  97744. private _initGLContext;
  97745. /**
  97746. * Gets version of the current webGL context
  97747. */
  97748. readonly webGLVersion: number;
  97749. /**
  97750. * Gets a string idenfifying the name of the class
  97751. * @returns "Engine" string
  97752. */
  97753. getClassName(): string;
  97754. /**
  97755. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97756. */
  97757. readonly isStencilEnable: boolean;
  97758. /** @hidden */
  97759. _prepareWorkingCanvas(): void;
  97760. /**
  97761. * Reset the texture cache to empty state
  97762. */
  97763. resetTextureCache(): void;
  97764. /**
  97765. * Gets an object containing information about the current webGL context
  97766. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97767. */
  97768. getGlInfo(): {
  97769. vendor: string;
  97770. renderer: string;
  97771. version: string;
  97772. };
  97773. /**
  97774. * Defines the hardware scaling level.
  97775. * By default the hardware scaling level is computed from the window device ratio.
  97776. * 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.
  97777. * @param level defines the level to use
  97778. */
  97779. setHardwareScalingLevel(level: number): void;
  97780. /**
  97781. * Gets the current hardware scaling level.
  97782. * By default the hardware scaling level is computed from the window device ratio.
  97783. * 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.
  97784. * @returns a number indicating the current hardware scaling level
  97785. */
  97786. getHardwareScalingLevel(): number;
  97787. /**
  97788. * Gets the list of loaded textures
  97789. * @returns an array containing all loaded textures
  97790. */
  97791. getLoadedTexturesCache(): InternalTexture[];
  97792. /**
  97793. * Gets the object containing all engine capabilities
  97794. * @returns the EngineCapabilities object
  97795. */
  97796. getCaps(): EngineCapabilities;
  97797. /**
  97798. * stop executing a render loop function and remove it from the execution array
  97799. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97800. */
  97801. stopRenderLoop(renderFunction?: () => void): void;
  97802. /** @hidden */
  97803. _renderLoop(): void;
  97804. /**
  97805. * Gets the HTML canvas attached with the current webGL context
  97806. * @returns a HTML canvas
  97807. */
  97808. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97809. /**
  97810. * Gets host window
  97811. * @returns the host window object
  97812. */
  97813. getHostWindow(): Nullable<Window>;
  97814. /**
  97815. * Gets the current render width
  97816. * @param useScreen defines if screen size must be used (or the current render target if any)
  97817. * @returns a number defining the current render width
  97818. */
  97819. getRenderWidth(useScreen?: boolean): number;
  97820. /**
  97821. * Gets the current render height
  97822. * @param useScreen defines if screen size must be used (or the current render target if any)
  97823. * @returns a number defining the current render height
  97824. */
  97825. getRenderHeight(useScreen?: boolean): number;
  97826. /**
  97827. * Can be used to override the current requestAnimationFrame requester.
  97828. * @hidden
  97829. */
  97830. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97831. /**
  97832. * Register and execute a render loop. The engine can have more than one render function
  97833. * @param renderFunction defines the function to continuously execute
  97834. */
  97835. runRenderLoop(renderFunction: () => void): void;
  97836. /**
  97837. * Clear the current render buffer or the current render target (if any is set up)
  97838. * @param color defines the color to use
  97839. * @param backBuffer defines if the back buffer must be cleared
  97840. * @param depth defines if the depth buffer must be cleared
  97841. * @param stencil defines if the stencil buffer must be cleared
  97842. */
  97843. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97844. private _viewportCached;
  97845. /** @hidden */
  97846. _viewport(x: number, y: number, width: number, height: number): void;
  97847. /**
  97848. * Set the WebGL's viewport
  97849. * @param viewport defines the viewport element to be used
  97850. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97851. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97852. */
  97853. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97854. /**
  97855. * Begin a new frame
  97856. */
  97857. beginFrame(): void;
  97858. /**
  97859. * Enf the current frame
  97860. */
  97861. endFrame(): void;
  97862. /**
  97863. * Resize the view according to the canvas' size
  97864. */
  97865. resize(): void;
  97866. /**
  97867. * Force a specific size of the canvas
  97868. * @param width defines the new canvas' width
  97869. * @param height defines the new canvas' height
  97870. */
  97871. setSize(width: number, height: number): void;
  97872. /**
  97873. * Binds the frame buffer to the specified texture.
  97874. * @param texture The texture to render to or null for the default canvas
  97875. * @param faceIndex The face of the texture to render to in case of cube texture
  97876. * @param requiredWidth The width of the target to render to
  97877. * @param requiredHeight The height of the target to render to
  97878. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97879. * @param depthStencilTexture The depth stencil texture to use to render
  97880. * @param lodLevel defines le lod level to bind to the frame buffer
  97881. */
  97882. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97883. /** @hidden */
  97884. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97885. /**
  97886. * Unbind the current render target texture from the webGL context
  97887. * @param texture defines the render target texture to unbind
  97888. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97889. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97890. */
  97891. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97892. /**
  97893. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97894. */
  97895. flushFramebuffer(): void;
  97896. /**
  97897. * Unbind the current render target and bind the default framebuffer
  97898. */
  97899. restoreDefaultFramebuffer(): void;
  97900. /** @hidden */
  97901. protected _resetVertexBufferBinding(): void;
  97902. /**
  97903. * Creates a vertex buffer
  97904. * @param data the data for the vertex buffer
  97905. * @returns the new WebGL static buffer
  97906. */
  97907. createVertexBuffer(data: DataArray): DataBuffer;
  97908. private _createVertexBuffer;
  97909. /**
  97910. * Creates a dynamic vertex buffer
  97911. * @param data the data for the dynamic vertex buffer
  97912. * @returns the new WebGL dynamic buffer
  97913. */
  97914. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97915. protected _resetIndexBufferBinding(): void;
  97916. /**
  97917. * Creates a new index buffer
  97918. * @param indices defines the content of the index buffer
  97919. * @param updatable defines if the index buffer must be updatable
  97920. * @returns a new webGL buffer
  97921. */
  97922. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97923. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97924. /**
  97925. * Bind a webGL buffer to the webGL context
  97926. * @param buffer defines the buffer to bind
  97927. */
  97928. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97929. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97930. private bindBuffer;
  97931. /**
  97932. * update the bound buffer with the given data
  97933. * @param data defines the data to update
  97934. */
  97935. updateArrayBuffer(data: Float32Array): void;
  97936. private _vertexAttribPointer;
  97937. private _bindIndexBufferWithCache;
  97938. private _bindVertexBuffersAttributes;
  97939. /**
  97940. * Records a vertex array object
  97941. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97942. * @param vertexBuffers defines the list of vertex buffers to store
  97943. * @param indexBuffer defines the index buffer to store
  97944. * @param effect defines the effect to store
  97945. * @returns the new vertex array object
  97946. */
  97947. recordVertexArrayObject(vertexBuffers: {
  97948. [key: string]: VertexBuffer;
  97949. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97950. /**
  97951. * Bind a specific vertex array object
  97952. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97953. * @param vertexArrayObject defines the vertex array object to bind
  97954. * @param indexBuffer defines the index buffer to bind
  97955. */
  97956. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97957. /**
  97958. * Bind webGl buffers directly to the webGL context
  97959. * @param vertexBuffer defines the vertex buffer to bind
  97960. * @param indexBuffer defines the index buffer to bind
  97961. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97962. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97963. * @param effect defines the effect associated with the vertex buffer
  97964. */
  97965. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97966. private _unbindVertexArrayObject;
  97967. /**
  97968. * Bind a list of vertex buffers to the webGL context
  97969. * @param vertexBuffers defines the list of vertex buffers to bind
  97970. * @param indexBuffer defines the index buffer to bind
  97971. * @param effect defines the effect associated with the vertex buffers
  97972. */
  97973. bindBuffers(vertexBuffers: {
  97974. [key: string]: Nullable<VertexBuffer>;
  97975. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97976. /**
  97977. * Unbind all instance attributes
  97978. */
  97979. unbindInstanceAttributes(): void;
  97980. /**
  97981. * Release and free the memory of a vertex array object
  97982. * @param vao defines the vertex array object to delete
  97983. */
  97984. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97985. /** @hidden */
  97986. _releaseBuffer(buffer: DataBuffer): boolean;
  97987. protected _deleteBuffer(buffer: DataBuffer): void;
  97988. /**
  97989. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97990. * @param instancesBuffer defines the webGL buffer to update and bind
  97991. * @param data defines the data to store in the buffer
  97992. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97993. */
  97994. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97995. /**
  97996. * Apply all cached states (depth, culling, stencil and alpha)
  97997. */
  97998. applyStates(): void;
  97999. /**
  98000. * Send a draw order
  98001. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98002. * @param indexStart defines the starting index
  98003. * @param indexCount defines the number of index to draw
  98004. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98005. */
  98006. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98007. /**
  98008. * Draw a list of points
  98009. * @param verticesStart defines the index of first vertex to draw
  98010. * @param verticesCount defines the count of vertices to draw
  98011. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98012. */
  98013. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98014. /**
  98015. * Draw a list of unindexed primitives
  98016. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98017. * @param verticesStart defines the index of first vertex to draw
  98018. * @param verticesCount defines the count of vertices to draw
  98019. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98020. */
  98021. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98022. /**
  98023. * Draw a list of indexed primitives
  98024. * @param fillMode defines the primitive to use
  98025. * @param indexStart defines the starting index
  98026. * @param indexCount defines the number of index to draw
  98027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98028. */
  98029. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98030. /**
  98031. * Draw a list of unindexed primitives
  98032. * @param fillMode defines the primitive to use
  98033. * @param verticesStart defines the index of first vertex to draw
  98034. * @param verticesCount defines the count of vertices to draw
  98035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98036. */
  98037. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98038. private _drawMode;
  98039. /** @hidden */
  98040. protected _reportDrawCall(): void;
  98041. /** @hidden */
  98042. _releaseEffect(effect: Effect): void;
  98043. /** @hidden */
  98044. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98045. /**
  98046. * Create a new effect (used to store vertex/fragment shaders)
  98047. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98048. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98049. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98050. * @param samplers defines an array of string used to represent textures
  98051. * @param defines defines the string containing the defines to use to compile the shaders
  98052. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98053. * @param onCompiled defines a function to call when the effect creation is successful
  98054. * @param onError defines a function to call when the effect creation has failed
  98055. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98056. * @returns the new Effect
  98057. */
  98058. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  98059. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98060. private _compileShader;
  98061. private _compileRawShader;
  98062. /**
  98063. * Directly creates a webGL program
  98064. * @param pipelineContext defines the pipeline context to attach to
  98065. * @param vertexCode defines the vertex shader code to use
  98066. * @param fragmentCode defines the fragment shader code to use
  98067. * @param context defines the webGL context to use (if not set, the current one will be used)
  98068. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98069. * @returns the new webGL program
  98070. */
  98071. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98072. /**
  98073. * Creates a webGL program
  98074. * @param pipelineContext defines the pipeline context to attach to
  98075. * @param vertexCode defines the vertex shader code to use
  98076. * @param fragmentCode defines the fragment shader code to use
  98077. * @param defines defines the string containing the defines to use to compile the shaders
  98078. * @param context defines the webGL context to use (if not set, the current one will be used)
  98079. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98080. * @returns the new webGL program
  98081. */
  98082. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98083. /**
  98084. * Creates a new pipeline context
  98085. * @returns the new pipeline
  98086. */
  98087. createPipelineContext(): IPipelineContext;
  98088. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98089. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98090. /** @hidden */
  98091. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98092. /** @hidden */
  98093. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98094. /** @hidden */
  98095. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98096. /**
  98097. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98098. * @param pipelineContext defines the pipeline context to use
  98099. * @param uniformsNames defines the list of uniform names
  98100. * @returns an array of webGL uniform locations
  98101. */
  98102. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98103. /**
  98104. * Gets the lsit of active attributes for a given webGL program
  98105. * @param pipelineContext defines the pipeline context to use
  98106. * @param attributesNames defines the list of attribute names to get
  98107. * @returns an array of indices indicating the offset of each attribute
  98108. */
  98109. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98110. /**
  98111. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98112. * @param effect defines the effect to activate
  98113. */
  98114. enableEffect(effect: Nullable<Effect>): void;
  98115. /**
  98116. * Set the value of an uniform to a number (int)
  98117. * @param uniform defines the webGL uniform location where to store the value
  98118. * @param value defines the int number to store
  98119. */
  98120. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98121. /**
  98122. * Set the value of an uniform to an array of int32
  98123. * @param uniform defines the webGL uniform location where to store the value
  98124. * @param array defines the array of int32 to store
  98125. */
  98126. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98127. /**
  98128. * Set the value of an uniform to an array of int32 (stored as vec2)
  98129. * @param uniform defines the webGL uniform location where to store the value
  98130. * @param array defines the array of int32 to store
  98131. */
  98132. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98133. /**
  98134. * Set the value of an uniform to an array of int32 (stored as vec3)
  98135. * @param uniform defines the webGL uniform location where to store the value
  98136. * @param array defines the array of int32 to store
  98137. */
  98138. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98139. /**
  98140. * Set the value of an uniform to an array of int32 (stored as vec4)
  98141. * @param uniform defines the webGL uniform location where to store the value
  98142. * @param array defines the array of int32 to store
  98143. */
  98144. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98145. /**
  98146. * Set the value of an uniform to an array of number
  98147. * @param uniform defines the webGL uniform location where to store the value
  98148. * @param array defines the array of number to store
  98149. */
  98150. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98151. /**
  98152. * Set the value of an uniform to an array of number (stored as vec2)
  98153. * @param uniform defines the webGL uniform location where to store the value
  98154. * @param array defines the array of number to store
  98155. */
  98156. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98157. /**
  98158. * Set the value of an uniform to an array of number (stored as vec3)
  98159. * @param uniform defines the webGL uniform location where to store the value
  98160. * @param array defines the array of number to store
  98161. */
  98162. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98163. /**
  98164. * Set the value of an uniform to an array of number (stored as vec4)
  98165. * @param uniform defines the webGL uniform location where to store the value
  98166. * @param array defines the array of number to store
  98167. */
  98168. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98169. /**
  98170. * Set the value of an uniform to an array of float32 (stored as matrices)
  98171. * @param uniform defines the webGL uniform location where to store the value
  98172. * @param matrices defines the array of float32 to store
  98173. */
  98174. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98175. /**
  98176. * Set the value of an uniform to a matrix (3x3)
  98177. * @param uniform defines the webGL uniform location where to store the value
  98178. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98179. */
  98180. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98181. /**
  98182. * Set the value of an uniform to a matrix (2x2)
  98183. * @param uniform defines the webGL uniform location where to store the value
  98184. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98185. */
  98186. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98187. /**
  98188. * Set the value of an uniform to a number (float)
  98189. * @param uniform defines the webGL uniform location where to store the value
  98190. * @param value defines the float number to store
  98191. */
  98192. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98193. /**
  98194. * Set the value of an uniform to a vec2
  98195. * @param uniform defines the webGL uniform location where to store the value
  98196. * @param x defines the 1st component of the value
  98197. * @param y defines the 2nd component of the value
  98198. */
  98199. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98200. /**
  98201. * Set the value of an uniform to a vec3
  98202. * @param uniform defines the webGL uniform location where to store the value
  98203. * @param x defines the 1st component of the value
  98204. * @param y defines the 2nd component of the value
  98205. * @param z defines the 3rd component of the value
  98206. */
  98207. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98208. /**
  98209. * Set the value of an uniform to a vec4
  98210. * @param uniform defines the webGL uniform location where to store the value
  98211. * @param x defines the 1st component of the value
  98212. * @param y defines the 2nd component of the value
  98213. * @param z defines the 3rd component of the value
  98214. * @param w defines the 4th component of the value
  98215. */
  98216. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98217. /**
  98218. * Gets the depth culling state manager
  98219. */
  98220. readonly depthCullingState: DepthCullingState;
  98221. /**
  98222. * Gets the alpha state manager
  98223. */
  98224. readonly alphaState: AlphaState;
  98225. /**
  98226. * Gets the stencil state manager
  98227. */
  98228. readonly stencilState: StencilState;
  98229. /**
  98230. * Clears the list of texture accessible through engine.
  98231. * This can help preventing texture load conflict due to name collision.
  98232. */
  98233. clearInternalTexturesCache(): void;
  98234. /**
  98235. * Force the entire cache to be cleared
  98236. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98237. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98238. */
  98239. wipeCaches(bruteForce?: boolean): void;
  98240. /** @hidden */
  98241. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98242. min: number;
  98243. mag: number;
  98244. };
  98245. /** @hidden */
  98246. _createTexture(): WebGLTexture;
  98247. /**
  98248. * Usually called from Texture.ts.
  98249. * Passed information to create a WebGLTexture
  98250. * @param urlArg defines a value which contains one of the following:
  98251. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98252. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98253. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98254. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98255. * @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)
  98256. * @param scene needed for loading to the correct scene
  98257. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98258. * @param onLoad optional callback to be called upon successful completion
  98259. * @param onError optional callback to be called upon failure
  98260. * @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
  98261. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98262. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98263. * @param forcedExtension defines the extension to use to pick the right loader
  98264. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98265. * @param mimeType defines an optional mime type
  98266. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98267. */
  98268. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  98269. /**
  98270. * @hidden
  98271. */
  98272. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98273. /**
  98274. * Creates a raw texture
  98275. * @param data defines the data to store in the texture
  98276. * @param width defines the width of the texture
  98277. * @param height defines the height of the texture
  98278. * @param format defines the format of the data
  98279. * @param generateMipMaps defines if the engine should generate the mip levels
  98280. * @param invertY defines if data must be stored with Y axis inverted
  98281. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98282. * @param compression defines the compression used (null by default)
  98283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98284. * @returns the raw texture inside an InternalTexture
  98285. */
  98286. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98287. /**
  98288. * Creates a new raw cube texture
  98289. * @param data defines the array of data to use to create each face
  98290. * @param size defines the size of the textures
  98291. * @param format defines the format of the data
  98292. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98293. * @param generateMipMaps defines if the engine should generate the mip levels
  98294. * @param invertY defines if data must be stored with Y axis inverted
  98295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98296. * @param compression defines the compression used (null by default)
  98297. * @returns the cube texture as an InternalTexture
  98298. */
  98299. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98300. /**
  98301. * Creates a new raw 3D texture
  98302. * @param data defines the data used to create the texture
  98303. * @param width defines the width of the texture
  98304. * @param height defines the height of the texture
  98305. * @param depth defines the depth of the texture
  98306. * @param format defines the format of the texture
  98307. * @param generateMipMaps defines if the engine must generate mip levels
  98308. * @param invertY defines if data must be stored with Y axis inverted
  98309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98310. * @param compression defines the compressed used (can be null)
  98311. * @param textureType defines the compressed used (can be null)
  98312. * @returns a new raw 3D texture (stored in an InternalTexture)
  98313. */
  98314. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98315. /**
  98316. * Creates a new raw 2D array texture
  98317. * @param data defines the data used to create the texture
  98318. * @param width defines the width of the texture
  98319. * @param height defines the height of the texture
  98320. * @param depth defines the number of layers of the texture
  98321. * @param format defines the format of the texture
  98322. * @param generateMipMaps defines if the engine must generate mip levels
  98323. * @param invertY defines if data must be stored with Y axis inverted
  98324. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98325. * @param compression defines the compressed used (can be null)
  98326. * @param textureType defines the compressed used (can be null)
  98327. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98328. */
  98329. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98330. private _unpackFlipYCached;
  98331. /**
  98332. * In case you are sharing the context with other applications, it might
  98333. * be interested to not cache the unpack flip y state to ensure a consistent
  98334. * value would be set.
  98335. */
  98336. enableUnpackFlipYCached: boolean;
  98337. /** @hidden */
  98338. _unpackFlipY(value: boolean): void;
  98339. /** @hidden */
  98340. _getUnpackAlignement(): number;
  98341. /**
  98342. * Update the sampling mode of a given texture
  98343. * @param samplingMode defines the required sampling mode
  98344. * @param texture defines the texture to update
  98345. */
  98346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98347. /** @hidden */
  98348. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98349. width: number;
  98350. height: number;
  98351. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98352. /** @hidden */
  98353. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98354. /** @hidden */
  98355. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98356. /** @hidden */
  98357. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98358. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98359. private _prepareWebGLTexture;
  98360. /** @hidden */
  98361. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98362. /** @hidden */
  98363. _releaseFramebufferObjects(texture: InternalTexture): void;
  98364. /** @hidden */
  98365. _releaseTexture(texture: InternalTexture): void;
  98366. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98367. protected _setProgram(program: WebGLProgram): void;
  98368. protected _boundUniforms: {
  98369. [key: number]: WebGLUniformLocation;
  98370. };
  98371. /**
  98372. * Binds an effect to the webGL context
  98373. * @param effect defines the effect to bind
  98374. */
  98375. bindSamplers(effect: Effect): void;
  98376. private _activateCurrentTexture;
  98377. /** @hidden */
  98378. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98379. /** @hidden */
  98380. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98381. /**
  98382. * Unbind all textures from the webGL context
  98383. */
  98384. unbindAllTextures(): void;
  98385. /**
  98386. * Sets a texture to the according uniform.
  98387. * @param channel The texture channel
  98388. * @param uniform The uniform to set
  98389. * @param texture The texture to apply
  98390. */
  98391. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98392. private _bindSamplerUniformToChannel;
  98393. private _getTextureWrapMode;
  98394. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98395. /**
  98396. * Sets an array of texture to the webGL context
  98397. * @param channel defines the channel where the texture array must be set
  98398. * @param uniform defines the associated uniform location
  98399. * @param textures defines the array of textures to bind
  98400. */
  98401. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98402. /** @hidden */
  98403. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98404. private _setTextureParameterFloat;
  98405. private _setTextureParameterInteger;
  98406. /**
  98407. * Unbind all vertex attributes from the webGL context
  98408. */
  98409. unbindAllAttributes(): void;
  98410. /**
  98411. * 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
  98412. */
  98413. releaseEffects(): void;
  98414. /**
  98415. * Dispose and release all associated resources
  98416. */
  98417. dispose(): void;
  98418. /**
  98419. * Attach a new callback raised when context lost event is fired
  98420. * @param callback defines the callback to call
  98421. */
  98422. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98423. /**
  98424. * Attach a new callback raised when context restored event is fired
  98425. * @param callback defines the callback to call
  98426. */
  98427. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98428. /**
  98429. * Get the current error code of the webGL context
  98430. * @returns the error code
  98431. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98432. */
  98433. getError(): number;
  98434. private _canRenderToFloatFramebuffer;
  98435. private _canRenderToHalfFloatFramebuffer;
  98436. private _canRenderToFramebuffer;
  98437. /** @hidden */
  98438. _getWebGLTextureType(type: number): number;
  98439. /** @hidden */
  98440. _getInternalFormat(format: number): number;
  98441. /** @hidden */
  98442. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98443. /** @hidden */
  98444. _getRGBAMultiSampleBufferFormat(type: number): number;
  98445. /** @hidden */
  98446. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  98447. /**
  98448. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98449. * @returns true if the engine can be created
  98450. * @ignorenaming
  98451. */
  98452. static isSupported(): boolean;
  98453. /**
  98454. * Find the next highest power of two.
  98455. * @param x Number to start search from.
  98456. * @return Next highest power of two.
  98457. */
  98458. static CeilingPOT(x: number): number;
  98459. /**
  98460. * Find the next lowest power of two.
  98461. * @param x Number to start search from.
  98462. * @return Next lowest power of two.
  98463. */
  98464. static FloorPOT(x: number): number;
  98465. /**
  98466. * Find the nearest power of two.
  98467. * @param x Number to start search from.
  98468. * @return Next nearest power of two.
  98469. */
  98470. static NearestPOT(x: number): number;
  98471. /**
  98472. * Get the closest exponent of two
  98473. * @param value defines the value to approximate
  98474. * @param max defines the maximum value to return
  98475. * @param mode defines how to define the closest value
  98476. * @returns closest exponent of two of the given value
  98477. */
  98478. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98479. /**
  98480. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98481. * @param func - the function to be called
  98482. * @param requester - the object that will request the next frame. Falls back to window.
  98483. * @returns frame number
  98484. */
  98485. static QueueNewFrame(func: () => void, requester?: any): number;
  98486. }
  98487. }
  98488. declare module BABYLON {
  98489. /**
  98490. * Class representing spherical harmonics coefficients to the 3rd degree
  98491. */
  98492. export class SphericalHarmonics {
  98493. /**
  98494. * Defines whether or not the harmonics have been prescaled for rendering.
  98495. */
  98496. preScaled: boolean;
  98497. /**
  98498. * The l0,0 coefficients of the spherical harmonics
  98499. */
  98500. l00: Vector3;
  98501. /**
  98502. * The l1,-1 coefficients of the spherical harmonics
  98503. */
  98504. l1_1: Vector3;
  98505. /**
  98506. * The l1,0 coefficients of the spherical harmonics
  98507. */
  98508. l10: Vector3;
  98509. /**
  98510. * The l1,1 coefficients of the spherical harmonics
  98511. */
  98512. l11: Vector3;
  98513. /**
  98514. * The l2,-2 coefficients of the spherical harmonics
  98515. */
  98516. l2_2: Vector3;
  98517. /**
  98518. * The l2,-1 coefficients of the spherical harmonics
  98519. */
  98520. l2_1: Vector3;
  98521. /**
  98522. * The l2,0 coefficients of the spherical harmonics
  98523. */
  98524. l20: Vector3;
  98525. /**
  98526. * The l2,1 coefficients of the spherical harmonics
  98527. */
  98528. l21: Vector3;
  98529. /**
  98530. * The l2,2 coefficients of the spherical harmonics
  98531. */
  98532. l22: Vector3;
  98533. /**
  98534. * Adds a light to the spherical harmonics
  98535. * @param direction the direction of the light
  98536. * @param color the color of the light
  98537. * @param deltaSolidAngle the delta solid angle of the light
  98538. */
  98539. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98540. /**
  98541. * Scales the spherical harmonics by the given amount
  98542. * @param scale the amount to scale
  98543. */
  98544. scaleInPlace(scale: number): void;
  98545. /**
  98546. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98547. *
  98548. * ```
  98549. * E_lm = A_l * L_lm
  98550. * ```
  98551. *
  98552. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98553. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98554. * the scaling factors are given in equation 9.
  98555. */
  98556. convertIncidentRadianceToIrradiance(): void;
  98557. /**
  98558. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98559. *
  98560. * ```
  98561. * L = (1/pi) * E * rho
  98562. * ```
  98563. *
  98564. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98565. */
  98566. convertIrradianceToLambertianRadiance(): void;
  98567. /**
  98568. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98569. * required operations at run time.
  98570. *
  98571. * This is simply done by scaling back the SH with Ylm constants parameter.
  98572. * The trigonometric part being applied by the shader at run time.
  98573. */
  98574. preScaleForRendering(): void;
  98575. /**
  98576. * Constructs a spherical harmonics from an array.
  98577. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98578. * @returns the spherical harmonics
  98579. */
  98580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98581. /**
  98582. * Gets the spherical harmonics from polynomial
  98583. * @param polynomial the spherical polynomial
  98584. * @returns the spherical harmonics
  98585. */
  98586. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98587. }
  98588. /**
  98589. * Class representing spherical polynomial coefficients to the 3rd degree
  98590. */
  98591. export class SphericalPolynomial {
  98592. private _harmonics;
  98593. /**
  98594. * The spherical harmonics used to create the polynomials.
  98595. */
  98596. readonly preScaledHarmonics: SphericalHarmonics;
  98597. /**
  98598. * The x coefficients of the spherical polynomial
  98599. */
  98600. x: Vector3;
  98601. /**
  98602. * The y coefficients of the spherical polynomial
  98603. */
  98604. y: Vector3;
  98605. /**
  98606. * The z coefficients of the spherical polynomial
  98607. */
  98608. z: Vector3;
  98609. /**
  98610. * The xx coefficients of the spherical polynomial
  98611. */
  98612. xx: Vector3;
  98613. /**
  98614. * The yy coefficients of the spherical polynomial
  98615. */
  98616. yy: Vector3;
  98617. /**
  98618. * The zz coefficients of the spherical polynomial
  98619. */
  98620. zz: Vector3;
  98621. /**
  98622. * The xy coefficients of the spherical polynomial
  98623. */
  98624. xy: Vector3;
  98625. /**
  98626. * The yz coefficients of the spherical polynomial
  98627. */
  98628. yz: Vector3;
  98629. /**
  98630. * The zx coefficients of the spherical polynomial
  98631. */
  98632. zx: Vector3;
  98633. /**
  98634. * Adds an ambient color to the spherical polynomial
  98635. * @param color the color to add
  98636. */
  98637. addAmbient(color: Color3): void;
  98638. /**
  98639. * Scales the spherical polynomial by the given amount
  98640. * @param scale the amount to scale
  98641. */
  98642. scaleInPlace(scale: number): void;
  98643. /**
  98644. * Gets the spherical polynomial from harmonics
  98645. * @param harmonics the spherical harmonics
  98646. * @returns the spherical polynomial
  98647. */
  98648. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98649. /**
  98650. * Constructs a spherical polynomial from an array.
  98651. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98652. * @returns the spherical polynomial
  98653. */
  98654. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98655. }
  98656. }
  98657. declare module BABYLON {
  98658. /**
  98659. * Defines the source of the internal texture
  98660. */
  98661. export enum InternalTextureSource {
  98662. /**
  98663. * The source of the texture data is unknown
  98664. */
  98665. Unknown = 0,
  98666. /**
  98667. * Texture data comes from an URL
  98668. */
  98669. Url = 1,
  98670. /**
  98671. * Texture data is only used for temporary storage
  98672. */
  98673. Temp = 2,
  98674. /**
  98675. * Texture data comes from raw data (ArrayBuffer)
  98676. */
  98677. Raw = 3,
  98678. /**
  98679. * Texture content is dynamic (video or dynamic texture)
  98680. */
  98681. Dynamic = 4,
  98682. /**
  98683. * Texture content is generated by rendering to it
  98684. */
  98685. RenderTarget = 5,
  98686. /**
  98687. * Texture content is part of a multi render target process
  98688. */
  98689. MultiRenderTarget = 6,
  98690. /**
  98691. * Texture data comes from a cube data file
  98692. */
  98693. Cube = 7,
  98694. /**
  98695. * Texture data comes from a raw cube data
  98696. */
  98697. CubeRaw = 8,
  98698. /**
  98699. * Texture data come from a prefiltered cube data file
  98700. */
  98701. CubePrefiltered = 9,
  98702. /**
  98703. * Texture content is raw 3D data
  98704. */
  98705. Raw3D = 10,
  98706. /**
  98707. * Texture content is raw 2D array data
  98708. */
  98709. Raw2DArray = 11,
  98710. /**
  98711. * Texture content is a depth texture
  98712. */
  98713. Depth = 12,
  98714. /**
  98715. * Texture data comes from a raw cube data encoded with RGBD
  98716. */
  98717. CubeRawRGBD = 13
  98718. }
  98719. /**
  98720. * Class used to store data associated with WebGL texture data for the engine
  98721. * This class should not be used directly
  98722. */
  98723. export class InternalTexture {
  98724. /** @hidden */
  98725. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  98726. /**
  98727. * Defines if the texture is ready
  98728. */
  98729. isReady: boolean;
  98730. /**
  98731. * Defines if the texture is a cube texture
  98732. */
  98733. isCube: boolean;
  98734. /**
  98735. * Defines if the texture contains 3D data
  98736. */
  98737. is3D: boolean;
  98738. /**
  98739. * Defines if the texture contains 2D array data
  98740. */
  98741. is2DArray: boolean;
  98742. /**
  98743. * Defines if the texture contains multiview data
  98744. */
  98745. isMultiview: boolean;
  98746. /**
  98747. * Gets the URL used to load this texture
  98748. */
  98749. url: string;
  98750. /**
  98751. * Gets the sampling mode of the texture
  98752. */
  98753. samplingMode: number;
  98754. /**
  98755. * Gets a boolean indicating if the texture needs mipmaps generation
  98756. */
  98757. generateMipMaps: boolean;
  98758. /**
  98759. * Gets the number of samples used by the texture (WebGL2+ only)
  98760. */
  98761. samples: number;
  98762. /**
  98763. * Gets the type of the texture (int, float...)
  98764. */
  98765. type: number;
  98766. /**
  98767. * Gets the format of the texture (RGB, RGBA...)
  98768. */
  98769. format: number;
  98770. /**
  98771. * Observable called when the texture is loaded
  98772. */
  98773. onLoadedObservable: Observable<InternalTexture>;
  98774. /**
  98775. * Gets the width of the texture
  98776. */
  98777. width: number;
  98778. /**
  98779. * Gets the height of the texture
  98780. */
  98781. height: number;
  98782. /**
  98783. * Gets the depth of the texture
  98784. */
  98785. depth: number;
  98786. /**
  98787. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98788. */
  98789. baseWidth: number;
  98790. /**
  98791. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98792. */
  98793. baseHeight: number;
  98794. /**
  98795. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98796. */
  98797. baseDepth: number;
  98798. /**
  98799. * Gets a boolean indicating if the texture is inverted on Y axis
  98800. */
  98801. invertY: boolean;
  98802. /** @hidden */
  98803. _invertVScale: boolean;
  98804. /** @hidden */
  98805. _associatedChannel: number;
  98806. /** @hidden */
  98807. _source: InternalTextureSource;
  98808. /** @hidden */
  98809. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98810. /** @hidden */
  98811. _bufferView: Nullable<ArrayBufferView>;
  98812. /** @hidden */
  98813. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98814. /** @hidden */
  98815. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98816. /** @hidden */
  98817. _size: number;
  98818. /** @hidden */
  98819. _extension: string;
  98820. /** @hidden */
  98821. _files: Nullable<string[]>;
  98822. /** @hidden */
  98823. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98824. /** @hidden */
  98825. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98826. /** @hidden */
  98827. _framebuffer: Nullable<WebGLFramebuffer>;
  98828. /** @hidden */
  98829. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98830. /** @hidden */
  98831. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98832. /** @hidden */
  98833. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98834. /** @hidden */
  98835. _attachments: Nullable<number[]>;
  98836. /** @hidden */
  98837. _cachedCoordinatesMode: Nullable<number>;
  98838. /** @hidden */
  98839. _cachedWrapU: Nullable<number>;
  98840. /** @hidden */
  98841. _cachedWrapV: Nullable<number>;
  98842. /** @hidden */
  98843. _cachedWrapR: Nullable<number>;
  98844. /** @hidden */
  98845. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98846. /** @hidden */
  98847. _isDisabled: boolean;
  98848. /** @hidden */
  98849. _compression: Nullable<string>;
  98850. /** @hidden */
  98851. _generateStencilBuffer: boolean;
  98852. /** @hidden */
  98853. _generateDepthBuffer: boolean;
  98854. /** @hidden */
  98855. _comparisonFunction: number;
  98856. /** @hidden */
  98857. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98858. /** @hidden */
  98859. _lodGenerationScale: number;
  98860. /** @hidden */
  98861. _lodGenerationOffset: number;
  98862. /** @hidden */
  98863. _colorTextureArray: Nullable<WebGLTexture>;
  98864. /** @hidden */
  98865. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98866. /** @hidden */
  98867. _lodTextureHigh: Nullable<BaseTexture>;
  98868. /** @hidden */
  98869. _lodTextureMid: Nullable<BaseTexture>;
  98870. /** @hidden */
  98871. _lodTextureLow: Nullable<BaseTexture>;
  98872. /** @hidden */
  98873. _isRGBD: boolean;
  98874. /** @hidden */
  98875. _linearSpecularLOD: boolean;
  98876. /** @hidden */
  98877. _irradianceTexture: Nullable<BaseTexture>;
  98878. /** @hidden */
  98879. _webGLTexture: Nullable<WebGLTexture>;
  98880. /** @hidden */
  98881. _references: number;
  98882. private _engine;
  98883. /**
  98884. * Gets the Engine the texture belongs to.
  98885. * @returns The babylon engine
  98886. */
  98887. getEngine(): ThinEngine;
  98888. /**
  98889. * Gets the data source type of the texture
  98890. */
  98891. readonly source: InternalTextureSource;
  98892. /**
  98893. * Creates a new InternalTexture
  98894. * @param engine defines the engine to use
  98895. * @param source defines the type of data that will be used
  98896. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98897. */
  98898. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98899. /**
  98900. * Increments the number of references (ie. the number of Texture that point to it)
  98901. */
  98902. incrementReferences(): void;
  98903. /**
  98904. * Change the size of the texture (not the size of the content)
  98905. * @param width defines the new width
  98906. * @param height defines the new height
  98907. * @param depth defines the new depth (1 by default)
  98908. */
  98909. updateSize(width: int, height: int, depth?: int): void;
  98910. /** @hidden */
  98911. _rebuild(): void;
  98912. /** @hidden */
  98913. _swapAndDie(target: InternalTexture): void;
  98914. /**
  98915. * Dispose the current allocated resources
  98916. */
  98917. dispose(): void;
  98918. }
  98919. }
  98920. declare module BABYLON {
  98921. /**
  98922. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98924. */
  98925. export class Analyser {
  98926. /**
  98927. * Gets or sets the smoothing
  98928. * @ignorenaming
  98929. */
  98930. SMOOTHING: number;
  98931. /**
  98932. * Gets or sets the FFT table size
  98933. * @ignorenaming
  98934. */
  98935. FFT_SIZE: number;
  98936. /**
  98937. * Gets or sets the bar graph amplitude
  98938. * @ignorenaming
  98939. */
  98940. BARGRAPHAMPLITUDE: number;
  98941. /**
  98942. * Gets or sets the position of the debug canvas
  98943. * @ignorenaming
  98944. */
  98945. DEBUGCANVASPOS: {
  98946. x: number;
  98947. y: number;
  98948. };
  98949. /**
  98950. * Gets or sets the debug canvas size
  98951. * @ignorenaming
  98952. */
  98953. DEBUGCANVASSIZE: {
  98954. width: number;
  98955. height: number;
  98956. };
  98957. private _byteFreqs;
  98958. private _byteTime;
  98959. private _floatFreqs;
  98960. private _webAudioAnalyser;
  98961. private _debugCanvas;
  98962. private _debugCanvasContext;
  98963. private _scene;
  98964. private _registerFunc;
  98965. private _audioEngine;
  98966. /**
  98967. * Creates a new analyser
  98968. * @param scene defines hosting scene
  98969. */
  98970. constructor(scene: Scene);
  98971. /**
  98972. * Get the number of data values you will have to play with for the visualization
  98973. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98974. * @returns a number
  98975. */
  98976. getFrequencyBinCount(): number;
  98977. /**
  98978. * Gets the current frequency data as a byte array
  98979. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98980. * @returns a Uint8Array
  98981. */
  98982. getByteFrequencyData(): Uint8Array;
  98983. /**
  98984. * Gets the current waveform as a byte array
  98985. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98986. * @returns a Uint8Array
  98987. */
  98988. getByteTimeDomainData(): Uint8Array;
  98989. /**
  98990. * Gets the current frequency data as a float array
  98991. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98992. * @returns a Float32Array
  98993. */
  98994. getFloatFrequencyData(): Float32Array;
  98995. /**
  98996. * Renders the debug canvas
  98997. */
  98998. drawDebugCanvas(): void;
  98999. /**
  99000. * Stops rendering the debug canvas and removes it
  99001. */
  99002. stopDebugCanvas(): void;
  99003. /**
  99004. * Connects two audio nodes
  99005. * @param inputAudioNode defines first node to connect
  99006. * @param outputAudioNode defines second node to connect
  99007. */
  99008. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99009. /**
  99010. * Releases all associated resources
  99011. */
  99012. dispose(): void;
  99013. }
  99014. }
  99015. declare module BABYLON {
  99016. /**
  99017. * This represents an audio engine and it is responsible
  99018. * to play, synchronize and analyse sounds throughout the application.
  99019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99020. */
  99021. export interface IAudioEngine extends IDisposable {
  99022. /**
  99023. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99024. */
  99025. readonly canUseWebAudio: boolean;
  99026. /**
  99027. * Gets the current AudioContext if available.
  99028. */
  99029. readonly audioContext: Nullable<AudioContext>;
  99030. /**
  99031. * The master gain node defines the global audio volume of your audio engine.
  99032. */
  99033. readonly masterGain: GainNode;
  99034. /**
  99035. * Gets whether or not mp3 are supported by your browser.
  99036. */
  99037. readonly isMP3supported: boolean;
  99038. /**
  99039. * Gets whether or not ogg are supported by your browser.
  99040. */
  99041. readonly isOGGsupported: boolean;
  99042. /**
  99043. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99044. * @ignoreNaming
  99045. */
  99046. WarnedWebAudioUnsupported: boolean;
  99047. /**
  99048. * Defines if the audio engine relies on a custom unlocked button.
  99049. * In this case, the embedded button will not be displayed.
  99050. */
  99051. useCustomUnlockedButton: boolean;
  99052. /**
  99053. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99054. */
  99055. readonly unlocked: boolean;
  99056. /**
  99057. * Event raised when audio has been unlocked on the browser.
  99058. */
  99059. onAudioUnlockedObservable: Observable<AudioEngine>;
  99060. /**
  99061. * Event raised when audio has been locked on the browser.
  99062. */
  99063. onAudioLockedObservable: Observable<AudioEngine>;
  99064. /**
  99065. * Flags the audio engine in Locked state.
  99066. * This happens due to new browser policies preventing audio to autoplay.
  99067. */
  99068. lock(): void;
  99069. /**
  99070. * Unlocks the audio engine once a user action has been done on the dom.
  99071. * This is helpful to resume play once browser policies have been satisfied.
  99072. */
  99073. unlock(): void;
  99074. }
  99075. /**
  99076. * This represents the default audio engine used in babylon.
  99077. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99079. */
  99080. export class AudioEngine implements IAudioEngine {
  99081. private _audioContext;
  99082. private _audioContextInitialized;
  99083. private _muteButton;
  99084. private _hostElement;
  99085. /**
  99086. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99087. */
  99088. canUseWebAudio: boolean;
  99089. /**
  99090. * The master gain node defines the global audio volume of your audio engine.
  99091. */
  99092. masterGain: GainNode;
  99093. /**
  99094. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99095. * @ignoreNaming
  99096. */
  99097. WarnedWebAudioUnsupported: boolean;
  99098. /**
  99099. * Gets whether or not mp3 are supported by your browser.
  99100. */
  99101. isMP3supported: boolean;
  99102. /**
  99103. * Gets whether or not ogg are supported by your browser.
  99104. */
  99105. isOGGsupported: boolean;
  99106. /**
  99107. * Gets whether audio has been unlocked on the device.
  99108. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99109. * a user interaction has happened.
  99110. */
  99111. unlocked: boolean;
  99112. /**
  99113. * Defines if the audio engine relies on a custom unlocked button.
  99114. * In this case, the embedded button will not be displayed.
  99115. */
  99116. useCustomUnlockedButton: boolean;
  99117. /**
  99118. * Event raised when audio has been unlocked on the browser.
  99119. */
  99120. onAudioUnlockedObservable: Observable<AudioEngine>;
  99121. /**
  99122. * Event raised when audio has been locked on the browser.
  99123. */
  99124. onAudioLockedObservable: Observable<AudioEngine>;
  99125. /**
  99126. * Gets the current AudioContext if available.
  99127. */
  99128. readonly audioContext: Nullable<AudioContext>;
  99129. private _connectedAnalyser;
  99130. /**
  99131. * Instantiates a new audio engine.
  99132. *
  99133. * There should be only one per page as some browsers restrict the number
  99134. * of audio contexts you can create.
  99135. * @param hostElement defines the host element where to display the mute icon if necessary
  99136. */
  99137. constructor(hostElement?: Nullable<HTMLElement>);
  99138. /**
  99139. * Flags the audio engine in Locked state.
  99140. * This happens due to new browser policies preventing audio to autoplay.
  99141. */
  99142. lock(): void;
  99143. /**
  99144. * Unlocks the audio engine once a user action has been done on the dom.
  99145. * This is helpful to resume play once browser policies have been satisfied.
  99146. */
  99147. unlock(): void;
  99148. private _resumeAudioContext;
  99149. private _initializeAudioContext;
  99150. private _tryToRun;
  99151. private _triggerRunningState;
  99152. private _triggerSuspendedState;
  99153. private _displayMuteButton;
  99154. private _moveButtonToTopLeft;
  99155. private _onResize;
  99156. private _hideMuteButton;
  99157. /**
  99158. * Destroy and release the resources associated with the audio ccontext.
  99159. */
  99160. dispose(): void;
  99161. /**
  99162. * Gets the global volume sets on the master gain.
  99163. * @returns the global volume if set or -1 otherwise
  99164. */
  99165. getGlobalVolume(): number;
  99166. /**
  99167. * Sets the global volume of your experience (sets on the master gain).
  99168. * @param newVolume Defines the new global volume of the application
  99169. */
  99170. setGlobalVolume(newVolume: number): void;
  99171. /**
  99172. * Connect the audio engine to an audio analyser allowing some amazing
  99173. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99175. * @param analyser The analyser to connect to the engine
  99176. */
  99177. connectToAnalyser(analyser: Analyser): void;
  99178. }
  99179. }
  99180. declare module BABYLON {
  99181. /**
  99182. * Interface used to present a loading screen while loading a scene
  99183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99184. */
  99185. export interface ILoadingScreen {
  99186. /**
  99187. * Function called to display the loading screen
  99188. */
  99189. displayLoadingUI: () => void;
  99190. /**
  99191. * Function called to hide the loading screen
  99192. */
  99193. hideLoadingUI: () => void;
  99194. /**
  99195. * Gets or sets the color to use for the background
  99196. */
  99197. loadingUIBackgroundColor: string;
  99198. /**
  99199. * Gets or sets the text to display while loading
  99200. */
  99201. loadingUIText: string;
  99202. }
  99203. /**
  99204. * Class used for the default loading screen
  99205. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99206. */
  99207. export class DefaultLoadingScreen implements ILoadingScreen {
  99208. private _renderingCanvas;
  99209. private _loadingText;
  99210. private _loadingDivBackgroundColor;
  99211. private _loadingDiv;
  99212. private _loadingTextDiv;
  99213. /** Gets or sets the logo url to use for the default loading screen */
  99214. static DefaultLogoUrl: string;
  99215. /** Gets or sets the spinner url to use for the default loading screen */
  99216. static DefaultSpinnerUrl: string;
  99217. /**
  99218. * Creates a new default loading screen
  99219. * @param _renderingCanvas defines the canvas used to render the scene
  99220. * @param _loadingText defines the default text to display
  99221. * @param _loadingDivBackgroundColor defines the default background color
  99222. */
  99223. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99224. /**
  99225. * Function called to display the loading screen
  99226. */
  99227. displayLoadingUI(): void;
  99228. /**
  99229. * Function called to hide the loading screen
  99230. */
  99231. hideLoadingUI(): void;
  99232. /**
  99233. * Gets or sets the text to display while loading
  99234. */
  99235. loadingUIText: string;
  99236. /**
  99237. * Gets or sets the color to use for the background
  99238. */
  99239. loadingUIBackgroundColor: string;
  99240. private _resizeLoadingUI;
  99241. }
  99242. }
  99243. declare module BABYLON {
  99244. /**
  99245. * Interface for any object that can request an animation frame
  99246. */
  99247. export interface ICustomAnimationFrameRequester {
  99248. /**
  99249. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99250. */
  99251. renderFunction?: Function;
  99252. /**
  99253. * Called to request the next frame to render to
  99254. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99255. */
  99256. requestAnimationFrame: Function;
  99257. /**
  99258. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99259. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99260. */
  99261. requestID?: number;
  99262. }
  99263. }
  99264. declare module BABYLON {
  99265. /**
  99266. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99267. */
  99268. export class PerformanceMonitor {
  99269. private _enabled;
  99270. private _rollingFrameTime;
  99271. private _lastFrameTimeMs;
  99272. /**
  99273. * constructor
  99274. * @param frameSampleSize The number of samples required to saturate the sliding window
  99275. */
  99276. constructor(frameSampleSize?: number);
  99277. /**
  99278. * Samples current frame
  99279. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99280. */
  99281. sampleFrame(timeMs?: number): void;
  99282. /**
  99283. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99284. */
  99285. readonly averageFrameTime: number;
  99286. /**
  99287. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99288. */
  99289. readonly averageFrameTimeVariance: number;
  99290. /**
  99291. * Returns the frame time of the most recent frame
  99292. */
  99293. readonly instantaneousFrameTime: number;
  99294. /**
  99295. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99296. */
  99297. readonly averageFPS: number;
  99298. /**
  99299. * Returns the average framerate in frames per second using the most recent frame time
  99300. */
  99301. readonly instantaneousFPS: number;
  99302. /**
  99303. * Returns true if enough samples have been taken to completely fill the sliding window
  99304. */
  99305. readonly isSaturated: boolean;
  99306. /**
  99307. * Enables contributions to the sliding window sample set
  99308. */
  99309. enable(): void;
  99310. /**
  99311. * Disables contributions to the sliding window sample set
  99312. * Samples will not be interpolated over the disabled period
  99313. */
  99314. disable(): void;
  99315. /**
  99316. * Returns true if sampling is enabled
  99317. */
  99318. readonly isEnabled: boolean;
  99319. /**
  99320. * Resets performance monitor
  99321. */
  99322. reset(): void;
  99323. }
  99324. /**
  99325. * RollingAverage
  99326. *
  99327. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99328. */
  99329. export class RollingAverage {
  99330. /**
  99331. * Current average
  99332. */
  99333. average: number;
  99334. /**
  99335. * Current variance
  99336. */
  99337. variance: number;
  99338. protected _samples: Array<number>;
  99339. protected _sampleCount: number;
  99340. protected _pos: number;
  99341. protected _m2: number;
  99342. /**
  99343. * constructor
  99344. * @param length The number of samples required to saturate the sliding window
  99345. */
  99346. constructor(length: number);
  99347. /**
  99348. * Adds a sample to the sample set
  99349. * @param v The sample value
  99350. */
  99351. add(v: number): void;
  99352. /**
  99353. * Returns previously added values or null if outside of history or outside the sliding window domain
  99354. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99355. * @return Value previously recorded with add() or null if outside of range
  99356. */
  99357. history(i: number): number;
  99358. /**
  99359. * Returns true if enough samples have been taken to completely fill the sliding window
  99360. * @return true if sample-set saturated
  99361. */
  99362. isSaturated(): boolean;
  99363. /**
  99364. * Resets the rolling average (equivalent to 0 samples taken so far)
  99365. */
  99366. reset(): void;
  99367. /**
  99368. * Wraps a value around the sample range boundaries
  99369. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99370. * @return Wrapped position in sample range
  99371. */
  99372. protected _wrapPosition(i: number): number;
  99373. }
  99374. }
  99375. declare module BABYLON {
  99376. /**
  99377. * This class is used to track a performance counter which is number based.
  99378. * The user has access to many properties which give statistics of different nature.
  99379. *
  99380. * The implementer can track two kinds of Performance Counter: time and count.
  99381. * 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.
  99382. * 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.
  99383. */
  99384. export class PerfCounter {
  99385. /**
  99386. * Gets or sets a global boolean to turn on and off all the counters
  99387. */
  99388. static Enabled: boolean;
  99389. /**
  99390. * Returns the smallest value ever
  99391. */
  99392. readonly min: number;
  99393. /**
  99394. * Returns the biggest value ever
  99395. */
  99396. readonly max: number;
  99397. /**
  99398. * Returns the average value since the performance counter is running
  99399. */
  99400. readonly average: number;
  99401. /**
  99402. * Returns the average value of the last second the counter was monitored
  99403. */
  99404. readonly lastSecAverage: number;
  99405. /**
  99406. * Returns the current value
  99407. */
  99408. readonly current: number;
  99409. /**
  99410. * Gets the accumulated total
  99411. */
  99412. readonly total: number;
  99413. /**
  99414. * Gets the total value count
  99415. */
  99416. readonly count: number;
  99417. /**
  99418. * Creates a new counter
  99419. */
  99420. constructor();
  99421. /**
  99422. * Call this method to start monitoring a new frame.
  99423. * 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.
  99424. */
  99425. fetchNewFrame(): void;
  99426. /**
  99427. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99428. * @param newCount the count value to add to the monitored count
  99429. * @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.
  99430. */
  99431. addCount(newCount: number, fetchResult: boolean): void;
  99432. /**
  99433. * Start monitoring this performance counter
  99434. */
  99435. beginMonitoring(): void;
  99436. /**
  99437. * Compute the time lapsed since the previous beginMonitoring() call.
  99438. * @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
  99439. */
  99440. endMonitoring(newFrame?: boolean): void;
  99441. private _fetchResult;
  99442. private _startMonitoringTime;
  99443. private _min;
  99444. private _max;
  99445. private _average;
  99446. private _current;
  99447. private _totalValueCount;
  99448. private _totalAccumulated;
  99449. private _lastSecAverage;
  99450. private _lastSecAccumulated;
  99451. private _lastSecTime;
  99452. private _lastSecValueCount;
  99453. }
  99454. }
  99455. declare module BABYLON {
  99456. /**
  99457. * Defines the interface used by display changed events
  99458. */
  99459. export interface IDisplayChangedEventArgs {
  99460. /** Gets the vrDisplay object (if any) */
  99461. vrDisplay: Nullable<any>;
  99462. /** Gets a boolean indicating if webVR is supported */
  99463. vrSupported: boolean;
  99464. }
  99465. /**
  99466. * Defines the interface used by objects containing a viewport (like a camera)
  99467. */
  99468. interface IViewportOwnerLike {
  99469. /**
  99470. * Gets or sets the viewport
  99471. */
  99472. viewport: IViewportLike;
  99473. }
  99474. /**
  99475. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99476. */
  99477. export class Engine extends ThinEngine {
  99478. /** Defines that alpha blending is disabled */
  99479. static readonly ALPHA_DISABLE: number;
  99480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99481. static readonly ALPHA_ADD: number;
  99482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99483. static readonly ALPHA_COMBINE: number;
  99484. /** Defines that alpha blending to DEST - SRC * DEST */
  99485. static readonly ALPHA_SUBTRACT: number;
  99486. /** Defines that alpha blending to SRC * DEST */
  99487. static readonly ALPHA_MULTIPLY: number;
  99488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99489. static readonly ALPHA_MAXIMIZED: number;
  99490. /** Defines that alpha blending to SRC + DEST */
  99491. static readonly ALPHA_ONEONE: number;
  99492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99493. static readonly ALPHA_PREMULTIPLIED: number;
  99494. /**
  99495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99497. */
  99498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99500. static readonly ALPHA_INTERPOLATE: number;
  99501. /**
  99502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99504. */
  99505. static readonly ALPHA_SCREENMODE: number;
  99506. /** Defines that the ressource is not delayed*/
  99507. static readonly DELAYLOADSTATE_NONE: number;
  99508. /** Defines that the ressource was successfully delay loaded */
  99509. static readonly DELAYLOADSTATE_LOADED: number;
  99510. /** Defines that the ressource is currently delay loading */
  99511. static readonly DELAYLOADSTATE_LOADING: number;
  99512. /** Defines that the ressource is delayed and has not started loading */
  99513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99515. static readonly NEVER: number;
  99516. /** 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 */
  99517. static readonly ALWAYS: number;
  99518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99519. static readonly LESS: number;
  99520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99521. static readonly EQUAL: number;
  99522. /** 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 */
  99523. static readonly LEQUAL: number;
  99524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99525. static readonly GREATER: number;
  99526. /** 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 */
  99527. static readonly GEQUAL: number;
  99528. /** 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 */
  99529. static readonly NOTEQUAL: number;
  99530. /** Passed to stencilOperation to specify that stencil value must be kept */
  99531. static readonly KEEP: number;
  99532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99533. static readonly REPLACE: number;
  99534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99535. static readonly INCR: number;
  99536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99537. static readonly DECR: number;
  99538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99539. static readonly INVERT: number;
  99540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99541. static readonly INCR_WRAP: number;
  99542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99543. static readonly DECR_WRAP: number;
  99544. /** Texture is not repeating outside of 0..1 UVs */
  99545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99546. /** Texture is repeating outside of 0..1 UVs */
  99547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99548. /** Texture is repeating and mirrored */
  99549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99550. /** ALPHA */
  99551. static readonly TEXTUREFORMAT_ALPHA: number;
  99552. /** LUMINANCE */
  99553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99554. /** LUMINANCE_ALPHA */
  99555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99556. /** RGB */
  99557. static readonly TEXTUREFORMAT_RGB: number;
  99558. /** RGBA */
  99559. static readonly TEXTUREFORMAT_RGBA: number;
  99560. /** RED */
  99561. static readonly TEXTUREFORMAT_RED: number;
  99562. /** RED (2nd reference) */
  99563. static readonly TEXTUREFORMAT_R: number;
  99564. /** RG */
  99565. static readonly TEXTUREFORMAT_RG: number;
  99566. /** RED_INTEGER */
  99567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99568. /** RED_INTEGER (2nd reference) */
  99569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99570. /** RG_INTEGER */
  99571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99572. /** RGB_INTEGER */
  99573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99574. /** RGBA_INTEGER */
  99575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99576. /** UNSIGNED_BYTE */
  99577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99578. /** UNSIGNED_BYTE (2nd reference) */
  99579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99580. /** FLOAT */
  99581. static readonly TEXTURETYPE_FLOAT: number;
  99582. /** HALF_FLOAT */
  99583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99584. /** BYTE */
  99585. static readonly TEXTURETYPE_BYTE: number;
  99586. /** SHORT */
  99587. static readonly TEXTURETYPE_SHORT: number;
  99588. /** UNSIGNED_SHORT */
  99589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99590. /** INT */
  99591. static readonly TEXTURETYPE_INT: number;
  99592. /** UNSIGNED_INT */
  99593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99594. /** UNSIGNED_SHORT_4_4_4_4 */
  99595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99596. /** UNSIGNED_SHORT_5_5_5_1 */
  99597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99598. /** UNSIGNED_SHORT_5_6_5 */
  99599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99600. /** UNSIGNED_INT_2_10_10_10_REV */
  99601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99602. /** UNSIGNED_INT_24_8 */
  99603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99604. /** UNSIGNED_INT_10F_11F_11F_REV */
  99605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99606. /** UNSIGNED_INT_5_9_9_9_REV */
  99607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99610. /** nearest is mag = nearest and min = nearest and mip = linear */
  99611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99614. /** Trilinear is mag = linear and min = linear and mip = linear */
  99615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99616. /** nearest is mag = nearest and min = nearest and mip = linear */
  99617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99620. /** Trilinear is mag = linear and min = linear and mip = linear */
  99621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99622. /** mag = nearest and min = nearest and mip = nearest */
  99623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99624. /** mag = nearest and min = linear and mip = nearest */
  99625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99626. /** mag = nearest and min = linear and mip = linear */
  99627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99628. /** mag = nearest and min = linear and mip = none */
  99629. static readonly TEXTURE_NEAREST_LINEAR: number;
  99630. /** mag = nearest and min = nearest and mip = none */
  99631. static readonly TEXTURE_NEAREST_NEAREST: number;
  99632. /** mag = linear and min = nearest and mip = nearest */
  99633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99634. /** mag = linear and min = nearest and mip = linear */
  99635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99636. /** mag = linear and min = linear and mip = none */
  99637. static readonly TEXTURE_LINEAR_LINEAR: number;
  99638. /** mag = linear and min = nearest and mip = none */
  99639. static readonly TEXTURE_LINEAR_NEAREST: number;
  99640. /** Explicit coordinates mode */
  99641. static readonly TEXTURE_EXPLICIT_MODE: number;
  99642. /** Spherical coordinates mode */
  99643. static readonly TEXTURE_SPHERICAL_MODE: number;
  99644. /** Planar coordinates mode */
  99645. static readonly TEXTURE_PLANAR_MODE: number;
  99646. /** Cubic coordinates mode */
  99647. static readonly TEXTURE_CUBIC_MODE: number;
  99648. /** Projection coordinates mode */
  99649. static readonly TEXTURE_PROJECTION_MODE: number;
  99650. /** Skybox coordinates mode */
  99651. static readonly TEXTURE_SKYBOX_MODE: number;
  99652. /** Inverse Cubic coordinates mode */
  99653. static readonly TEXTURE_INVCUBIC_MODE: number;
  99654. /** Equirectangular coordinates mode */
  99655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99656. /** Equirectangular Fixed coordinates mode */
  99657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99658. /** Equirectangular Fixed Mirrored coordinates mode */
  99659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99661. static readonly SCALEMODE_FLOOR: number;
  99662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99663. static readonly SCALEMODE_NEAREST: number;
  99664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99665. static readonly SCALEMODE_CEILING: number;
  99666. /**
  99667. * Returns the current npm package of the sdk
  99668. */
  99669. static readonly NpmPackage: string;
  99670. /**
  99671. * Returns the current version of the framework
  99672. */
  99673. static readonly Version: string;
  99674. /** Gets the list of created engines */
  99675. static readonly Instances: Engine[];
  99676. /**
  99677. * Gets the latest created engine
  99678. */
  99679. static readonly LastCreatedEngine: Nullable<Engine>;
  99680. /**
  99681. * Gets the latest created scene
  99682. */
  99683. static readonly LastCreatedScene: Nullable<Scene>;
  99684. /**
  99685. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99686. * @param flag defines which part of the materials must be marked as dirty
  99687. * @param predicate defines a predicate used to filter which materials should be affected
  99688. */
  99689. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99690. /**
  99691. * Method called to create the default loading screen.
  99692. * This can be overriden in your own app.
  99693. * @param canvas The rendering canvas element
  99694. * @returns The loading screen
  99695. */
  99696. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99697. /**
  99698. * Method called to create the default rescale post process on each engine.
  99699. */
  99700. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99701. /**
  99702. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99703. **/
  99704. enableOfflineSupport: boolean;
  99705. /**
  99706. * 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)
  99707. **/
  99708. disableManifestCheck: boolean;
  99709. /**
  99710. * Gets the list of created scenes
  99711. */
  99712. scenes: Scene[];
  99713. /**
  99714. * Event raised when a new scene is created
  99715. */
  99716. onNewSceneAddedObservable: Observable<Scene>;
  99717. /**
  99718. * Gets the list of created postprocesses
  99719. */
  99720. postProcesses: PostProcess[];
  99721. /**
  99722. * Gets a boolean indicating if the pointer is currently locked
  99723. */
  99724. isPointerLock: boolean;
  99725. /**
  99726. * Observable event triggered each time the rendering canvas is resized
  99727. */
  99728. onResizeObservable: Observable<Engine>;
  99729. /**
  99730. * Observable event triggered each time the canvas loses focus
  99731. */
  99732. onCanvasBlurObservable: Observable<Engine>;
  99733. /**
  99734. * Observable event triggered each time the canvas gains focus
  99735. */
  99736. onCanvasFocusObservable: Observable<Engine>;
  99737. /**
  99738. * Observable event triggered each time the canvas receives pointerout event
  99739. */
  99740. onCanvasPointerOutObservable: Observable<PointerEvent>;
  99741. /**
  99742. * Observable raised when the engine begins a new frame
  99743. */
  99744. onBeginFrameObservable: Observable<Engine>;
  99745. /**
  99746. * If set, will be used to request the next animation frame for the render loop
  99747. */
  99748. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  99749. /**
  99750. * Observable raised when the engine ends the current frame
  99751. */
  99752. onEndFrameObservable: Observable<Engine>;
  99753. /**
  99754. * Observable raised when the engine is about to compile a shader
  99755. */
  99756. onBeforeShaderCompilationObservable: Observable<Engine>;
  99757. /**
  99758. * Observable raised when the engine has jsut compiled a shader
  99759. */
  99760. onAfterShaderCompilationObservable: Observable<Engine>;
  99761. /**
  99762. * Gets the audio engine
  99763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99764. * @ignorenaming
  99765. */
  99766. static audioEngine: IAudioEngine;
  99767. /**
  99768. * Default AudioEngine factory responsible of creating the Audio Engine.
  99769. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  99770. */
  99771. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  99772. /**
  99773. * Default offline support factory responsible of creating a tool used to store data locally.
  99774. * By default, this will create a Database object if the workload has been embedded.
  99775. */
  99776. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  99777. private _loadingScreen;
  99778. private _pointerLockRequested;
  99779. private _dummyFramebuffer;
  99780. private _rescalePostProcess;
  99781. /** @hidden */
  99782. protected _alphaMode: number;
  99783. /** @hidden */
  99784. protected _alphaEquation: number;
  99785. private _deterministicLockstep;
  99786. private _lockstepMaxSteps;
  99787. protected readonly _supportsHardwareTextureRescaling: boolean;
  99788. private _fps;
  99789. private _deltaTime;
  99790. /** @hidden */
  99791. _drawCalls: PerfCounter;
  99792. /**
  99793. * Turn this value on if you want to pause FPS computation when in background
  99794. */
  99795. disablePerformanceMonitorInBackground: boolean;
  99796. private _performanceMonitor;
  99797. /**
  99798. * Gets the performance monitor attached to this engine
  99799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99800. */
  99801. readonly performanceMonitor: PerformanceMonitor;
  99802. private _onFocus;
  99803. private _onBlur;
  99804. private _onCanvasPointerOut;
  99805. private _onCanvasBlur;
  99806. private _onCanvasFocus;
  99807. private _onFullscreenChange;
  99808. private _onPointerLockChange;
  99809. /**
  99810. * Gets the HTML element used to attach event listeners
  99811. * @returns a HTML element
  99812. */
  99813. getInputElement(): Nullable<HTMLElement>;
  99814. /**
  99815. * Creates a new engine
  99816. * @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
  99817. * @param antialias defines enable antialiasing (default: false)
  99818. * @param options defines further options to be sent to the getContext() function
  99819. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99820. */
  99821. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99822. /**
  99823. * Gets current aspect ratio
  99824. * @param viewportOwner defines the camera to use to get the aspect ratio
  99825. * @param useScreen defines if screen size must be used (or the current render target if any)
  99826. * @returns a number defining the aspect ratio
  99827. */
  99828. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99829. /**
  99830. * Gets current screen aspect ratio
  99831. * @returns a number defining the aspect ratio
  99832. */
  99833. getScreenAspectRatio(): number;
  99834. /**
  99835. * Gets host document
  99836. * @returns the host document object
  99837. */
  99838. getHostDocument(): Document;
  99839. /**
  99840. * Gets the client rect of the HTML canvas attached with the current webGL context
  99841. * @returns a client rectanglee
  99842. */
  99843. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99844. /**
  99845. * Gets the client rect of the HTML element used for events
  99846. * @returns a client rectanglee
  99847. */
  99848. getInputElementClientRect(): Nullable<ClientRect>;
  99849. /**
  99850. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99852. * @returns true if engine is in deterministic lock step mode
  99853. */
  99854. isDeterministicLockStep(): boolean;
  99855. /**
  99856. * Gets the max steps when engine is running in deterministic lock step
  99857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99858. * @returns the max steps
  99859. */
  99860. getLockstepMaxSteps(): number;
  99861. /**
  99862. * Force the mipmap generation for the given render target texture
  99863. * @param texture defines the render target texture to use
  99864. */
  99865. generateMipMapsForCubemap(texture: InternalTexture): void;
  99866. /** States */
  99867. /**
  99868. * Set various states to the webGL context
  99869. * @param culling defines backface culling state
  99870. * @param zOffset defines the value to apply to zOffset (0 by default)
  99871. * @param force defines if states must be applied even if cache is up to date
  99872. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99873. */
  99874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99875. /**
  99876. * Set the z offset to apply to current rendering
  99877. * @param value defines the offset to apply
  99878. */
  99879. setZOffset(value: number): void;
  99880. /**
  99881. * Gets the current value of the zOffset
  99882. * @returns the current zOffset state
  99883. */
  99884. getZOffset(): number;
  99885. /**
  99886. * Enable or disable depth buffering
  99887. * @param enable defines the state to set
  99888. */
  99889. setDepthBuffer(enable: boolean): void;
  99890. /**
  99891. * Gets a boolean indicating if depth writing is enabled
  99892. * @returns the current depth writing state
  99893. */
  99894. getDepthWrite(): boolean;
  99895. /**
  99896. * Enable or disable depth writing
  99897. * @param enable defines the state to set
  99898. */
  99899. setDepthWrite(enable: boolean): void;
  99900. /**
  99901. * Enable or disable color writing
  99902. * @param enable defines the state to set
  99903. */
  99904. setColorWrite(enable: boolean): void;
  99905. /**
  99906. * Gets a boolean indicating if color writing is enabled
  99907. * @returns the current color writing state
  99908. */
  99909. getColorWrite(): boolean;
  99910. /**
  99911. * Sets alpha constants used by some alpha blending modes
  99912. * @param r defines the red component
  99913. * @param g defines the green component
  99914. * @param b defines the blue component
  99915. * @param a defines the alpha component
  99916. */
  99917. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99918. /**
  99919. * Sets the current alpha mode
  99920. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99921. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99922. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99923. */
  99924. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99925. /**
  99926. * Gets the current alpha mode
  99927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99928. * @returns the current alpha mode
  99929. */
  99930. getAlphaMode(): number;
  99931. /**
  99932. * Sets the current alpha equation
  99933. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99934. */
  99935. setAlphaEquation(equation: number): void;
  99936. /**
  99937. * Gets the current alpha equation.
  99938. * @returns the current alpha equation
  99939. */
  99940. getAlphaEquation(): number;
  99941. /**
  99942. * Gets a boolean indicating if stencil buffer is enabled
  99943. * @returns the current stencil buffer state
  99944. */
  99945. getStencilBuffer(): boolean;
  99946. /**
  99947. * Enable or disable the stencil buffer
  99948. * @param enable defines if the stencil buffer must be enabled or disabled
  99949. */
  99950. setStencilBuffer(enable: boolean): void;
  99951. /**
  99952. * Gets the current stencil mask
  99953. * @returns a number defining the new stencil mask to use
  99954. */
  99955. getStencilMask(): number;
  99956. /**
  99957. * Sets the current stencil mask
  99958. * @param mask defines the new stencil mask to use
  99959. */
  99960. setStencilMask(mask: number): void;
  99961. /**
  99962. * Gets the current stencil function
  99963. * @returns a number defining the stencil function to use
  99964. */
  99965. getStencilFunction(): number;
  99966. /**
  99967. * Gets the current stencil reference value
  99968. * @returns a number defining the stencil reference value to use
  99969. */
  99970. getStencilFunctionReference(): number;
  99971. /**
  99972. * Gets the current stencil mask
  99973. * @returns a number defining the stencil mask to use
  99974. */
  99975. getStencilFunctionMask(): number;
  99976. /**
  99977. * Sets the current stencil function
  99978. * @param stencilFunc defines the new stencil function to use
  99979. */
  99980. setStencilFunction(stencilFunc: number): void;
  99981. /**
  99982. * Sets the current stencil reference
  99983. * @param reference defines the new stencil reference to use
  99984. */
  99985. setStencilFunctionReference(reference: number): void;
  99986. /**
  99987. * Sets the current stencil mask
  99988. * @param mask defines the new stencil mask to use
  99989. */
  99990. setStencilFunctionMask(mask: number): void;
  99991. /**
  99992. * Gets the current stencil operation when stencil fails
  99993. * @returns a number defining stencil operation to use when stencil fails
  99994. */
  99995. getStencilOperationFail(): number;
  99996. /**
  99997. * Gets the current stencil operation when depth fails
  99998. * @returns a number defining stencil operation to use when depth fails
  99999. */
  100000. getStencilOperationDepthFail(): number;
  100001. /**
  100002. * Gets the current stencil operation when stencil passes
  100003. * @returns a number defining stencil operation to use when stencil passes
  100004. */
  100005. getStencilOperationPass(): number;
  100006. /**
  100007. * Sets the stencil operation to use when stencil fails
  100008. * @param operation defines the stencil operation to use when stencil fails
  100009. */
  100010. setStencilOperationFail(operation: number): void;
  100011. /**
  100012. * Sets the stencil operation to use when depth fails
  100013. * @param operation defines the stencil operation to use when depth fails
  100014. */
  100015. setStencilOperationDepthFail(operation: number): void;
  100016. /**
  100017. * Sets the stencil operation to use when stencil passes
  100018. * @param operation defines the stencil operation to use when stencil passes
  100019. */
  100020. setStencilOperationPass(operation: number): void;
  100021. /**
  100022. * Sets a boolean indicating if the dithering state is enabled or disabled
  100023. * @param value defines the dithering state
  100024. */
  100025. setDitheringState(value: boolean): void;
  100026. /**
  100027. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100028. * @param value defines the rasterizer state
  100029. */
  100030. setRasterizerState(value: boolean): void;
  100031. /**
  100032. * Gets the current depth function
  100033. * @returns a number defining the depth function
  100034. */
  100035. getDepthFunction(): Nullable<number>;
  100036. /**
  100037. * Sets the current depth function
  100038. * @param depthFunc defines the function to use
  100039. */
  100040. setDepthFunction(depthFunc: number): void;
  100041. /**
  100042. * Sets the current depth function to GREATER
  100043. */
  100044. setDepthFunctionToGreater(): void;
  100045. /**
  100046. * Sets the current depth function to GEQUAL
  100047. */
  100048. setDepthFunctionToGreaterOrEqual(): void;
  100049. /**
  100050. * Sets the current depth function to LESS
  100051. */
  100052. setDepthFunctionToLess(): void;
  100053. /**
  100054. * Sets the current depth function to LEQUAL
  100055. */
  100056. setDepthFunctionToLessOrEqual(): void;
  100057. private _cachedStencilBuffer;
  100058. private _cachedStencilFunction;
  100059. private _cachedStencilMask;
  100060. private _cachedStencilOperationPass;
  100061. private _cachedStencilOperationFail;
  100062. private _cachedStencilOperationDepthFail;
  100063. private _cachedStencilReference;
  100064. /**
  100065. * Caches the the state of the stencil buffer
  100066. */
  100067. cacheStencilState(): void;
  100068. /**
  100069. * Restores the state of the stencil buffer
  100070. */
  100071. restoreStencilState(): void;
  100072. /**
  100073. * Directly set the WebGL Viewport
  100074. * @param x defines the x coordinate of the viewport (in screen space)
  100075. * @param y defines the y coordinate of the viewport (in screen space)
  100076. * @param width defines the width of the viewport (in screen space)
  100077. * @param height defines the height of the viewport (in screen space)
  100078. * @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
  100079. */
  100080. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100081. /**
  100082. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100083. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100084. * @param y defines the y-coordinate of the corner of the clear rectangle
  100085. * @param width defines the width of the clear rectangle
  100086. * @param height defines the height of the clear rectangle
  100087. * @param clearColor defines the clear color
  100088. */
  100089. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100090. /**
  100091. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100092. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100093. * @param y defines the y-coordinate of the corner of the clear rectangle
  100094. * @param width defines the width of the clear rectangle
  100095. * @param height defines the height of the clear rectangle
  100096. */
  100097. enableScissor(x: number, y: number, width: number, height: number): void;
  100098. /**
  100099. * Disable previously set scissor test rectangle
  100100. */
  100101. disableScissor(): void;
  100102. protected _reportDrawCall(): void;
  100103. /**
  100104. * Initializes a webVR display and starts listening to display change events
  100105. * The onVRDisplayChangedObservable will be notified upon these changes
  100106. * @returns The onVRDisplayChangedObservable
  100107. */
  100108. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100109. /** @hidden */
  100110. _prepareVRComponent(): void;
  100111. /** @hidden */
  100112. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100113. /** @hidden */
  100114. _submitVRFrame(): void;
  100115. /**
  100116. * Call this function to leave webVR mode
  100117. * Will do nothing if webVR is not supported or if there is no webVR device
  100118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100119. */
  100120. disableVR(): void;
  100121. /**
  100122. * Gets a boolean indicating that the system is in VR mode and is presenting
  100123. * @returns true if VR mode is engaged
  100124. */
  100125. isVRPresenting(): boolean;
  100126. /** @hidden */
  100127. _requestVRFrame(): void;
  100128. /** @hidden */
  100129. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100130. /**
  100131. * Gets the source code of the vertex shader associated with a specific webGL program
  100132. * @param program defines the program to use
  100133. * @returns a string containing the source code of the vertex shader associated with the program
  100134. */
  100135. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100136. /**
  100137. * Gets the source code of the fragment shader associated with a specific webGL program
  100138. * @param program defines the program to use
  100139. * @returns a string containing the source code of the fragment shader associated with the program
  100140. */
  100141. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100142. /**
  100143. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100144. * @param x defines the x coordinate of the rectangle where pixels must be read
  100145. * @param y defines the y coordinate of the rectangle where pixels must be read
  100146. * @param width defines the width of the rectangle where pixels must be read
  100147. * @param height defines the height of the rectangle where pixels must be read
  100148. * @returns a Uint8Array containing RGBA colors
  100149. */
  100150. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100151. /**
  100152. * Sets a depth stencil texture from a render target to the according uniform.
  100153. * @param channel The texture channel
  100154. * @param uniform The uniform to set
  100155. * @param texture The render target texture containing the depth stencil texture to apply
  100156. */
  100157. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100158. /**
  100159. * Sets a texture to the webGL context from a postprocess
  100160. * @param channel defines the channel to use
  100161. * @param postProcess defines the source postprocess
  100162. */
  100163. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100164. /**
  100165. * Binds the output of the passed in post process to the texture channel specified
  100166. * @param channel The channel the texture should be bound to
  100167. * @param postProcess The post process which's output should be bound
  100168. */
  100169. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100170. /** @hidden */
  100171. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100172. protected _rebuildBuffers(): void;
  100173. /** @hidden */
  100174. _renderFrame(): void;
  100175. _renderLoop(): void;
  100176. /** @hidden */
  100177. _renderViews(): boolean;
  100178. /**
  100179. * Toggle full screen mode
  100180. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100181. */
  100182. switchFullscreen(requestPointerLock: boolean): void;
  100183. /**
  100184. * Enters full screen mode
  100185. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100186. */
  100187. enterFullscreen(requestPointerLock: boolean): void;
  100188. /**
  100189. * Exits full screen mode
  100190. */
  100191. exitFullscreen(): void;
  100192. /**
  100193. * Enters Pointerlock mode
  100194. */
  100195. enterPointerlock(): void;
  100196. /**
  100197. * Exits Pointerlock mode
  100198. */
  100199. exitPointerlock(): void;
  100200. /**
  100201. * Begin a new frame
  100202. */
  100203. beginFrame(): void;
  100204. /**
  100205. * Enf the current frame
  100206. */
  100207. endFrame(): void;
  100208. resize(): void;
  100209. /**
  100210. * Set the compressed texture format to use, based on the formats you have, and the formats
  100211. * supported by the hardware / browser.
  100212. *
  100213. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100214. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100215. * to API arguments needed to compressed textures. This puts the burden on the container
  100216. * generator to house the arcane code for determining these for current & future formats.
  100217. *
  100218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100220. *
  100221. * Note: The result of this call is not taken into account when a texture is base64.
  100222. *
  100223. * @param formatsAvailable defines the list of those format families you have created
  100224. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100225. *
  100226. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100227. * @returns The extension selected.
  100228. */
  100229. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100230. /**
  100231. * Force a specific size of the canvas
  100232. * @param width defines the new canvas' width
  100233. * @param height defines the new canvas' height
  100234. */
  100235. setSize(width: number, height: number): void;
  100236. /**
  100237. * Updates a dynamic vertex buffer.
  100238. * @param vertexBuffer the vertex buffer to update
  100239. * @param data the data used to update the vertex buffer
  100240. * @param byteOffset the byte offset of the data
  100241. * @param byteLength the byte length of the data
  100242. */
  100243. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100244. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100245. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100246. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100247. _releaseTexture(texture: InternalTexture): void;
  100248. /**
  100249. * @hidden
  100250. * Rescales a texture
  100251. * @param source input texutre
  100252. * @param destination destination texture
  100253. * @param scene scene to use to render the resize
  100254. * @param internalFormat format to use when resizing
  100255. * @param onComplete callback to be called when resize has completed
  100256. */
  100257. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100258. /**
  100259. * Gets the current framerate
  100260. * @returns a number representing the framerate
  100261. */
  100262. getFps(): number;
  100263. /**
  100264. * Gets the time spent between current and previous frame
  100265. * @returns a number representing the delta time in ms
  100266. */
  100267. getDeltaTime(): number;
  100268. private _measureFps;
  100269. /** @hidden */
  100270. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100271. /**
  100272. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100273. * @param renderTarget The render target to set the frame buffer for
  100274. */
  100275. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100276. /**
  100277. * Update a dynamic index buffer
  100278. * @param indexBuffer defines the target index buffer
  100279. * @param indices defines the data to update
  100280. * @param offset defines the offset in the target index buffer where update should start
  100281. */
  100282. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100283. /**
  100284. * Updates the sample count of a render target texture
  100285. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100286. * @param texture defines the texture to update
  100287. * @param samples defines the sample count to set
  100288. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100289. */
  100290. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100291. /**
  100292. * Updates a depth texture Comparison Mode and Function.
  100293. * If the comparison Function is equal to 0, the mode will be set to none.
  100294. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100295. * @param texture The texture to set the comparison function for
  100296. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100297. */
  100298. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100299. /**
  100300. * Creates a webGL buffer to use with instanciation
  100301. * @param capacity defines the size of the buffer
  100302. * @returns the webGL buffer
  100303. */
  100304. createInstancesBuffer(capacity: number): DataBuffer;
  100305. /**
  100306. * Delete a webGL buffer used with instanciation
  100307. * @param buffer defines the webGL buffer to delete
  100308. */
  100309. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100310. /** @hidden */
  100311. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100312. dispose(): void;
  100313. private _disableTouchAction;
  100314. /**
  100315. * Display the loading screen
  100316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100317. */
  100318. displayLoadingUI(): void;
  100319. /**
  100320. * Hide the loading screen
  100321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100322. */
  100323. hideLoadingUI(): void;
  100324. /**
  100325. * Gets the current loading screen object
  100326. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100327. */
  100328. /**
  100329. * Sets the current loading screen object
  100330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100331. */
  100332. loadingScreen: ILoadingScreen;
  100333. /**
  100334. * Sets the current loading screen text
  100335. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100336. */
  100337. loadingUIText: string;
  100338. /**
  100339. * Sets the current loading screen background color
  100340. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100341. */
  100342. loadingUIBackgroundColor: string;
  100343. /** Pointerlock and fullscreen */
  100344. /**
  100345. * Ask the browser to promote the current element to pointerlock mode
  100346. * @param element defines the DOM element to promote
  100347. */
  100348. static _RequestPointerlock(element: HTMLElement): void;
  100349. /**
  100350. * Asks the browser to exit pointerlock mode
  100351. */
  100352. static _ExitPointerlock(): void;
  100353. /**
  100354. * Ask the browser to promote the current element to fullscreen rendering mode
  100355. * @param element defines the DOM element to promote
  100356. */
  100357. static _RequestFullscreen(element: HTMLElement): void;
  100358. /**
  100359. * Asks the browser to exit fullscreen mode
  100360. */
  100361. static _ExitFullscreen(): void;
  100362. }
  100363. }
  100364. declare module BABYLON {
  100365. /**
  100366. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100367. * during the life time of the application.
  100368. */
  100369. export class EngineStore {
  100370. /** Gets the list of created engines */
  100371. static Instances: Engine[];
  100372. /** @hidden */
  100373. static _LastCreatedScene: Nullable<Scene>;
  100374. /**
  100375. * Gets the latest created engine
  100376. */
  100377. static readonly LastCreatedEngine: Nullable<Engine>;
  100378. /**
  100379. * Gets the latest created scene
  100380. */
  100381. static readonly LastCreatedScene: Nullable<Scene>;
  100382. /**
  100383. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100384. * @ignorenaming
  100385. */
  100386. static UseFallbackTexture: boolean;
  100387. /**
  100388. * Texture content used if a texture cannot loaded
  100389. * @ignorenaming
  100390. */
  100391. static FallbackTexture: string;
  100392. }
  100393. }
  100394. declare module BABYLON {
  100395. /**
  100396. * Helper class that provides a small promise polyfill
  100397. */
  100398. export class PromisePolyfill {
  100399. /**
  100400. * Static function used to check if the polyfill is required
  100401. * If this is the case then the function will inject the polyfill to window.Promise
  100402. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100403. */
  100404. static Apply(force?: boolean): void;
  100405. }
  100406. }
  100407. declare module BABYLON {
  100408. /**
  100409. * Interface for screenshot methods with describe argument called `size` as object with options
  100410. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100411. */
  100412. export interface IScreenshotSize {
  100413. /**
  100414. * number in pixels for canvas height
  100415. */
  100416. height?: number;
  100417. /**
  100418. * multiplier allowing render at a higher or lower resolution
  100419. * If value is defined then height and width will be ignored and taken from camera
  100420. */
  100421. precision?: number;
  100422. /**
  100423. * number in pixels for canvas width
  100424. */
  100425. width?: number;
  100426. }
  100427. }
  100428. declare module BABYLON {
  100429. interface IColor4Like {
  100430. r: float;
  100431. g: float;
  100432. b: float;
  100433. a: float;
  100434. }
  100435. /**
  100436. * Class containing a set of static utilities functions
  100437. */
  100438. export class Tools {
  100439. /**
  100440. * Gets or sets the base URL to use to load assets
  100441. */
  100442. static BaseUrl: string;
  100443. /**
  100444. * Enable/Disable Custom HTTP Request Headers globally.
  100445. * default = false
  100446. * @see CustomRequestHeaders
  100447. */
  100448. static UseCustomRequestHeaders: boolean;
  100449. /**
  100450. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100451. * i.e. when loading files, where the server/service expects an Authorization header
  100452. */
  100453. static CustomRequestHeaders: {
  100454. [key: string]: string;
  100455. };
  100456. /**
  100457. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100458. */
  100459. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100460. /**
  100461. * Default behaviour for cors in the application.
  100462. * It can be a string if the expected behavior is identical in the entire app.
  100463. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100464. */
  100465. static CorsBehavior: string | ((url: string | string[]) => string);
  100466. /**
  100467. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100468. * @ignorenaming
  100469. */
  100470. static UseFallbackTexture: boolean;
  100471. /**
  100472. * Use this object to register external classes like custom textures or material
  100473. * to allow the laoders to instantiate them
  100474. */
  100475. static RegisteredExternalClasses: {
  100476. [key: string]: Object;
  100477. };
  100478. /**
  100479. * Texture content used if a texture cannot loaded
  100480. * @ignorenaming
  100481. */
  100482. static fallbackTexture: string;
  100483. /**
  100484. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100485. * @param u defines the coordinate on X axis
  100486. * @param v defines the coordinate on Y axis
  100487. * @param width defines the width of the source data
  100488. * @param height defines the height of the source data
  100489. * @param pixels defines the source byte array
  100490. * @param color defines the output color
  100491. */
  100492. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100493. /**
  100494. * Interpolates between a and b via alpha
  100495. * @param a The lower value (returned when alpha = 0)
  100496. * @param b The upper value (returned when alpha = 1)
  100497. * @param alpha The interpolation-factor
  100498. * @return The mixed value
  100499. */
  100500. static Mix(a: number, b: number, alpha: number): number;
  100501. /**
  100502. * Tries to instantiate a new object from a given class name
  100503. * @param className defines the class name to instantiate
  100504. * @returns the new object or null if the system was not able to do the instantiation
  100505. */
  100506. static Instantiate(className: string): any;
  100507. /**
  100508. * Provides a slice function that will work even on IE
  100509. * @param data defines the array to slice
  100510. * @param start defines the start of the data (optional)
  100511. * @param end defines the end of the data (optional)
  100512. * @returns the new sliced array
  100513. */
  100514. static Slice<T>(data: T, start?: number, end?: number): T;
  100515. /**
  100516. * Polyfill for setImmediate
  100517. * @param action defines the action to execute after the current execution block
  100518. */
  100519. static SetImmediate(action: () => void): void;
  100520. /**
  100521. * Function indicating if a number is an exponent of 2
  100522. * @param value defines the value to test
  100523. * @returns true if the value is an exponent of 2
  100524. */
  100525. static IsExponentOfTwo(value: number): boolean;
  100526. private static _tmpFloatArray;
  100527. /**
  100528. * Returns the nearest 32-bit single precision float representation of a Number
  100529. * @param value A Number. If the parameter is of a different type, it will get converted
  100530. * to a number or to NaN if it cannot be converted
  100531. * @returns number
  100532. */
  100533. static FloatRound(value: number): number;
  100534. /**
  100535. * Extracts the filename from a path
  100536. * @param path defines the path to use
  100537. * @returns the filename
  100538. */
  100539. static GetFilename(path: string): string;
  100540. /**
  100541. * Extracts the "folder" part of a path (everything before the filename).
  100542. * @param uri The URI to extract the info from
  100543. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100544. * @returns The "folder" part of the path
  100545. */
  100546. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100547. /**
  100548. * Extracts text content from a DOM element hierarchy
  100549. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100550. */
  100551. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100552. /**
  100553. * Convert an angle in radians to degrees
  100554. * @param angle defines the angle to convert
  100555. * @returns the angle in degrees
  100556. */
  100557. static ToDegrees(angle: number): number;
  100558. /**
  100559. * Convert an angle in degrees to radians
  100560. * @param angle defines the angle to convert
  100561. * @returns the angle in radians
  100562. */
  100563. static ToRadians(angle: number): number;
  100564. /**
  100565. * Returns an array if obj is not an array
  100566. * @param obj defines the object to evaluate as an array
  100567. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100568. * @returns either obj directly if obj is an array or a new array containing obj
  100569. */
  100570. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100571. /**
  100572. * Gets the pointer prefix to use
  100573. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100574. */
  100575. static GetPointerPrefix(): string;
  100576. /**
  100577. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100578. * @param url define the url we are trying
  100579. * @param element define the dom element where to configure the cors policy
  100580. */
  100581. static SetCorsBehavior(url: string | string[], element: {
  100582. crossOrigin: string | null;
  100583. }): void;
  100584. /**
  100585. * Removes unwanted characters from an url
  100586. * @param url defines the url to clean
  100587. * @returns the cleaned url
  100588. */
  100589. static CleanUrl(url: string): string;
  100590. /**
  100591. * Gets or sets a function used to pre-process url before using them to load assets
  100592. */
  100593. static PreprocessUrl: (url: string) => string;
  100594. /**
  100595. * Loads an image as an HTMLImageElement.
  100596. * @param input url string, ArrayBuffer, or Blob to load
  100597. * @param onLoad callback called when the image successfully loads
  100598. * @param onError callback called when the image fails to load
  100599. * @param offlineProvider offline provider for caching
  100600. * @param mimeType optional mime type
  100601. * @returns the HTMLImageElement of the loaded image
  100602. */
  100603. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100604. /**
  100605. * Loads a file from a url
  100606. * @param url url string, ArrayBuffer, or Blob to load
  100607. * @param onSuccess callback called when the file successfully loads
  100608. * @param onProgress callback called while file is loading (if the server supports this mode)
  100609. * @param offlineProvider defines the offline provider for caching
  100610. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100611. * @param onError callback called when the file fails to load
  100612. * @returns a file request object
  100613. */
  100614. 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;
  100615. /**
  100616. * Loads a file from a url
  100617. * @param url the file url to load
  100618. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100619. */
  100620. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100621. /**
  100622. * Load a script (identified by an url). When the url returns, the
  100623. * content of this file is added into a new script element, attached to the DOM (body element)
  100624. * @param scriptUrl defines the url of the script to laod
  100625. * @param onSuccess defines the callback called when the script is loaded
  100626. * @param onError defines the callback to call if an error occurs
  100627. * @param scriptId defines the id of the script element
  100628. */
  100629. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100630. /**
  100631. * Load an asynchronous script (identified by an url). When the url returns, the
  100632. * content of this file is added into a new script element, attached to the DOM (body element)
  100633. * @param scriptUrl defines the url of the script to laod
  100634. * @param scriptId defines the id of the script element
  100635. * @returns a promise request object
  100636. */
  100637. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100638. /**
  100639. * Loads a file from a blob
  100640. * @param fileToLoad defines the blob to use
  100641. * @param callback defines the callback to call when data is loaded
  100642. * @param progressCallback defines the callback to call during loading process
  100643. * @returns a file request object
  100644. */
  100645. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100646. /**
  100647. * Reads a file from a File object
  100648. * @param file defines the file to load
  100649. * @param onSuccess defines the callback to call when data is loaded
  100650. * @param onProgress defines the callback to call during loading process
  100651. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100652. * @param onError defines the callback to call when an error occurs
  100653. * @returns a file request object
  100654. */
  100655. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100656. /**
  100657. * Creates a data url from a given string content
  100658. * @param content defines the content to convert
  100659. * @returns the new data url link
  100660. */
  100661. static FileAsURL(content: string): string;
  100662. /**
  100663. * Format the given number to a specific decimal format
  100664. * @param value defines the number to format
  100665. * @param decimals defines the number of decimals to use
  100666. * @returns the formatted string
  100667. */
  100668. static Format(value: number, decimals?: number): string;
  100669. /**
  100670. * Tries to copy an object by duplicating every property
  100671. * @param source defines the source object
  100672. * @param destination defines the target object
  100673. * @param doNotCopyList defines a list of properties to avoid
  100674. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100675. */
  100676. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100677. /**
  100678. * Gets a boolean indicating if the given object has no own property
  100679. * @param obj defines the object to test
  100680. * @returns true if object has no own property
  100681. */
  100682. static IsEmpty(obj: any): boolean;
  100683. /**
  100684. * Function used to register events at window level
  100685. * @param windowElement defines the Window object to use
  100686. * @param events defines the events to register
  100687. */
  100688. static RegisterTopRootEvents(windowElement: Window, events: {
  100689. name: string;
  100690. handler: Nullable<(e: FocusEvent) => any>;
  100691. }[]): void;
  100692. /**
  100693. * Function used to unregister events from window level
  100694. * @param windowElement defines the Window object to use
  100695. * @param events defines the events to unregister
  100696. */
  100697. static UnregisterTopRootEvents(windowElement: Window, events: {
  100698. name: string;
  100699. handler: Nullable<(e: FocusEvent) => any>;
  100700. }[]): void;
  100701. /**
  100702. * @ignore
  100703. */
  100704. static _ScreenshotCanvas: HTMLCanvasElement;
  100705. /**
  100706. * Dumps the current bound framebuffer
  100707. * @param width defines the rendering width
  100708. * @param height defines the rendering height
  100709. * @param engine defines the hosting engine
  100710. * @param successCallback defines the callback triggered once the data are available
  100711. * @param mimeType defines the mime type of the result
  100712. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  100713. */
  100714. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100715. /**
  100716. * Converts the canvas data to blob.
  100717. * This acts as a polyfill for browsers not supporting the to blob function.
  100718. * @param canvas Defines the canvas to extract the data from
  100719. * @param successCallback Defines the callback triggered once the data are available
  100720. * @param mimeType Defines the mime type of the result
  100721. */
  100722. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  100723. /**
  100724. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  100725. * @param successCallback defines the callback triggered once the data are available
  100726. * @param mimeType defines the mime type of the result
  100727. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  100728. */
  100729. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  100730. /**
  100731. * Downloads a blob in the browser
  100732. * @param blob defines the blob to download
  100733. * @param fileName defines the name of the downloaded file
  100734. */
  100735. static Download(blob: Blob, fileName: string): void;
  100736. /**
  100737. * Captures a screenshot of the current rendering
  100738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100739. * @param engine defines the rendering engine
  100740. * @param camera defines the source camera
  100741. * @param size This parameter can be set to a single number or to an object with the
  100742. * following (optional) properties: precision, width, height. If a single number is passed,
  100743. * it will be used for both width and height. If an object is passed, the screenshot size
  100744. * will be derived from the parameters. The precision property is a multiplier allowing
  100745. * rendering at a higher or lower resolution
  100746. * @param successCallback defines the callback receives a single parameter which contains the
  100747. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100748. * src parameter of an <img> to display it
  100749. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100750. * Check your browser for supported MIME types
  100751. */
  100752. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  100753. /**
  100754. * Captures a screenshot of the current rendering
  100755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100756. * @param engine defines the rendering engine
  100757. * @param camera defines the source camera
  100758. * @param size This parameter can be set to a single number or to an object with the
  100759. * following (optional) properties: precision, width, height. If a single number is passed,
  100760. * it will be used for both width and height. If an object is passed, the screenshot size
  100761. * will be derived from the parameters. The precision property is a multiplier allowing
  100762. * rendering at a higher or lower resolution
  100763. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  100764. * Check your browser for supported MIME types
  100765. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100766. * to the src parameter of an <img> to display it
  100767. */
  100768. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  100769. /**
  100770. * Generates an image screenshot from the specified camera.
  100771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100772. * @param engine The engine to use for rendering
  100773. * @param camera The camera to use for rendering
  100774. * @param size This parameter can be set to a single number or to an object with the
  100775. * following (optional) properties: precision, width, height. If a single number is passed,
  100776. * it will be used for both width and height. If an object is passed, the screenshot size
  100777. * will be derived from the parameters. The precision property is a multiplier allowing
  100778. * rendering at a higher or lower resolution
  100779. * @param successCallback The callback receives a single parameter which contains the
  100780. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100781. * src parameter of an <img> to display it
  100782. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100783. * Check your browser for supported MIME types
  100784. * @param samples Texture samples (default: 1)
  100785. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100786. * @param fileName A name for for the downloaded file.
  100787. */
  100788. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  100789. /**
  100790. * Generates an image screenshot from the specified camera.
  100791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  100792. * @param engine The engine to use for rendering
  100793. * @param camera The camera to use for rendering
  100794. * @param size This parameter can be set to a single number or to an object with the
  100795. * following (optional) properties: precision, width, height. If a single number is passed,
  100796. * it will be used for both width and height. If an object is passed, the screenshot size
  100797. * will be derived from the parameters. The precision property is a multiplier allowing
  100798. * rendering at a higher or lower resolution
  100799. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100800. * Check your browser for supported MIME types
  100801. * @param samples Texture samples (default: 1)
  100802. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100803. * @param fileName A name for for the downloaded file.
  100804. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100805. * to the src parameter of an <img> to display it
  100806. */
  100807. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100808. /**
  100809. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100810. * Be aware Math.random() could cause collisions, but:
  100811. * "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"
  100812. * @returns a pseudo random id
  100813. */
  100814. static RandomId(): string;
  100815. /**
  100816. * Test if the given uri is a base64 string
  100817. * @param uri The uri to test
  100818. * @return True if the uri is a base64 string or false otherwise
  100819. */
  100820. static IsBase64(uri: string): boolean;
  100821. /**
  100822. * Decode the given base64 uri.
  100823. * @param uri The uri to decode
  100824. * @return The decoded base64 data.
  100825. */
  100826. static DecodeBase64(uri: string): ArrayBuffer;
  100827. /**
  100828. * Gets the absolute url.
  100829. * @param url the input url
  100830. * @return the absolute url
  100831. */
  100832. static GetAbsoluteUrl(url: string): string;
  100833. /**
  100834. * No log
  100835. */
  100836. static readonly NoneLogLevel: number;
  100837. /**
  100838. * Only message logs
  100839. */
  100840. static readonly MessageLogLevel: number;
  100841. /**
  100842. * Only warning logs
  100843. */
  100844. static readonly WarningLogLevel: number;
  100845. /**
  100846. * Only error logs
  100847. */
  100848. static readonly ErrorLogLevel: number;
  100849. /**
  100850. * All logs
  100851. */
  100852. static readonly AllLogLevel: number;
  100853. /**
  100854. * Gets a value indicating the number of loading errors
  100855. * @ignorenaming
  100856. */
  100857. static readonly errorsCount: number;
  100858. /**
  100859. * Callback called when a new log is added
  100860. */
  100861. static OnNewCacheEntry: (entry: string) => void;
  100862. /**
  100863. * Log a message to the console
  100864. * @param message defines the message to log
  100865. */
  100866. static Log(message: string): void;
  100867. /**
  100868. * Write a warning message to the console
  100869. * @param message defines the message to log
  100870. */
  100871. static Warn(message: string): void;
  100872. /**
  100873. * Write an error message to the console
  100874. * @param message defines the message to log
  100875. */
  100876. static Error(message: string): void;
  100877. /**
  100878. * Gets current log cache (list of logs)
  100879. */
  100880. static readonly LogCache: string;
  100881. /**
  100882. * Clears the log cache
  100883. */
  100884. static ClearLogCache(): void;
  100885. /**
  100886. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100887. */
  100888. static LogLevels: number;
  100889. /**
  100890. * Checks if the window object exists
  100891. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100892. */
  100893. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100894. /**
  100895. * No performance log
  100896. */
  100897. static readonly PerformanceNoneLogLevel: number;
  100898. /**
  100899. * Use user marks to log performance
  100900. */
  100901. static readonly PerformanceUserMarkLogLevel: number;
  100902. /**
  100903. * Log performance to the console
  100904. */
  100905. static readonly PerformanceConsoleLogLevel: number;
  100906. private static _performance;
  100907. /**
  100908. * Sets the current performance log level
  100909. */
  100910. static PerformanceLogLevel: number;
  100911. private static _StartPerformanceCounterDisabled;
  100912. private static _EndPerformanceCounterDisabled;
  100913. private static _StartUserMark;
  100914. private static _EndUserMark;
  100915. private static _StartPerformanceConsole;
  100916. private static _EndPerformanceConsole;
  100917. /**
  100918. * Starts a performance counter
  100919. */
  100920. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100921. /**
  100922. * Ends a specific performance coutner
  100923. */
  100924. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100925. /**
  100926. * Gets either window.performance.now() if supported or Date.now() else
  100927. */
  100928. static readonly Now: number;
  100929. /**
  100930. * This method will return the name of the class used to create the instance of the given object.
  100931. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100932. * @param object the object to get the class name from
  100933. * @param isType defines if the object is actually a type
  100934. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100935. */
  100936. static GetClassName(object: any, isType?: boolean): string;
  100937. /**
  100938. * Gets the first element of an array satisfying a given predicate
  100939. * @param array defines the array to browse
  100940. * @param predicate defines the predicate to use
  100941. * @returns null if not found or the element
  100942. */
  100943. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100944. /**
  100945. * This method will return the name of the full name of the class, including its owning module (if any).
  100946. * 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).
  100947. * @param object the object to get the class name from
  100948. * @param isType defines if the object is actually a type
  100949. * @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.
  100950. * @ignorenaming
  100951. */
  100952. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100953. /**
  100954. * Returns a promise that resolves after the given amount of time.
  100955. * @param delay Number of milliseconds to delay
  100956. * @returns Promise that resolves after the given amount of time
  100957. */
  100958. static DelayAsync(delay: number): Promise<void>;
  100959. }
  100960. /**
  100961. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100962. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100963. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100964. * @param name The name of the class, case should be preserved
  100965. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100966. */
  100967. export function className(name: string, module?: string): (target: Object) => void;
  100968. /**
  100969. * An implementation of a loop for asynchronous functions.
  100970. */
  100971. export class AsyncLoop {
  100972. /**
  100973. * Defines the number of iterations for the loop
  100974. */
  100975. iterations: number;
  100976. /**
  100977. * Defines the current index of the loop.
  100978. */
  100979. index: number;
  100980. private _done;
  100981. private _fn;
  100982. private _successCallback;
  100983. /**
  100984. * Constructor.
  100985. * @param iterations the number of iterations.
  100986. * @param func the function to run each iteration
  100987. * @param successCallback the callback that will be called upon succesful execution
  100988. * @param offset starting offset.
  100989. */
  100990. constructor(
  100991. /**
  100992. * Defines the number of iterations for the loop
  100993. */
  100994. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100995. /**
  100996. * Execute the next iteration. Must be called after the last iteration was finished.
  100997. */
  100998. executeNext(): void;
  100999. /**
  101000. * Break the loop and run the success callback.
  101001. */
  101002. breakLoop(): void;
  101003. /**
  101004. * Create and run an async loop.
  101005. * @param iterations the number of iterations.
  101006. * @param fn the function to run each iteration
  101007. * @param successCallback the callback that will be called upon succesful execution
  101008. * @param offset starting offset.
  101009. * @returns the created async loop object
  101010. */
  101011. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101012. /**
  101013. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101014. * @param iterations total number of iterations
  101015. * @param syncedIterations number of synchronous iterations in each async iteration.
  101016. * @param fn the function to call each iteration.
  101017. * @param callback a success call back that will be called when iterating stops.
  101018. * @param breakFunction a break condition (optional)
  101019. * @param timeout timeout settings for the setTimeout function. default - 0.
  101020. * @returns the created async loop object
  101021. */
  101022. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101023. }
  101024. }
  101025. declare module BABYLON {
  101026. /**
  101027. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101028. * The underlying implementation relies on an associative array to ensure the best performances.
  101029. * The value can be anything including 'null' but except 'undefined'
  101030. */
  101031. export class StringDictionary<T> {
  101032. /**
  101033. * This will clear this dictionary and copy the content from the 'source' one.
  101034. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101035. * @param source the dictionary to take the content from and copy to this dictionary
  101036. */
  101037. copyFrom(source: StringDictionary<T>): void;
  101038. /**
  101039. * Get a value based from its key
  101040. * @param key the given key to get the matching value from
  101041. * @return the value if found, otherwise undefined is returned
  101042. */
  101043. get(key: string): T | undefined;
  101044. /**
  101045. * Get a value from its key or add it if it doesn't exist.
  101046. * This method will ensure you that a given key/data will be present in the dictionary.
  101047. * @param key the given key to get the matching value from
  101048. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101049. * The factory will only be invoked if there's no data for the given key.
  101050. * @return the value corresponding to the key.
  101051. */
  101052. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101053. /**
  101054. * Get a value from its key if present in the dictionary otherwise add it
  101055. * @param key the key to get the value from
  101056. * @param val if there's no such key/value pair in the dictionary add it with this value
  101057. * @return the value corresponding to the key
  101058. */
  101059. getOrAdd(key: string, val: T): T;
  101060. /**
  101061. * Check if there's a given key in the dictionary
  101062. * @param key the key to check for
  101063. * @return true if the key is present, false otherwise
  101064. */
  101065. contains(key: string): boolean;
  101066. /**
  101067. * Add a new key and its corresponding value
  101068. * @param key the key to add
  101069. * @param value the value corresponding to the key
  101070. * @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
  101071. */
  101072. add(key: string, value: T): boolean;
  101073. /**
  101074. * Update a specific value associated to a key
  101075. * @param key defines the key to use
  101076. * @param value defines the value to store
  101077. * @returns true if the value was updated (or false if the key was not found)
  101078. */
  101079. set(key: string, value: T): boolean;
  101080. /**
  101081. * Get the element of the given key and remove it from the dictionary
  101082. * @param key defines the key to search
  101083. * @returns the value associated with the key or null if not found
  101084. */
  101085. getAndRemove(key: string): Nullable<T>;
  101086. /**
  101087. * Remove a key/value from the dictionary.
  101088. * @param key the key to remove
  101089. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101090. */
  101091. remove(key: string): boolean;
  101092. /**
  101093. * Clear the whole content of the dictionary
  101094. */
  101095. clear(): void;
  101096. /**
  101097. * Gets the current count
  101098. */
  101099. readonly count: number;
  101100. /**
  101101. * Execute a callback on each key/val of the dictionary.
  101102. * Note that you can remove any element in this dictionary in the callback implementation
  101103. * @param callback the callback to execute on a given key/value pair
  101104. */
  101105. forEach(callback: (key: string, val: T) => void): void;
  101106. /**
  101107. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101108. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101109. * Note that you can remove any element in this dictionary in the callback implementation
  101110. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101111. * @returns the first item
  101112. */
  101113. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101114. private _count;
  101115. private _data;
  101116. }
  101117. }
  101118. declare module BABYLON {
  101119. /** @hidden */
  101120. export interface ICollisionCoordinator {
  101121. createCollider(): Collider;
  101122. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101123. init(scene: Scene): void;
  101124. }
  101125. /** @hidden */
  101126. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101127. private _scene;
  101128. private _scaledPosition;
  101129. private _scaledVelocity;
  101130. private _finalPosition;
  101131. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101132. createCollider(): Collider;
  101133. init(scene: Scene): void;
  101134. private _collideWithWorld;
  101135. }
  101136. }
  101137. declare module BABYLON {
  101138. /**
  101139. * Class used to manage all inputs for the scene.
  101140. */
  101141. export class InputManager {
  101142. /** The distance in pixel that you have to move to prevent some events */
  101143. static DragMovementThreshold: number;
  101144. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101145. static LongPressDelay: number;
  101146. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101147. static DoubleClickDelay: number;
  101148. /** If you need to check double click without raising a single click at first click, enable this flag */
  101149. static ExclusiveDoubleClickMode: boolean;
  101150. private _wheelEventName;
  101151. private _onPointerMove;
  101152. private _onPointerDown;
  101153. private _onPointerUp;
  101154. private _initClickEvent;
  101155. private _initActionManager;
  101156. private _delayedSimpleClick;
  101157. private _delayedSimpleClickTimeout;
  101158. private _previousDelayedSimpleClickTimeout;
  101159. private _meshPickProceed;
  101160. private _previousButtonPressed;
  101161. private _currentPickResult;
  101162. private _previousPickResult;
  101163. private _totalPointersPressed;
  101164. private _doubleClickOccured;
  101165. private _pointerOverMesh;
  101166. private _pickedDownMesh;
  101167. private _pickedUpMesh;
  101168. private _pointerX;
  101169. private _pointerY;
  101170. private _unTranslatedPointerX;
  101171. private _unTranslatedPointerY;
  101172. private _startingPointerPosition;
  101173. private _previousStartingPointerPosition;
  101174. private _startingPointerTime;
  101175. private _previousStartingPointerTime;
  101176. private _pointerCaptures;
  101177. private _onKeyDown;
  101178. private _onKeyUp;
  101179. private _onCanvasFocusObserver;
  101180. private _onCanvasBlurObserver;
  101181. private _scene;
  101182. /**
  101183. * Creates a new InputManager
  101184. * @param scene defines the hosting scene
  101185. */
  101186. constructor(scene: Scene);
  101187. /**
  101188. * Gets the mesh that is currently under the pointer
  101189. */
  101190. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101191. /**
  101192. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101193. */
  101194. readonly unTranslatedPointer: Vector2;
  101195. /**
  101196. * Gets or sets the current on-screen X position of the pointer
  101197. */
  101198. pointerX: number;
  101199. /**
  101200. * Gets or sets the current on-screen Y position of the pointer
  101201. */
  101202. pointerY: number;
  101203. private _updatePointerPosition;
  101204. private _processPointerMove;
  101205. private _setRayOnPointerInfo;
  101206. private _checkPrePointerObservable;
  101207. /**
  101208. * Use this method to simulate a pointer move on a mesh
  101209. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101210. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101211. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101212. */
  101213. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101214. /**
  101215. * Use this method to simulate a pointer down on a mesh
  101216. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101217. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101218. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101219. */
  101220. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101221. private _processPointerDown;
  101222. /** @hidden */
  101223. _isPointerSwiping(): boolean;
  101224. /**
  101225. * Use this method to simulate a pointer up on a mesh
  101226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101229. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101230. */
  101231. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101232. private _processPointerUp;
  101233. /**
  101234. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101235. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101236. * @returns true if the pointer was captured
  101237. */
  101238. isPointerCaptured(pointerId?: number): boolean;
  101239. /**
  101240. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101241. * @param attachUp defines if you want to attach events to pointerup
  101242. * @param attachDown defines if you want to attach events to pointerdown
  101243. * @param attachMove defines if you want to attach events to pointermove
  101244. */
  101245. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101246. /**
  101247. * Detaches all event handlers
  101248. */
  101249. detachControl(): void;
  101250. /**
  101251. * Force the value of meshUnderPointer
  101252. * @param mesh defines the mesh to use
  101253. */
  101254. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101255. /**
  101256. * Gets the mesh under the pointer
  101257. * @returns a Mesh or null if no mesh is under the pointer
  101258. */
  101259. getPointerOverMesh(): Nullable<AbstractMesh>;
  101260. }
  101261. }
  101262. declare module BABYLON {
  101263. /**
  101264. * Helper class used to generate session unique ID
  101265. */
  101266. export class UniqueIdGenerator {
  101267. private static _UniqueIdCounter;
  101268. /**
  101269. * Gets an unique (relatively to the current scene) Id
  101270. */
  101271. static readonly UniqueId: number;
  101272. }
  101273. }
  101274. declare module BABYLON {
  101275. /**
  101276. * This class defines the direct association between an animation and a target
  101277. */
  101278. export class TargetedAnimation {
  101279. /**
  101280. * Animation to perform
  101281. */
  101282. animation: Animation;
  101283. /**
  101284. * Target to animate
  101285. */
  101286. target: any;
  101287. /**
  101288. * Serialize the object
  101289. * @returns the JSON object representing the current entity
  101290. */
  101291. serialize(): any;
  101292. }
  101293. /**
  101294. * Use this class to create coordinated animations on multiple targets
  101295. */
  101296. export class AnimationGroup implements IDisposable {
  101297. /** The name of the animation group */
  101298. name: string;
  101299. private _scene;
  101300. private _targetedAnimations;
  101301. private _animatables;
  101302. private _from;
  101303. private _to;
  101304. private _isStarted;
  101305. private _isPaused;
  101306. private _speedRatio;
  101307. private _loopAnimation;
  101308. /**
  101309. * Gets or sets the unique id of the node
  101310. */
  101311. uniqueId: number;
  101312. /**
  101313. * This observable will notify when one animation have ended
  101314. */
  101315. onAnimationEndObservable: Observable<TargetedAnimation>;
  101316. /**
  101317. * Observer raised when one animation loops
  101318. */
  101319. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101320. /**
  101321. * Observer raised when all animations have looped
  101322. */
  101323. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101324. /**
  101325. * This observable will notify when all animations have ended.
  101326. */
  101327. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101328. /**
  101329. * This observable will notify when all animations have paused.
  101330. */
  101331. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101332. /**
  101333. * This observable will notify when all animations are playing.
  101334. */
  101335. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101336. /**
  101337. * Gets the first frame
  101338. */
  101339. readonly from: number;
  101340. /**
  101341. * Gets the last frame
  101342. */
  101343. readonly to: number;
  101344. /**
  101345. * Define if the animations are started
  101346. */
  101347. readonly isStarted: boolean;
  101348. /**
  101349. * Gets a value indicating that the current group is playing
  101350. */
  101351. readonly isPlaying: boolean;
  101352. /**
  101353. * Gets or sets the speed ratio to use for all animations
  101354. */
  101355. /**
  101356. * Gets or sets the speed ratio to use for all animations
  101357. */
  101358. speedRatio: number;
  101359. /**
  101360. * Gets or sets if all animations should loop or not
  101361. */
  101362. loopAnimation: boolean;
  101363. /**
  101364. * Gets the targeted animations for this animation group
  101365. */
  101366. readonly targetedAnimations: Array<TargetedAnimation>;
  101367. /**
  101368. * returning the list of animatables controlled by this animation group.
  101369. */
  101370. readonly animatables: Array<Animatable>;
  101371. /**
  101372. * Instantiates a new Animation Group.
  101373. * This helps managing several animations at once.
  101374. * @see http://doc.babylonjs.com/how_to/group
  101375. * @param name Defines the name of the group
  101376. * @param scene Defines the scene the group belongs to
  101377. */
  101378. constructor(
  101379. /** The name of the animation group */
  101380. name: string, scene?: Nullable<Scene>);
  101381. /**
  101382. * Add an animation (with its target) in the group
  101383. * @param animation defines the animation we want to add
  101384. * @param target defines the target of the animation
  101385. * @returns the TargetedAnimation object
  101386. */
  101387. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101388. /**
  101389. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101390. * It can add constant keys at begin or end
  101391. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101392. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101393. * @returns the animation group
  101394. */
  101395. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101396. private _animationLoopCount;
  101397. private _animationLoopFlags;
  101398. private _processLoop;
  101399. /**
  101400. * Start all animations on given targets
  101401. * @param loop defines if animations must loop
  101402. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101403. * @param from defines the from key (optional)
  101404. * @param to defines the to key (optional)
  101405. * @returns the current animation group
  101406. */
  101407. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101408. /**
  101409. * Pause all animations
  101410. * @returns the animation group
  101411. */
  101412. pause(): AnimationGroup;
  101413. /**
  101414. * Play all animations to initial state
  101415. * This function will start() the animations if they were not started or will restart() them if they were paused
  101416. * @param loop defines if animations must loop
  101417. * @returns the animation group
  101418. */
  101419. play(loop?: boolean): AnimationGroup;
  101420. /**
  101421. * Reset all animations to initial state
  101422. * @returns the animation group
  101423. */
  101424. reset(): AnimationGroup;
  101425. /**
  101426. * Restart animations from key 0
  101427. * @returns the animation group
  101428. */
  101429. restart(): AnimationGroup;
  101430. /**
  101431. * Stop all animations
  101432. * @returns the animation group
  101433. */
  101434. stop(): AnimationGroup;
  101435. /**
  101436. * Set animation weight for all animatables
  101437. * @param weight defines the weight to use
  101438. * @return the animationGroup
  101439. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101440. */
  101441. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101442. /**
  101443. * Synchronize and normalize all animatables with a source animatable
  101444. * @param root defines the root animatable to synchronize with
  101445. * @return the animationGroup
  101446. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101447. */
  101448. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101449. /**
  101450. * Goes to a specific frame in this animation group
  101451. * @param frame the frame number to go to
  101452. * @return the animationGroup
  101453. */
  101454. goToFrame(frame: number): AnimationGroup;
  101455. /**
  101456. * Dispose all associated resources
  101457. */
  101458. dispose(): void;
  101459. private _checkAnimationGroupEnded;
  101460. /**
  101461. * Clone the current animation group and returns a copy
  101462. * @param newName defines the name of the new group
  101463. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101464. * @returns the new aniamtion group
  101465. */
  101466. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101467. /**
  101468. * Serializes the animationGroup to an object
  101469. * @returns Serialized object
  101470. */
  101471. serialize(): any;
  101472. /**
  101473. * Returns a new AnimationGroup object parsed from the source provided.
  101474. * @param parsedAnimationGroup defines the source
  101475. * @param scene defines the scene that will receive the animationGroup
  101476. * @returns a new AnimationGroup
  101477. */
  101478. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101479. /**
  101480. * Returns the string "AnimationGroup"
  101481. * @returns "AnimationGroup"
  101482. */
  101483. getClassName(): string;
  101484. /**
  101485. * Creates a detailled string about the object
  101486. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101487. * @returns a string representing the object
  101488. */
  101489. toString(fullDetails?: boolean): string;
  101490. }
  101491. }
  101492. declare module BABYLON {
  101493. /**
  101494. * Define an interface for all classes that will hold resources
  101495. */
  101496. export interface IDisposable {
  101497. /**
  101498. * Releases all held resources
  101499. */
  101500. dispose(): void;
  101501. }
  101502. /** Interface defining initialization parameters for Scene class */
  101503. export interface SceneOptions {
  101504. /**
  101505. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101506. * It will improve performance when the number of geometries becomes important.
  101507. */
  101508. useGeometryUniqueIdsMap?: boolean;
  101509. /**
  101510. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101511. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101512. */
  101513. useMaterialMeshMap?: boolean;
  101514. /**
  101515. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101516. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101517. */
  101518. useClonedMeshhMap?: boolean;
  101519. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101520. virtual?: boolean;
  101521. }
  101522. /**
  101523. * Represents a scene to be rendered by the engine.
  101524. * @see http://doc.babylonjs.com/features/scene
  101525. */
  101526. export class Scene extends AbstractScene implements IAnimatable {
  101527. /** The fog is deactivated */
  101528. static readonly FOGMODE_NONE: number;
  101529. /** The fog density is following an exponential function */
  101530. static readonly FOGMODE_EXP: number;
  101531. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101532. static readonly FOGMODE_EXP2: number;
  101533. /** The fog density is following a linear function. */
  101534. static readonly FOGMODE_LINEAR: number;
  101535. /**
  101536. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101537. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101538. */
  101539. static MinDeltaTime: number;
  101540. /**
  101541. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101542. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101543. */
  101544. static MaxDeltaTime: number;
  101545. /**
  101546. * Factory used to create the default material.
  101547. * @param name The name of the material to create
  101548. * @param scene The scene to create the material for
  101549. * @returns The default material
  101550. */
  101551. static DefaultMaterialFactory(scene: Scene): Material;
  101552. /**
  101553. * Factory used to create the a collision coordinator.
  101554. * @returns The collision coordinator
  101555. */
  101556. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101557. /** @hidden */
  101558. _inputManager: InputManager;
  101559. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101560. cameraToUseForPointers: Nullable<Camera>;
  101561. /** @hidden */
  101562. readonly _isScene: boolean;
  101563. /**
  101564. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101565. */
  101566. autoClear: boolean;
  101567. /**
  101568. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101569. */
  101570. autoClearDepthAndStencil: boolean;
  101571. /**
  101572. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101573. */
  101574. clearColor: Color4;
  101575. /**
  101576. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101577. */
  101578. ambientColor: Color3;
  101579. /**
  101580. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101581. * It should only be one of the following (if not the default embedded one):
  101582. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101583. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101584. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101585. * The material properties need to be setup according to the type of texture in use.
  101586. */
  101587. environmentBRDFTexture: BaseTexture;
  101588. /** @hidden */
  101589. protected _environmentTexture: Nullable<BaseTexture>;
  101590. /**
  101591. * Texture used in all pbr material as the reflection texture.
  101592. * As in the majority of the scene they are the same (exception for multi room and so on),
  101593. * this is easier to reference from here than from all the materials.
  101594. */
  101595. /**
  101596. * Texture used in all pbr material as the reflection texture.
  101597. * As in the majority of the scene they are the same (exception for multi room and so on),
  101598. * this is easier to set here than in all the materials.
  101599. */
  101600. environmentTexture: Nullable<BaseTexture>;
  101601. /** @hidden */
  101602. protected _environmentIntensity: number;
  101603. /**
  101604. * Intensity of the environment in all pbr material.
  101605. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101606. * As in the majority of the scene they are the same (exception for multi room and so on),
  101607. * this is easier to reference from here than from all the materials.
  101608. */
  101609. /**
  101610. * Intensity of the environment in all pbr material.
  101611. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101612. * As in the majority of the scene they are the same (exception for multi room and so on),
  101613. * this is easier to set here than in all the materials.
  101614. */
  101615. environmentIntensity: number;
  101616. /** @hidden */
  101617. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101618. /**
  101619. * Default image processing configuration used either in the rendering
  101620. * Forward main pass or through the imageProcessingPostProcess if present.
  101621. * As in the majority of the scene they are the same (exception for multi camera),
  101622. * this is easier to reference from here than from all the materials and post process.
  101623. *
  101624. * No setter as we it is a shared configuration, you can set the values instead.
  101625. */
  101626. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101627. private _forceWireframe;
  101628. /**
  101629. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101630. */
  101631. forceWireframe: boolean;
  101632. private _forcePointsCloud;
  101633. /**
  101634. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101635. */
  101636. forcePointsCloud: boolean;
  101637. /**
  101638. * Gets or sets the active clipplane 1
  101639. */
  101640. clipPlane: Nullable<Plane>;
  101641. /**
  101642. * Gets or sets the active clipplane 2
  101643. */
  101644. clipPlane2: Nullable<Plane>;
  101645. /**
  101646. * Gets or sets the active clipplane 3
  101647. */
  101648. clipPlane3: Nullable<Plane>;
  101649. /**
  101650. * Gets or sets the active clipplane 4
  101651. */
  101652. clipPlane4: Nullable<Plane>;
  101653. /**
  101654. * Gets or sets a boolean indicating if animations are enabled
  101655. */
  101656. animationsEnabled: boolean;
  101657. private _animationPropertiesOverride;
  101658. /**
  101659. * Gets or sets the animation properties override
  101660. */
  101661. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101662. /**
  101663. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101664. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101665. */
  101666. useConstantAnimationDeltaTime: boolean;
  101667. /**
  101668. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101669. * Please note that it requires to run a ray cast through the scene on every frame
  101670. */
  101671. constantlyUpdateMeshUnderPointer: boolean;
  101672. /**
  101673. * Defines the HTML cursor to use when hovering over interactive elements
  101674. */
  101675. hoverCursor: string;
  101676. /**
  101677. * Defines the HTML default cursor to use (empty by default)
  101678. */
  101679. defaultCursor: string;
  101680. /**
  101681. * Defines wether cursors are handled by the scene.
  101682. */
  101683. doNotHandleCursors: boolean;
  101684. /**
  101685. * This is used to call preventDefault() on pointer down
  101686. * in order to block unwanted artifacts like system double clicks
  101687. */
  101688. preventDefaultOnPointerDown: boolean;
  101689. /**
  101690. * This is used to call preventDefault() on pointer up
  101691. * in order to block unwanted artifacts like system double clicks
  101692. */
  101693. preventDefaultOnPointerUp: boolean;
  101694. /**
  101695. * Gets or sets user defined metadata
  101696. */
  101697. metadata: any;
  101698. /**
  101699. * For internal use only. Please do not use.
  101700. */
  101701. reservedDataStore: any;
  101702. /**
  101703. * Gets the name of the plugin used to load this scene (null by default)
  101704. */
  101705. loadingPluginName: string;
  101706. /**
  101707. * Use this array to add regular expressions used to disable offline support for specific urls
  101708. */
  101709. disableOfflineSupportExceptionRules: RegExp[];
  101710. /**
  101711. * An event triggered when the scene is disposed.
  101712. */
  101713. onDisposeObservable: Observable<Scene>;
  101714. private _onDisposeObserver;
  101715. /** Sets a function to be executed when this scene is disposed. */
  101716. onDispose: () => void;
  101717. /**
  101718. * An event triggered before rendering the scene (right after animations and physics)
  101719. */
  101720. onBeforeRenderObservable: Observable<Scene>;
  101721. private _onBeforeRenderObserver;
  101722. /** Sets a function to be executed before rendering this scene */
  101723. beforeRender: Nullable<() => void>;
  101724. /**
  101725. * An event triggered after rendering the scene
  101726. */
  101727. onAfterRenderObservable: Observable<Scene>;
  101728. /**
  101729. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  101730. */
  101731. onAfterRenderCameraObservable: Observable<Camera>;
  101732. private _onAfterRenderObserver;
  101733. /** Sets a function to be executed after rendering this scene */
  101734. afterRender: Nullable<() => void>;
  101735. /**
  101736. * An event triggered before animating the scene
  101737. */
  101738. onBeforeAnimationsObservable: Observable<Scene>;
  101739. /**
  101740. * An event triggered after animations processing
  101741. */
  101742. onAfterAnimationsObservable: Observable<Scene>;
  101743. /**
  101744. * An event triggered before draw calls are ready to be sent
  101745. */
  101746. onBeforeDrawPhaseObservable: Observable<Scene>;
  101747. /**
  101748. * An event triggered after draw calls have been sent
  101749. */
  101750. onAfterDrawPhaseObservable: Observable<Scene>;
  101751. /**
  101752. * An event triggered when the scene is ready
  101753. */
  101754. onReadyObservable: Observable<Scene>;
  101755. /**
  101756. * An event triggered before rendering a camera
  101757. */
  101758. onBeforeCameraRenderObservable: Observable<Camera>;
  101759. private _onBeforeCameraRenderObserver;
  101760. /** Sets a function to be executed before rendering a camera*/
  101761. beforeCameraRender: () => void;
  101762. /**
  101763. * An event triggered after rendering a camera
  101764. */
  101765. onAfterCameraRenderObservable: Observable<Camera>;
  101766. private _onAfterCameraRenderObserver;
  101767. /** Sets a function to be executed after rendering a camera*/
  101768. afterCameraRender: () => void;
  101769. /**
  101770. * An event triggered when active meshes evaluation is about to start
  101771. */
  101772. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  101773. /**
  101774. * An event triggered when active meshes evaluation is done
  101775. */
  101776. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  101777. /**
  101778. * An event triggered when particles rendering is about to start
  101779. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101780. */
  101781. onBeforeParticlesRenderingObservable: Observable<Scene>;
  101782. /**
  101783. * An event triggered when particles rendering is done
  101784. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  101785. */
  101786. onAfterParticlesRenderingObservable: Observable<Scene>;
  101787. /**
  101788. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  101789. */
  101790. onDataLoadedObservable: Observable<Scene>;
  101791. /**
  101792. * An event triggered when a camera is created
  101793. */
  101794. onNewCameraAddedObservable: Observable<Camera>;
  101795. /**
  101796. * An event triggered when a camera is removed
  101797. */
  101798. onCameraRemovedObservable: Observable<Camera>;
  101799. /**
  101800. * An event triggered when a light is created
  101801. */
  101802. onNewLightAddedObservable: Observable<Light>;
  101803. /**
  101804. * An event triggered when a light is removed
  101805. */
  101806. onLightRemovedObservable: Observable<Light>;
  101807. /**
  101808. * An event triggered when a geometry is created
  101809. */
  101810. onNewGeometryAddedObservable: Observable<Geometry>;
  101811. /**
  101812. * An event triggered when a geometry is removed
  101813. */
  101814. onGeometryRemovedObservable: Observable<Geometry>;
  101815. /**
  101816. * An event triggered when a transform node is created
  101817. */
  101818. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101819. /**
  101820. * An event triggered when a transform node is removed
  101821. */
  101822. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101823. /**
  101824. * An event triggered when a mesh is created
  101825. */
  101826. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101827. /**
  101828. * An event triggered when a mesh is removed
  101829. */
  101830. onMeshRemovedObservable: Observable<AbstractMesh>;
  101831. /**
  101832. * An event triggered when a skeleton is created
  101833. */
  101834. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101835. /**
  101836. * An event triggered when a skeleton is removed
  101837. */
  101838. onSkeletonRemovedObservable: Observable<Skeleton>;
  101839. /**
  101840. * An event triggered when a material is created
  101841. */
  101842. onNewMaterialAddedObservable: Observable<Material>;
  101843. /**
  101844. * An event triggered when a material is removed
  101845. */
  101846. onMaterialRemovedObservable: Observable<Material>;
  101847. /**
  101848. * An event triggered when a texture is created
  101849. */
  101850. onNewTextureAddedObservable: Observable<BaseTexture>;
  101851. /**
  101852. * An event triggered when a texture is removed
  101853. */
  101854. onTextureRemovedObservable: Observable<BaseTexture>;
  101855. /**
  101856. * An event triggered when render targets are about to be rendered
  101857. * Can happen multiple times per frame.
  101858. */
  101859. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101860. /**
  101861. * An event triggered when render targets were rendered.
  101862. * Can happen multiple times per frame.
  101863. */
  101864. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101865. /**
  101866. * An event triggered before calculating deterministic simulation step
  101867. */
  101868. onBeforeStepObservable: Observable<Scene>;
  101869. /**
  101870. * An event triggered after calculating deterministic simulation step
  101871. */
  101872. onAfterStepObservable: Observable<Scene>;
  101873. /**
  101874. * An event triggered when the activeCamera property is updated
  101875. */
  101876. onActiveCameraChanged: Observable<Scene>;
  101877. /**
  101878. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101879. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101880. * 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)
  101881. */
  101882. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101883. /**
  101884. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101885. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101886. * 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)
  101887. */
  101888. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101889. /**
  101890. * This Observable will when a mesh has been imported into the scene.
  101891. */
  101892. onMeshImportedObservable: Observable<AbstractMesh>;
  101893. /**
  101894. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101895. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101896. */
  101897. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101898. /** @hidden */
  101899. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101900. /**
  101901. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101902. */
  101903. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101904. /**
  101905. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101906. */
  101907. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101908. /**
  101909. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101910. */
  101911. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101912. /** Callback called when a pointer move is detected */
  101913. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101914. /** Callback called when a pointer down is detected */
  101915. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101916. /** Callback called when a pointer up is detected */
  101917. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101918. /** Callback called when a pointer pick is detected */
  101919. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101920. /**
  101921. * 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).
  101922. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101923. */
  101924. onPrePointerObservable: Observable<PointerInfoPre>;
  101925. /**
  101926. * Observable event triggered each time an input event is received from the rendering canvas
  101927. */
  101928. onPointerObservable: Observable<PointerInfo>;
  101929. /**
  101930. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101931. */
  101932. readonly unTranslatedPointer: Vector2;
  101933. /**
  101934. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101935. */
  101936. static DragMovementThreshold: number;
  101937. /**
  101938. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101939. */
  101940. static LongPressDelay: number;
  101941. /**
  101942. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101943. */
  101944. static DoubleClickDelay: number;
  101945. /** If you need to check double click without raising a single click at first click, enable this flag */
  101946. static ExclusiveDoubleClickMode: boolean;
  101947. /** @hidden */
  101948. _mirroredCameraPosition: Nullable<Vector3>;
  101949. /**
  101950. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101951. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101952. */
  101953. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101954. /**
  101955. * Observable event triggered each time an keyboard event is received from the hosting window
  101956. */
  101957. onKeyboardObservable: Observable<KeyboardInfo>;
  101958. private _useRightHandedSystem;
  101959. /**
  101960. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101961. */
  101962. useRightHandedSystem: boolean;
  101963. private _timeAccumulator;
  101964. private _currentStepId;
  101965. private _currentInternalStep;
  101966. /**
  101967. * Sets the step Id used by deterministic lock step
  101968. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101969. * @param newStepId defines the step Id
  101970. */
  101971. setStepId(newStepId: number): void;
  101972. /**
  101973. * Gets the step Id used by deterministic lock step
  101974. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101975. * @returns the step Id
  101976. */
  101977. getStepId(): number;
  101978. /**
  101979. * Gets the internal step used by deterministic lock step
  101980. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101981. * @returns the internal step
  101982. */
  101983. getInternalStep(): number;
  101984. private _fogEnabled;
  101985. /**
  101986. * Gets or sets a boolean indicating if fog is enabled on this scene
  101987. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101988. * (Default is true)
  101989. */
  101990. fogEnabled: boolean;
  101991. private _fogMode;
  101992. /**
  101993. * Gets or sets the fog mode to use
  101994. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101995. * | mode | value |
  101996. * | --- | --- |
  101997. * | FOGMODE_NONE | 0 |
  101998. * | FOGMODE_EXP | 1 |
  101999. * | FOGMODE_EXP2 | 2 |
  102000. * | FOGMODE_LINEAR | 3 |
  102001. */
  102002. fogMode: number;
  102003. /**
  102004. * Gets or sets the fog color to use
  102005. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102006. * (Default is Color3(0.2, 0.2, 0.3))
  102007. */
  102008. fogColor: Color3;
  102009. /**
  102010. * Gets or sets the fog density to use
  102011. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102012. * (Default is 0.1)
  102013. */
  102014. fogDensity: number;
  102015. /**
  102016. * Gets or sets the fog start distance to use
  102017. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102018. * (Default is 0)
  102019. */
  102020. fogStart: number;
  102021. /**
  102022. * Gets or sets the fog end distance to use
  102023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102024. * (Default is 1000)
  102025. */
  102026. fogEnd: number;
  102027. private _shadowsEnabled;
  102028. /**
  102029. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102030. */
  102031. shadowsEnabled: boolean;
  102032. private _lightsEnabled;
  102033. /**
  102034. * Gets or sets a boolean indicating if lights are enabled on this scene
  102035. */
  102036. lightsEnabled: boolean;
  102037. /** All of the active cameras added to this scene. */
  102038. activeCameras: Camera[];
  102039. /** @hidden */
  102040. _activeCamera: Nullable<Camera>;
  102041. /** Gets or sets the current active camera */
  102042. activeCamera: Nullable<Camera>;
  102043. private _defaultMaterial;
  102044. /** The default material used on meshes when no material is affected */
  102045. /** The default material used on meshes when no material is affected */
  102046. defaultMaterial: Material;
  102047. private _texturesEnabled;
  102048. /**
  102049. * Gets or sets a boolean indicating if textures are enabled on this scene
  102050. */
  102051. texturesEnabled: boolean;
  102052. /**
  102053. * Gets or sets a boolean indicating if particles are enabled on this scene
  102054. */
  102055. particlesEnabled: boolean;
  102056. /**
  102057. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102058. */
  102059. spritesEnabled: boolean;
  102060. private _skeletonsEnabled;
  102061. /**
  102062. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102063. */
  102064. skeletonsEnabled: boolean;
  102065. /**
  102066. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102067. */
  102068. lensFlaresEnabled: boolean;
  102069. /**
  102070. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102072. */
  102073. collisionsEnabled: boolean;
  102074. private _collisionCoordinator;
  102075. /** @hidden */
  102076. readonly collisionCoordinator: ICollisionCoordinator;
  102077. /**
  102078. * Defines the gravity applied to this scene (used only for collisions)
  102079. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102080. */
  102081. gravity: Vector3;
  102082. /**
  102083. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102084. */
  102085. postProcessesEnabled: boolean;
  102086. /**
  102087. * The list of postprocesses added to the scene
  102088. */
  102089. postProcesses: PostProcess[];
  102090. /**
  102091. * Gets the current postprocess manager
  102092. */
  102093. postProcessManager: PostProcessManager;
  102094. /**
  102095. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102096. */
  102097. renderTargetsEnabled: boolean;
  102098. /**
  102099. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102100. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102101. */
  102102. dumpNextRenderTargets: boolean;
  102103. /**
  102104. * The list of user defined render targets added to the scene
  102105. */
  102106. customRenderTargets: RenderTargetTexture[];
  102107. /**
  102108. * Defines if texture loading must be delayed
  102109. * If true, textures will only be loaded when they need to be rendered
  102110. */
  102111. useDelayedTextureLoading: boolean;
  102112. /**
  102113. * Gets the list of meshes imported to the scene through SceneLoader
  102114. */
  102115. importedMeshesFiles: String[];
  102116. /**
  102117. * Gets or sets a boolean indicating if probes are enabled on this scene
  102118. */
  102119. probesEnabled: boolean;
  102120. /**
  102121. * Gets or sets the current offline provider to use to store scene data
  102122. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102123. */
  102124. offlineProvider: IOfflineProvider;
  102125. /**
  102126. * Gets or sets the action manager associated with the scene
  102127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102128. */
  102129. actionManager: AbstractActionManager;
  102130. private _meshesForIntersections;
  102131. /**
  102132. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102133. */
  102134. proceduralTexturesEnabled: boolean;
  102135. private _engine;
  102136. private _totalVertices;
  102137. /** @hidden */
  102138. _activeIndices: PerfCounter;
  102139. /** @hidden */
  102140. _activeParticles: PerfCounter;
  102141. /** @hidden */
  102142. _activeBones: PerfCounter;
  102143. private _animationRatio;
  102144. /** @hidden */
  102145. _animationTimeLast: number;
  102146. /** @hidden */
  102147. _animationTime: number;
  102148. /**
  102149. * Gets or sets a general scale for animation speed
  102150. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102151. */
  102152. animationTimeScale: number;
  102153. /** @hidden */
  102154. _cachedMaterial: Nullable<Material>;
  102155. /** @hidden */
  102156. _cachedEffect: Nullable<Effect>;
  102157. /** @hidden */
  102158. _cachedVisibility: Nullable<number>;
  102159. private _renderId;
  102160. private _frameId;
  102161. private _executeWhenReadyTimeoutId;
  102162. private _intermediateRendering;
  102163. private _viewUpdateFlag;
  102164. private _projectionUpdateFlag;
  102165. /** @hidden */
  102166. _toBeDisposed: Nullable<IDisposable>[];
  102167. private _activeRequests;
  102168. /** @hidden */
  102169. _pendingData: any[];
  102170. private _isDisposed;
  102171. /**
  102172. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102173. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102174. */
  102175. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102176. private _activeMeshes;
  102177. private _processedMaterials;
  102178. private _renderTargets;
  102179. /** @hidden */
  102180. _activeParticleSystems: SmartArray<IParticleSystem>;
  102181. private _activeSkeletons;
  102182. private _softwareSkinnedMeshes;
  102183. private _renderingManager;
  102184. /** @hidden */
  102185. _activeAnimatables: Animatable[];
  102186. private _transformMatrix;
  102187. private _sceneUbo;
  102188. /** @hidden */
  102189. _viewMatrix: Matrix;
  102190. private _projectionMatrix;
  102191. /** @hidden */
  102192. _forcedViewPosition: Nullable<Vector3>;
  102193. /** @hidden */
  102194. _frustumPlanes: Plane[];
  102195. /**
  102196. * Gets the list of frustum planes (built from the active camera)
  102197. */
  102198. readonly frustumPlanes: Plane[];
  102199. /**
  102200. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102201. * This is useful if there are more lights that the maximum simulteanous authorized
  102202. */
  102203. requireLightSorting: boolean;
  102204. /** @hidden */
  102205. readonly useMaterialMeshMap: boolean;
  102206. /** @hidden */
  102207. readonly useClonedMeshhMap: boolean;
  102208. private _externalData;
  102209. private _uid;
  102210. /**
  102211. * @hidden
  102212. * Backing store of defined scene components.
  102213. */
  102214. _components: ISceneComponent[];
  102215. /**
  102216. * @hidden
  102217. * Backing store of defined scene components.
  102218. */
  102219. _serializableComponents: ISceneSerializableComponent[];
  102220. /**
  102221. * List of components to register on the next registration step.
  102222. */
  102223. private _transientComponents;
  102224. /**
  102225. * Registers the transient components if needed.
  102226. */
  102227. private _registerTransientComponents;
  102228. /**
  102229. * @hidden
  102230. * Add a component to the scene.
  102231. * Note that the ccomponent could be registered on th next frame if this is called after
  102232. * the register component stage.
  102233. * @param component Defines the component to add to the scene
  102234. */
  102235. _addComponent(component: ISceneComponent): void;
  102236. /**
  102237. * @hidden
  102238. * Gets a component from the scene.
  102239. * @param name defines the name of the component to retrieve
  102240. * @returns the component or null if not present
  102241. */
  102242. _getComponent(name: string): Nullable<ISceneComponent>;
  102243. /**
  102244. * @hidden
  102245. * Defines the actions happening before camera updates.
  102246. */
  102247. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102248. /**
  102249. * @hidden
  102250. * Defines the actions happening before clear the canvas.
  102251. */
  102252. _beforeClearStage: Stage<SimpleStageAction>;
  102253. /**
  102254. * @hidden
  102255. * Defines the actions when collecting render targets for the frame.
  102256. */
  102257. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102258. /**
  102259. * @hidden
  102260. * Defines the actions happening for one camera in the frame.
  102261. */
  102262. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102263. /**
  102264. * @hidden
  102265. * Defines the actions happening during the per mesh ready checks.
  102266. */
  102267. _isReadyForMeshStage: Stage<MeshStageAction>;
  102268. /**
  102269. * @hidden
  102270. * Defines the actions happening before evaluate active mesh checks.
  102271. */
  102272. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102273. /**
  102274. * @hidden
  102275. * Defines the actions happening during the evaluate sub mesh checks.
  102276. */
  102277. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102278. /**
  102279. * @hidden
  102280. * Defines the actions happening during the active mesh stage.
  102281. */
  102282. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102283. /**
  102284. * @hidden
  102285. * Defines the actions happening during the per camera render target step.
  102286. */
  102287. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102288. /**
  102289. * @hidden
  102290. * Defines the actions happening just before the active camera is drawing.
  102291. */
  102292. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102293. /**
  102294. * @hidden
  102295. * Defines the actions happening just before a render target is drawing.
  102296. */
  102297. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102298. /**
  102299. * @hidden
  102300. * Defines the actions happening just before a rendering group is drawing.
  102301. */
  102302. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102303. /**
  102304. * @hidden
  102305. * Defines the actions happening just before a mesh is drawing.
  102306. */
  102307. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102308. /**
  102309. * @hidden
  102310. * Defines the actions happening just after a mesh has been drawn.
  102311. */
  102312. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102313. /**
  102314. * @hidden
  102315. * Defines the actions happening just after a rendering group has been drawn.
  102316. */
  102317. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102318. /**
  102319. * @hidden
  102320. * Defines the actions happening just after the active camera has been drawn.
  102321. */
  102322. _afterCameraDrawStage: Stage<CameraStageAction>;
  102323. /**
  102324. * @hidden
  102325. * Defines the actions happening just after a render target has been drawn.
  102326. */
  102327. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102328. /**
  102329. * @hidden
  102330. * Defines the actions happening just after rendering all cameras and computing intersections.
  102331. */
  102332. _afterRenderStage: Stage<SimpleStageAction>;
  102333. /**
  102334. * @hidden
  102335. * Defines the actions happening when a pointer move event happens.
  102336. */
  102337. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102338. /**
  102339. * @hidden
  102340. * Defines the actions happening when a pointer down event happens.
  102341. */
  102342. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102343. /**
  102344. * @hidden
  102345. * Defines the actions happening when a pointer up event happens.
  102346. */
  102347. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102348. /**
  102349. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102350. */
  102351. private geometriesByUniqueId;
  102352. /**
  102353. * Creates a new Scene
  102354. * @param engine defines the engine to use to render this scene
  102355. * @param options defines the scene options
  102356. */
  102357. constructor(engine: Engine, options?: SceneOptions);
  102358. /**
  102359. * Gets a string idenfifying the name of the class
  102360. * @returns "Scene" string
  102361. */
  102362. getClassName(): string;
  102363. private _defaultMeshCandidates;
  102364. /**
  102365. * @hidden
  102366. */
  102367. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102368. private _defaultSubMeshCandidates;
  102369. /**
  102370. * @hidden
  102371. */
  102372. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102373. /**
  102374. * Sets the default candidate providers for the scene.
  102375. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102376. * and getCollidingSubMeshCandidates to their default function
  102377. */
  102378. setDefaultCandidateProviders(): void;
  102379. /**
  102380. * Gets the mesh that is currently under the pointer
  102381. */
  102382. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102383. /**
  102384. * Gets or sets the current on-screen X position of the pointer
  102385. */
  102386. pointerX: number;
  102387. /**
  102388. * Gets or sets the current on-screen Y position of the pointer
  102389. */
  102390. pointerY: number;
  102391. /**
  102392. * Gets the cached material (ie. the latest rendered one)
  102393. * @returns the cached material
  102394. */
  102395. getCachedMaterial(): Nullable<Material>;
  102396. /**
  102397. * Gets the cached effect (ie. the latest rendered one)
  102398. * @returns the cached effect
  102399. */
  102400. getCachedEffect(): Nullable<Effect>;
  102401. /**
  102402. * Gets the cached visibility state (ie. the latest rendered one)
  102403. * @returns the cached visibility state
  102404. */
  102405. getCachedVisibility(): Nullable<number>;
  102406. /**
  102407. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102408. * @param material defines the current material
  102409. * @param effect defines the current effect
  102410. * @param visibility defines the current visibility state
  102411. * @returns true if one parameter is not cached
  102412. */
  102413. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102414. /**
  102415. * Gets the engine associated with the scene
  102416. * @returns an Engine
  102417. */
  102418. getEngine(): Engine;
  102419. /**
  102420. * Gets the total number of vertices rendered per frame
  102421. * @returns the total number of vertices rendered per frame
  102422. */
  102423. getTotalVertices(): number;
  102424. /**
  102425. * Gets the performance counter for total vertices
  102426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102427. */
  102428. readonly totalVerticesPerfCounter: PerfCounter;
  102429. /**
  102430. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102431. * @returns the total number of active indices rendered per frame
  102432. */
  102433. getActiveIndices(): number;
  102434. /**
  102435. * Gets the performance counter for active indices
  102436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102437. */
  102438. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102439. /**
  102440. * Gets the total number of active particles rendered per frame
  102441. * @returns the total number of active particles rendered per frame
  102442. */
  102443. getActiveParticles(): number;
  102444. /**
  102445. * Gets the performance counter for active particles
  102446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102447. */
  102448. readonly activeParticlesPerfCounter: PerfCounter;
  102449. /**
  102450. * Gets the total number of active bones rendered per frame
  102451. * @returns the total number of active bones rendered per frame
  102452. */
  102453. getActiveBones(): number;
  102454. /**
  102455. * Gets the performance counter for active bones
  102456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102457. */
  102458. readonly activeBonesPerfCounter: PerfCounter;
  102459. /**
  102460. * Gets the array of active meshes
  102461. * @returns an array of AbstractMesh
  102462. */
  102463. getActiveMeshes(): SmartArray<AbstractMesh>;
  102464. /**
  102465. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102466. * @returns a number
  102467. */
  102468. getAnimationRatio(): number;
  102469. /**
  102470. * Gets an unique Id for the current render phase
  102471. * @returns a number
  102472. */
  102473. getRenderId(): number;
  102474. /**
  102475. * Gets an unique Id for the current frame
  102476. * @returns a number
  102477. */
  102478. getFrameId(): number;
  102479. /** Call this function if you want to manually increment the render Id*/
  102480. incrementRenderId(): void;
  102481. private _createUbo;
  102482. /**
  102483. * Use this method to simulate a pointer move on a mesh
  102484. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102485. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102486. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102487. * @returns the current scene
  102488. */
  102489. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102490. /**
  102491. * Use this method to simulate a pointer down on a mesh
  102492. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102493. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102494. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102495. * @returns the current scene
  102496. */
  102497. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102498. /**
  102499. * Use this method to simulate a pointer up on a mesh
  102500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102503. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102504. * @returns the current scene
  102505. */
  102506. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102507. /**
  102508. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102509. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102510. * @returns true if the pointer was captured
  102511. */
  102512. isPointerCaptured(pointerId?: number): boolean;
  102513. /**
  102514. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102515. * @param attachUp defines if you want to attach events to pointerup
  102516. * @param attachDown defines if you want to attach events to pointerdown
  102517. * @param attachMove defines if you want to attach events to pointermove
  102518. */
  102519. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102520. /** Detaches all event handlers*/
  102521. detachControl(): void;
  102522. /**
  102523. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102524. * Delay loaded resources are not taking in account
  102525. * @return true if all required resources are ready
  102526. */
  102527. isReady(): boolean;
  102528. /** Resets all cached information relative to material (including effect and visibility) */
  102529. resetCachedMaterial(): void;
  102530. /**
  102531. * Registers a function to be called before every frame render
  102532. * @param func defines the function to register
  102533. */
  102534. registerBeforeRender(func: () => void): void;
  102535. /**
  102536. * Unregisters a function called before every frame render
  102537. * @param func defines the function to unregister
  102538. */
  102539. unregisterBeforeRender(func: () => void): void;
  102540. /**
  102541. * Registers a function to be called after every frame render
  102542. * @param func defines the function to register
  102543. */
  102544. registerAfterRender(func: () => void): void;
  102545. /**
  102546. * Unregisters a function called after every frame render
  102547. * @param func defines the function to unregister
  102548. */
  102549. unregisterAfterRender(func: () => void): void;
  102550. private _executeOnceBeforeRender;
  102551. /**
  102552. * The provided function will run before render once and will be disposed afterwards.
  102553. * A timeout delay can be provided so that the function will be executed in N ms.
  102554. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102555. * @param func The function to be executed.
  102556. * @param timeout optional delay in ms
  102557. */
  102558. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102559. /** @hidden */
  102560. _addPendingData(data: any): void;
  102561. /** @hidden */
  102562. _removePendingData(data: any): void;
  102563. /**
  102564. * Returns the number of items waiting to be loaded
  102565. * @returns the number of items waiting to be loaded
  102566. */
  102567. getWaitingItemsCount(): number;
  102568. /**
  102569. * Returns a boolean indicating if the scene is still loading data
  102570. */
  102571. readonly isLoading: boolean;
  102572. /**
  102573. * Registers a function to be executed when the scene is ready
  102574. * @param {Function} func - the function to be executed
  102575. */
  102576. executeWhenReady(func: () => void): void;
  102577. /**
  102578. * Returns a promise that resolves when the scene is ready
  102579. * @returns A promise that resolves when the scene is ready
  102580. */
  102581. whenReadyAsync(): Promise<void>;
  102582. /** @hidden */
  102583. _checkIsReady(): void;
  102584. /**
  102585. * Gets all animatable attached to the scene
  102586. */
  102587. readonly animatables: Animatable[];
  102588. /**
  102589. * Resets the last animation time frame.
  102590. * Useful to override when animations start running when loading a scene for the first time.
  102591. */
  102592. resetLastAnimationTimeFrame(): void;
  102593. /**
  102594. * Gets the current view matrix
  102595. * @returns a Matrix
  102596. */
  102597. getViewMatrix(): Matrix;
  102598. /**
  102599. * Gets the current projection matrix
  102600. * @returns a Matrix
  102601. */
  102602. getProjectionMatrix(): Matrix;
  102603. /**
  102604. * Gets the current transform matrix
  102605. * @returns a Matrix made of View * Projection
  102606. */
  102607. getTransformMatrix(): Matrix;
  102608. /**
  102609. * Sets the current transform matrix
  102610. * @param viewL defines the View matrix to use
  102611. * @param projectionL defines the Projection matrix to use
  102612. * @param viewR defines the right View matrix to use (if provided)
  102613. * @param projectionR defines the right Projection matrix to use (if provided)
  102614. */
  102615. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102616. /**
  102617. * Gets the uniform buffer used to store scene data
  102618. * @returns a UniformBuffer
  102619. */
  102620. getSceneUniformBuffer(): UniformBuffer;
  102621. /**
  102622. * Gets an unique (relatively to the current scene) Id
  102623. * @returns an unique number for the scene
  102624. */
  102625. getUniqueId(): number;
  102626. /**
  102627. * Add a mesh to the list of scene's meshes
  102628. * @param newMesh defines the mesh to add
  102629. * @param recursive if all child meshes should also be added to the scene
  102630. */
  102631. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102632. /**
  102633. * Remove a mesh for the list of scene's meshes
  102634. * @param toRemove defines the mesh to remove
  102635. * @param recursive if all child meshes should also be removed from the scene
  102636. * @returns the index where the mesh was in the mesh list
  102637. */
  102638. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102639. /**
  102640. * Add a transform node to the list of scene's transform nodes
  102641. * @param newTransformNode defines the transform node to add
  102642. */
  102643. addTransformNode(newTransformNode: TransformNode): void;
  102644. /**
  102645. * Remove a transform node for the list of scene's transform nodes
  102646. * @param toRemove defines the transform node to remove
  102647. * @returns the index where the transform node was in the transform node list
  102648. */
  102649. removeTransformNode(toRemove: TransformNode): number;
  102650. /**
  102651. * Remove a skeleton for the list of scene's skeletons
  102652. * @param toRemove defines the skeleton to remove
  102653. * @returns the index where the skeleton was in the skeleton list
  102654. */
  102655. removeSkeleton(toRemove: Skeleton): number;
  102656. /**
  102657. * Remove a morph target for the list of scene's morph targets
  102658. * @param toRemove defines the morph target to remove
  102659. * @returns the index where the morph target was in the morph target list
  102660. */
  102661. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102662. /**
  102663. * Remove a light for the list of scene's lights
  102664. * @param toRemove defines the light to remove
  102665. * @returns the index where the light was in the light list
  102666. */
  102667. removeLight(toRemove: Light): number;
  102668. /**
  102669. * Remove a camera for the list of scene's cameras
  102670. * @param toRemove defines the camera to remove
  102671. * @returns the index where the camera was in the camera list
  102672. */
  102673. removeCamera(toRemove: Camera): number;
  102674. /**
  102675. * Remove a particle system for the list of scene's particle systems
  102676. * @param toRemove defines the particle system to remove
  102677. * @returns the index where the particle system was in the particle system list
  102678. */
  102679. removeParticleSystem(toRemove: IParticleSystem): number;
  102680. /**
  102681. * Remove a animation for the list of scene's animations
  102682. * @param toRemove defines the animation to remove
  102683. * @returns the index where the animation was in the animation list
  102684. */
  102685. removeAnimation(toRemove: Animation): number;
  102686. /**
  102687. * Will stop the animation of the given target
  102688. * @param target - the target
  102689. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102690. * @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)
  102691. */
  102692. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102693. /**
  102694. * Removes the given animation group from this scene.
  102695. * @param toRemove The animation group to remove
  102696. * @returns The index of the removed animation group
  102697. */
  102698. removeAnimationGroup(toRemove: AnimationGroup): number;
  102699. /**
  102700. * Removes the given multi-material from this scene.
  102701. * @param toRemove The multi-material to remove
  102702. * @returns The index of the removed multi-material
  102703. */
  102704. removeMultiMaterial(toRemove: MultiMaterial): number;
  102705. /**
  102706. * Removes the given material from this scene.
  102707. * @param toRemove The material to remove
  102708. * @returns The index of the removed material
  102709. */
  102710. removeMaterial(toRemove: Material): number;
  102711. /**
  102712. * Removes the given action manager from this scene.
  102713. * @param toRemove The action manager to remove
  102714. * @returns The index of the removed action manager
  102715. */
  102716. removeActionManager(toRemove: AbstractActionManager): number;
  102717. /**
  102718. * Removes the given texture from this scene.
  102719. * @param toRemove The texture to remove
  102720. * @returns The index of the removed texture
  102721. */
  102722. removeTexture(toRemove: BaseTexture): number;
  102723. /**
  102724. * Adds the given light to this scene
  102725. * @param newLight The light to add
  102726. */
  102727. addLight(newLight: Light): void;
  102728. /**
  102729. * Sorts the list list based on light priorities
  102730. */
  102731. sortLightsByPriority(): void;
  102732. /**
  102733. * Adds the given camera to this scene
  102734. * @param newCamera The camera to add
  102735. */
  102736. addCamera(newCamera: Camera): void;
  102737. /**
  102738. * Adds the given skeleton to this scene
  102739. * @param newSkeleton The skeleton to add
  102740. */
  102741. addSkeleton(newSkeleton: Skeleton): void;
  102742. /**
  102743. * Adds the given particle system to this scene
  102744. * @param newParticleSystem The particle system to add
  102745. */
  102746. addParticleSystem(newParticleSystem: IParticleSystem): void;
  102747. /**
  102748. * Adds the given animation to this scene
  102749. * @param newAnimation The animation to add
  102750. */
  102751. addAnimation(newAnimation: Animation): void;
  102752. /**
  102753. * Adds the given animation group to this scene.
  102754. * @param newAnimationGroup The animation group to add
  102755. */
  102756. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  102757. /**
  102758. * Adds the given multi-material to this scene
  102759. * @param newMultiMaterial The multi-material to add
  102760. */
  102761. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  102762. /**
  102763. * Adds the given material to this scene
  102764. * @param newMaterial The material to add
  102765. */
  102766. addMaterial(newMaterial: Material): void;
  102767. /**
  102768. * Adds the given morph target to this scene
  102769. * @param newMorphTargetManager The morph target to add
  102770. */
  102771. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  102772. /**
  102773. * Adds the given geometry to this scene
  102774. * @param newGeometry The geometry to add
  102775. */
  102776. addGeometry(newGeometry: Geometry): void;
  102777. /**
  102778. * Adds the given action manager to this scene
  102779. * @param newActionManager The action manager to add
  102780. */
  102781. addActionManager(newActionManager: AbstractActionManager): void;
  102782. /**
  102783. * Adds the given texture to this scene.
  102784. * @param newTexture The texture to add
  102785. */
  102786. addTexture(newTexture: BaseTexture): void;
  102787. /**
  102788. * Switch active camera
  102789. * @param newCamera defines the new active camera
  102790. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  102791. */
  102792. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102793. /**
  102794. * sets the active camera of the scene using its ID
  102795. * @param id defines the camera's ID
  102796. * @return the new active camera or null if none found.
  102797. */
  102798. setActiveCameraByID(id: string): Nullable<Camera>;
  102799. /**
  102800. * sets the active camera of the scene using its name
  102801. * @param name defines the camera's name
  102802. * @returns the new active camera or null if none found.
  102803. */
  102804. setActiveCameraByName(name: string): Nullable<Camera>;
  102805. /**
  102806. * get an animation group using its name
  102807. * @param name defines the material's name
  102808. * @return the animation group or null if none found.
  102809. */
  102810. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102811. /**
  102812. * Get a material using its unique id
  102813. * @param uniqueId defines the material's unique id
  102814. * @return the material or null if none found.
  102815. */
  102816. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102817. /**
  102818. * get a material using its id
  102819. * @param id defines the material's ID
  102820. * @return the material or null if none found.
  102821. */
  102822. getMaterialByID(id: string): Nullable<Material>;
  102823. /**
  102824. * Gets a the last added material using a given id
  102825. * @param id defines the material's ID
  102826. * @return the last material with the given id or null if none found.
  102827. */
  102828. getLastMaterialByID(id: string): Nullable<Material>;
  102829. /**
  102830. * Gets a material using its name
  102831. * @param name defines the material's name
  102832. * @return the material or null if none found.
  102833. */
  102834. getMaterialByName(name: string): Nullable<Material>;
  102835. /**
  102836. * Get a texture using its unique id
  102837. * @param uniqueId defines the texture's unique id
  102838. * @return the texture or null if none found.
  102839. */
  102840. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102841. /**
  102842. * Gets a camera using its id
  102843. * @param id defines the id to look for
  102844. * @returns the camera or null if not found
  102845. */
  102846. getCameraByID(id: string): Nullable<Camera>;
  102847. /**
  102848. * Gets a camera using its unique id
  102849. * @param uniqueId defines the unique id to look for
  102850. * @returns the camera or null if not found
  102851. */
  102852. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102853. /**
  102854. * Gets a camera using its name
  102855. * @param name defines the camera's name
  102856. * @return the camera or null if none found.
  102857. */
  102858. getCameraByName(name: string): Nullable<Camera>;
  102859. /**
  102860. * Gets a bone using its id
  102861. * @param id defines the bone's id
  102862. * @return the bone or null if not found
  102863. */
  102864. getBoneByID(id: string): Nullable<Bone>;
  102865. /**
  102866. * Gets a bone using its id
  102867. * @param name defines the bone's name
  102868. * @return the bone or null if not found
  102869. */
  102870. getBoneByName(name: string): Nullable<Bone>;
  102871. /**
  102872. * Gets a light node using its name
  102873. * @param name defines the the light's name
  102874. * @return the light or null if none found.
  102875. */
  102876. getLightByName(name: string): Nullable<Light>;
  102877. /**
  102878. * Gets a light node using its id
  102879. * @param id defines the light's id
  102880. * @return the light or null if none found.
  102881. */
  102882. getLightByID(id: string): Nullable<Light>;
  102883. /**
  102884. * Gets a light node using its scene-generated unique ID
  102885. * @param uniqueId defines the light's unique id
  102886. * @return the light or null if none found.
  102887. */
  102888. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102889. /**
  102890. * Gets a particle system by id
  102891. * @param id defines the particle system id
  102892. * @return the corresponding system or null if none found
  102893. */
  102894. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102895. /**
  102896. * Gets a geometry using its ID
  102897. * @param id defines the geometry's id
  102898. * @return the geometry or null if none found.
  102899. */
  102900. getGeometryByID(id: string): Nullable<Geometry>;
  102901. private _getGeometryByUniqueID;
  102902. /**
  102903. * Add a new geometry to this scene
  102904. * @param geometry defines the geometry to be added to the scene.
  102905. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102906. * @return a boolean defining if the geometry was added or not
  102907. */
  102908. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102909. /**
  102910. * Removes an existing geometry
  102911. * @param geometry defines the geometry to be removed from the scene
  102912. * @return a boolean defining if the geometry was removed or not
  102913. */
  102914. removeGeometry(geometry: Geometry): boolean;
  102915. /**
  102916. * Gets the list of geometries attached to the scene
  102917. * @returns an array of Geometry
  102918. */
  102919. getGeometries(): Geometry[];
  102920. /**
  102921. * Gets the first added mesh found of a given ID
  102922. * @param id defines the id to search for
  102923. * @return the mesh found or null if not found at all
  102924. */
  102925. getMeshByID(id: string): Nullable<AbstractMesh>;
  102926. /**
  102927. * Gets a list of meshes using their id
  102928. * @param id defines the id to search for
  102929. * @returns a list of meshes
  102930. */
  102931. getMeshesByID(id: string): Array<AbstractMesh>;
  102932. /**
  102933. * Gets the first added transform node found of a given ID
  102934. * @param id defines the id to search for
  102935. * @return the found transform node or null if not found at all.
  102936. */
  102937. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102938. /**
  102939. * Gets a transform node with its auto-generated unique id
  102940. * @param uniqueId efines the unique id to search for
  102941. * @return the found transform node or null if not found at all.
  102942. */
  102943. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102944. /**
  102945. * Gets a list of transform nodes using their id
  102946. * @param id defines the id to search for
  102947. * @returns a list of transform nodes
  102948. */
  102949. getTransformNodesByID(id: string): Array<TransformNode>;
  102950. /**
  102951. * Gets a mesh with its auto-generated unique id
  102952. * @param uniqueId defines the unique id to search for
  102953. * @return the found mesh or null if not found at all.
  102954. */
  102955. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102956. /**
  102957. * Gets a the last added mesh using a given id
  102958. * @param id defines the id to search for
  102959. * @return the found mesh or null if not found at all.
  102960. */
  102961. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102962. /**
  102963. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102964. * @param id defines the id to search for
  102965. * @return the found node or null if not found at all
  102966. */
  102967. getLastEntryByID(id: string): Nullable<Node>;
  102968. /**
  102969. * Gets a node (Mesh, Camera, Light) using a given id
  102970. * @param id defines the id to search for
  102971. * @return the found node or null if not found at all
  102972. */
  102973. getNodeByID(id: string): Nullable<Node>;
  102974. /**
  102975. * Gets a node (Mesh, Camera, Light) using a given name
  102976. * @param name defines the name to search for
  102977. * @return the found node or null if not found at all.
  102978. */
  102979. getNodeByName(name: string): Nullable<Node>;
  102980. /**
  102981. * Gets a mesh using a given name
  102982. * @param name defines the name to search for
  102983. * @return the found mesh or null if not found at all.
  102984. */
  102985. getMeshByName(name: string): Nullable<AbstractMesh>;
  102986. /**
  102987. * Gets a transform node using a given name
  102988. * @param name defines the name to search for
  102989. * @return the found transform node or null if not found at all.
  102990. */
  102991. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102992. /**
  102993. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102994. * @param id defines the id to search for
  102995. * @return the found skeleton or null if not found at all.
  102996. */
  102997. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102998. /**
  102999. * Gets a skeleton using a given auto generated unique id
  103000. * @param uniqueId defines the unique id to search for
  103001. * @return the found skeleton or null if not found at all.
  103002. */
  103003. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103004. /**
  103005. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103006. * @param id defines the id to search for
  103007. * @return the found skeleton or null if not found at all.
  103008. */
  103009. getSkeletonById(id: string): Nullable<Skeleton>;
  103010. /**
  103011. * Gets a skeleton using a given name
  103012. * @param name defines the name to search for
  103013. * @return the found skeleton or null if not found at all.
  103014. */
  103015. getSkeletonByName(name: string): Nullable<Skeleton>;
  103016. /**
  103017. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103018. * @param id defines the id to search for
  103019. * @return the found morph target manager or null if not found at all.
  103020. */
  103021. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103022. /**
  103023. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103024. * @param id defines the id to search for
  103025. * @return the found morph target or null if not found at all.
  103026. */
  103027. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103028. /**
  103029. * Gets a boolean indicating if the given mesh is active
  103030. * @param mesh defines the mesh to look for
  103031. * @returns true if the mesh is in the active list
  103032. */
  103033. isActiveMesh(mesh: AbstractMesh): boolean;
  103034. /**
  103035. * Return a unique id as a string which can serve as an identifier for the scene
  103036. */
  103037. readonly uid: string;
  103038. /**
  103039. * Add an externaly attached data from its key.
  103040. * This method call will fail and return false, if such key already exists.
  103041. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103042. * @param key the unique key that identifies the data
  103043. * @param data the data object to associate to the key for this Engine instance
  103044. * @return true if no such key were already present and the data was added successfully, false otherwise
  103045. */
  103046. addExternalData<T>(key: string, data: T): boolean;
  103047. /**
  103048. * Get an externaly attached data from its key
  103049. * @param key the unique key that identifies the data
  103050. * @return the associated data, if present (can be null), or undefined if not present
  103051. */
  103052. getExternalData<T>(key: string): Nullable<T>;
  103053. /**
  103054. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103055. * @param key the unique key that identifies the data
  103056. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103057. * @return the associated data, can be null if the factory returned null.
  103058. */
  103059. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103060. /**
  103061. * Remove an externaly attached data from the Engine instance
  103062. * @param key the unique key that identifies the data
  103063. * @return true if the data was successfully removed, false if it doesn't exist
  103064. */
  103065. removeExternalData(key: string): boolean;
  103066. private _evaluateSubMesh;
  103067. /**
  103068. * Clear the processed materials smart array preventing retention point in material dispose.
  103069. */
  103070. freeProcessedMaterials(): void;
  103071. private _preventFreeActiveMeshesAndRenderingGroups;
  103072. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103073. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103074. * when disposing several meshes in a row or a hierarchy of meshes.
  103075. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103076. */
  103077. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103078. /**
  103079. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103080. */
  103081. freeActiveMeshes(): void;
  103082. /**
  103083. * Clear the info related to rendering groups preventing retention points during dispose.
  103084. */
  103085. freeRenderingGroups(): void;
  103086. /** @hidden */
  103087. _isInIntermediateRendering(): boolean;
  103088. /**
  103089. * Lambda returning the list of potentially active meshes.
  103090. */
  103091. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103092. /**
  103093. * Lambda returning the list of potentially active sub meshes.
  103094. */
  103095. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103096. /**
  103097. * Lambda returning the list of potentially intersecting sub meshes.
  103098. */
  103099. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103100. /**
  103101. * Lambda returning the list of potentially colliding sub meshes.
  103102. */
  103103. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103104. private _activeMeshesFrozen;
  103105. private _skipEvaluateActiveMeshesCompletely;
  103106. /**
  103107. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103108. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103109. * @returns the current scene
  103110. */
  103111. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103112. /**
  103113. * Use this function to restart evaluating active meshes on every frame
  103114. * @returns the current scene
  103115. */
  103116. unfreezeActiveMeshes(): Scene;
  103117. private _evaluateActiveMeshes;
  103118. private _activeMesh;
  103119. /**
  103120. * Update the transform matrix to update from the current active camera
  103121. * @param force defines a boolean used to force the update even if cache is up to date
  103122. */
  103123. updateTransformMatrix(force?: boolean): void;
  103124. private _bindFrameBuffer;
  103125. /** @hidden */
  103126. _allowPostProcessClearColor: boolean;
  103127. /** @hidden */
  103128. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103129. private _processSubCameras;
  103130. private _checkIntersections;
  103131. /** @hidden */
  103132. _advancePhysicsEngineStep(step: number): void;
  103133. /**
  103134. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103135. */
  103136. getDeterministicFrameTime: () => number;
  103137. /** @hidden */
  103138. _animate(): void;
  103139. /** Execute all animations (for a frame) */
  103140. animate(): void;
  103141. /**
  103142. * Render the scene
  103143. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103144. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103145. */
  103146. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103147. /**
  103148. * Freeze all materials
  103149. * A frozen material will not be updatable but should be faster to render
  103150. */
  103151. freezeMaterials(): void;
  103152. /**
  103153. * Unfreeze all materials
  103154. * A frozen material will not be updatable but should be faster to render
  103155. */
  103156. unfreezeMaterials(): void;
  103157. /**
  103158. * Releases all held ressources
  103159. */
  103160. dispose(): void;
  103161. /**
  103162. * Gets if the scene is already disposed
  103163. */
  103164. readonly isDisposed: boolean;
  103165. /**
  103166. * Call this function to reduce memory footprint of the scene.
  103167. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103168. */
  103169. clearCachedVertexData(): void;
  103170. /**
  103171. * This function will remove the local cached buffer data from texture.
  103172. * It will save memory but will prevent the texture from being rebuilt
  103173. */
  103174. cleanCachedTextureBuffer(): void;
  103175. /**
  103176. * Get the world extend vectors with an optional filter
  103177. *
  103178. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103179. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103180. */
  103181. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103182. min: Vector3;
  103183. max: Vector3;
  103184. };
  103185. /**
  103186. * Creates a ray that can be used to pick in the scene
  103187. * @param x defines the x coordinate of the origin (on-screen)
  103188. * @param y defines the y coordinate of the origin (on-screen)
  103189. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103190. * @param camera defines the camera to use for the picking
  103191. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103192. * @returns a Ray
  103193. */
  103194. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103195. /**
  103196. * Creates a ray that can be used to pick in the scene
  103197. * @param x defines the x coordinate of the origin (on-screen)
  103198. * @param y defines the y coordinate of the origin (on-screen)
  103199. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103200. * @param result defines the ray where to store the picking ray
  103201. * @param camera defines the camera to use for the picking
  103202. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103203. * @returns the current scene
  103204. */
  103205. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103206. /**
  103207. * Creates a ray that can be used to pick in the scene
  103208. * @param x defines the x coordinate of the origin (on-screen)
  103209. * @param y defines the y coordinate of the origin (on-screen)
  103210. * @param camera defines the camera to use for the picking
  103211. * @returns a Ray
  103212. */
  103213. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103214. /**
  103215. * Creates a ray that can be used to pick in the scene
  103216. * @param x defines the x coordinate of the origin (on-screen)
  103217. * @param y defines the y coordinate of the origin (on-screen)
  103218. * @param result defines the ray where to store the picking ray
  103219. * @param camera defines the camera to use for the picking
  103220. * @returns the current scene
  103221. */
  103222. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103223. /** Launch a ray to try to pick a mesh in the scene
  103224. * @param x position on screen
  103225. * @param y position on screen
  103226. * @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
  103227. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103228. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103229. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103230. * @returns a PickingInfo
  103231. */
  103232. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103233. /** Use the given ray to pick a mesh in the scene
  103234. * @param ray The ray to use to pick meshes
  103235. * @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
  103236. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103238. * @returns a PickingInfo
  103239. */
  103240. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103241. /**
  103242. * Launch a ray to try to pick a mesh in the scene
  103243. * @param x X position on screen
  103244. * @param y Y position on screen
  103245. * @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
  103246. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103248. * @returns an array of PickingInfo
  103249. */
  103250. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103251. /**
  103252. * Launch a ray to try to pick a mesh in the scene
  103253. * @param ray Ray to use
  103254. * @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
  103255. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103256. * @returns an array of PickingInfo
  103257. */
  103258. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103259. /**
  103260. * Force the value of meshUnderPointer
  103261. * @param mesh defines the mesh to use
  103262. */
  103263. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103264. /**
  103265. * Gets the mesh under the pointer
  103266. * @returns a Mesh or null if no mesh is under the pointer
  103267. */
  103268. getPointerOverMesh(): Nullable<AbstractMesh>;
  103269. /** @hidden */
  103270. _rebuildGeometries(): void;
  103271. /** @hidden */
  103272. _rebuildTextures(): void;
  103273. private _getByTags;
  103274. /**
  103275. * Get a list of meshes by tags
  103276. * @param tagsQuery defines the tags query to use
  103277. * @param forEach defines a predicate used to filter results
  103278. * @returns an array of Mesh
  103279. */
  103280. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103281. /**
  103282. * Get a list of cameras by tags
  103283. * @param tagsQuery defines the tags query to use
  103284. * @param forEach defines a predicate used to filter results
  103285. * @returns an array of Camera
  103286. */
  103287. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103288. /**
  103289. * Get a list of lights by tags
  103290. * @param tagsQuery defines the tags query to use
  103291. * @param forEach defines a predicate used to filter results
  103292. * @returns an array of Light
  103293. */
  103294. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103295. /**
  103296. * Get a list of materials by tags
  103297. * @param tagsQuery defines the tags query to use
  103298. * @param forEach defines a predicate used to filter results
  103299. * @returns an array of Material
  103300. */
  103301. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103302. /**
  103303. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103304. * This allowed control for front to back rendering or reversly depending of the special needs.
  103305. *
  103306. * @param renderingGroupId The rendering group id corresponding to its index
  103307. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103308. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103309. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103310. */
  103311. 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;
  103312. /**
  103313. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103314. *
  103315. * @param renderingGroupId The rendering group id corresponding to its index
  103316. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103317. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103318. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103319. */
  103320. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103321. /**
  103322. * Gets the current auto clear configuration for one rendering group of the rendering
  103323. * manager.
  103324. * @param index the rendering group index to get the information for
  103325. * @returns The auto clear setup for the requested rendering group
  103326. */
  103327. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103328. private _blockMaterialDirtyMechanism;
  103329. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103330. blockMaterialDirtyMechanism: boolean;
  103331. /**
  103332. * Will flag all materials as dirty to trigger new shader compilation
  103333. * @param flag defines the flag used to specify which material part must be marked as dirty
  103334. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103335. */
  103336. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103337. /** @hidden */
  103338. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  103339. /** @hidden */
  103340. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103341. /** @hidden */
  103342. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  103343. /** @hidden */
  103344. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103345. /** @hidden */
  103346. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103347. /** @hidden */
  103348. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103349. }
  103350. }
  103351. declare module BABYLON {
  103352. /**
  103353. * Set of assets to keep when moving a scene into an asset container.
  103354. */
  103355. export class KeepAssets extends AbstractScene {
  103356. }
  103357. /**
  103358. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103359. */
  103360. export class InstantiatedEntries {
  103361. /**
  103362. * List of new root nodes (eg. nodes with no parent)
  103363. */
  103364. rootNodes: TransformNode[];
  103365. /**
  103366. * List of new skeletons
  103367. */
  103368. skeletons: Skeleton[];
  103369. /**
  103370. * List of new animation groups
  103371. */
  103372. animationGroups: AnimationGroup[];
  103373. }
  103374. /**
  103375. * Container with a set of assets that can be added or removed from a scene.
  103376. */
  103377. export class AssetContainer extends AbstractScene {
  103378. /**
  103379. * The scene the AssetContainer belongs to.
  103380. */
  103381. scene: Scene;
  103382. /**
  103383. * Instantiates an AssetContainer.
  103384. * @param scene The scene the AssetContainer belongs to.
  103385. */
  103386. constructor(scene: Scene);
  103387. /**
  103388. * Instantiate or clone all meshes and add the new ones to the scene.
  103389. * Skeletons and animation groups will all be cloned
  103390. * @param nameFunction defines an optional function used to get new names for clones
  103391. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103392. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103393. */
  103394. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103395. /**
  103396. * Adds all the assets from the container to the scene.
  103397. */
  103398. addAllToScene(): void;
  103399. /**
  103400. * Removes all the assets in the container from the scene
  103401. */
  103402. removeAllFromScene(): void;
  103403. /**
  103404. * Disposes all the assets in the container
  103405. */
  103406. dispose(): void;
  103407. private _moveAssets;
  103408. /**
  103409. * Removes all the assets contained in the scene and adds them to the container.
  103410. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103411. */
  103412. moveAllFromScene(keepAssets?: KeepAssets): void;
  103413. /**
  103414. * 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.
  103415. * @returns the root mesh
  103416. */
  103417. createRootMesh(): Mesh;
  103418. }
  103419. }
  103420. declare module BABYLON {
  103421. /**
  103422. * Defines how the parser contract is defined.
  103423. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103424. */
  103425. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103426. /**
  103427. * Defines how the individual parser contract is defined.
  103428. * These parser can parse an individual asset
  103429. */
  103430. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103431. /**
  103432. * Base class of the scene acting as a container for the different elements composing a scene.
  103433. * This class is dynamically extended by the different components of the scene increasing
  103434. * flexibility and reducing coupling
  103435. */
  103436. export abstract class AbstractScene {
  103437. /**
  103438. * Stores the list of available parsers in the application.
  103439. */
  103440. private static _BabylonFileParsers;
  103441. /**
  103442. * Stores the list of available individual parsers in the application.
  103443. */
  103444. private static _IndividualBabylonFileParsers;
  103445. /**
  103446. * Adds a parser in the list of available ones
  103447. * @param name Defines the name of the parser
  103448. * @param parser Defines the parser to add
  103449. */
  103450. static AddParser(name: string, parser: BabylonFileParser): void;
  103451. /**
  103452. * Gets a general parser from the list of avaialble ones
  103453. * @param name Defines the name of the parser
  103454. * @returns the requested parser or null
  103455. */
  103456. static GetParser(name: string): Nullable<BabylonFileParser>;
  103457. /**
  103458. * Adds n individual parser in the list of available ones
  103459. * @param name Defines the name of the parser
  103460. * @param parser Defines the parser to add
  103461. */
  103462. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103463. /**
  103464. * Gets an individual parser from the list of avaialble ones
  103465. * @param name Defines the name of the parser
  103466. * @returns the requested parser or null
  103467. */
  103468. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103469. /**
  103470. * Parser json data and populate both a scene and its associated container object
  103471. * @param jsonData Defines the data to parse
  103472. * @param scene Defines the scene to parse the data for
  103473. * @param container Defines the container attached to the parsing sequence
  103474. * @param rootUrl Defines the root url of the data
  103475. */
  103476. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103477. /**
  103478. * Gets the list of root nodes (ie. nodes with no parent)
  103479. */
  103480. rootNodes: Node[];
  103481. /** All of the cameras added to this scene
  103482. * @see http://doc.babylonjs.com/babylon101/cameras
  103483. */
  103484. cameras: Camera[];
  103485. /**
  103486. * All of the lights added to this scene
  103487. * @see http://doc.babylonjs.com/babylon101/lights
  103488. */
  103489. lights: Light[];
  103490. /**
  103491. * All of the (abstract) meshes added to this scene
  103492. */
  103493. meshes: AbstractMesh[];
  103494. /**
  103495. * The list of skeletons added to the scene
  103496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103497. */
  103498. skeletons: Skeleton[];
  103499. /**
  103500. * All of the particle systems added to this scene
  103501. * @see http://doc.babylonjs.com/babylon101/particles
  103502. */
  103503. particleSystems: IParticleSystem[];
  103504. /**
  103505. * Gets a list of Animations associated with the scene
  103506. */
  103507. animations: Animation[];
  103508. /**
  103509. * All of the animation groups added to this scene
  103510. * @see http://doc.babylonjs.com/how_to/group
  103511. */
  103512. animationGroups: AnimationGroup[];
  103513. /**
  103514. * All of the multi-materials added to this scene
  103515. * @see http://doc.babylonjs.com/how_to/multi_materials
  103516. */
  103517. multiMaterials: MultiMaterial[];
  103518. /**
  103519. * All of the materials added to this scene
  103520. * In the context of a Scene, it is not supposed to be modified manually.
  103521. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103522. * Note also that the order of the Material within the array is not significant and might change.
  103523. * @see http://doc.babylonjs.com/babylon101/materials
  103524. */
  103525. materials: Material[];
  103526. /**
  103527. * The list of morph target managers added to the scene
  103528. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103529. */
  103530. morphTargetManagers: MorphTargetManager[];
  103531. /**
  103532. * The list of geometries used in the scene.
  103533. */
  103534. geometries: Geometry[];
  103535. /**
  103536. * All of the tranform nodes added to this scene
  103537. * In the context of a Scene, it is not supposed to be modified manually.
  103538. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103539. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103540. * @see http://doc.babylonjs.com/how_to/transformnode
  103541. */
  103542. transformNodes: TransformNode[];
  103543. /**
  103544. * ActionManagers available on the scene.
  103545. */
  103546. actionManagers: AbstractActionManager[];
  103547. /**
  103548. * Textures to keep.
  103549. */
  103550. textures: BaseTexture[];
  103551. /**
  103552. * Environment texture for the scene
  103553. */
  103554. environmentTexture: Nullable<BaseTexture>;
  103555. }
  103556. }
  103557. declare module BABYLON {
  103558. /**
  103559. * Interface used to define options for Sound class
  103560. */
  103561. export interface ISoundOptions {
  103562. /**
  103563. * Does the sound autoplay once loaded.
  103564. */
  103565. autoplay?: boolean;
  103566. /**
  103567. * Does the sound loop after it finishes playing once.
  103568. */
  103569. loop?: boolean;
  103570. /**
  103571. * Sound's volume
  103572. */
  103573. volume?: number;
  103574. /**
  103575. * Is it a spatial sound?
  103576. */
  103577. spatialSound?: boolean;
  103578. /**
  103579. * Maximum distance to hear that sound
  103580. */
  103581. maxDistance?: number;
  103582. /**
  103583. * Uses user defined attenuation function
  103584. */
  103585. useCustomAttenuation?: boolean;
  103586. /**
  103587. * Define the roll off factor of spatial sounds.
  103588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103589. */
  103590. rolloffFactor?: number;
  103591. /**
  103592. * Define the reference distance the sound should be heard perfectly.
  103593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103594. */
  103595. refDistance?: number;
  103596. /**
  103597. * Define the distance attenuation model the sound will follow.
  103598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103599. */
  103600. distanceModel?: string;
  103601. /**
  103602. * Defines the playback speed (1 by default)
  103603. */
  103604. playbackRate?: number;
  103605. /**
  103606. * Defines if the sound is from a streaming source
  103607. */
  103608. streaming?: boolean;
  103609. /**
  103610. * Defines an optional length (in seconds) inside the sound file
  103611. */
  103612. length?: number;
  103613. /**
  103614. * Defines an optional offset (in seconds) inside the sound file
  103615. */
  103616. offset?: number;
  103617. /**
  103618. * If true, URLs will not be required to state the audio file codec to use.
  103619. */
  103620. skipCodecCheck?: boolean;
  103621. }
  103622. /**
  103623. * Defines a sound that can be played in the application.
  103624. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103626. */
  103627. export class Sound {
  103628. /**
  103629. * The name of the sound in the scene.
  103630. */
  103631. name: string;
  103632. /**
  103633. * Does the sound autoplay once loaded.
  103634. */
  103635. autoplay: boolean;
  103636. /**
  103637. * Does the sound loop after it finishes playing once.
  103638. */
  103639. loop: boolean;
  103640. /**
  103641. * Does the sound use a custom attenuation curve to simulate the falloff
  103642. * happening when the source gets further away from the camera.
  103643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103644. */
  103645. useCustomAttenuation: boolean;
  103646. /**
  103647. * The sound track id this sound belongs to.
  103648. */
  103649. soundTrackId: number;
  103650. /**
  103651. * Is this sound currently played.
  103652. */
  103653. isPlaying: boolean;
  103654. /**
  103655. * Is this sound currently paused.
  103656. */
  103657. isPaused: boolean;
  103658. /**
  103659. * Does this sound enables spatial sound.
  103660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103661. */
  103662. spatialSound: boolean;
  103663. /**
  103664. * Define the reference distance the sound should be heard perfectly.
  103665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103666. */
  103667. refDistance: number;
  103668. /**
  103669. * Define the roll off factor of spatial sounds.
  103670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103671. */
  103672. rolloffFactor: number;
  103673. /**
  103674. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103676. */
  103677. maxDistance: number;
  103678. /**
  103679. * Define the distance attenuation model the sound will follow.
  103680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103681. */
  103682. distanceModel: string;
  103683. /**
  103684. * @hidden
  103685. * Back Compat
  103686. **/
  103687. onended: () => any;
  103688. /**
  103689. * Observable event when the current playing sound finishes.
  103690. */
  103691. onEndedObservable: Observable<Sound>;
  103692. private _panningModel;
  103693. private _playbackRate;
  103694. private _streaming;
  103695. private _startTime;
  103696. private _startOffset;
  103697. private _position;
  103698. /** @hidden */
  103699. _positionInEmitterSpace: boolean;
  103700. private _localDirection;
  103701. private _volume;
  103702. private _isReadyToPlay;
  103703. private _isDirectional;
  103704. private _readyToPlayCallback;
  103705. private _audioBuffer;
  103706. private _soundSource;
  103707. private _streamingSource;
  103708. private _soundPanner;
  103709. private _soundGain;
  103710. private _inputAudioNode;
  103711. private _outputAudioNode;
  103712. private _coneInnerAngle;
  103713. private _coneOuterAngle;
  103714. private _coneOuterGain;
  103715. private _scene;
  103716. private _connectedTransformNode;
  103717. private _customAttenuationFunction;
  103718. private _registerFunc;
  103719. private _isOutputConnected;
  103720. private _htmlAudioElement;
  103721. private _urlType;
  103722. private _length?;
  103723. private _offset?;
  103724. /** @hidden */
  103725. static _SceneComponentInitialization: (scene: Scene) => void;
  103726. /**
  103727. * Create a sound and attach it to a scene
  103728. * @param name Name of your sound
  103729. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  103730. * @param scene defines the scene the sound belongs to
  103731. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  103732. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  103733. */
  103734. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  103735. /**
  103736. * Release the sound and its associated resources
  103737. */
  103738. dispose(): void;
  103739. /**
  103740. * Gets if the sounds is ready to be played or not.
  103741. * @returns true if ready, otherwise false
  103742. */
  103743. isReady(): boolean;
  103744. private _soundLoaded;
  103745. /**
  103746. * Sets the data of the sound from an audiobuffer
  103747. * @param audioBuffer The audioBuffer containing the data
  103748. */
  103749. setAudioBuffer(audioBuffer: AudioBuffer): void;
  103750. /**
  103751. * Updates the current sounds options such as maxdistance, loop...
  103752. * @param options A JSON object containing values named as the object properties
  103753. */
  103754. updateOptions(options: ISoundOptions): void;
  103755. private _createSpatialParameters;
  103756. private _updateSpatialParameters;
  103757. /**
  103758. * Switch the panning model to HRTF:
  103759. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103761. */
  103762. switchPanningModelToHRTF(): void;
  103763. /**
  103764. * Switch the panning model to Equal Power:
  103765. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103767. */
  103768. switchPanningModelToEqualPower(): void;
  103769. private _switchPanningModel;
  103770. /**
  103771. * Connect this sound to a sound track audio node like gain...
  103772. * @param soundTrackAudioNode the sound track audio node to connect to
  103773. */
  103774. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  103775. /**
  103776. * Transform this sound into a directional source
  103777. * @param coneInnerAngle Size of the inner cone in degree
  103778. * @param coneOuterAngle Size of the outer cone in degree
  103779. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  103780. */
  103781. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  103782. /**
  103783. * Gets or sets the inner angle for the directional cone.
  103784. */
  103785. /**
  103786. * Gets or sets the inner angle for the directional cone.
  103787. */
  103788. directionalConeInnerAngle: number;
  103789. /**
  103790. * Gets or sets the outer angle for the directional cone.
  103791. */
  103792. /**
  103793. * Gets or sets the outer angle for the directional cone.
  103794. */
  103795. directionalConeOuterAngle: number;
  103796. /**
  103797. * Sets the position of the emitter if spatial sound is enabled
  103798. * @param newPosition Defines the new posisiton
  103799. */
  103800. setPosition(newPosition: Vector3): void;
  103801. /**
  103802. * Sets the local direction of the emitter if spatial sound is enabled
  103803. * @param newLocalDirection Defines the new local direction
  103804. */
  103805. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103806. private _updateDirection;
  103807. /** @hidden */
  103808. updateDistanceFromListener(): void;
  103809. /**
  103810. * Sets a new custom attenuation function for the sound.
  103811. * @param callback Defines the function used for the attenuation
  103812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103813. */
  103814. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103815. /**
  103816. * Play the sound
  103817. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103818. * @param offset (optional) Start the sound at a specific time in seconds
  103819. * @param length (optional) Sound duration (in seconds)
  103820. */
  103821. play(time?: number, offset?: number, length?: number): void;
  103822. private _onended;
  103823. /**
  103824. * Stop the sound
  103825. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103826. */
  103827. stop(time?: number): void;
  103828. /**
  103829. * Put the sound in pause
  103830. */
  103831. pause(): void;
  103832. /**
  103833. * Sets a dedicated volume for this sounds
  103834. * @param newVolume Define the new volume of the sound
  103835. * @param time Define time for gradual change to new volume
  103836. */
  103837. setVolume(newVolume: number, time?: number): void;
  103838. /**
  103839. * Set the sound play back rate
  103840. * @param newPlaybackRate Define the playback rate the sound should be played at
  103841. */
  103842. setPlaybackRate(newPlaybackRate: number): void;
  103843. /**
  103844. * Gets the volume of the sound.
  103845. * @returns the volume of the sound
  103846. */
  103847. getVolume(): number;
  103848. /**
  103849. * Attach the sound to a dedicated mesh
  103850. * @param transformNode The transform node to connect the sound with
  103851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103852. */
  103853. attachToMesh(transformNode: TransformNode): void;
  103854. /**
  103855. * Detach the sound from the previously attached mesh
  103856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103857. */
  103858. detachFromMesh(): void;
  103859. private _onRegisterAfterWorldMatrixUpdate;
  103860. /**
  103861. * Clone the current sound in the scene.
  103862. * @returns the new sound clone
  103863. */
  103864. clone(): Nullable<Sound>;
  103865. /**
  103866. * Gets the current underlying audio buffer containing the data
  103867. * @returns the audio buffer
  103868. */
  103869. getAudioBuffer(): Nullable<AudioBuffer>;
  103870. /**
  103871. * Serializes the Sound in a JSON representation
  103872. * @returns the JSON representation of the sound
  103873. */
  103874. serialize(): any;
  103875. /**
  103876. * Parse a JSON representation of a sound to innstantiate in a given scene
  103877. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103878. * @param scene Define the scene the new parsed sound should be created in
  103879. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103880. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103881. * @returns the newly parsed sound
  103882. */
  103883. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103884. }
  103885. }
  103886. declare module BABYLON {
  103887. /**
  103888. * This defines an action helpful to play a defined sound on a triggered action.
  103889. */
  103890. export class PlaySoundAction extends Action {
  103891. private _sound;
  103892. /**
  103893. * Instantiate the action
  103894. * @param triggerOptions defines the trigger options
  103895. * @param sound defines the sound to play
  103896. * @param condition defines the trigger related conditions
  103897. */
  103898. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103899. /** @hidden */
  103900. _prepare(): void;
  103901. /**
  103902. * Execute the action and play the sound.
  103903. */
  103904. execute(): void;
  103905. /**
  103906. * Serializes the actions and its related information.
  103907. * @param parent defines the object to serialize in
  103908. * @returns the serialized object
  103909. */
  103910. serialize(parent: any): any;
  103911. }
  103912. /**
  103913. * This defines an action helpful to stop a defined sound on a triggered action.
  103914. */
  103915. export class StopSoundAction extends Action {
  103916. private _sound;
  103917. /**
  103918. * Instantiate the action
  103919. * @param triggerOptions defines the trigger options
  103920. * @param sound defines the sound to stop
  103921. * @param condition defines the trigger related conditions
  103922. */
  103923. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103924. /** @hidden */
  103925. _prepare(): void;
  103926. /**
  103927. * Execute the action and stop the sound.
  103928. */
  103929. execute(): void;
  103930. /**
  103931. * Serializes the actions and its related information.
  103932. * @param parent defines the object to serialize in
  103933. * @returns the serialized object
  103934. */
  103935. serialize(parent: any): any;
  103936. }
  103937. }
  103938. declare module BABYLON {
  103939. /**
  103940. * This defines an action responsible to change the value of a property
  103941. * by interpolating between its current value and the newly set one once triggered.
  103942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103943. */
  103944. export class InterpolateValueAction extends Action {
  103945. /**
  103946. * Defines the path of the property where the value should be interpolated
  103947. */
  103948. propertyPath: string;
  103949. /**
  103950. * Defines the target value at the end of the interpolation.
  103951. */
  103952. value: any;
  103953. /**
  103954. * Defines the time it will take for the property to interpolate to the value.
  103955. */
  103956. duration: number;
  103957. /**
  103958. * Defines if the other scene animations should be stopped when the action has been triggered
  103959. */
  103960. stopOtherAnimations?: boolean;
  103961. /**
  103962. * Defines a callback raised once the interpolation animation has been done.
  103963. */
  103964. onInterpolationDone?: () => void;
  103965. /**
  103966. * Observable triggered once the interpolation animation has been done.
  103967. */
  103968. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103969. private _target;
  103970. private _effectiveTarget;
  103971. private _property;
  103972. /**
  103973. * Instantiate the action
  103974. * @param triggerOptions defines the trigger options
  103975. * @param target defines the object containing the value to interpolate
  103976. * @param propertyPath defines the path to the property in the target object
  103977. * @param value defines the target value at the end of the interpolation
  103978. * @param duration deines the time it will take for the property to interpolate to the value.
  103979. * @param condition defines the trigger related conditions
  103980. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103981. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103982. */
  103983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103984. /** @hidden */
  103985. _prepare(): void;
  103986. /**
  103987. * Execute the action starts the value interpolation.
  103988. */
  103989. execute(): void;
  103990. /**
  103991. * Serializes the actions and its related information.
  103992. * @param parent defines the object to serialize in
  103993. * @returns the serialized object
  103994. */
  103995. serialize(parent: any): any;
  103996. }
  103997. }
  103998. declare module BABYLON {
  103999. /**
  104000. * Options allowed during the creation of a sound track.
  104001. */
  104002. export interface ISoundTrackOptions {
  104003. /**
  104004. * The volume the sound track should take during creation
  104005. */
  104006. volume?: number;
  104007. /**
  104008. * Define if the sound track is the main sound track of the scene
  104009. */
  104010. mainTrack?: boolean;
  104011. }
  104012. /**
  104013. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104014. * It will be also used in a future release to apply effects on a specific track.
  104015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104016. */
  104017. export class SoundTrack {
  104018. /**
  104019. * The unique identifier of the sound track in the scene.
  104020. */
  104021. id: number;
  104022. /**
  104023. * The list of sounds included in the sound track.
  104024. */
  104025. soundCollection: Array<Sound>;
  104026. private _outputAudioNode;
  104027. private _scene;
  104028. private _connectedAnalyser;
  104029. private _options;
  104030. private _isInitialized;
  104031. /**
  104032. * Creates a new sound track.
  104033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104034. * @param scene Define the scene the sound track belongs to
  104035. * @param options
  104036. */
  104037. constructor(scene: Scene, options?: ISoundTrackOptions);
  104038. private _initializeSoundTrackAudioGraph;
  104039. /**
  104040. * Release the sound track and its associated resources
  104041. */
  104042. dispose(): void;
  104043. /**
  104044. * Adds a sound to this sound track
  104045. * @param sound define the cound to add
  104046. * @ignoreNaming
  104047. */
  104048. AddSound(sound: Sound): void;
  104049. /**
  104050. * Removes a sound to this sound track
  104051. * @param sound define the cound to remove
  104052. * @ignoreNaming
  104053. */
  104054. RemoveSound(sound: Sound): void;
  104055. /**
  104056. * Set a global volume for the full sound track.
  104057. * @param newVolume Define the new volume of the sound track
  104058. */
  104059. setVolume(newVolume: number): void;
  104060. /**
  104061. * Switch the panning model to HRTF:
  104062. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104064. */
  104065. switchPanningModelToHRTF(): void;
  104066. /**
  104067. * Switch the panning model to Equal Power:
  104068. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104070. */
  104071. switchPanningModelToEqualPower(): void;
  104072. /**
  104073. * Connect the sound track to an audio analyser allowing some amazing
  104074. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104076. * @param analyser The analyser to connect to the engine
  104077. */
  104078. connectToAnalyser(analyser: Analyser): void;
  104079. }
  104080. }
  104081. declare module BABYLON {
  104082. interface AbstractScene {
  104083. /**
  104084. * The list of sounds used in the scene.
  104085. */
  104086. sounds: Nullable<Array<Sound>>;
  104087. }
  104088. interface Scene {
  104089. /**
  104090. * @hidden
  104091. * Backing field
  104092. */
  104093. _mainSoundTrack: SoundTrack;
  104094. /**
  104095. * The main sound track played by the scene.
  104096. * It cotains your primary collection of sounds.
  104097. */
  104098. mainSoundTrack: SoundTrack;
  104099. /**
  104100. * The list of sound tracks added to the scene
  104101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104102. */
  104103. soundTracks: Nullable<Array<SoundTrack>>;
  104104. /**
  104105. * Gets a sound using a given name
  104106. * @param name defines the name to search for
  104107. * @return the found sound or null if not found at all.
  104108. */
  104109. getSoundByName(name: string): Nullable<Sound>;
  104110. /**
  104111. * Gets or sets if audio support is enabled
  104112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104113. */
  104114. audioEnabled: boolean;
  104115. /**
  104116. * Gets or sets if audio will be output to headphones
  104117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104118. */
  104119. headphone: boolean;
  104120. /**
  104121. * Gets or sets custom audio listener position provider
  104122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104123. */
  104124. audioListenerPositionProvider: Nullable<() => Vector3>;
  104125. /**
  104126. * Gets or sets a refresh rate when using 3D audio positioning
  104127. */
  104128. audioPositioningRefreshRate: number;
  104129. }
  104130. /**
  104131. * Defines the sound scene component responsible to manage any sounds
  104132. * in a given scene.
  104133. */
  104134. export class AudioSceneComponent implements ISceneSerializableComponent {
  104135. /**
  104136. * The component name helpfull to identify the component in the list of scene components.
  104137. */
  104138. readonly name: string;
  104139. /**
  104140. * The scene the component belongs to.
  104141. */
  104142. scene: Scene;
  104143. private _audioEnabled;
  104144. /**
  104145. * Gets whether audio is enabled or not.
  104146. * Please use related enable/disable method to switch state.
  104147. */
  104148. readonly audioEnabled: boolean;
  104149. private _headphone;
  104150. /**
  104151. * Gets whether audio is outputing to headphone or not.
  104152. * Please use the according Switch methods to change output.
  104153. */
  104154. readonly headphone: boolean;
  104155. /**
  104156. * Gets or sets a refresh rate when using 3D audio positioning
  104157. */
  104158. audioPositioningRefreshRate: number;
  104159. private _audioListenerPositionProvider;
  104160. /**
  104161. * Gets the current audio listener position provider
  104162. */
  104163. /**
  104164. * Sets a custom listener position for all sounds in the scene
  104165. * By default, this is the position of the first active camera
  104166. */
  104167. audioListenerPositionProvider: Nullable<() => Vector3>;
  104168. /**
  104169. * Creates a new instance of the component for the given scene
  104170. * @param scene Defines the scene to register the component in
  104171. */
  104172. constructor(scene: Scene);
  104173. /**
  104174. * Registers the component in a given scene
  104175. */
  104176. register(): void;
  104177. /**
  104178. * Rebuilds the elements related to this component in case of
  104179. * context lost for instance.
  104180. */
  104181. rebuild(): void;
  104182. /**
  104183. * Serializes the component data to the specified json object
  104184. * @param serializationObject The object to serialize to
  104185. */
  104186. serialize(serializationObject: any): void;
  104187. /**
  104188. * Adds all the elements from the container to the scene
  104189. * @param container the container holding the elements
  104190. */
  104191. addFromContainer(container: AbstractScene): void;
  104192. /**
  104193. * Removes all the elements in the container from the scene
  104194. * @param container contains the elements to remove
  104195. * @param dispose if the removed element should be disposed (default: false)
  104196. */
  104197. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104198. /**
  104199. * Disposes the component and the associated ressources.
  104200. */
  104201. dispose(): void;
  104202. /**
  104203. * Disables audio in the associated scene.
  104204. */
  104205. disableAudio(): void;
  104206. /**
  104207. * Enables audio in the associated scene.
  104208. */
  104209. enableAudio(): void;
  104210. /**
  104211. * Switch audio to headphone output.
  104212. */
  104213. switchAudioModeForHeadphones(): void;
  104214. /**
  104215. * Switch audio to normal speakers.
  104216. */
  104217. switchAudioModeForNormalSpeakers(): void;
  104218. private _cachedCameraDirection;
  104219. private _cachedCameraPosition;
  104220. private _lastCheck;
  104221. private _afterRender;
  104222. }
  104223. }
  104224. declare module BABYLON {
  104225. /**
  104226. * Wraps one or more Sound objects and selects one with random weight for playback.
  104227. */
  104228. export class WeightedSound {
  104229. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104230. loop: boolean;
  104231. private _coneInnerAngle;
  104232. private _coneOuterAngle;
  104233. private _volume;
  104234. /** A Sound is currently playing. */
  104235. isPlaying: boolean;
  104236. /** A Sound is currently paused. */
  104237. isPaused: boolean;
  104238. private _sounds;
  104239. private _weights;
  104240. private _currentIndex?;
  104241. /**
  104242. * Creates a new WeightedSound from the list of sounds given.
  104243. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104244. * @param sounds Array of Sounds that will be selected from.
  104245. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104246. */
  104247. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104248. /**
  104249. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104250. */
  104251. /**
  104252. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104253. */
  104254. directionalConeInnerAngle: number;
  104255. /**
  104256. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104257. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104258. */
  104259. /**
  104260. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104261. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104262. */
  104263. directionalConeOuterAngle: number;
  104264. /**
  104265. * Playback volume.
  104266. */
  104267. /**
  104268. * Playback volume.
  104269. */
  104270. volume: number;
  104271. private _onended;
  104272. /**
  104273. * Suspend playback
  104274. */
  104275. pause(): void;
  104276. /**
  104277. * Stop playback
  104278. */
  104279. stop(): void;
  104280. /**
  104281. * Start playback.
  104282. * @param startOffset Position the clip head at a specific time in seconds.
  104283. */
  104284. play(startOffset?: number): void;
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104291. */
  104292. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104293. /**
  104294. * Gets the name of the behavior.
  104295. */
  104296. readonly name: string;
  104297. /**
  104298. * The easing function used by animations
  104299. */
  104300. static EasingFunction: BackEase;
  104301. /**
  104302. * The easing mode used by animations
  104303. */
  104304. static EasingMode: number;
  104305. /**
  104306. * The duration of the animation, in milliseconds
  104307. */
  104308. transitionDuration: number;
  104309. /**
  104310. * Length of the distance animated by the transition when lower radius is reached
  104311. */
  104312. lowerRadiusTransitionRange: number;
  104313. /**
  104314. * Length of the distance animated by the transition when upper radius is reached
  104315. */
  104316. upperRadiusTransitionRange: number;
  104317. private _autoTransitionRange;
  104318. /**
  104319. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104320. */
  104321. /**
  104322. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104323. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104324. */
  104325. autoTransitionRange: boolean;
  104326. private _attachedCamera;
  104327. private _onAfterCheckInputsObserver;
  104328. private _onMeshTargetChangedObserver;
  104329. /**
  104330. * Initializes the behavior.
  104331. */
  104332. init(): void;
  104333. /**
  104334. * Attaches the behavior to its arc rotate camera.
  104335. * @param camera Defines the camera to attach the behavior to
  104336. */
  104337. attach(camera: ArcRotateCamera): void;
  104338. /**
  104339. * Detaches the behavior from its current arc rotate camera.
  104340. */
  104341. detach(): void;
  104342. private _radiusIsAnimating;
  104343. private _radiusBounceTransition;
  104344. private _animatables;
  104345. private _cachedWheelPrecision;
  104346. /**
  104347. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104348. * @param radiusLimit The limit to check against.
  104349. * @return Bool to indicate if at limit.
  104350. */
  104351. private _isRadiusAtLimit;
  104352. /**
  104353. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104354. * @param radiusDelta The delta by which to animate to. Can be negative.
  104355. */
  104356. private _applyBoundRadiusAnimation;
  104357. /**
  104358. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104359. */
  104360. protected _clearAnimationLocks(): void;
  104361. /**
  104362. * Stops and removes all animations that have been applied to the camera
  104363. */
  104364. stopAllAnimations(): void;
  104365. }
  104366. }
  104367. declare module BABYLON {
  104368. /**
  104369. * 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.
  104370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104371. */
  104372. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104373. /**
  104374. * Gets the name of the behavior.
  104375. */
  104376. readonly name: string;
  104377. private _mode;
  104378. private _radiusScale;
  104379. private _positionScale;
  104380. private _defaultElevation;
  104381. private _elevationReturnTime;
  104382. private _elevationReturnWaitTime;
  104383. private _zoomStopsAnimation;
  104384. private _framingTime;
  104385. /**
  104386. * The easing function used by animations
  104387. */
  104388. static EasingFunction: ExponentialEase;
  104389. /**
  104390. * The easing mode used by animations
  104391. */
  104392. static EasingMode: number;
  104393. /**
  104394. * Sets the current mode used by the behavior
  104395. */
  104396. /**
  104397. * Gets current mode used by the behavior.
  104398. */
  104399. mode: number;
  104400. /**
  104401. * Sets the scale applied to the radius (1 by default)
  104402. */
  104403. /**
  104404. * Gets the scale applied to the radius
  104405. */
  104406. radiusScale: number;
  104407. /**
  104408. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104409. */
  104410. /**
  104411. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104412. */
  104413. positionScale: number;
  104414. /**
  104415. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104416. * behaviour is triggered, in radians.
  104417. */
  104418. /**
  104419. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104420. * behaviour is triggered, in radians.
  104421. */
  104422. defaultElevation: number;
  104423. /**
  104424. * Sets the time (in milliseconds) taken to return to the default beta position.
  104425. * Negative value indicates camera should not return to default.
  104426. */
  104427. /**
  104428. * Gets the time (in milliseconds) taken to return to the default beta position.
  104429. * Negative value indicates camera should not return to default.
  104430. */
  104431. elevationReturnTime: number;
  104432. /**
  104433. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104434. */
  104435. /**
  104436. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104437. */
  104438. elevationReturnWaitTime: number;
  104439. /**
  104440. * Sets the flag that indicates if user zooming should stop animation.
  104441. */
  104442. /**
  104443. * Gets the flag that indicates if user zooming should stop animation.
  104444. */
  104445. zoomStopsAnimation: boolean;
  104446. /**
  104447. * Sets the transition time when framing the mesh, in milliseconds
  104448. */
  104449. /**
  104450. * Gets the transition time when framing the mesh, in milliseconds
  104451. */
  104452. framingTime: number;
  104453. /**
  104454. * Define if the behavior should automatically change the configured
  104455. * camera limits and sensibilities.
  104456. */
  104457. autoCorrectCameraLimitsAndSensibility: boolean;
  104458. private _onPrePointerObservableObserver;
  104459. private _onAfterCheckInputsObserver;
  104460. private _onMeshTargetChangedObserver;
  104461. private _attachedCamera;
  104462. private _isPointerDown;
  104463. private _lastInteractionTime;
  104464. /**
  104465. * Initializes the behavior.
  104466. */
  104467. init(): void;
  104468. /**
  104469. * Attaches the behavior to its arc rotate camera.
  104470. * @param camera Defines the camera to attach the behavior to
  104471. */
  104472. attach(camera: ArcRotateCamera): void;
  104473. /**
  104474. * Detaches the behavior from its current arc rotate camera.
  104475. */
  104476. detach(): void;
  104477. private _animatables;
  104478. private _betaIsAnimating;
  104479. private _betaTransition;
  104480. private _radiusTransition;
  104481. private _vectorTransition;
  104482. /**
  104483. * Targets the given mesh and updates zoom level accordingly.
  104484. * @param mesh The mesh to target.
  104485. * @param radius Optional. If a cached radius position already exists, overrides default.
  104486. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104489. */
  104490. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104491. /**
  104492. * Targets the given mesh with its children and updates zoom level accordingly.
  104493. * @param mesh The mesh to target.
  104494. * @param radius Optional. If a cached radius position already exists, overrides default.
  104495. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104498. */
  104499. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104500. /**
  104501. * Targets the given meshes with their children and updates zoom level accordingly.
  104502. * @param meshes The mesh to target.
  104503. * @param radius Optional. If a cached radius position already exists, overrides default.
  104504. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104507. */
  104508. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104509. /**
  104510. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104511. * @param minimumWorld Determines the smaller position of the bounding box extend
  104512. * @param maximumWorld Determines the bigger position of the bounding box extend
  104513. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104514. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104515. */
  104516. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104517. /**
  104518. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104519. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104520. * frustum width.
  104521. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104522. * to fully enclose the mesh in the viewing frustum.
  104523. */
  104524. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104525. /**
  104526. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104527. * is automatically returned to its default position (expected to be above ground plane).
  104528. */
  104529. private _maintainCameraAboveGround;
  104530. /**
  104531. * Returns the frustum slope based on the canvas ratio and camera FOV
  104532. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104533. */
  104534. private _getFrustumSlope;
  104535. /**
  104536. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104537. */
  104538. private _clearAnimationLocks;
  104539. /**
  104540. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104541. */
  104542. private _applyUserInteraction;
  104543. /**
  104544. * Stops and removes all animations that have been applied to the camera
  104545. */
  104546. stopAllAnimations(): void;
  104547. /**
  104548. * Gets a value indicating if the user is moving the camera
  104549. */
  104550. readonly isUserIsMoving: boolean;
  104551. /**
  104552. * The camera can move all the way towards the mesh.
  104553. */
  104554. static IgnoreBoundsSizeMode: number;
  104555. /**
  104556. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104557. */
  104558. static FitFrustumSidesMode: number;
  104559. }
  104560. }
  104561. declare module BABYLON {
  104562. /**
  104563. * Base class for Camera Pointer Inputs.
  104564. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104565. * for example usage.
  104566. */
  104567. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104568. /**
  104569. * Defines the camera the input is attached to.
  104570. */
  104571. abstract camera: Camera;
  104572. /**
  104573. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104574. */
  104575. protected _altKey: boolean;
  104576. protected _ctrlKey: boolean;
  104577. protected _metaKey: boolean;
  104578. protected _shiftKey: boolean;
  104579. /**
  104580. * Which mouse buttons were pressed at time of last mouse event.
  104581. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104582. */
  104583. protected _buttonsPressed: number;
  104584. /**
  104585. * Defines the buttons associated with the input to handle camera move.
  104586. */
  104587. buttons: number[];
  104588. /**
  104589. * Attach the input controls to a specific dom element to get the input from.
  104590. * @param element Defines the element the controls should be listened from
  104591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104592. */
  104593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104594. /**
  104595. * Detach the current controls from the specified dom element.
  104596. * @param element Defines the element to stop listening the inputs from
  104597. */
  104598. detachControl(element: Nullable<HTMLElement>): void;
  104599. /**
  104600. * Gets the class name of the current input.
  104601. * @returns the class name
  104602. */
  104603. getClassName(): string;
  104604. /**
  104605. * Get the friendly name associated with the input class.
  104606. * @returns the input friendly name
  104607. */
  104608. getSimpleName(): string;
  104609. /**
  104610. * Called on pointer POINTERDOUBLETAP event.
  104611. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104612. */
  104613. protected onDoubleTap(type: string): void;
  104614. /**
  104615. * Called on pointer POINTERMOVE event if only a single touch is active.
  104616. * Override this method to provide functionality.
  104617. */
  104618. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104619. /**
  104620. * Called on pointer POINTERMOVE event if multiple touches are active.
  104621. * Override this method to provide functionality.
  104622. */
  104623. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104624. /**
  104625. * Called on JS contextmenu event.
  104626. * Override this method to provide functionality.
  104627. */
  104628. protected onContextMenu(evt: PointerEvent): void;
  104629. /**
  104630. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104631. * press.
  104632. * Override this method to provide functionality.
  104633. */
  104634. protected onButtonDown(evt: PointerEvent): void;
  104635. /**
  104636. * Called each time a new POINTERUP event occurs. Ie, for each button
  104637. * release.
  104638. * Override this method to provide functionality.
  104639. */
  104640. protected onButtonUp(evt: PointerEvent): void;
  104641. /**
  104642. * Called when window becomes inactive.
  104643. * Override this method to provide functionality.
  104644. */
  104645. protected onLostFocus(): void;
  104646. private _pointerInput;
  104647. private _observer;
  104648. private _onLostFocus;
  104649. private pointA;
  104650. private pointB;
  104651. }
  104652. }
  104653. declare module BABYLON {
  104654. /**
  104655. * Manage the pointers inputs to control an arc rotate camera.
  104656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104657. */
  104658. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104659. /**
  104660. * Defines the camera the input is attached to.
  104661. */
  104662. camera: ArcRotateCamera;
  104663. /**
  104664. * Gets the class name of the current input.
  104665. * @returns the class name
  104666. */
  104667. getClassName(): string;
  104668. /**
  104669. * Defines the buttons associated with the input to handle camera move.
  104670. */
  104671. buttons: number[];
  104672. /**
  104673. * Defines the pointer angular sensibility along the X axis or how fast is
  104674. * the camera rotating.
  104675. */
  104676. angularSensibilityX: number;
  104677. /**
  104678. * Defines the pointer angular sensibility along the Y axis or how fast is
  104679. * the camera rotating.
  104680. */
  104681. angularSensibilityY: number;
  104682. /**
  104683. * Defines the pointer pinch precision or how fast is the camera zooming.
  104684. */
  104685. pinchPrecision: number;
  104686. /**
  104687. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104688. * from 0.
  104689. * It defines the percentage of current camera.radius to use as delta when
  104690. * pinch zoom is used.
  104691. */
  104692. pinchDeltaPercentage: number;
  104693. /**
  104694. * Defines the pointer panning sensibility or how fast is the camera moving.
  104695. */
  104696. panningSensibility: number;
  104697. /**
  104698. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104699. */
  104700. multiTouchPanning: boolean;
  104701. /**
  104702. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104703. * zoom (pinch) through multitouch.
  104704. */
  104705. multiTouchPanAndZoom: boolean;
  104706. /**
  104707. * Revers pinch action direction.
  104708. */
  104709. pinchInwards: boolean;
  104710. private _isPanClick;
  104711. private _twoFingerActivityCount;
  104712. private _isPinching;
  104713. /**
  104714. * Called on pointer POINTERMOVE event if only a single touch is active.
  104715. */
  104716. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104717. /**
  104718. * Called on pointer POINTERDOUBLETAP event.
  104719. */
  104720. protected onDoubleTap(type: string): void;
  104721. /**
  104722. * Called on pointer POINTERMOVE event if multiple touches are active.
  104723. */
  104724. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104725. /**
  104726. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104727. * press.
  104728. */
  104729. protected onButtonDown(evt: PointerEvent): void;
  104730. /**
  104731. * Called each time a new POINTERUP event occurs. Ie, for each button
  104732. * release.
  104733. */
  104734. protected onButtonUp(evt: PointerEvent): void;
  104735. /**
  104736. * Called when window becomes inactive.
  104737. */
  104738. protected onLostFocus(): void;
  104739. }
  104740. }
  104741. declare module BABYLON {
  104742. /**
  104743. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  104744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104745. */
  104746. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  104747. /**
  104748. * Defines the camera the input is attached to.
  104749. */
  104750. camera: ArcRotateCamera;
  104751. /**
  104752. * Defines the list of key codes associated with the up action (increase alpha)
  104753. */
  104754. keysUp: number[];
  104755. /**
  104756. * Defines the list of key codes associated with the down action (decrease alpha)
  104757. */
  104758. keysDown: number[];
  104759. /**
  104760. * Defines the list of key codes associated with the left action (increase beta)
  104761. */
  104762. keysLeft: number[];
  104763. /**
  104764. * Defines the list of key codes associated with the right action (decrease beta)
  104765. */
  104766. keysRight: number[];
  104767. /**
  104768. * Defines the list of key codes associated with the reset action.
  104769. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  104770. */
  104771. keysReset: number[];
  104772. /**
  104773. * Defines the panning sensibility of the inputs.
  104774. * (How fast is the camera paning)
  104775. */
  104776. panningSensibility: number;
  104777. /**
  104778. * Defines the zooming sensibility of the inputs.
  104779. * (How fast is the camera zooming)
  104780. */
  104781. zoomingSensibility: number;
  104782. /**
  104783. * Defines wether maintaining the alt key down switch the movement mode from
  104784. * orientation to zoom.
  104785. */
  104786. useAltToZoom: boolean;
  104787. /**
  104788. * Rotation speed of the camera
  104789. */
  104790. angularSpeed: number;
  104791. private _keys;
  104792. private _ctrlPressed;
  104793. private _altPressed;
  104794. private _onCanvasBlurObserver;
  104795. private _onKeyboardObserver;
  104796. private _engine;
  104797. private _scene;
  104798. /**
  104799. * Attach the input controls to a specific dom element to get the input from.
  104800. * @param element Defines the element the controls should be listened from
  104801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104802. */
  104803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104804. /**
  104805. * Detach the current controls from the specified dom element.
  104806. * @param element Defines the element to stop listening the inputs from
  104807. */
  104808. detachControl(element: Nullable<HTMLElement>): void;
  104809. /**
  104810. * Update the current camera state depending on the inputs that have been used this frame.
  104811. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104812. */
  104813. checkInputs(): void;
  104814. /**
  104815. * Gets the class name of the current intput.
  104816. * @returns the class name
  104817. */
  104818. getClassName(): string;
  104819. /**
  104820. * Get the friendly name associated with the input class.
  104821. * @returns the input friendly name
  104822. */
  104823. getSimpleName(): string;
  104824. }
  104825. }
  104826. declare module BABYLON {
  104827. /**
  104828. * Manage the mouse wheel inputs to control an arc rotate camera.
  104829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104830. */
  104831. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104832. /**
  104833. * Defines the camera the input is attached to.
  104834. */
  104835. camera: ArcRotateCamera;
  104836. /**
  104837. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104838. */
  104839. wheelPrecision: number;
  104840. /**
  104841. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104842. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104843. */
  104844. wheelDeltaPercentage: number;
  104845. private _wheel;
  104846. private _observer;
  104847. private computeDeltaFromMouseWheelLegacyEvent;
  104848. /**
  104849. * Attach the input controls to a specific dom element to get the input from.
  104850. * @param element Defines the element the controls should be listened from
  104851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104852. */
  104853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104854. /**
  104855. * Detach the current controls from the specified dom element.
  104856. * @param element Defines the element to stop listening the inputs from
  104857. */
  104858. detachControl(element: Nullable<HTMLElement>): void;
  104859. /**
  104860. * Gets the class name of the current intput.
  104861. * @returns the class name
  104862. */
  104863. getClassName(): string;
  104864. /**
  104865. * Get the friendly name associated with the input class.
  104866. * @returns the input friendly name
  104867. */
  104868. getSimpleName(): string;
  104869. }
  104870. }
  104871. declare module BABYLON {
  104872. /**
  104873. * Default Inputs manager for the ArcRotateCamera.
  104874. * It groups all the default supported inputs for ease of use.
  104875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104876. */
  104877. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104878. /**
  104879. * Instantiates a new ArcRotateCameraInputsManager.
  104880. * @param camera Defines the camera the inputs belong to
  104881. */
  104882. constructor(camera: ArcRotateCamera);
  104883. /**
  104884. * Add mouse wheel input support to the input manager.
  104885. * @returns the current input manager
  104886. */
  104887. addMouseWheel(): ArcRotateCameraInputsManager;
  104888. /**
  104889. * Add pointers input support to the input manager.
  104890. * @returns the current input manager
  104891. */
  104892. addPointers(): ArcRotateCameraInputsManager;
  104893. /**
  104894. * Add keyboard input support to the input manager.
  104895. * @returns the current input manager
  104896. */
  104897. addKeyboard(): ArcRotateCameraInputsManager;
  104898. }
  104899. }
  104900. declare module BABYLON {
  104901. /**
  104902. * This represents an orbital type of camera.
  104903. *
  104904. * 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.
  104905. * 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.
  104906. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104907. */
  104908. export class ArcRotateCamera extends TargetCamera {
  104909. /**
  104910. * Defines the rotation angle of the camera along the longitudinal axis.
  104911. */
  104912. alpha: number;
  104913. /**
  104914. * Defines the rotation angle of the camera along the latitudinal axis.
  104915. */
  104916. beta: number;
  104917. /**
  104918. * Defines the radius of the camera from it s target point.
  104919. */
  104920. radius: number;
  104921. protected _target: Vector3;
  104922. protected _targetHost: Nullable<AbstractMesh>;
  104923. /**
  104924. * Defines the target point of the camera.
  104925. * The camera looks towards it form the radius distance.
  104926. */
  104927. target: Vector3;
  104928. /**
  104929. * Define the current local position of the camera in the scene
  104930. */
  104931. position: Vector3;
  104932. protected _upVector: Vector3;
  104933. protected _upToYMatrix: Matrix;
  104934. protected _YToUpMatrix: Matrix;
  104935. /**
  104936. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104937. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104938. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104939. */
  104940. upVector: Vector3;
  104941. /**
  104942. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104943. */
  104944. setMatUp(): void;
  104945. /**
  104946. * Current inertia value on the longitudinal axis.
  104947. * The bigger this number the longer it will take for the camera to stop.
  104948. */
  104949. inertialAlphaOffset: number;
  104950. /**
  104951. * Current inertia value on the latitudinal axis.
  104952. * The bigger this number the longer it will take for the camera to stop.
  104953. */
  104954. inertialBetaOffset: number;
  104955. /**
  104956. * Current inertia value on the radius axis.
  104957. * The bigger this number the longer it will take for the camera to stop.
  104958. */
  104959. inertialRadiusOffset: number;
  104960. /**
  104961. * Minimum allowed angle on the longitudinal axis.
  104962. * This can help limiting how the Camera is able to move in the scene.
  104963. */
  104964. lowerAlphaLimit: Nullable<number>;
  104965. /**
  104966. * Maximum allowed angle on the longitudinal axis.
  104967. * This can help limiting how the Camera is able to move in the scene.
  104968. */
  104969. upperAlphaLimit: Nullable<number>;
  104970. /**
  104971. * Minimum allowed angle on the latitudinal axis.
  104972. * This can help limiting how the Camera is able to move in the scene.
  104973. */
  104974. lowerBetaLimit: number;
  104975. /**
  104976. * Maximum allowed angle on the latitudinal axis.
  104977. * This can help limiting how the Camera is able to move in the scene.
  104978. */
  104979. upperBetaLimit: number;
  104980. /**
  104981. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104982. * This can help limiting how the Camera is able to move in the scene.
  104983. */
  104984. lowerRadiusLimit: Nullable<number>;
  104985. /**
  104986. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104987. * This can help limiting how the Camera is able to move in the scene.
  104988. */
  104989. upperRadiusLimit: Nullable<number>;
  104990. /**
  104991. * Defines the current inertia value used during panning of the camera along the X axis.
  104992. */
  104993. inertialPanningX: number;
  104994. /**
  104995. * Defines the current inertia value used during panning of the camera along the Y axis.
  104996. */
  104997. inertialPanningY: number;
  104998. /**
  104999. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105000. * Basically if your fingers moves away from more than this distance you will be considered
  105001. * in pinch mode.
  105002. */
  105003. pinchToPanMaxDistance: number;
  105004. /**
  105005. * Defines the maximum distance the camera can pan.
  105006. * This could help keeping the cammera always in your scene.
  105007. */
  105008. panningDistanceLimit: Nullable<number>;
  105009. /**
  105010. * Defines the target of the camera before paning.
  105011. */
  105012. panningOriginTarget: Vector3;
  105013. /**
  105014. * Defines the value of the inertia used during panning.
  105015. * 0 would mean stop inertia and one would mean no decelleration at all.
  105016. */
  105017. panningInertia: number;
  105018. /**
  105019. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105020. */
  105021. angularSensibilityX: number;
  105022. /**
  105023. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105024. */
  105025. angularSensibilityY: number;
  105026. /**
  105027. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105028. */
  105029. pinchPrecision: number;
  105030. /**
  105031. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105032. * It will be used instead of pinchDeltaPrecision if different from 0.
  105033. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105034. */
  105035. pinchDeltaPercentage: number;
  105036. /**
  105037. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105038. */
  105039. panningSensibility: number;
  105040. /**
  105041. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105042. */
  105043. keysUp: number[];
  105044. /**
  105045. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105046. */
  105047. keysDown: number[];
  105048. /**
  105049. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105050. */
  105051. keysLeft: number[];
  105052. /**
  105053. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105054. */
  105055. keysRight: number[];
  105056. /**
  105057. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105058. */
  105059. wheelPrecision: number;
  105060. /**
  105061. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105062. * It will be used instead of pinchDeltaPrecision if different from 0.
  105063. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105064. */
  105065. wheelDeltaPercentage: number;
  105066. /**
  105067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105068. */
  105069. zoomOnFactor: number;
  105070. /**
  105071. * Defines a screen offset for the camera position.
  105072. */
  105073. targetScreenOffset: Vector2;
  105074. /**
  105075. * Allows the camera to be completely reversed.
  105076. * If false the camera can not arrive upside down.
  105077. */
  105078. allowUpsideDown: boolean;
  105079. /**
  105080. * Define if double tap/click is used to restore the previously saved state of the camera.
  105081. */
  105082. useInputToRestoreState: boolean;
  105083. /** @hidden */
  105084. _viewMatrix: Matrix;
  105085. /** @hidden */
  105086. _useCtrlForPanning: boolean;
  105087. /** @hidden */
  105088. _panningMouseButton: number;
  105089. /**
  105090. * Defines the input associated to the camera.
  105091. */
  105092. inputs: ArcRotateCameraInputsManager;
  105093. /** @hidden */
  105094. _reset: () => void;
  105095. /**
  105096. * Defines the allowed panning axis.
  105097. */
  105098. panningAxis: Vector3;
  105099. protected _localDirection: Vector3;
  105100. protected _transformedDirection: Vector3;
  105101. private _bouncingBehavior;
  105102. /**
  105103. * Gets the bouncing behavior of the camera if it has been enabled.
  105104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105105. */
  105106. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105107. /**
  105108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105110. */
  105111. useBouncingBehavior: boolean;
  105112. private _framingBehavior;
  105113. /**
  105114. * Gets the framing behavior of the camera if it has been enabled.
  105115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105116. */
  105117. readonly framingBehavior: Nullable<FramingBehavior>;
  105118. /**
  105119. * Defines if the framing behavior of the camera is enabled on the camera.
  105120. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105121. */
  105122. useFramingBehavior: boolean;
  105123. private _autoRotationBehavior;
  105124. /**
  105125. * Gets the auto rotation behavior of the camera if it has been enabled.
  105126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105127. */
  105128. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105129. /**
  105130. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105132. */
  105133. useAutoRotationBehavior: boolean;
  105134. /**
  105135. * Observable triggered when the mesh target has been changed on the camera.
  105136. */
  105137. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105138. /**
  105139. * Event raised when the camera is colliding with a mesh.
  105140. */
  105141. onCollide: (collidedMesh: AbstractMesh) => void;
  105142. /**
  105143. * Defines whether the camera should check collision with the objects oh the scene.
  105144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105145. */
  105146. checkCollisions: boolean;
  105147. /**
  105148. * Defines the collision radius of the camera.
  105149. * This simulates a sphere around the camera.
  105150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105151. */
  105152. collisionRadius: Vector3;
  105153. protected _collider: Collider;
  105154. protected _previousPosition: Vector3;
  105155. protected _collisionVelocity: Vector3;
  105156. protected _newPosition: Vector3;
  105157. protected _previousAlpha: number;
  105158. protected _previousBeta: number;
  105159. protected _previousRadius: number;
  105160. protected _collisionTriggered: boolean;
  105161. protected _targetBoundingCenter: Nullable<Vector3>;
  105162. private _computationVector;
  105163. /**
  105164. * Instantiates a new ArcRotateCamera in a given scene
  105165. * @param name Defines the name of the camera
  105166. * @param alpha Defines the camera rotation along the logitudinal axis
  105167. * @param beta Defines the camera rotation along the latitudinal axis
  105168. * @param radius Defines the camera distance from its target
  105169. * @param target Defines the camera target
  105170. * @param scene Defines the scene the camera belongs to
  105171. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105172. */
  105173. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105174. /** @hidden */
  105175. _initCache(): void;
  105176. /** @hidden */
  105177. _updateCache(ignoreParentClass?: boolean): void;
  105178. protected _getTargetPosition(): Vector3;
  105179. private _storedAlpha;
  105180. private _storedBeta;
  105181. private _storedRadius;
  105182. private _storedTarget;
  105183. private _storedTargetScreenOffset;
  105184. /**
  105185. * Stores the current state of the camera (alpha, beta, radius and target)
  105186. * @returns the camera itself
  105187. */
  105188. storeState(): Camera;
  105189. /**
  105190. * @hidden
  105191. * Restored camera state. You must call storeState() first
  105192. */
  105193. _restoreStateValues(): boolean;
  105194. /** @hidden */
  105195. _isSynchronizedViewMatrix(): boolean;
  105196. /**
  105197. * Attached controls to the current camera.
  105198. * @param element Defines the element the controls should be listened from
  105199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105200. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105201. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105202. */
  105203. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105204. /**
  105205. * Detach the current controls from the camera.
  105206. * The camera will stop reacting to inputs.
  105207. * @param element Defines the element to stop listening the inputs from
  105208. */
  105209. detachControl(element: HTMLElement): void;
  105210. /** @hidden */
  105211. _checkInputs(): void;
  105212. protected _checkLimits(): void;
  105213. /**
  105214. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105215. */
  105216. rebuildAnglesAndRadius(): void;
  105217. /**
  105218. * Use a position to define the current camera related information like alpha, beta and radius
  105219. * @param position Defines the position to set the camera at
  105220. */
  105221. setPosition(position: Vector3): void;
  105222. /**
  105223. * Defines the target the camera should look at.
  105224. * This will automatically adapt alpha beta and radius to fit within the new target.
  105225. * @param target Defines the new target as a Vector or a mesh
  105226. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105227. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105228. */
  105229. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105230. /** @hidden */
  105231. _getViewMatrix(): Matrix;
  105232. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105233. /**
  105234. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105235. * @param meshes Defines the mesh to zoom on
  105236. * @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)
  105237. */
  105238. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105239. /**
  105240. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105241. * The target will be changed but the radius
  105242. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105243. * @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)
  105244. */
  105245. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105246. min: Vector3;
  105247. max: Vector3;
  105248. distance: number;
  105249. }, doNotUpdateMaxZ?: boolean): void;
  105250. /**
  105251. * @override
  105252. * Override Camera.createRigCamera
  105253. */
  105254. createRigCamera(name: string, cameraIndex: number): Camera;
  105255. /**
  105256. * @hidden
  105257. * @override
  105258. * Override Camera._updateRigCameras
  105259. */
  105260. _updateRigCameras(): void;
  105261. /**
  105262. * Destroy the camera and release the current resources hold by it.
  105263. */
  105264. dispose(): void;
  105265. /**
  105266. * Gets the current object class name.
  105267. * @return the class name
  105268. */
  105269. getClassName(): string;
  105270. }
  105271. }
  105272. declare module BABYLON {
  105273. /**
  105274. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105276. */
  105277. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105278. /**
  105279. * Gets the name of the behavior.
  105280. */
  105281. readonly name: string;
  105282. private _zoomStopsAnimation;
  105283. private _idleRotationSpeed;
  105284. private _idleRotationWaitTime;
  105285. private _idleRotationSpinupTime;
  105286. /**
  105287. * Sets the flag that indicates if user zooming should stop animation.
  105288. */
  105289. /**
  105290. * Gets the flag that indicates if user zooming should stop animation.
  105291. */
  105292. zoomStopsAnimation: boolean;
  105293. /**
  105294. * Sets the default speed at which the camera rotates around the model.
  105295. */
  105296. /**
  105297. * Gets the default speed at which the camera rotates around the model.
  105298. */
  105299. idleRotationSpeed: number;
  105300. /**
  105301. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105302. */
  105303. /**
  105304. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105305. */
  105306. idleRotationWaitTime: number;
  105307. /**
  105308. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105309. */
  105310. /**
  105311. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105312. */
  105313. idleRotationSpinupTime: number;
  105314. /**
  105315. * Gets a value indicating if the camera is currently rotating because of this behavior
  105316. */
  105317. readonly rotationInProgress: boolean;
  105318. private _onPrePointerObservableObserver;
  105319. private _onAfterCheckInputsObserver;
  105320. private _attachedCamera;
  105321. private _isPointerDown;
  105322. private _lastFrameTime;
  105323. private _lastInteractionTime;
  105324. private _cameraRotationSpeed;
  105325. /**
  105326. * Initializes the behavior.
  105327. */
  105328. init(): void;
  105329. /**
  105330. * Attaches the behavior to its arc rotate camera.
  105331. * @param camera Defines the camera to attach the behavior to
  105332. */
  105333. attach(camera: ArcRotateCamera): void;
  105334. /**
  105335. * Detaches the behavior from its current arc rotate camera.
  105336. */
  105337. detach(): void;
  105338. /**
  105339. * Returns true if user is scrolling.
  105340. * @return true if user is scrolling.
  105341. */
  105342. private _userIsZooming;
  105343. private _lastFrameRadius;
  105344. private _shouldAnimationStopForInteraction;
  105345. /**
  105346. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105347. */
  105348. private _applyUserInteraction;
  105349. private _userIsMoving;
  105350. }
  105351. }
  105352. declare module BABYLON {
  105353. /**
  105354. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105355. */
  105356. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105357. private ui;
  105358. /**
  105359. * The name of the behavior
  105360. */
  105361. name: string;
  105362. /**
  105363. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105364. */
  105365. distanceAwayFromFace: number;
  105366. /**
  105367. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105368. */
  105369. distanceAwayFromBottomOfFace: number;
  105370. private _faceVectors;
  105371. private _target;
  105372. private _scene;
  105373. private _onRenderObserver;
  105374. private _tmpMatrix;
  105375. private _tmpVector;
  105376. /**
  105377. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105378. * @param ui The transform node that should be attched to the mesh
  105379. */
  105380. constructor(ui: TransformNode);
  105381. /**
  105382. * Initializes the behavior
  105383. */
  105384. init(): void;
  105385. private _closestFace;
  105386. private _zeroVector;
  105387. private _lookAtTmpMatrix;
  105388. private _lookAtToRef;
  105389. /**
  105390. * Attaches the AttachToBoxBehavior to the passed in mesh
  105391. * @param target The mesh that the specified node will be attached to
  105392. */
  105393. attach(target: Mesh): void;
  105394. /**
  105395. * Detaches the behavior from the mesh
  105396. */
  105397. detach(): void;
  105398. }
  105399. }
  105400. declare module BABYLON {
  105401. /**
  105402. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105403. */
  105404. export class FadeInOutBehavior implements Behavior<Mesh> {
  105405. /**
  105406. * Time in milliseconds to delay before fading in (Default: 0)
  105407. */
  105408. delay: number;
  105409. /**
  105410. * Time in milliseconds for the mesh to fade in (Default: 300)
  105411. */
  105412. fadeInTime: number;
  105413. private _millisecondsPerFrame;
  105414. private _hovered;
  105415. private _hoverValue;
  105416. private _ownerNode;
  105417. /**
  105418. * Instatiates the FadeInOutBehavior
  105419. */
  105420. constructor();
  105421. /**
  105422. * The name of the behavior
  105423. */
  105424. readonly name: string;
  105425. /**
  105426. * Initializes the behavior
  105427. */
  105428. init(): void;
  105429. /**
  105430. * Attaches the fade behavior on the passed in mesh
  105431. * @param ownerNode The mesh that will be faded in/out once attached
  105432. */
  105433. attach(ownerNode: Mesh): void;
  105434. /**
  105435. * Detaches the behavior from the mesh
  105436. */
  105437. detach(): void;
  105438. /**
  105439. * Triggers the mesh to begin fading in or out
  105440. * @param value if the object should fade in or out (true to fade in)
  105441. */
  105442. fadeIn(value: boolean): void;
  105443. private _update;
  105444. private _setAllVisibility;
  105445. }
  105446. }
  105447. declare module BABYLON {
  105448. /**
  105449. * Class containing a set of static utilities functions for managing Pivots
  105450. * @hidden
  105451. */
  105452. export class PivotTools {
  105453. private static _PivotCached;
  105454. private static _OldPivotPoint;
  105455. private static _PivotTranslation;
  105456. private static _PivotTmpVector;
  105457. /** @hidden */
  105458. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105459. /** @hidden */
  105460. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105461. }
  105462. }
  105463. declare module BABYLON {
  105464. /**
  105465. * Class containing static functions to help procedurally build meshes
  105466. */
  105467. export class PlaneBuilder {
  105468. /**
  105469. * Creates a plane mesh
  105470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105476. * @param name defines the name of the mesh
  105477. * @param options defines the options used to create the mesh
  105478. * @param scene defines the hosting scene
  105479. * @returns the plane mesh
  105480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105481. */
  105482. static CreatePlane(name: string, options: {
  105483. size?: number;
  105484. width?: number;
  105485. height?: number;
  105486. sideOrientation?: number;
  105487. frontUVs?: Vector4;
  105488. backUVs?: Vector4;
  105489. updatable?: boolean;
  105490. sourcePlane?: Plane;
  105491. }, scene?: Nullable<Scene>): Mesh;
  105492. }
  105493. }
  105494. declare module BABYLON {
  105495. /**
  105496. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105497. */
  105498. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105499. private static _AnyMouseID;
  105500. /**
  105501. * Abstract mesh the behavior is set on
  105502. */
  105503. attachedNode: AbstractMesh;
  105504. private _dragPlane;
  105505. private _scene;
  105506. private _pointerObserver;
  105507. private _beforeRenderObserver;
  105508. private static _planeScene;
  105509. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105510. /**
  105511. * 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)
  105512. */
  105513. maxDragAngle: number;
  105514. /**
  105515. * @hidden
  105516. */
  105517. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105518. /**
  105519. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105520. */
  105521. currentDraggingPointerID: number;
  105522. /**
  105523. * The last position where the pointer hit the drag plane in world space
  105524. */
  105525. lastDragPosition: Vector3;
  105526. /**
  105527. * If the behavior is currently in a dragging state
  105528. */
  105529. dragging: boolean;
  105530. /**
  105531. * 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)
  105532. */
  105533. dragDeltaRatio: number;
  105534. /**
  105535. * If the drag plane orientation should be updated during the dragging (Default: true)
  105536. */
  105537. updateDragPlane: boolean;
  105538. private _debugMode;
  105539. private _moving;
  105540. /**
  105541. * Fires each time the attached mesh is dragged with the pointer
  105542. * * delta between last drag position and current drag position in world space
  105543. * * dragDistance along the drag axis
  105544. * * dragPlaneNormal normal of the current drag plane used during the drag
  105545. * * dragPlanePoint in world space where the drag intersects the drag plane
  105546. */
  105547. onDragObservable: Observable<{
  105548. delta: Vector3;
  105549. dragPlanePoint: Vector3;
  105550. dragPlaneNormal: Vector3;
  105551. dragDistance: number;
  105552. pointerId: number;
  105553. }>;
  105554. /**
  105555. * Fires each time a drag begins (eg. mouse down on mesh)
  105556. */
  105557. onDragStartObservable: Observable<{
  105558. dragPlanePoint: Vector3;
  105559. pointerId: number;
  105560. }>;
  105561. /**
  105562. * Fires each time a drag ends (eg. mouse release after drag)
  105563. */
  105564. onDragEndObservable: Observable<{
  105565. dragPlanePoint: Vector3;
  105566. pointerId: number;
  105567. }>;
  105568. /**
  105569. * If the attached mesh should be moved when dragged
  105570. */
  105571. moveAttached: boolean;
  105572. /**
  105573. * If the drag behavior will react to drag events (Default: true)
  105574. */
  105575. enabled: boolean;
  105576. /**
  105577. * If pointer events should start and release the drag (Default: true)
  105578. */
  105579. startAndReleaseDragOnPointerEvents: boolean;
  105580. /**
  105581. * If camera controls should be detached during the drag
  105582. */
  105583. detachCameraControls: boolean;
  105584. /**
  105585. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105586. */
  105587. useObjectOrienationForDragging: boolean;
  105588. private _options;
  105589. /**
  105590. * Creates a pointer drag behavior that can be attached to a mesh
  105591. * @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)
  105592. */
  105593. constructor(options?: {
  105594. dragAxis?: Vector3;
  105595. dragPlaneNormal?: Vector3;
  105596. });
  105597. /**
  105598. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105599. */
  105600. validateDrag: (targetPosition: Vector3) => boolean;
  105601. /**
  105602. * The name of the behavior
  105603. */
  105604. readonly name: string;
  105605. /**
  105606. * Initializes the behavior
  105607. */
  105608. init(): void;
  105609. private _tmpVector;
  105610. private _alternatePickedPoint;
  105611. private _worldDragAxis;
  105612. private _targetPosition;
  105613. private _attachedElement;
  105614. /**
  105615. * Attaches the drag behavior the passed in mesh
  105616. * @param ownerNode The mesh that will be dragged around once attached
  105617. * @param predicate Predicate to use for pick filtering
  105618. */
  105619. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105620. /**
  105621. * Force relase the drag action by code.
  105622. */
  105623. releaseDrag(): void;
  105624. private _startDragRay;
  105625. private _lastPointerRay;
  105626. /**
  105627. * Simulates the start of a pointer drag event on the behavior
  105628. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105629. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105630. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105631. */
  105632. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105633. private _startDrag;
  105634. private _dragDelta;
  105635. private _moveDrag;
  105636. private _pickWithRayOnDragPlane;
  105637. private _pointA;
  105638. private _pointB;
  105639. private _pointC;
  105640. private _lineA;
  105641. private _lineB;
  105642. private _localAxis;
  105643. private _lookAt;
  105644. private _updateDragPlanePosition;
  105645. /**
  105646. * Detaches the behavior from the mesh
  105647. */
  105648. detach(): void;
  105649. }
  105650. }
  105651. declare module BABYLON {
  105652. /**
  105653. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105654. */
  105655. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105656. private _dragBehaviorA;
  105657. private _dragBehaviorB;
  105658. private _startDistance;
  105659. private _initialScale;
  105660. private _targetScale;
  105661. private _ownerNode;
  105662. private _sceneRenderObserver;
  105663. /**
  105664. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105665. */
  105666. constructor();
  105667. /**
  105668. * The name of the behavior
  105669. */
  105670. readonly name: string;
  105671. /**
  105672. * Initializes the behavior
  105673. */
  105674. init(): void;
  105675. private _getCurrentDistance;
  105676. /**
  105677. * Attaches the scale behavior the passed in mesh
  105678. * @param ownerNode The mesh that will be scaled around once attached
  105679. */
  105680. attach(ownerNode: Mesh): void;
  105681. /**
  105682. * Detaches the behavior from the mesh
  105683. */
  105684. detach(): void;
  105685. }
  105686. }
  105687. declare module BABYLON {
  105688. /**
  105689. * 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
  105690. */
  105691. export class SixDofDragBehavior implements Behavior<Mesh> {
  105692. private static _virtualScene;
  105693. private _ownerNode;
  105694. private _sceneRenderObserver;
  105695. private _scene;
  105696. private _targetPosition;
  105697. private _virtualOriginMesh;
  105698. private _virtualDragMesh;
  105699. private _pointerObserver;
  105700. private _moving;
  105701. private _startingOrientation;
  105702. /**
  105703. * 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)
  105704. */
  105705. private zDragFactor;
  105706. /**
  105707. * If the object should rotate to face the drag origin
  105708. */
  105709. rotateDraggedObject: boolean;
  105710. /**
  105711. * If the behavior is currently in a dragging state
  105712. */
  105713. dragging: boolean;
  105714. /**
  105715. * 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)
  105716. */
  105717. dragDeltaRatio: number;
  105718. /**
  105719. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105720. */
  105721. currentDraggingPointerID: number;
  105722. /**
  105723. * If camera controls should be detached during the drag
  105724. */
  105725. detachCameraControls: boolean;
  105726. /**
  105727. * Fires each time a drag starts
  105728. */
  105729. onDragStartObservable: Observable<{}>;
  105730. /**
  105731. * Fires each time a drag ends (eg. mouse release after drag)
  105732. */
  105733. onDragEndObservable: Observable<{}>;
  105734. /**
  105735. * 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
  105736. */
  105737. constructor();
  105738. /**
  105739. * The name of the behavior
  105740. */
  105741. readonly name: string;
  105742. /**
  105743. * Initializes the behavior
  105744. */
  105745. init(): void;
  105746. /**
  105747. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  105748. */
  105749. private readonly _pointerCamera;
  105750. /**
  105751. * Attaches the scale behavior the passed in mesh
  105752. * @param ownerNode The mesh that will be scaled around once attached
  105753. */
  105754. attach(ownerNode: Mesh): void;
  105755. /**
  105756. * Detaches the behavior from the mesh
  105757. */
  105758. detach(): void;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. /**
  105763. * Class used to apply inverse kinematics to bones
  105764. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  105765. */
  105766. export class BoneIKController {
  105767. private static _tmpVecs;
  105768. private static _tmpQuat;
  105769. private static _tmpMats;
  105770. /**
  105771. * Gets or sets the target mesh
  105772. */
  105773. targetMesh: AbstractMesh;
  105774. /** Gets or sets the mesh used as pole */
  105775. poleTargetMesh: AbstractMesh;
  105776. /**
  105777. * Gets or sets the bone used as pole
  105778. */
  105779. poleTargetBone: Nullable<Bone>;
  105780. /**
  105781. * Gets or sets the target position
  105782. */
  105783. targetPosition: Vector3;
  105784. /**
  105785. * Gets or sets the pole target position
  105786. */
  105787. poleTargetPosition: Vector3;
  105788. /**
  105789. * Gets or sets the pole target local offset
  105790. */
  105791. poleTargetLocalOffset: Vector3;
  105792. /**
  105793. * Gets or sets the pole angle
  105794. */
  105795. poleAngle: number;
  105796. /**
  105797. * Gets or sets the mesh associated with the controller
  105798. */
  105799. mesh: AbstractMesh;
  105800. /**
  105801. * 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)
  105802. */
  105803. slerpAmount: number;
  105804. private _bone1Quat;
  105805. private _bone1Mat;
  105806. private _bone2Ang;
  105807. private _bone1;
  105808. private _bone2;
  105809. private _bone1Length;
  105810. private _bone2Length;
  105811. private _maxAngle;
  105812. private _maxReach;
  105813. private _rightHandedSystem;
  105814. private _bendAxis;
  105815. private _slerping;
  105816. private _adjustRoll;
  105817. /**
  105818. * Gets or sets maximum allowed angle
  105819. */
  105820. maxAngle: number;
  105821. /**
  105822. * Creates a new BoneIKController
  105823. * @param mesh defines the mesh to control
  105824. * @param bone defines the bone to control
  105825. * @param options defines options to set up the controller
  105826. */
  105827. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105828. targetMesh?: AbstractMesh;
  105829. poleTargetMesh?: AbstractMesh;
  105830. poleTargetBone?: Bone;
  105831. poleTargetLocalOffset?: Vector3;
  105832. poleAngle?: number;
  105833. bendAxis?: Vector3;
  105834. maxAngle?: number;
  105835. slerpAmount?: number;
  105836. });
  105837. private _setMaxAngle;
  105838. /**
  105839. * Force the controller to update the bones
  105840. */
  105841. update(): void;
  105842. }
  105843. }
  105844. declare module BABYLON {
  105845. /**
  105846. * Class used to make a bone look toward a point in space
  105847. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105848. */
  105849. export class BoneLookController {
  105850. private static _tmpVecs;
  105851. private static _tmpQuat;
  105852. private static _tmpMats;
  105853. /**
  105854. * The target Vector3 that the bone will look at
  105855. */
  105856. target: Vector3;
  105857. /**
  105858. * The mesh that the bone is attached to
  105859. */
  105860. mesh: AbstractMesh;
  105861. /**
  105862. * The bone that will be looking to the target
  105863. */
  105864. bone: Bone;
  105865. /**
  105866. * The up axis of the coordinate system that is used when the bone is rotated
  105867. */
  105868. upAxis: Vector3;
  105869. /**
  105870. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105871. */
  105872. upAxisSpace: Space;
  105873. /**
  105874. * Used to make an adjustment to the yaw of the bone
  105875. */
  105876. adjustYaw: number;
  105877. /**
  105878. * Used to make an adjustment to the pitch of the bone
  105879. */
  105880. adjustPitch: number;
  105881. /**
  105882. * Used to make an adjustment to the roll of the bone
  105883. */
  105884. adjustRoll: number;
  105885. /**
  105886. * 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)
  105887. */
  105888. slerpAmount: number;
  105889. private _minYaw;
  105890. private _maxYaw;
  105891. private _minPitch;
  105892. private _maxPitch;
  105893. private _minYawSin;
  105894. private _minYawCos;
  105895. private _maxYawSin;
  105896. private _maxYawCos;
  105897. private _midYawConstraint;
  105898. private _minPitchTan;
  105899. private _maxPitchTan;
  105900. private _boneQuat;
  105901. private _slerping;
  105902. private _transformYawPitch;
  105903. private _transformYawPitchInv;
  105904. private _firstFrameSkipped;
  105905. private _yawRange;
  105906. private _fowardAxis;
  105907. /**
  105908. * Gets or sets the minimum yaw angle that the bone can look to
  105909. */
  105910. minYaw: number;
  105911. /**
  105912. * Gets or sets the maximum yaw angle that the bone can look to
  105913. */
  105914. maxYaw: number;
  105915. /**
  105916. * Gets or sets the minimum pitch angle that the bone can look to
  105917. */
  105918. minPitch: number;
  105919. /**
  105920. * Gets or sets the maximum pitch angle that the bone can look to
  105921. */
  105922. maxPitch: number;
  105923. /**
  105924. * Create a BoneLookController
  105925. * @param mesh the mesh that the bone belongs to
  105926. * @param bone the bone that will be looking to the target
  105927. * @param target the target Vector3 to look at
  105928. * @param options optional settings:
  105929. * * maxYaw: the maximum angle the bone will yaw to
  105930. * * minYaw: the minimum angle the bone will yaw to
  105931. * * maxPitch: the maximum angle the bone will pitch to
  105932. * * minPitch: the minimum angle the bone will yaw to
  105933. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105934. * * upAxis: the up axis of the coordinate system
  105935. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105936. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105937. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105938. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105939. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105940. * * adjustRoll: used to make an adjustment to the roll of the bone
  105941. **/
  105942. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105943. maxYaw?: number;
  105944. minYaw?: number;
  105945. maxPitch?: number;
  105946. minPitch?: number;
  105947. slerpAmount?: number;
  105948. upAxis?: Vector3;
  105949. upAxisSpace?: Space;
  105950. yawAxis?: Vector3;
  105951. pitchAxis?: Vector3;
  105952. adjustYaw?: number;
  105953. adjustPitch?: number;
  105954. adjustRoll?: number;
  105955. });
  105956. /**
  105957. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105958. */
  105959. update(): void;
  105960. private _getAngleDiff;
  105961. private _getAngleBetween;
  105962. private _isAngleBetween;
  105963. }
  105964. }
  105965. declare module BABYLON {
  105966. /**
  105967. * Manage the gamepad inputs to control an arc rotate camera.
  105968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105969. */
  105970. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105971. /**
  105972. * Defines the camera the input is attached to.
  105973. */
  105974. camera: ArcRotateCamera;
  105975. /**
  105976. * Defines the gamepad the input is gathering event from.
  105977. */
  105978. gamepad: Nullable<Gamepad>;
  105979. /**
  105980. * Defines the gamepad rotation sensiblity.
  105981. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105982. */
  105983. gamepadRotationSensibility: number;
  105984. /**
  105985. * Defines the gamepad move sensiblity.
  105986. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105987. */
  105988. gamepadMoveSensibility: number;
  105989. private _yAxisScale;
  105990. /**
  105991. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105992. */
  105993. invertYAxis: boolean;
  105994. private _onGamepadConnectedObserver;
  105995. private _onGamepadDisconnectedObserver;
  105996. /**
  105997. * Attach the input controls to a specific dom element to get the input from.
  105998. * @param element Defines the element the controls should be listened from
  105999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106000. */
  106001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106002. /**
  106003. * Detach the current controls from the specified dom element.
  106004. * @param element Defines the element to stop listening the inputs from
  106005. */
  106006. detachControl(element: Nullable<HTMLElement>): void;
  106007. /**
  106008. * Update the current camera state depending on the inputs that have been used this frame.
  106009. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106010. */
  106011. checkInputs(): void;
  106012. /**
  106013. * Gets the class name of the current intput.
  106014. * @returns the class name
  106015. */
  106016. getClassName(): string;
  106017. /**
  106018. * Get the friendly name associated with the input class.
  106019. * @returns the input friendly name
  106020. */
  106021. getSimpleName(): string;
  106022. }
  106023. }
  106024. declare module BABYLON {
  106025. interface ArcRotateCameraInputsManager {
  106026. /**
  106027. * Add orientation input support to the input manager.
  106028. * @returns the current input manager
  106029. */
  106030. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106031. }
  106032. /**
  106033. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106035. */
  106036. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106037. /**
  106038. * Defines the camera the input is attached to.
  106039. */
  106040. camera: ArcRotateCamera;
  106041. /**
  106042. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106043. */
  106044. alphaCorrection: number;
  106045. /**
  106046. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106047. */
  106048. gammaCorrection: number;
  106049. private _alpha;
  106050. private _gamma;
  106051. private _dirty;
  106052. private _deviceOrientationHandler;
  106053. /**
  106054. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106055. */
  106056. constructor();
  106057. /**
  106058. * Attach the input controls to a specific dom element to get the input from.
  106059. * @param element Defines the element the controls should be listened from
  106060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106061. */
  106062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106063. /** @hidden */
  106064. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106065. /**
  106066. * Update the current camera state depending on the inputs that have been used this frame.
  106067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106068. */
  106069. checkInputs(): void;
  106070. /**
  106071. * Detach the current controls from the specified dom element.
  106072. * @param element Defines the element to stop listening the inputs from
  106073. */
  106074. detachControl(element: Nullable<HTMLElement>): void;
  106075. /**
  106076. * Gets the class name of the current intput.
  106077. * @returns the class name
  106078. */
  106079. getClassName(): string;
  106080. /**
  106081. * Get the friendly name associated with the input class.
  106082. * @returns the input friendly name
  106083. */
  106084. getSimpleName(): string;
  106085. }
  106086. }
  106087. declare module BABYLON {
  106088. /**
  106089. * Listen to mouse events to control the camera.
  106090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106091. */
  106092. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106093. /**
  106094. * Defines the camera the input is attached to.
  106095. */
  106096. camera: FlyCamera;
  106097. /**
  106098. * Defines if touch is enabled. (Default is true.)
  106099. */
  106100. touchEnabled: boolean;
  106101. /**
  106102. * Defines the buttons associated with the input to handle camera rotation.
  106103. */
  106104. buttons: number[];
  106105. /**
  106106. * Assign buttons for Yaw control.
  106107. */
  106108. buttonsYaw: number[];
  106109. /**
  106110. * Assign buttons for Pitch control.
  106111. */
  106112. buttonsPitch: number[];
  106113. /**
  106114. * Assign buttons for Roll control.
  106115. */
  106116. buttonsRoll: number[];
  106117. /**
  106118. * Detect if any button is being pressed while mouse is moved.
  106119. * -1 = Mouse locked.
  106120. * 0 = Left button.
  106121. * 1 = Middle Button.
  106122. * 2 = Right Button.
  106123. */
  106124. activeButton: number;
  106125. /**
  106126. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106127. * Higher values reduce its sensitivity.
  106128. */
  106129. angularSensibility: number;
  106130. private _mousemoveCallback;
  106131. private _observer;
  106132. private _rollObserver;
  106133. private previousPosition;
  106134. private noPreventDefault;
  106135. private element;
  106136. /**
  106137. * Listen to mouse events to control the camera.
  106138. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106140. */
  106141. constructor(touchEnabled?: boolean);
  106142. /**
  106143. * Attach the mouse control to the HTML DOM element.
  106144. * @param element Defines the element that listens to the input events.
  106145. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106146. */
  106147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106148. /**
  106149. * Detach the current controls from the specified dom element.
  106150. * @param element Defines the element to stop listening the inputs from
  106151. */
  106152. detachControl(element: Nullable<HTMLElement>): void;
  106153. /**
  106154. * Gets the class name of the current input.
  106155. * @returns the class name.
  106156. */
  106157. getClassName(): string;
  106158. /**
  106159. * Get the friendly name associated with the input class.
  106160. * @returns the input's friendly name.
  106161. */
  106162. getSimpleName(): string;
  106163. private _pointerInput;
  106164. private _onMouseMove;
  106165. /**
  106166. * Rotate camera by mouse offset.
  106167. */
  106168. private rotateCamera;
  106169. }
  106170. }
  106171. declare module BABYLON {
  106172. /**
  106173. * Default Inputs manager for the FlyCamera.
  106174. * It groups all the default supported inputs for ease of use.
  106175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106176. */
  106177. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106178. /**
  106179. * Instantiates a new FlyCameraInputsManager.
  106180. * @param camera Defines the camera the inputs belong to.
  106181. */
  106182. constructor(camera: FlyCamera);
  106183. /**
  106184. * Add keyboard input support to the input manager.
  106185. * @returns the new FlyCameraKeyboardMoveInput().
  106186. */
  106187. addKeyboard(): FlyCameraInputsManager;
  106188. /**
  106189. * Add mouse input support to the input manager.
  106190. * @param touchEnabled Enable touch screen support.
  106191. * @returns the new FlyCameraMouseInput().
  106192. */
  106193. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106194. }
  106195. }
  106196. declare module BABYLON {
  106197. /**
  106198. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106199. * such as in a 3D Space Shooter or a Flight Simulator.
  106200. */
  106201. export class FlyCamera extends TargetCamera {
  106202. /**
  106203. * Define the collision ellipsoid of the camera.
  106204. * This is helpful for simulating a camera body, like a player's body.
  106205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106206. */
  106207. ellipsoid: Vector3;
  106208. /**
  106209. * Define an offset for the position of the ellipsoid around the camera.
  106210. * This can be helpful if the camera is attached away from the player's body center,
  106211. * such as at its head.
  106212. */
  106213. ellipsoidOffset: Vector3;
  106214. /**
  106215. * Enable or disable collisions of the camera with the rest of the scene objects.
  106216. */
  106217. checkCollisions: boolean;
  106218. /**
  106219. * Enable or disable gravity on the camera.
  106220. */
  106221. applyGravity: boolean;
  106222. /**
  106223. * Define the current direction the camera is moving to.
  106224. */
  106225. cameraDirection: Vector3;
  106226. /**
  106227. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106228. * This overrides and empties cameraRotation.
  106229. */
  106230. rotationQuaternion: Quaternion;
  106231. /**
  106232. * Track Roll to maintain the wanted Rolling when looking around.
  106233. */
  106234. _trackRoll: number;
  106235. /**
  106236. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106237. */
  106238. rollCorrect: number;
  106239. /**
  106240. * Mimic a banked turn, Rolling the camera when Yawing.
  106241. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106242. */
  106243. bankedTurn: boolean;
  106244. /**
  106245. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106246. */
  106247. bankedTurnLimit: number;
  106248. /**
  106249. * Value of 0 disables the banked Roll.
  106250. * Value of 1 is equal to the Yaw angle in radians.
  106251. */
  106252. bankedTurnMultiplier: number;
  106253. /**
  106254. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106255. */
  106256. inputs: FlyCameraInputsManager;
  106257. /**
  106258. * Gets the input sensibility for mouse input.
  106259. * Higher values reduce sensitivity.
  106260. */
  106261. /**
  106262. * Sets the input sensibility for a mouse input.
  106263. * Higher values reduce sensitivity.
  106264. */
  106265. angularSensibility: number;
  106266. /**
  106267. * Get the keys for camera movement forward.
  106268. */
  106269. /**
  106270. * Set the keys for camera movement forward.
  106271. */
  106272. keysForward: number[];
  106273. /**
  106274. * Get the keys for camera movement backward.
  106275. */
  106276. keysBackward: number[];
  106277. /**
  106278. * Get the keys for camera movement up.
  106279. */
  106280. /**
  106281. * Set the keys for camera movement up.
  106282. */
  106283. keysUp: number[];
  106284. /**
  106285. * Get the keys for camera movement down.
  106286. */
  106287. /**
  106288. * Set the keys for camera movement down.
  106289. */
  106290. keysDown: number[];
  106291. /**
  106292. * Get the keys for camera movement left.
  106293. */
  106294. /**
  106295. * Set the keys for camera movement left.
  106296. */
  106297. keysLeft: number[];
  106298. /**
  106299. * Set the keys for camera movement right.
  106300. */
  106301. /**
  106302. * Set the keys for camera movement right.
  106303. */
  106304. keysRight: number[];
  106305. /**
  106306. * Event raised when the camera collides with a mesh in the scene.
  106307. */
  106308. onCollide: (collidedMesh: AbstractMesh) => void;
  106309. private _collider;
  106310. private _needMoveForGravity;
  106311. private _oldPosition;
  106312. private _diffPosition;
  106313. private _newPosition;
  106314. /** @hidden */
  106315. _localDirection: Vector3;
  106316. /** @hidden */
  106317. _transformedDirection: Vector3;
  106318. /**
  106319. * Instantiates a FlyCamera.
  106320. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106321. * such as in a 3D Space Shooter or a Flight Simulator.
  106322. * @param name Define the name of the camera in the scene.
  106323. * @param position Define the starting position of the camera in the scene.
  106324. * @param scene Define the scene the camera belongs to.
  106325. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106326. */
  106327. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106328. /**
  106329. * Attach a control to the HTML DOM element.
  106330. * @param element Defines the element that listens to the input events.
  106331. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106332. */
  106333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106334. /**
  106335. * Detach a control from the HTML DOM element.
  106336. * The camera will stop reacting to that input.
  106337. * @param element Defines the element that listens to the input events.
  106338. */
  106339. detachControl(element: HTMLElement): void;
  106340. private _collisionMask;
  106341. /**
  106342. * Get the mask that the camera ignores in collision events.
  106343. */
  106344. /**
  106345. * Set the mask that the camera ignores in collision events.
  106346. */
  106347. collisionMask: number;
  106348. /** @hidden */
  106349. _collideWithWorld(displacement: Vector3): void;
  106350. /** @hidden */
  106351. private _onCollisionPositionChange;
  106352. /** @hidden */
  106353. _checkInputs(): void;
  106354. /** @hidden */
  106355. _decideIfNeedsToMove(): boolean;
  106356. /** @hidden */
  106357. _updatePosition(): void;
  106358. /**
  106359. * Restore the Roll to its target value at the rate specified.
  106360. * @param rate - Higher means slower restoring.
  106361. * @hidden
  106362. */
  106363. restoreRoll(rate: number): void;
  106364. /**
  106365. * Destroy the camera and release the current resources held by it.
  106366. */
  106367. dispose(): void;
  106368. /**
  106369. * Get the current object class name.
  106370. * @returns the class name.
  106371. */
  106372. getClassName(): string;
  106373. }
  106374. }
  106375. declare module BABYLON {
  106376. /**
  106377. * Listen to keyboard events to control the camera.
  106378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106379. */
  106380. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106381. /**
  106382. * Defines the camera the input is attached to.
  106383. */
  106384. camera: FlyCamera;
  106385. /**
  106386. * The list of keyboard keys used to control the forward move of the camera.
  106387. */
  106388. keysForward: number[];
  106389. /**
  106390. * The list of keyboard keys used to control the backward move of the camera.
  106391. */
  106392. keysBackward: number[];
  106393. /**
  106394. * The list of keyboard keys used to control the forward move of the camera.
  106395. */
  106396. keysUp: number[];
  106397. /**
  106398. * The list of keyboard keys used to control the backward move of the camera.
  106399. */
  106400. keysDown: number[];
  106401. /**
  106402. * The list of keyboard keys used to control the right strafe move of the camera.
  106403. */
  106404. keysRight: number[];
  106405. /**
  106406. * The list of keyboard keys used to control the left strafe move of the camera.
  106407. */
  106408. keysLeft: number[];
  106409. private _keys;
  106410. private _onCanvasBlurObserver;
  106411. private _onKeyboardObserver;
  106412. private _engine;
  106413. private _scene;
  106414. /**
  106415. * Attach the input controls to a specific dom element to get the input from.
  106416. * @param element Defines the element the controls should be listened from
  106417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106418. */
  106419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106420. /**
  106421. * Detach the current controls from the specified dom element.
  106422. * @param element Defines the element to stop listening the inputs from
  106423. */
  106424. detachControl(element: Nullable<HTMLElement>): void;
  106425. /**
  106426. * Gets the class name of the current intput.
  106427. * @returns the class name
  106428. */
  106429. getClassName(): string;
  106430. /** @hidden */
  106431. _onLostFocus(e: FocusEvent): void;
  106432. /**
  106433. * Get the friendly name associated with the input class.
  106434. * @returns the input friendly name
  106435. */
  106436. getSimpleName(): string;
  106437. /**
  106438. * Update the current camera state depending on the inputs that have been used this frame.
  106439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106440. */
  106441. checkInputs(): void;
  106442. }
  106443. }
  106444. declare module BABYLON {
  106445. /**
  106446. * Manage the mouse wheel inputs to control a follow camera.
  106447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106448. */
  106449. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106450. /**
  106451. * Defines the camera the input is attached to.
  106452. */
  106453. camera: FollowCamera;
  106454. /**
  106455. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106456. */
  106457. axisControlRadius: boolean;
  106458. /**
  106459. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106460. */
  106461. axisControlHeight: boolean;
  106462. /**
  106463. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106464. */
  106465. axisControlRotation: boolean;
  106466. /**
  106467. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106468. * relation to mouseWheel events.
  106469. */
  106470. wheelPrecision: number;
  106471. /**
  106472. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106473. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106474. */
  106475. wheelDeltaPercentage: number;
  106476. private _wheel;
  106477. private _observer;
  106478. /**
  106479. * Attach the input controls to a specific dom element to get the input from.
  106480. * @param element Defines the element the controls should be listened from
  106481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106482. */
  106483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106484. /**
  106485. * Detach the current controls from the specified dom element.
  106486. * @param element Defines the element to stop listening the inputs from
  106487. */
  106488. detachControl(element: Nullable<HTMLElement>): void;
  106489. /**
  106490. * Gets the class name of the current intput.
  106491. * @returns the class name
  106492. */
  106493. getClassName(): string;
  106494. /**
  106495. * Get the friendly name associated with the input class.
  106496. * @returns the input friendly name
  106497. */
  106498. getSimpleName(): string;
  106499. }
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * Manage the pointers inputs to control an follow camera.
  106504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106505. */
  106506. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106507. /**
  106508. * Defines the camera the input is attached to.
  106509. */
  106510. camera: FollowCamera;
  106511. /**
  106512. * Gets the class name of the current input.
  106513. * @returns the class name
  106514. */
  106515. getClassName(): string;
  106516. /**
  106517. * Defines the pointer angular sensibility along the X axis or how fast is
  106518. * the camera rotating.
  106519. * A negative number will reverse the axis direction.
  106520. */
  106521. angularSensibilityX: number;
  106522. /**
  106523. * Defines the pointer angular sensibility along the Y axis or how fast is
  106524. * the camera rotating.
  106525. * A negative number will reverse the axis direction.
  106526. */
  106527. angularSensibilityY: number;
  106528. /**
  106529. * Defines the pointer pinch precision or how fast is the camera zooming.
  106530. * A negative number will reverse the axis direction.
  106531. */
  106532. pinchPrecision: number;
  106533. /**
  106534. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106535. * from 0.
  106536. * It defines the percentage of current camera.radius to use as delta when
  106537. * pinch zoom is used.
  106538. */
  106539. pinchDeltaPercentage: number;
  106540. /**
  106541. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106542. */
  106543. axisXControlRadius: boolean;
  106544. /**
  106545. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106546. */
  106547. axisXControlHeight: boolean;
  106548. /**
  106549. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106550. */
  106551. axisXControlRotation: boolean;
  106552. /**
  106553. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106554. */
  106555. axisYControlRadius: boolean;
  106556. /**
  106557. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106558. */
  106559. axisYControlHeight: boolean;
  106560. /**
  106561. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106562. */
  106563. axisYControlRotation: boolean;
  106564. /**
  106565. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106566. */
  106567. axisPinchControlRadius: boolean;
  106568. /**
  106569. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106570. */
  106571. axisPinchControlHeight: boolean;
  106572. /**
  106573. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106574. */
  106575. axisPinchControlRotation: boolean;
  106576. /**
  106577. * Log error messages if basic misconfiguration has occurred.
  106578. */
  106579. warningEnable: boolean;
  106580. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106581. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106582. private _warningCounter;
  106583. private _warning;
  106584. }
  106585. }
  106586. declare module BABYLON {
  106587. /**
  106588. * Default Inputs manager for the FollowCamera.
  106589. * It groups all the default supported inputs for ease of use.
  106590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106591. */
  106592. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106593. /**
  106594. * Instantiates a new FollowCameraInputsManager.
  106595. * @param camera Defines the camera the inputs belong to
  106596. */
  106597. constructor(camera: FollowCamera);
  106598. /**
  106599. * Add keyboard input support to the input manager.
  106600. * @returns the current input manager
  106601. */
  106602. addKeyboard(): FollowCameraInputsManager;
  106603. /**
  106604. * Add mouse wheel input support to the input manager.
  106605. * @returns the current input manager
  106606. */
  106607. addMouseWheel(): FollowCameraInputsManager;
  106608. /**
  106609. * Add pointers input support to the input manager.
  106610. * @returns the current input manager
  106611. */
  106612. addPointers(): FollowCameraInputsManager;
  106613. /**
  106614. * Add orientation input support to the input manager.
  106615. * @returns the current input manager
  106616. */
  106617. addVRDeviceOrientation(): FollowCameraInputsManager;
  106618. }
  106619. }
  106620. declare module BABYLON {
  106621. /**
  106622. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106623. * an arc rotate version arcFollowCamera are available.
  106624. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106625. */
  106626. export class FollowCamera extends TargetCamera {
  106627. /**
  106628. * Distance the follow camera should follow an object at
  106629. */
  106630. radius: number;
  106631. /**
  106632. * Minimum allowed distance of the camera to the axis of rotation
  106633. * (The camera can not get closer).
  106634. * This can help limiting how the Camera is able to move in the scene.
  106635. */
  106636. lowerRadiusLimit: Nullable<number>;
  106637. /**
  106638. * Maximum allowed distance of the camera to the axis of rotation
  106639. * (The camera can not get further).
  106640. * This can help limiting how the Camera is able to move in the scene.
  106641. */
  106642. upperRadiusLimit: Nullable<number>;
  106643. /**
  106644. * Define a rotation offset between the camera and the object it follows
  106645. */
  106646. rotationOffset: number;
  106647. /**
  106648. * Minimum allowed angle to camera position relative to target object.
  106649. * This can help limiting how the Camera is able to move in the scene.
  106650. */
  106651. lowerRotationOffsetLimit: Nullable<number>;
  106652. /**
  106653. * Maximum allowed angle to camera position relative to target object.
  106654. * This can help limiting how the Camera is able to move in the scene.
  106655. */
  106656. upperRotationOffsetLimit: Nullable<number>;
  106657. /**
  106658. * Define a height offset between the camera and the object it follows.
  106659. * It can help following an object from the top (like a car chaing a plane)
  106660. */
  106661. heightOffset: number;
  106662. /**
  106663. * Minimum allowed height of camera position relative to target object.
  106664. * This can help limiting how the Camera is able to move in the scene.
  106665. */
  106666. lowerHeightOffsetLimit: Nullable<number>;
  106667. /**
  106668. * Maximum allowed height of camera position relative to target object.
  106669. * This can help limiting how the Camera is able to move in the scene.
  106670. */
  106671. upperHeightOffsetLimit: Nullable<number>;
  106672. /**
  106673. * Define how fast the camera can accelerate to follow it s target.
  106674. */
  106675. cameraAcceleration: number;
  106676. /**
  106677. * Define the speed limit of the camera following an object.
  106678. */
  106679. maxCameraSpeed: number;
  106680. /**
  106681. * Define the target of the camera.
  106682. */
  106683. lockedTarget: Nullable<AbstractMesh>;
  106684. /**
  106685. * Defines the input associated with the camera.
  106686. */
  106687. inputs: FollowCameraInputsManager;
  106688. /**
  106689. * Instantiates the follow camera.
  106690. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106691. * @param name Define the name of the camera in the scene
  106692. * @param position Define the position of the camera
  106693. * @param scene Define the scene the camera belong to
  106694. * @param lockedTarget Define the target of the camera
  106695. */
  106696. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106697. private _follow;
  106698. /**
  106699. * Attached controls to the current camera.
  106700. * @param element Defines the element the controls should be listened from
  106701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106702. */
  106703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106704. /**
  106705. * Detach the current controls from the camera.
  106706. * The camera will stop reacting to inputs.
  106707. * @param element Defines the element to stop listening the inputs from
  106708. */
  106709. detachControl(element: HTMLElement): void;
  106710. /** @hidden */
  106711. _checkInputs(): void;
  106712. private _checkLimits;
  106713. /**
  106714. * Gets the camera class name.
  106715. * @returns the class name
  106716. */
  106717. getClassName(): string;
  106718. }
  106719. /**
  106720. * Arc Rotate version of the follow camera.
  106721. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  106722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106723. */
  106724. export class ArcFollowCamera extends TargetCamera {
  106725. /** The longitudinal angle of the camera */
  106726. alpha: number;
  106727. /** The latitudinal angle of the camera */
  106728. beta: number;
  106729. /** The radius of the camera from its target */
  106730. radius: number;
  106731. /** Define the camera target (the messh it should follow) */
  106732. target: Nullable<AbstractMesh>;
  106733. private _cartesianCoordinates;
  106734. /**
  106735. * Instantiates a new ArcFollowCamera
  106736. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106737. * @param name Define the name of the camera
  106738. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  106739. * @param beta Define the rotation angle of the camera around the elevation axis
  106740. * @param radius Define the radius of the camera from its target point
  106741. * @param target Define the target of the camera
  106742. * @param scene Define the scene the camera belongs to
  106743. */
  106744. constructor(name: string,
  106745. /** The longitudinal angle of the camera */
  106746. alpha: number,
  106747. /** The latitudinal angle of the camera */
  106748. beta: number,
  106749. /** The radius of the camera from its target */
  106750. radius: number,
  106751. /** Define the camera target (the messh it should follow) */
  106752. target: Nullable<AbstractMesh>, scene: Scene);
  106753. private _follow;
  106754. /** @hidden */
  106755. _checkInputs(): void;
  106756. /**
  106757. * Returns the class name of the object.
  106758. * It is mostly used internally for serialization purposes.
  106759. */
  106760. getClassName(): string;
  106761. }
  106762. }
  106763. declare module BABYLON {
  106764. /**
  106765. * Manage the keyboard inputs to control the movement of a follow camera.
  106766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106767. */
  106768. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  106769. /**
  106770. * Defines the camera the input is attached to.
  106771. */
  106772. camera: FollowCamera;
  106773. /**
  106774. * Defines the list of key codes associated with the up action (increase heightOffset)
  106775. */
  106776. keysHeightOffsetIncr: number[];
  106777. /**
  106778. * Defines the list of key codes associated with the down action (decrease heightOffset)
  106779. */
  106780. keysHeightOffsetDecr: number[];
  106781. /**
  106782. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  106783. */
  106784. keysHeightOffsetModifierAlt: boolean;
  106785. /**
  106786. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  106787. */
  106788. keysHeightOffsetModifierCtrl: boolean;
  106789. /**
  106790. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  106791. */
  106792. keysHeightOffsetModifierShift: boolean;
  106793. /**
  106794. * Defines the list of key codes associated with the left action (increase rotationOffset)
  106795. */
  106796. keysRotationOffsetIncr: number[];
  106797. /**
  106798. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106799. */
  106800. keysRotationOffsetDecr: number[];
  106801. /**
  106802. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106803. */
  106804. keysRotationOffsetModifierAlt: boolean;
  106805. /**
  106806. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106807. */
  106808. keysRotationOffsetModifierCtrl: boolean;
  106809. /**
  106810. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106811. */
  106812. keysRotationOffsetModifierShift: boolean;
  106813. /**
  106814. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106815. */
  106816. keysRadiusIncr: number[];
  106817. /**
  106818. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106819. */
  106820. keysRadiusDecr: number[];
  106821. /**
  106822. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106823. */
  106824. keysRadiusModifierAlt: boolean;
  106825. /**
  106826. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106827. */
  106828. keysRadiusModifierCtrl: boolean;
  106829. /**
  106830. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106831. */
  106832. keysRadiusModifierShift: boolean;
  106833. /**
  106834. * Defines the rate of change of heightOffset.
  106835. */
  106836. heightSensibility: number;
  106837. /**
  106838. * Defines the rate of change of rotationOffset.
  106839. */
  106840. rotationSensibility: number;
  106841. /**
  106842. * Defines the rate of change of radius.
  106843. */
  106844. radiusSensibility: number;
  106845. private _keys;
  106846. private _ctrlPressed;
  106847. private _altPressed;
  106848. private _shiftPressed;
  106849. private _onCanvasBlurObserver;
  106850. private _onKeyboardObserver;
  106851. private _engine;
  106852. private _scene;
  106853. /**
  106854. * Attach the input controls to a specific dom element to get the input from.
  106855. * @param element Defines the element the controls should be listened from
  106856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106857. */
  106858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106859. /**
  106860. * Detach the current controls from the specified dom element.
  106861. * @param element Defines the element to stop listening the inputs from
  106862. */
  106863. detachControl(element: Nullable<HTMLElement>): void;
  106864. /**
  106865. * Update the current camera state depending on the inputs that have been used this frame.
  106866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106867. */
  106868. checkInputs(): void;
  106869. /**
  106870. * Gets the class name of the current input.
  106871. * @returns the class name
  106872. */
  106873. getClassName(): string;
  106874. /**
  106875. * Get the friendly name associated with the input class.
  106876. * @returns the input friendly name
  106877. */
  106878. getSimpleName(): string;
  106879. /**
  106880. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106881. * allow modification of the heightOffset value.
  106882. */
  106883. private _modifierHeightOffset;
  106884. /**
  106885. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106886. * allow modification of the rotationOffset value.
  106887. */
  106888. private _modifierRotationOffset;
  106889. /**
  106890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106891. * allow modification of the radius value.
  106892. */
  106893. private _modifierRadius;
  106894. }
  106895. }
  106896. declare module BABYLON {
  106897. interface FreeCameraInputsManager {
  106898. /**
  106899. * @hidden
  106900. */
  106901. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106902. /**
  106903. * Add orientation input support to the input manager.
  106904. * @returns the current input manager
  106905. */
  106906. addDeviceOrientation(): FreeCameraInputsManager;
  106907. }
  106908. /**
  106909. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106910. * Screen rotation is taken into account.
  106911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106912. */
  106913. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106914. private _camera;
  106915. private _screenOrientationAngle;
  106916. private _constantTranform;
  106917. private _screenQuaternion;
  106918. private _alpha;
  106919. private _beta;
  106920. private _gamma;
  106921. /**
  106922. * Can be used to detect if a device orientation sensor is availible on a device
  106923. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106924. * @returns a promise that will resolve on orientation change
  106925. */
  106926. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106927. /**
  106928. * @hidden
  106929. */
  106930. _onDeviceOrientationChangedObservable: Observable<void>;
  106931. /**
  106932. * Instantiates a new input
  106933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106934. */
  106935. constructor();
  106936. /**
  106937. * Define the camera controlled by the input.
  106938. */
  106939. camera: FreeCamera;
  106940. /**
  106941. * Attach the input controls to a specific dom element to get the input from.
  106942. * @param element Defines the element the controls should be listened from
  106943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106944. */
  106945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106946. private _orientationChanged;
  106947. private _deviceOrientation;
  106948. /**
  106949. * Detach the current controls from the specified dom element.
  106950. * @param element Defines the element to stop listening the inputs from
  106951. */
  106952. detachControl(element: Nullable<HTMLElement>): void;
  106953. /**
  106954. * Update the current camera state depending on the inputs that have been used this frame.
  106955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106956. */
  106957. checkInputs(): void;
  106958. /**
  106959. * Gets the class name of the current intput.
  106960. * @returns the class name
  106961. */
  106962. getClassName(): string;
  106963. /**
  106964. * Get the friendly name associated with the input class.
  106965. * @returns the input friendly name
  106966. */
  106967. getSimpleName(): string;
  106968. }
  106969. }
  106970. declare module BABYLON {
  106971. /**
  106972. * Manage the gamepad inputs to control a free camera.
  106973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106974. */
  106975. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106976. /**
  106977. * Define the camera the input is attached to.
  106978. */
  106979. camera: FreeCamera;
  106980. /**
  106981. * Define the Gamepad controlling the input
  106982. */
  106983. gamepad: Nullable<Gamepad>;
  106984. /**
  106985. * Defines the gamepad rotation sensiblity.
  106986. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106987. */
  106988. gamepadAngularSensibility: number;
  106989. /**
  106990. * Defines the gamepad move sensiblity.
  106991. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106992. */
  106993. gamepadMoveSensibility: number;
  106994. private _yAxisScale;
  106995. /**
  106996. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106997. */
  106998. invertYAxis: boolean;
  106999. private _onGamepadConnectedObserver;
  107000. private _onGamepadDisconnectedObserver;
  107001. private _cameraTransform;
  107002. private _deltaTransform;
  107003. private _vector3;
  107004. private _vector2;
  107005. /**
  107006. * Attach the input controls to a specific dom element to get the input from.
  107007. * @param element Defines the element the controls should be listened from
  107008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107009. */
  107010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107011. /**
  107012. * Detach the current controls from the specified dom element.
  107013. * @param element Defines the element to stop listening the inputs from
  107014. */
  107015. detachControl(element: Nullable<HTMLElement>): void;
  107016. /**
  107017. * Update the current camera state depending on the inputs that have been used this frame.
  107018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107019. */
  107020. checkInputs(): void;
  107021. /**
  107022. * Gets the class name of the current intput.
  107023. * @returns the class name
  107024. */
  107025. getClassName(): string;
  107026. /**
  107027. * Get the friendly name associated with the input class.
  107028. * @returns the input friendly name
  107029. */
  107030. getSimpleName(): string;
  107031. }
  107032. }
  107033. declare module BABYLON {
  107034. /**
  107035. * Defines the potential axis of a Joystick
  107036. */
  107037. export enum JoystickAxis {
  107038. /** X axis */
  107039. X = 0,
  107040. /** Y axis */
  107041. Y = 1,
  107042. /** Z axis */
  107043. Z = 2
  107044. }
  107045. /**
  107046. * Class used to define virtual joystick (used in touch mode)
  107047. */
  107048. export class VirtualJoystick {
  107049. /**
  107050. * Gets or sets a boolean indicating that left and right values must be inverted
  107051. */
  107052. reverseLeftRight: boolean;
  107053. /**
  107054. * Gets or sets a boolean indicating that up and down values must be inverted
  107055. */
  107056. reverseUpDown: boolean;
  107057. /**
  107058. * Gets the offset value for the position (ie. the change of the position value)
  107059. */
  107060. deltaPosition: Vector3;
  107061. /**
  107062. * Gets a boolean indicating if the virtual joystick was pressed
  107063. */
  107064. pressed: boolean;
  107065. /**
  107066. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107067. */
  107068. static Canvas: Nullable<HTMLCanvasElement>;
  107069. private static _globalJoystickIndex;
  107070. private static vjCanvasContext;
  107071. private static vjCanvasWidth;
  107072. private static vjCanvasHeight;
  107073. private static halfWidth;
  107074. private _action;
  107075. private _axisTargetedByLeftAndRight;
  107076. private _axisTargetedByUpAndDown;
  107077. private _joystickSensibility;
  107078. private _inversedSensibility;
  107079. private _joystickPointerID;
  107080. private _joystickColor;
  107081. private _joystickPointerPos;
  107082. private _joystickPreviousPointerPos;
  107083. private _joystickPointerStartPos;
  107084. private _deltaJoystickVector;
  107085. private _leftJoystick;
  107086. private _touches;
  107087. private _onPointerDownHandlerRef;
  107088. private _onPointerMoveHandlerRef;
  107089. private _onPointerUpHandlerRef;
  107090. private _onResize;
  107091. /**
  107092. * Creates a new virtual joystick
  107093. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107094. */
  107095. constructor(leftJoystick?: boolean);
  107096. /**
  107097. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107098. * @param newJoystickSensibility defines the new sensibility
  107099. */
  107100. setJoystickSensibility(newJoystickSensibility: number): void;
  107101. private _onPointerDown;
  107102. private _onPointerMove;
  107103. private _onPointerUp;
  107104. /**
  107105. * Change the color of the virtual joystick
  107106. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107107. */
  107108. setJoystickColor(newColor: string): void;
  107109. /**
  107110. * Defines a callback to call when the joystick is touched
  107111. * @param action defines the callback
  107112. */
  107113. setActionOnTouch(action: () => any): void;
  107114. /**
  107115. * Defines which axis you'd like to control for left & right
  107116. * @param axis defines the axis to use
  107117. */
  107118. setAxisForLeftRight(axis: JoystickAxis): void;
  107119. /**
  107120. * Defines which axis you'd like to control for up & down
  107121. * @param axis defines the axis to use
  107122. */
  107123. setAxisForUpDown(axis: JoystickAxis): void;
  107124. private _drawVirtualJoystick;
  107125. /**
  107126. * Release internal HTML canvas
  107127. */
  107128. releaseCanvas(): void;
  107129. }
  107130. }
  107131. declare module BABYLON {
  107132. interface FreeCameraInputsManager {
  107133. /**
  107134. * Add virtual joystick input support to the input manager.
  107135. * @returns the current input manager
  107136. */
  107137. addVirtualJoystick(): FreeCameraInputsManager;
  107138. }
  107139. /**
  107140. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107142. */
  107143. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107144. /**
  107145. * Defines the camera the input is attached to.
  107146. */
  107147. camera: FreeCamera;
  107148. private _leftjoystick;
  107149. private _rightjoystick;
  107150. /**
  107151. * Gets the left stick of the virtual joystick.
  107152. * @returns The virtual Joystick
  107153. */
  107154. getLeftJoystick(): VirtualJoystick;
  107155. /**
  107156. * Gets the right stick of the virtual joystick.
  107157. * @returns The virtual Joystick
  107158. */
  107159. getRightJoystick(): VirtualJoystick;
  107160. /**
  107161. * Update the current camera state depending on the inputs that have been used this frame.
  107162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107163. */
  107164. checkInputs(): void;
  107165. /**
  107166. * Attach the input controls to a specific dom element to get the input from.
  107167. * @param element Defines the element the controls should be listened from
  107168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107169. */
  107170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107171. /**
  107172. * Detach the current controls from the specified dom element.
  107173. * @param element Defines the element to stop listening the inputs from
  107174. */
  107175. detachControl(element: Nullable<HTMLElement>): void;
  107176. /**
  107177. * Gets the class name of the current intput.
  107178. * @returns the class name
  107179. */
  107180. getClassName(): string;
  107181. /**
  107182. * Get the friendly name associated with the input class.
  107183. * @returns the input friendly name
  107184. */
  107185. getSimpleName(): string;
  107186. }
  107187. }
  107188. declare module BABYLON {
  107189. /**
  107190. * This represents a FPS type of camera controlled by touch.
  107191. * This is like a universal camera minus the Gamepad controls.
  107192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107193. */
  107194. export class TouchCamera extends FreeCamera {
  107195. /**
  107196. * Defines the touch sensibility for rotation.
  107197. * The higher the faster.
  107198. */
  107199. touchAngularSensibility: number;
  107200. /**
  107201. * Defines the touch sensibility for move.
  107202. * The higher the faster.
  107203. */
  107204. touchMoveSensibility: number;
  107205. /**
  107206. * Instantiates a new touch camera.
  107207. * This represents a FPS type of camera controlled by touch.
  107208. * This is like a universal camera minus the Gamepad controls.
  107209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107210. * @param name Define the name of the camera in the scene
  107211. * @param position Define the start position of the camera in the scene
  107212. * @param scene Define the scene the camera belongs to
  107213. */
  107214. constructor(name: string, position: Vector3, scene: Scene);
  107215. /**
  107216. * Gets the current object class name.
  107217. * @return the class name
  107218. */
  107219. getClassName(): string;
  107220. /** @hidden */
  107221. _setupInputs(): void;
  107222. }
  107223. }
  107224. declare module BABYLON {
  107225. /**
  107226. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107227. * being tilted forward or back and left or right.
  107228. */
  107229. export class DeviceOrientationCamera extends FreeCamera {
  107230. private _initialQuaternion;
  107231. private _quaternionCache;
  107232. private _tmpDragQuaternion;
  107233. private _disablePointerInputWhenUsingDeviceOrientation;
  107234. /**
  107235. * Creates a new device orientation camera
  107236. * @param name The name of the camera
  107237. * @param position The start position camera
  107238. * @param scene The scene the camera belongs to
  107239. */
  107240. constructor(name: string, position: Vector3, scene: Scene);
  107241. /**
  107242. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107243. */
  107244. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107245. private _dragFactor;
  107246. /**
  107247. * Enabled turning on the y axis when the orientation sensor is active
  107248. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107249. */
  107250. enableHorizontalDragging(dragFactor?: number): void;
  107251. /**
  107252. * Gets the current instance class name ("DeviceOrientationCamera").
  107253. * This helps avoiding instanceof at run time.
  107254. * @returns the class name
  107255. */
  107256. getClassName(): string;
  107257. /**
  107258. * @hidden
  107259. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107260. */
  107261. _checkInputs(): void;
  107262. /**
  107263. * Reset the camera to its default orientation on the specified axis only.
  107264. * @param axis The axis to reset
  107265. */
  107266. resetToCurrentRotation(axis?: Axis): void;
  107267. }
  107268. }
  107269. declare module BABYLON {
  107270. /**
  107271. * Defines supported buttons for XBox360 compatible gamepads
  107272. */
  107273. export enum Xbox360Button {
  107274. /** A */
  107275. A = 0,
  107276. /** B */
  107277. B = 1,
  107278. /** X */
  107279. X = 2,
  107280. /** Y */
  107281. Y = 3,
  107282. /** Start */
  107283. Start = 4,
  107284. /** Back */
  107285. Back = 5,
  107286. /** Left button */
  107287. LB = 6,
  107288. /** Right button */
  107289. RB = 7,
  107290. /** Left stick */
  107291. LeftStick = 8,
  107292. /** Right stick */
  107293. RightStick = 9
  107294. }
  107295. /** Defines values for XBox360 DPad */
  107296. export enum Xbox360Dpad {
  107297. /** Up */
  107298. Up = 0,
  107299. /** Down */
  107300. Down = 1,
  107301. /** Left */
  107302. Left = 2,
  107303. /** Right */
  107304. Right = 3
  107305. }
  107306. /**
  107307. * Defines a XBox360 gamepad
  107308. */
  107309. export class Xbox360Pad extends Gamepad {
  107310. private _leftTrigger;
  107311. private _rightTrigger;
  107312. private _onlefttriggerchanged;
  107313. private _onrighttriggerchanged;
  107314. private _onbuttondown;
  107315. private _onbuttonup;
  107316. private _ondpaddown;
  107317. private _ondpadup;
  107318. /** Observable raised when a button is pressed */
  107319. onButtonDownObservable: Observable<Xbox360Button>;
  107320. /** Observable raised when a button is released */
  107321. onButtonUpObservable: Observable<Xbox360Button>;
  107322. /** Observable raised when a pad is pressed */
  107323. onPadDownObservable: Observable<Xbox360Dpad>;
  107324. /** Observable raised when a pad is released */
  107325. onPadUpObservable: Observable<Xbox360Dpad>;
  107326. private _buttonA;
  107327. private _buttonB;
  107328. private _buttonX;
  107329. private _buttonY;
  107330. private _buttonBack;
  107331. private _buttonStart;
  107332. private _buttonLB;
  107333. private _buttonRB;
  107334. private _buttonLeftStick;
  107335. private _buttonRightStick;
  107336. private _dPadUp;
  107337. private _dPadDown;
  107338. private _dPadLeft;
  107339. private _dPadRight;
  107340. private _isXboxOnePad;
  107341. /**
  107342. * Creates a new XBox360 gamepad object
  107343. * @param id defines the id of this gamepad
  107344. * @param index defines its index
  107345. * @param gamepad defines the internal HTML gamepad object
  107346. * @param xboxOne defines if it is a XBox One gamepad
  107347. */
  107348. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107349. /**
  107350. * Defines the callback to call when left trigger is pressed
  107351. * @param callback defines the callback to use
  107352. */
  107353. onlefttriggerchanged(callback: (value: number) => void): void;
  107354. /**
  107355. * Defines the callback to call when right trigger is pressed
  107356. * @param callback defines the callback to use
  107357. */
  107358. onrighttriggerchanged(callback: (value: number) => void): void;
  107359. /**
  107360. * Gets the left trigger value
  107361. */
  107362. /**
  107363. * Sets the left trigger value
  107364. */
  107365. leftTrigger: number;
  107366. /**
  107367. * Gets the right trigger value
  107368. */
  107369. /**
  107370. * Sets the right trigger value
  107371. */
  107372. rightTrigger: number;
  107373. /**
  107374. * Defines the callback to call when a button is pressed
  107375. * @param callback defines the callback to use
  107376. */
  107377. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107378. /**
  107379. * Defines the callback to call when a button is released
  107380. * @param callback defines the callback to use
  107381. */
  107382. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107383. /**
  107384. * Defines the callback to call when a pad is pressed
  107385. * @param callback defines the callback to use
  107386. */
  107387. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107388. /**
  107389. * Defines the callback to call when a pad is released
  107390. * @param callback defines the callback to use
  107391. */
  107392. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107393. private _setButtonValue;
  107394. private _setDPadValue;
  107395. /**
  107396. * Gets the value of the `A` button
  107397. */
  107398. /**
  107399. * Sets the value of the `A` button
  107400. */
  107401. buttonA: number;
  107402. /**
  107403. * Gets the value of the `B` button
  107404. */
  107405. /**
  107406. * Sets the value of the `B` button
  107407. */
  107408. buttonB: number;
  107409. /**
  107410. * Gets the value of the `X` button
  107411. */
  107412. /**
  107413. * Sets the value of the `X` button
  107414. */
  107415. buttonX: number;
  107416. /**
  107417. * Gets the value of the `Y` button
  107418. */
  107419. /**
  107420. * Sets the value of the `Y` button
  107421. */
  107422. buttonY: number;
  107423. /**
  107424. * Gets the value of the `Start` button
  107425. */
  107426. /**
  107427. * Sets the value of the `Start` button
  107428. */
  107429. buttonStart: number;
  107430. /**
  107431. * Gets the value of the `Back` button
  107432. */
  107433. /**
  107434. * Sets the value of the `Back` button
  107435. */
  107436. buttonBack: number;
  107437. /**
  107438. * Gets the value of the `Left` button
  107439. */
  107440. /**
  107441. * Sets the value of the `Left` button
  107442. */
  107443. buttonLB: number;
  107444. /**
  107445. * Gets the value of the `Right` button
  107446. */
  107447. /**
  107448. * Sets the value of the `Right` button
  107449. */
  107450. buttonRB: number;
  107451. /**
  107452. * Gets the value of the Left joystick
  107453. */
  107454. /**
  107455. * Sets the value of the Left joystick
  107456. */
  107457. buttonLeftStick: number;
  107458. /**
  107459. * Gets the value of the Right joystick
  107460. */
  107461. /**
  107462. * Sets the value of the Right joystick
  107463. */
  107464. buttonRightStick: number;
  107465. /**
  107466. * Gets the value of D-pad up
  107467. */
  107468. /**
  107469. * Sets the value of D-pad up
  107470. */
  107471. dPadUp: number;
  107472. /**
  107473. * Gets the value of D-pad down
  107474. */
  107475. /**
  107476. * Sets the value of D-pad down
  107477. */
  107478. dPadDown: number;
  107479. /**
  107480. * Gets the value of D-pad left
  107481. */
  107482. /**
  107483. * Sets the value of D-pad left
  107484. */
  107485. dPadLeft: number;
  107486. /**
  107487. * Gets the value of D-pad right
  107488. */
  107489. /**
  107490. * Sets the value of D-pad right
  107491. */
  107492. dPadRight: number;
  107493. /**
  107494. * Force the gamepad to synchronize with device values
  107495. */
  107496. update(): void;
  107497. /**
  107498. * Disposes the gamepad
  107499. */
  107500. dispose(): void;
  107501. }
  107502. }
  107503. declare module BABYLON {
  107504. /**
  107505. * Defines supported buttons for DualShock compatible gamepads
  107506. */
  107507. export enum DualShockButton {
  107508. /** Cross */
  107509. Cross = 0,
  107510. /** Circle */
  107511. Circle = 1,
  107512. /** Square */
  107513. Square = 2,
  107514. /** Triangle */
  107515. Triangle = 3,
  107516. /** Options */
  107517. Options = 4,
  107518. /** Share */
  107519. Share = 5,
  107520. /** L1 */
  107521. L1 = 6,
  107522. /** R1 */
  107523. R1 = 7,
  107524. /** Left stick */
  107525. LeftStick = 8,
  107526. /** Right stick */
  107527. RightStick = 9
  107528. }
  107529. /** Defines values for DualShock DPad */
  107530. export enum DualShockDpad {
  107531. /** Up */
  107532. Up = 0,
  107533. /** Down */
  107534. Down = 1,
  107535. /** Left */
  107536. Left = 2,
  107537. /** Right */
  107538. Right = 3
  107539. }
  107540. /**
  107541. * Defines a DualShock gamepad
  107542. */
  107543. export class DualShockPad extends Gamepad {
  107544. private _leftTrigger;
  107545. private _rightTrigger;
  107546. private _onlefttriggerchanged;
  107547. private _onrighttriggerchanged;
  107548. private _onbuttondown;
  107549. private _onbuttonup;
  107550. private _ondpaddown;
  107551. private _ondpadup;
  107552. /** Observable raised when a button is pressed */
  107553. onButtonDownObservable: Observable<DualShockButton>;
  107554. /** Observable raised when a button is released */
  107555. onButtonUpObservable: Observable<DualShockButton>;
  107556. /** Observable raised when a pad is pressed */
  107557. onPadDownObservable: Observable<DualShockDpad>;
  107558. /** Observable raised when a pad is released */
  107559. onPadUpObservable: Observable<DualShockDpad>;
  107560. private _buttonCross;
  107561. private _buttonCircle;
  107562. private _buttonSquare;
  107563. private _buttonTriangle;
  107564. private _buttonShare;
  107565. private _buttonOptions;
  107566. private _buttonL1;
  107567. private _buttonR1;
  107568. private _buttonLeftStick;
  107569. private _buttonRightStick;
  107570. private _dPadUp;
  107571. private _dPadDown;
  107572. private _dPadLeft;
  107573. private _dPadRight;
  107574. /**
  107575. * Creates a new DualShock gamepad object
  107576. * @param id defines the id of this gamepad
  107577. * @param index defines its index
  107578. * @param gamepad defines the internal HTML gamepad object
  107579. */
  107580. constructor(id: string, index: number, gamepad: any);
  107581. /**
  107582. * Defines the callback to call when left trigger is pressed
  107583. * @param callback defines the callback to use
  107584. */
  107585. onlefttriggerchanged(callback: (value: number) => void): void;
  107586. /**
  107587. * Defines the callback to call when right trigger is pressed
  107588. * @param callback defines the callback to use
  107589. */
  107590. onrighttriggerchanged(callback: (value: number) => void): void;
  107591. /**
  107592. * Gets the left trigger value
  107593. */
  107594. /**
  107595. * Sets the left trigger value
  107596. */
  107597. leftTrigger: number;
  107598. /**
  107599. * Gets the right trigger value
  107600. */
  107601. /**
  107602. * Sets the right trigger value
  107603. */
  107604. rightTrigger: number;
  107605. /**
  107606. * Defines the callback to call when a button is pressed
  107607. * @param callback defines the callback to use
  107608. */
  107609. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107610. /**
  107611. * Defines the callback to call when a button is released
  107612. * @param callback defines the callback to use
  107613. */
  107614. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107615. /**
  107616. * Defines the callback to call when a pad is pressed
  107617. * @param callback defines the callback to use
  107618. */
  107619. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107620. /**
  107621. * Defines the callback to call when a pad is released
  107622. * @param callback defines the callback to use
  107623. */
  107624. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107625. private _setButtonValue;
  107626. private _setDPadValue;
  107627. /**
  107628. * Gets the value of the `Cross` button
  107629. */
  107630. /**
  107631. * Sets the value of the `Cross` button
  107632. */
  107633. buttonCross: number;
  107634. /**
  107635. * Gets the value of the `Circle` button
  107636. */
  107637. /**
  107638. * Sets the value of the `Circle` button
  107639. */
  107640. buttonCircle: number;
  107641. /**
  107642. * Gets the value of the `Square` button
  107643. */
  107644. /**
  107645. * Sets the value of the `Square` button
  107646. */
  107647. buttonSquare: number;
  107648. /**
  107649. * Gets the value of the `Triangle` button
  107650. */
  107651. /**
  107652. * Sets the value of the `Triangle` button
  107653. */
  107654. buttonTriangle: number;
  107655. /**
  107656. * Gets the value of the `Options` button
  107657. */
  107658. /**
  107659. * Sets the value of the `Options` button
  107660. */
  107661. buttonOptions: number;
  107662. /**
  107663. * Gets the value of the `Share` button
  107664. */
  107665. /**
  107666. * Sets the value of the `Share` button
  107667. */
  107668. buttonShare: number;
  107669. /**
  107670. * Gets the value of the `L1` button
  107671. */
  107672. /**
  107673. * Sets the value of the `L1` button
  107674. */
  107675. buttonL1: number;
  107676. /**
  107677. * Gets the value of the `R1` button
  107678. */
  107679. /**
  107680. * Sets the value of the `R1` button
  107681. */
  107682. buttonR1: number;
  107683. /**
  107684. * Gets the value of the Left joystick
  107685. */
  107686. /**
  107687. * Sets the value of the Left joystick
  107688. */
  107689. buttonLeftStick: number;
  107690. /**
  107691. * Gets the value of the Right joystick
  107692. */
  107693. /**
  107694. * Sets the value of the Right joystick
  107695. */
  107696. buttonRightStick: number;
  107697. /**
  107698. * Gets the value of D-pad up
  107699. */
  107700. /**
  107701. * Sets the value of D-pad up
  107702. */
  107703. dPadUp: number;
  107704. /**
  107705. * Gets the value of D-pad down
  107706. */
  107707. /**
  107708. * Sets the value of D-pad down
  107709. */
  107710. dPadDown: number;
  107711. /**
  107712. * Gets the value of D-pad left
  107713. */
  107714. /**
  107715. * Sets the value of D-pad left
  107716. */
  107717. dPadLeft: number;
  107718. /**
  107719. * Gets the value of D-pad right
  107720. */
  107721. /**
  107722. * Sets the value of D-pad right
  107723. */
  107724. dPadRight: number;
  107725. /**
  107726. * Force the gamepad to synchronize with device values
  107727. */
  107728. update(): void;
  107729. /**
  107730. * Disposes the gamepad
  107731. */
  107732. dispose(): void;
  107733. }
  107734. }
  107735. declare module BABYLON {
  107736. /**
  107737. * Manager for handling gamepads
  107738. */
  107739. export class GamepadManager {
  107740. private _scene?;
  107741. private _babylonGamepads;
  107742. private _oneGamepadConnected;
  107743. /** @hidden */
  107744. _isMonitoring: boolean;
  107745. private _gamepadEventSupported;
  107746. private _gamepadSupport;
  107747. /**
  107748. * observable to be triggered when the gamepad controller has been connected
  107749. */
  107750. onGamepadConnectedObservable: Observable<Gamepad>;
  107751. /**
  107752. * observable to be triggered when the gamepad controller has been disconnected
  107753. */
  107754. onGamepadDisconnectedObservable: Observable<Gamepad>;
  107755. private _onGamepadConnectedEvent;
  107756. private _onGamepadDisconnectedEvent;
  107757. /**
  107758. * Initializes the gamepad manager
  107759. * @param _scene BabylonJS scene
  107760. */
  107761. constructor(_scene?: Scene | undefined);
  107762. /**
  107763. * The gamepads in the game pad manager
  107764. */
  107765. readonly gamepads: Gamepad[];
  107766. /**
  107767. * Get the gamepad controllers based on type
  107768. * @param type The type of gamepad controller
  107769. * @returns Nullable gamepad
  107770. */
  107771. getGamepadByType(type?: number): Nullable<Gamepad>;
  107772. /**
  107773. * Disposes the gamepad manager
  107774. */
  107775. dispose(): void;
  107776. private _addNewGamepad;
  107777. private _startMonitoringGamepads;
  107778. private _stopMonitoringGamepads;
  107779. /** @hidden */
  107780. _checkGamepadsStatus(): void;
  107781. private _updateGamepadObjects;
  107782. }
  107783. }
  107784. declare module BABYLON {
  107785. interface Scene {
  107786. /** @hidden */
  107787. _gamepadManager: Nullable<GamepadManager>;
  107788. /**
  107789. * Gets the gamepad manager associated with the scene
  107790. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  107791. */
  107792. gamepadManager: GamepadManager;
  107793. }
  107794. /**
  107795. * Interface representing a free camera inputs manager
  107796. */
  107797. interface FreeCameraInputsManager {
  107798. /**
  107799. * Adds gamepad input support to the FreeCameraInputsManager.
  107800. * @returns the FreeCameraInputsManager
  107801. */
  107802. addGamepad(): FreeCameraInputsManager;
  107803. }
  107804. /**
  107805. * Interface representing an arc rotate camera inputs manager
  107806. */
  107807. interface ArcRotateCameraInputsManager {
  107808. /**
  107809. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107810. * @returns the camera inputs manager
  107811. */
  107812. addGamepad(): ArcRotateCameraInputsManager;
  107813. }
  107814. /**
  107815. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107816. */
  107817. export class GamepadSystemSceneComponent implements ISceneComponent {
  107818. /**
  107819. * The component name helpfull to identify the component in the list of scene components.
  107820. */
  107821. readonly name: string;
  107822. /**
  107823. * The scene the component belongs to.
  107824. */
  107825. scene: Scene;
  107826. /**
  107827. * Creates a new instance of the component for the given scene
  107828. * @param scene Defines the scene to register the component in
  107829. */
  107830. constructor(scene: Scene);
  107831. /**
  107832. * Registers the component in a given scene
  107833. */
  107834. register(): void;
  107835. /**
  107836. * Rebuilds the elements related to this component in case of
  107837. * context lost for instance.
  107838. */
  107839. rebuild(): void;
  107840. /**
  107841. * Disposes the component and the associated ressources
  107842. */
  107843. dispose(): void;
  107844. private _beforeCameraUpdate;
  107845. }
  107846. }
  107847. declare module BABYLON {
  107848. /**
  107849. * 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,
  107850. * which still works and will still be found in many Playgrounds.
  107851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107852. */
  107853. export class UniversalCamera extends TouchCamera {
  107854. /**
  107855. * Defines the gamepad rotation sensiblity.
  107856. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107857. */
  107858. gamepadAngularSensibility: number;
  107859. /**
  107860. * Defines the gamepad move sensiblity.
  107861. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107862. */
  107863. gamepadMoveSensibility: number;
  107864. /**
  107865. * 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,
  107866. * which still works and will still be found in many Playgrounds.
  107867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107868. * @param name Define the name of the camera in the scene
  107869. * @param position Define the start position of the camera in the scene
  107870. * @param scene Define the scene the camera belongs to
  107871. */
  107872. constructor(name: string, position: Vector3, scene: Scene);
  107873. /**
  107874. * Gets the current object class name.
  107875. * @return the class name
  107876. */
  107877. getClassName(): string;
  107878. }
  107879. }
  107880. declare module BABYLON {
  107881. /**
  107882. * This represents a FPS type of camera. This is only here for back compat purpose.
  107883. * Please use the UniversalCamera instead as both are identical.
  107884. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107885. */
  107886. export class GamepadCamera extends UniversalCamera {
  107887. /**
  107888. * Instantiates a new Gamepad Camera
  107889. * This represents a FPS type of camera. This is only here for back compat purpose.
  107890. * Please use the UniversalCamera instead as both are identical.
  107891. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107892. * @param name Define the name of the camera in the scene
  107893. * @param position Define the start position of the camera in the scene
  107894. * @param scene Define the scene the camera belongs to
  107895. */
  107896. constructor(name: string, position: Vector3, scene: Scene);
  107897. /**
  107898. * Gets the current object class name.
  107899. * @return the class name
  107900. */
  107901. getClassName(): string;
  107902. }
  107903. }
  107904. declare module BABYLON {
  107905. /** @hidden */
  107906. export var passPixelShader: {
  107907. name: string;
  107908. shader: string;
  107909. };
  107910. }
  107911. declare module BABYLON {
  107912. /** @hidden */
  107913. export var passCubePixelShader: {
  107914. name: string;
  107915. shader: string;
  107916. };
  107917. }
  107918. declare module BABYLON {
  107919. /**
  107920. * PassPostProcess which produces an output the same as it's input
  107921. */
  107922. export class PassPostProcess extends PostProcess {
  107923. /**
  107924. * Creates the PassPostProcess
  107925. * @param name The name of the effect.
  107926. * @param options The required width/height ratio to downsize to before computing the render pass.
  107927. * @param camera The camera to apply the render pass to.
  107928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107929. * @param engine The engine which the post process will be applied. (default: current engine)
  107930. * @param reusable If the post process can be reused on the same frame. (default: false)
  107931. * @param textureType The type of texture to be used when performing the post processing.
  107932. * @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)
  107933. */
  107934. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107935. }
  107936. /**
  107937. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107938. */
  107939. export class PassCubePostProcess extends PostProcess {
  107940. private _face;
  107941. /**
  107942. * Gets or sets the cube face to display.
  107943. * * 0 is +X
  107944. * * 1 is -X
  107945. * * 2 is +Y
  107946. * * 3 is -Y
  107947. * * 4 is +Z
  107948. * * 5 is -Z
  107949. */
  107950. face: number;
  107951. /**
  107952. * Creates the PassCubePostProcess
  107953. * @param name The name of the effect.
  107954. * @param options The required width/height ratio to downsize to before computing the render pass.
  107955. * @param camera The camera to apply the render pass to.
  107956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107957. * @param engine The engine which the post process will be applied. (default: current engine)
  107958. * @param reusable If the post process can be reused on the same frame. (default: false)
  107959. * @param textureType The type of texture to be used when performing the post processing.
  107960. * @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)
  107961. */
  107962. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107963. }
  107964. }
  107965. declare module BABYLON {
  107966. /** @hidden */
  107967. export var anaglyphPixelShader: {
  107968. name: string;
  107969. shader: string;
  107970. };
  107971. }
  107972. declare module BABYLON {
  107973. /**
  107974. * Postprocess used to generate anaglyphic rendering
  107975. */
  107976. export class AnaglyphPostProcess extends PostProcess {
  107977. private _passedProcess;
  107978. /**
  107979. * Creates a new AnaglyphPostProcess
  107980. * @param name defines postprocess name
  107981. * @param options defines creation options or target ratio scale
  107982. * @param rigCameras defines cameras using this postprocess
  107983. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107984. * @param engine defines hosting engine
  107985. * @param reusable defines if the postprocess will be reused multiple times per frame
  107986. */
  107987. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107988. }
  107989. }
  107990. declare module BABYLON {
  107991. /**
  107992. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107993. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107994. */
  107995. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107996. /**
  107997. * Creates a new AnaglyphArcRotateCamera
  107998. * @param name defines camera name
  107999. * @param alpha defines alpha angle (in radians)
  108000. * @param beta defines beta angle (in radians)
  108001. * @param radius defines radius
  108002. * @param target defines camera target
  108003. * @param interaxialDistance defines distance between each color axis
  108004. * @param scene defines the hosting scene
  108005. */
  108006. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108007. /**
  108008. * Gets camera class name
  108009. * @returns AnaglyphArcRotateCamera
  108010. */
  108011. getClassName(): string;
  108012. }
  108013. }
  108014. declare module BABYLON {
  108015. /**
  108016. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108017. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108018. */
  108019. export class AnaglyphFreeCamera extends FreeCamera {
  108020. /**
  108021. * Creates a new AnaglyphFreeCamera
  108022. * @param name defines camera name
  108023. * @param position defines initial position
  108024. * @param interaxialDistance defines distance between each color axis
  108025. * @param scene defines the hosting scene
  108026. */
  108027. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108028. /**
  108029. * Gets camera class name
  108030. * @returns AnaglyphFreeCamera
  108031. */
  108032. getClassName(): string;
  108033. }
  108034. }
  108035. declare module BABYLON {
  108036. /**
  108037. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108038. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108039. */
  108040. export class AnaglyphGamepadCamera extends GamepadCamera {
  108041. /**
  108042. * Creates a new AnaglyphGamepadCamera
  108043. * @param name defines camera name
  108044. * @param position defines initial position
  108045. * @param interaxialDistance defines distance between each color axis
  108046. * @param scene defines the hosting scene
  108047. */
  108048. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108049. /**
  108050. * Gets camera class name
  108051. * @returns AnaglyphGamepadCamera
  108052. */
  108053. getClassName(): string;
  108054. }
  108055. }
  108056. declare module BABYLON {
  108057. /**
  108058. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108059. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108060. */
  108061. export class AnaglyphUniversalCamera extends UniversalCamera {
  108062. /**
  108063. * Creates a new AnaglyphUniversalCamera
  108064. * @param name defines camera name
  108065. * @param position defines initial position
  108066. * @param interaxialDistance defines distance between each color axis
  108067. * @param scene defines the hosting scene
  108068. */
  108069. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108070. /**
  108071. * Gets camera class name
  108072. * @returns AnaglyphUniversalCamera
  108073. */
  108074. getClassName(): string;
  108075. }
  108076. }
  108077. declare module BABYLON {
  108078. /** @hidden */
  108079. export var stereoscopicInterlacePixelShader: {
  108080. name: string;
  108081. shader: string;
  108082. };
  108083. }
  108084. declare module BABYLON {
  108085. /**
  108086. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108087. */
  108088. export class StereoscopicInterlacePostProcess extends PostProcess {
  108089. private _stepSize;
  108090. private _passedProcess;
  108091. /**
  108092. * Initializes a StereoscopicInterlacePostProcess
  108093. * @param name The name of the effect.
  108094. * @param rigCameras The rig cameras to be appled to the post process
  108095. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108097. * @param engine The engine which the post process will be applied. (default: current engine)
  108098. * @param reusable If the post process can be reused on the same frame. (default: false)
  108099. */
  108100. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108101. }
  108102. }
  108103. declare module BABYLON {
  108104. /**
  108105. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108106. * @see http://doc.babylonjs.com/features/cameras
  108107. */
  108108. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108109. /**
  108110. * Creates a new StereoscopicArcRotateCamera
  108111. * @param name defines camera name
  108112. * @param alpha defines alpha angle (in radians)
  108113. * @param beta defines beta angle (in radians)
  108114. * @param radius defines radius
  108115. * @param target defines camera target
  108116. * @param interaxialDistance defines distance between each color axis
  108117. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108118. * @param scene defines the hosting scene
  108119. */
  108120. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108121. /**
  108122. * Gets camera class name
  108123. * @returns StereoscopicArcRotateCamera
  108124. */
  108125. getClassName(): string;
  108126. }
  108127. }
  108128. declare module BABYLON {
  108129. /**
  108130. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108131. * @see http://doc.babylonjs.com/features/cameras
  108132. */
  108133. export class StereoscopicFreeCamera extends FreeCamera {
  108134. /**
  108135. * Creates a new StereoscopicFreeCamera
  108136. * @param name defines camera name
  108137. * @param position defines initial position
  108138. * @param interaxialDistance defines distance between each color axis
  108139. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108140. * @param scene defines the hosting scene
  108141. */
  108142. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108143. /**
  108144. * Gets camera class name
  108145. * @returns StereoscopicFreeCamera
  108146. */
  108147. getClassName(): string;
  108148. }
  108149. }
  108150. declare module BABYLON {
  108151. /**
  108152. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108153. * @see http://doc.babylonjs.com/features/cameras
  108154. */
  108155. export class StereoscopicGamepadCamera extends GamepadCamera {
  108156. /**
  108157. * Creates a new StereoscopicGamepadCamera
  108158. * @param name defines camera name
  108159. * @param position defines initial position
  108160. * @param interaxialDistance defines distance between each color axis
  108161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108162. * @param scene defines the hosting scene
  108163. */
  108164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108165. /**
  108166. * Gets camera class name
  108167. * @returns StereoscopicGamepadCamera
  108168. */
  108169. getClassName(): string;
  108170. }
  108171. }
  108172. declare module BABYLON {
  108173. /**
  108174. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108175. * @see http://doc.babylonjs.com/features/cameras
  108176. */
  108177. export class StereoscopicUniversalCamera extends UniversalCamera {
  108178. /**
  108179. * Creates a new StereoscopicUniversalCamera
  108180. * @param name defines camera name
  108181. * @param position defines initial position
  108182. * @param interaxialDistance defines distance between each color axis
  108183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108184. * @param scene defines the hosting scene
  108185. */
  108186. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108187. /**
  108188. * Gets camera class name
  108189. * @returns StereoscopicUniversalCamera
  108190. */
  108191. getClassName(): string;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. /**
  108196. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108197. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108198. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108199. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108200. */
  108201. export class VirtualJoysticksCamera extends FreeCamera {
  108202. /**
  108203. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108204. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108205. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108206. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108207. * @param name Define the name of the camera in the scene
  108208. * @param position Define the start position of the camera in the scene
  108209. * @param scene Define the scene the camera belongs to
  108210. */
  108211. constructor(name: string, position: Vector3, scene: Scene);
  108212. /**
  108213. * Gets the current object class name.
  108214. * @return the class name
  108215. */
  108216. getClassName(): string;
  108217. }
  108218. }
  108219. declare module BABYLON {
  108220. /**
  108221. * This represents all the required metrics to create a VR camera.
  108222. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108223. */
  108224. export class VRCameraMetrics {
  108225. /**
  108226. * Define the horizontal resolution off the screen.
  108227. */
  108228. hResolution: number;
  108229. /**
  108230. * Define the vertical resolution off the screen.
  108231. */
  108232. vResolution: number;
  108233. /**
  108234. * Define the horizontal screen size.
  108235. */
  108236. hScreenSize: number;
  108237. /**
  108238. * Define the vertical screen size.
  108239. */
  108240. vScreenSize: number;
  108241. /**
  108242. * Define the vertical screen center position.
  108243. */
  108244. vScreenCenter: number;
  108245. /**
  108246. * Define the distance of the eyes to the screen.
  108247. */
  108248. eyeToScreenDistance: number;
  108249. /**
  108250. * Define the distance between both lenses
  108251. */
  108252. lensSeparationDistance: number;
  108253. /**
  108254. * Define the distance between both viewer's eyes.
  108255. */
  108256. interpupillaryDistance: number;
  108257. /**
  108258. * Define the distortion factor of the VR postprocess.
  108259. * Please, touch with care.
  108260. */
  108261. distortionK: number[];
  108262. /**
  108263. * Define the chromatic aberration correction factors for the VR post process.
  108264. */
  108265. chromaAbCorrection: number[];
  108266. /**
  108267. * Define the scale factor of the post process.
  108268. * The smaller the better but the slower.
  108269. */
  108270. postProcessScaleFactor: number;
  108271. /**
  108272. * Define an offset for the lens center.
  108273. */
  108274. lensCenterOffset: number;
  108275. /**
  108276. * Define if the current vr camera should compensate the distortion of the lense or not.
  108277. */
  108278. compensateDistortion: boolean;
  108279. /**
  108280. * Defines if multiview should be enabled when rendering (Default: false)
  108281. */
  108282. multiviewEnabled: boolean;
  108283. /**
  108284. * Gets the rendering aspect ratio based on the provided resolutions.
  108285. */
  108286. readonly aspectRatio: number;
  108287. /**
  108288. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108289. */
  108290. readonly aspectRatioFov: number;
  108291. /**
  108292. * @hidden
  108293. */
  108294. readonly leftHMatrix: Matrix;
  108295. /**
  108296. * @hidden
  108297. */
  108298. readonly rightHMatrix: Matrix;
  108299. /**
  108300. * @hidden
  108301. */
  108302. readonly leftPreViewMatrix: Matrix;
  108303. /**
  108304. * @hidden
  108305. */
  108306. readonly rightPreViewMatrix: Matrix;
  108307. /**
  108308. * Get the default VRMetrics based on the most generic setup.
  108309. * @returns the default vr metrics
  108310. */
  108311. static GetDefault(): VRCameraMetrics;
  108312. }
  108313. }
  108314. declare module BABYLON {
  108315. /** @hidden */
  108316. export var vrDistortionCorrectionPixelShader: {
  108317. name: string;
  108318. shader: string;
  108319. };
  108320. }
  108321. declare module BABYLON {
  108322. /**
  108323. * VRDistortionCorrectionPostProcess used for mobile VR
  108324. */
  108325. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108326. private _isRightEye;
  108327. private _distortionFactors;
  108328. private _postProcessScaleFactor;
  108329. private _lensCenterOffset;
  108330. private _scaleIn;
  108331. private _scaleFactor;
  108332. private _lensCenter;
  108333. /**
  108334. * Initializes the VRDistortionCorrectionPostProcess
  108335. * @param name The name of the effect.
  108336. * @param camera The camera to apply the render pass to.
  108337. * @param isRightEye If this is for the right eye distortion
  108338. * @param vrMetrics All the required metrics for the VR camera
  108339. */
  108340. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108341. }
  108342. }
  108343. declare module BABYLON {
  108344. /**
  108345. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108346. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108347. */
  108348. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108349. /**
  108350. * Creates a new VRDeviceOrientationArcRotateCamera
  108351. * @param name defines camera name
  108352. * @param alpha defines the camera rotation along the logitudinal axis
  108353. * @param beta defines the camera rotation along the latitudinal axis
  108354. * @param radius defines the camera distance from its target
  108355. * @param target defines the camera target
  108356. * @param scene defines the scene the camera belongs to
  108357. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108358. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108359. */
  108360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108361. /**
  108362. * Gets camera class name
  108363. * @returns VRDeviceOrientationArcRotateCamera
  108364. */
  108365. getClassName(): string;
  108366. }
  108367. }
  108368. declare module BABYLON {
  108369. /**
  108370. * Camera used to simulate VR rendering (based on FreeCamera)
  108371. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108372. */
  108373. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108374. /**
  108375. * Creates a new VRDeviceOrientationFreeCamera
  108376. * @param name defines camera name
  108377. * @param position defines the start position of the camera
  108378. * @param scene defines the scene the camera belongs to
  108379. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108380. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108381. */
  108382. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108383. /**
  108384. * Gets camera class name
  108385. * @returns VRDeviceOrientationFreeCamera
  108386. */
  108387. getClassName(): string;
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. /**
  108392. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108393. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108394. */
  108395. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108396. /**
  108397. * Creates a new VRDeviceOrientationGamepadCamera
  108398. * @param name defines camera name
  108399. * @param position defines the start position of the camera
  108400. * @param scene defines the scene the camera belongs to
  108401. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108402. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108403. */
  108404. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108405. /**
  108406. * Gets camera class name
  108407. * @returns VRDeviceOrientationGamepadCamera
  108408. */
  108409. getClassName(): string;
  108410. }
  108411. }
  108412. declare module BABYLON {
  108413. /**
  108414. * Base class of materials working in push mode in babylon JS
  108415. * @hidden
  108416. */
  108417. export class PushMaterial extends Material {
  108418. protected _activeEffect: Effect;
  108419. protected _normalMatrix: Matrix;
  108420. /**
  108421. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108422. * This means that the material can keep using a previous shader while a new one is being compiled.
  108423. * This is mostly used when shader parallel compilation is supported (true by default)
  108424. */
  108425. allowShaderHotSwapping: boolean;
  108426. constructor(name: string, scene: Scene);
  108427. getEffect(): Effect;
  108428. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108429. /**
  108430. * Binds the given world matrix to the active effect
  108431. *
  108432. * @param world the matrix to bind
  108433. */
  108434. bindOnlyWorldMatrix(world: Matrix): void;
  108435. /**
  108436. * Binds the given normal matrix to the active effect
  108437. *
  108438. * @param normalMatrix the matrix to bind
  108439. */
  108440. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108441. bind(world: Matrix, mesh?: Mesh): void;
  108442. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108443. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108444. }
  108445. }
  108446. declare module BABYLON {
  108447. /**
  108448. * This groups all the flags used to control the materials channel.
  108449. */
  108450. export class MaterialFlags {
  108451. private static _DiffuseTextureEnabled;
  108452. /**
  108453. * Are diffuse textures enabled in the application.
  108454. */
  108455. static DiffuseTextureEnabled: boolean;
  108456. private static _AmbientTextureEnabled;
  108457. /**
  108458. * Are ambient textures enabled in the application.
  108459. */
  108460. static AmbientTextureEnabled: boolean;
  108461. private static _OpacityTextureEnabled;
  108462. /**
  108463. * Are opacity textures enabled in the application.
  108464. */
  108465. static OpacityTextureEnabled: boolean;
  108466. private static _ReflectionTextureEnabled;
  108467. /**
  108468. * Are reflection textures enabled in the application.
  108469. */
  108470. static ReflectionTextureEnabled: boolean;
  108471. private static _EmissiveTextureEnabled;
  108472. /**
  108473. * Are emissive textures enabled in the application.
  108474. */
  108475. static EmissiveTextureEnabled: boolean;
  108476. private static _SpecularTextureEnabled;
  108477. /**
  108478. * Are specular textures enabled in the application.
  108479. */
  108480. static SpecularTextureEnabled: boolean;
  108481. private static _BumpTextureEnabled;
  108482. /**
  108483. * Are bump textures enabled in the application.
  108484. */
  108485. static BumpTextureEnabled: boolean;
  108486. private static _LightmapTextureEnabled;
  108487. /**
  108488. * Are lightmap textures enabled in the application.
  108489. */
  108490. static LightmapTextureEnabled: boolean;
  108491. private static _RefractionTextureEnabled;
  108492. /**
  108493. * Are refraction textures enabled in the application.
  108494. */
  108495. static RefractionTextureEnabled: boolean;
  108496. private static _ColorGradingTextureEnabled;
  108497. /**
  108498. * Are color grading textures enabled in the application.
  108499. */
  108500. static ColorGradingTextureEnabled: boolean;
  108501. private static _FresnelEnabled;
  108502. /**
  108503. * Are fresnels enabled in the application.
  108504. */
  108505. static FresnelEnabled: boolean;
  108506. private static _ClearCoatTextureEnabled;
  108507. /**
  108508. * Are clear coat textures enabled in the application.
  108509. */
  108510. static ClearCoatTextureEnabled: boolean;
  108511. private static _ClearCoatBumpTextureEnabled;
  108512. /**
  108513. * Are clear coat bump textures enabled in the application.
  108514. */
  108515. static ClearCoatBumpTextureEnabled: boolean;
  108516. private static _ClearCoatTintTextureEnabled;
  108517. /**
  108518. * Are clear coat tint textures enabled in the application.
  108519. */
  108520. static ClearCoatTintTextureEnabled: boolean;
  108521. private static _SheenTextureEnabled;
  108522. /**
  108523. * Are sheen textures enabled in the application.
  108524. */
  108525. static SheenTextureEnabled: boolean;
  108526. private static _AnisotropicTextureEnabled;
  108527. /**
  108528. * Are anisotropic textures enabled in the application.
  108529. */
  108530. static AnisotropicTextureEnabled: boolean;
  108531. private static _ThicknessTextureEnabled;
  108532. /**
  108533. * Are thickness textures enabled in the application.
  108534. */
  108535. static ThicknessTextureEnabled: boolean;
  108536. }
  108537. }
  108538. declare module BABYLON {
  108539. /** @hidden */
  108540. export var defaultFragmentDeclaration: {
  108541. name: string;
  108542. shader: string;
  108543. };
  108544. }
  108545. declare module BABYLON {
  108546. /** @hidden */
  108547. export var defaultUboDeclaration: {
  108548. name: string;
  108549. shader: string;
  108550. };
  108551. }
  108552. declare module BABYLON {
  108553. /** @hidden */
  108554. export var lightFragmentDeclaration: {
  108555. name: string;
  108556. shader: string;
  108557. };
  108558. }
  108559. declare module BABYLON {
  108560. /** @hidden */
  108561. export var lightUboDeclaration: {
  108562. name: string;
  108563. shader: string;
  108564. };
  108565. }
  108566. declare module BABYLON {
  108567. /** @hidden */
  108568. export var lightsFragmentFunctions: {
  108569. name: string;
  108570. shader: string;
  108571. };
  108572. }
  108573. declare module BABYLON {
  108574. /** @hidden */
  108575. export var shadowsFragmentFunctions: {
  108576. name: string;
  108577. shader: string;
  108578. };
  108579. }
  108580. declare module BABYLON {
  108581. /** @hidden */
  108582. export var fresnelFunction: {
  108583. name: string;
  108584. shader: string;
  108585. };
  108586. }
  108587. declare module BABYLON {
  108588. /** @hidden */
  108589. export var reflectionFunction: {
  108590. name: string;
  108591. shader: string;
  108592. };
  108593. }
  108594. declare module BABYLON {
  108595. /** @hidden */
  108596. export var bumpFragmentFunctions: {
  108597. name: string;
  108598. shader: string;
  108599. };
  108600. }
  108601. declare module BABYLON {
  108602. /** @hidden */
  108603. export var logDepthDeclaration: {
  108604. name: string;
  108605. shader: string;
  108606. };
  108607. }
  108608. declare module BABYLON {
  108609. /** @hidden */
  108610. export var bumpFragment: {
  108611. name: string;
  108612. shader: string;
  108613. };
  108614. }
  108615. declare module BABYLON {
  108616. /** @hidden */
  108617. export var depthPrePass: {
  108618. name: string;
  108619. shader: string;
  108620. };
  108621. }
  108622. declare module BABYLON {
  108623. /** @hidden */
  108624. export var lightFragment: {
  108625. name: string;
  108626. shader: string;
  108627. };
  108628. }
  108629. declare module BABYLON {
  108630. /** @hidden */
  108631. export var logDepthFragment: {
  108632. name: string;
  108633. shader: string;
  108634. };
  108635. }
  108636. declare module BABYLON {
  108637. /** @hidden */
  108638. export var defaultPixelShader: {
  108639. name: string;
  108640. shader: string;
  108641. };
  108642. }
  108643. declare module BABYLON {
  108644. /** @hidden */
  108645. export var defaultVertexDeclaration: {
  108646. name: string;
  108647. shader: string;
  108648. };
  108649. }
  108650. declare module BABYLON {
  108651. /** @hidden */
  108652. export var bumpVertexDeclaration: {
  108653. name: string;
  108654. shader: string;
  108655. };
  108656. }
  108657. declare module BABYLON {
  108658. /** @hidden */
  108659. export var bumpVertex: {
  108660. name: string;
  108661. shader: string;
  108662. };
  108663. }
  108664. declare module BABYLON {
  108665. /** @hidden */
  108666. export var fogVertex: {
  108667. name: string;
  108668. shader: string;
  108669. };
  108670. }
  108671. declare module BABYLON {
  108672. /** @hidden */
  108673. export var shadowsVertex: {
  108674. name: string;
  108675. shader: string;
  108676. };
  108677. }
  108678. declare module BABYLON {
  108679. /** @hidden */
  108680. export var pointCloudVertex: {
  108681. name: string;
  108682. shader: string;
  108683. };
  108684. }
  108685. declare module BABYLON {
  108686. /** @hidden */
  108687. export var logDepthVertex: {
  108688. name: string;
  108689. shader: string;
  108690. };
  108691. }
  108692. declare module BABYLON {
  108693. /** @hidden */
  108694. export var defaultVertexShader: {
  108695. name: string;
  108696. shader: string;
  108697. };
  108698. }
  108699. declare module BABYLON {
  108700. /** @hidden */
  108701. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108702. MAINUV1: boolean;
  108703. MAINUV2: boolean;
  108704. DIFFUSE: boolean;
  108705. DIFFUSEDIRECTUV: number;
  108706. AMBIENT: boolean;
  108707. AMBIENTDIRECTUV: number;
  108708. OPACITY: boolean;
  108709. OPACITYDIRECTUV: number;
  108710. OPACITYRGB: boolean;
  108711. REFLECTION: boolean;
  108712. EMISSIVE: boolean;
  108713. EMISSIVEDIRECTUV: number;
  108714. SPECULAR: boolean;
  108715. SPECULARDIRECTUV: number;
  108716. BUMP: boolean;
  108717. BUMPDIRECTUV: number;
  108718. PARALLAX: boolean;
  108719. PARALLAXOCCLUSION: boolean;
  108720. SPECULAROVERALPHA: boolean;
  108721. CLIPPLANE: boolean;
  108722. CLIPPLANE2: boolean;
  108723. CLIPPLANE3: boolean;
  108724. CLIPPLANE4: boolean;
  108725. ALPHATEST: boolean;
  108726. DEPTHPREPASS: boolean;
  108727. ALPHAFROMDIFFUSE: boolean;
  108728. POINTSIZE: boolean;
  108729. FOG: boolean;
  108730. SPECULARTERM: boolean;
  108731. DIFFUSEFRESNEL: boolean;
  108732. OPACITYFRESNEL: boolean;
  108733. REFLECTIONFRESNEL: boolean;
  108734. REFRACTIONFRESNEL: boolean;
  108735. EMISSIVEFRESNEL: boolean;
  108736. FRESNEL: boolean;
  108737. NORMAL: boolean;
  108738. UV1: boolean;
  108739. UV2: boolean;
  108740. VERTEXCOLOR: boolean;
  108741. VERTEXALPHA: boolean;
  108742. NUM_BONE_INFLUENCERS: number;
  108743. BonesPerMesh: number;
  108744. BONETEXTURE: boolean;
  108745. INSTANCES: boolean;
  108746. GLOSSINESS: boolean;
  108747. ROUGHNESS: boolean;
  108748. EMISSIVEASILLUMINATION: boolean;
  108749. LINKEMISSIVEWITHDIFFUSE: boolean;
  108750. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108751. LIGHTMAP: boolean;
  108752. LIGHTMAPDIRECTUV: number;
  108753. OBJECTSPACE_NORMALMAP: boolean;
  108754. USELIGHTMAPASSHADOWMAP: boolean;
  108755. REFLECTIONMAP_3D: boolean;
  108756. REFLECTIONMAP_SPHERICAL: boolean;
  108757. REFLECTIONMAP_PLANAR: boolean;
  108758. REFLECTIONMAP_CUBIC: boolean;
  108759. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108760. REFLECTIONMAP_PROJECTION: boolean;
  108761. REFLECTIONMAP_SKYBOX: boolean;
  108762. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108763. REFLECTIONMAP_EXPLICIT: boolean;
  108764. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108765. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108766. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108767. INVERTCUBICMAP: boolean;
  108768. LOGARITHMICDEPTH: boolean;
  108769. REFRACTION: boolean;
  108770. REFRACTIONMAP_3D: boolean;
  108771. REFLECTIONOVERALPHA: boolean;
  108772. TWOSIDEDLIGHTING: boolean;
  108773. SHADOWFLOAT: boolean;
  108774. MORPHTARGETS: boolean;
  108775. MORPHTARGETS_NORMAL: boolean;
  108776. MORPHTARGETS_TANGENT: boolean;
  108777. MORPHTARGETS_UV: boolean;
  108778. NUM_MORPH_INFLUENCERS: number;
  108779. NONUNIFORMSCALING: boolean;
  108780. PREMULTIPLYALPHA: boolean;
  108781. IMAGEPROCESSING: boolean;
  108782. VIGNETTE: boolean;
  108783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108784. VIGNETTEBLENDMODEOPAQUE: boolean;
  108785. TONEMAPPING: boolean;
  108786. TONEMAPPING_ACES: boolean;
  108787. CONTRAST: boolean;
  108788. COLORCURVES: boolean;
  108789. COLORGRADING: boolean;
  108790. COLORGRADING3D: boolean;
  108791. SAMPLER3DGREENDEPTH: boolean;
  108792. SAMPLER3DBGRMAP: boolean;
  108793. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108794. MULTIVIEW: boolean;
  108795. /**
  108796. * If the reflection texture on this material is in linear color space
  108797. * @hidden
  108798. */
  108799. IS_REFLECTION_LINEAR: boolean;
  108800. /**
  108801. * If the refraction texture on this material is in linear color space
  108802. * @hidden
  108803. */
  108804. IS_REFRACTION_LINEAR: boolean;
  108805. EXPOSURE: boolean;
  108806. constructor();
  108807. setReflectionMode(modeToEnable: string): void;
  108808. }
  108809. /**
  108810. * This is the default material used in Babylon. It is the best trade off between quality
  108811. * and performances.
  108812. * @see http://doc.babylonjs.com/babylon101/materials
  108813. */
  108814. export class StandardMaterial extends PushMaterial {
  108815. private _diffuseTexture;
  108816. /**
  108817. * The basic texture of the material as viewed under a light.
  108818. */
  108819. diffuseTexture: Nullable<BaseTexture>;
  108820. private _ambientTexture;
  108821. /**
  108822. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108823. */
  108824. ambientTexture: Nullable<BaseTexture>;
  108825. private _opacityTexture;
  108826. /**
  108827. * Define the transparency of the material from a texture.
  108828. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108829. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108830. */
  108831. opacityTexture: Nullable<BaseTexture>;
  108832. private _reflectionTexture;
  108833. /**
  108834. * Define the texture used to display the reflection.
  108835. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108836. */
  108837. reflectionTexture: Nullable<BaseTexture>;
  108838. private _emissiveTexture;
  108839. /**
  108840. * Define texture of the material as if self lit.
  108841. * This will be mixed in the final result even in the absence of light.
  108842. */
  108843. emissiveTexture: Nullable<BaseTexture>;
  108844. private _specularTexture;
  108845. /**
  108846. * Define how the color and intensity of the highlight given by the light in the material.
  108847. */
  108848. specularTexture: Nullable<BaseTexture>;
  108849. private _bumpTexture;
  108850. /**
  108851. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108852. * 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.
  108853. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108854. */
  108855. bumpTexture: Nullable<BaseTexture>;
  108856. private _lightmapTexture;
  108857. /**
  108858. * Complex lighting can be computationally expensive to compute at runtime.
  108859. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108860. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108861. */
  108862. lightmapTexture: Nullable<BaseTexture>;
  108863. private _refractionTexture;
  108864. /**
  108865. * Define the texture used to display the refraction.
  108866. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108867. */
  108868. refractionTexture: Nullable<BaseTexture>;
  108869. /**
  108870. * The color of the material lit by the environmental background lighting.
  108871. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108872. */
  108873. ambientColor: Color3;
  108874. /**
  108875. * The basic color of the material as viewed under a light.
  108876. */
  108877. diffuseColor: Color3;
  108878. /**
  108879. * Define how the color and intensity of the highlight given by the light in the material.
  108880. */
  108881. specularColor: Color3;
  108882. /**
  108883. * Define the color of the material as if self lit.
  108884. * This will be mixed in the final result even in the absence of light.
  108885. */
  108886. emissiveColor: Color3;
  108887. /**
  108888. * Defines how sharp are the highlights in the material.
  108889. * The bigger the value the sharper giving a more glossy feeling to the result.
  108890. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108891. */
  108892. specularPower: number;
  108893. private _useAlphaFromDiffuseTexture;
  108894. /**
  108895. * Does the transparency come from the diffuse texture alpha channel.
  108896. */
  108897. useAlphaFromDiffuseTexture: boolean;
  108898. private _useEmissiveAsIllumination;
  108899. /**
  108900. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108901. */
  108902. useEmissiveAsIllumination: boolean;
  108903. private _linkEmissiveWithDiffuse;
  108904. /**
  108905. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108906. * the emissive level when the final color is close to one.
  108907. */
  108908. linkEmissiveWithDiffuse: boolean;
  108909. private _useSpecularOverAlpha;
  108910. /**
  108911. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108912. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108913. */
  108914. useSpecularOverAlpha: boolean;
  108915. private _useReflectionOverAlpha;
  108916. /**
  108917. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108918. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108919. */
  108920. useReflectionOverAlpha: boolean;
  108921. private _disableLighting;
  108922. /**
  108923. * Does lights from the scene impacts this material.
  108924. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108925. */
  108926. disableLighting: boolean;
  108927. private _useObjectSpaceNormalMap;
  108928. /**
  108929. * Allows using an object space normal map (instead of tangent space).
  108930. */
  108931. useObjectSpaceNormalMap: boolean;
  108932. private _useParallax;
  108933. /**
  108934. * Is parallax enabled or not.
  108935. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108936. */
  108937. useParallax: boolean;
  108938. private _useParallaxOcclusion;
  108939. /**
  108940. * Is parallax occlusion enabled or not.
  108941. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108942. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108943. */
  108944. useParallaxOcclusion: boolean;
  108945. /**
  108946. * 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.
  108947. */
  108948. parallaxScaleBias: number;
  108949. private _roughness;
  108950. /**
  108951. * Helps to define how blurry the reflections should appears in the material.
  108952. */
  108953. roughness: number;
  108954. /**
  108955. * In case of refraction, define the value of the index of refraction.
  108956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108957. */
  108958. indexOfRefraction: number;
  108959. /**
  108960. * Invert the refraction texture alongside the y axis.
  108961. * It can be useful with procedural textures or probe for instance.
  108962. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108963. */
  108964. invertRefractionY: boolean;
  108965. /**
  108966. * Defines the alpha limits in alpha test mode.
  108967. */
  108968. alphaCutOff: number;
  108969. private _useLightmapAsShadowmap;
  108970. /**
  108971. * In case of light mapping, define whether the map contains light or shadow informations.
  108972. */
  108973. useLightmapAsShadowmap: boolean;
  108974. private _diffuseFresnelParameters;
  108975. /**
  108976. * Define the diffuse fresnel parameters of the material.
  108977. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108978. */
  108979. diffuseFresnelParameters: FresnelParameters;
  108980. private _opacityFresnelParameters;
  108981. /**
  108982. * Define the opacity fresnel parameters of the material.
  108983. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108984. */
  108985. opacityFresnelParameters: FresnelParameters;
  108986. private _reflectionFresnelParameters;
  108987. /**
  108988. * Define the reflection fresnel parameters of the material.
  108989. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108990. */
  108991. reflectionFresnelParameters: FresnelParameters;
  108992. private _refractionFresnelParameters;
  108993. /**
  108994. * Define the refraction fresnel parameters of the material.
  108995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108996. */
  108997. refractionFresnelParameters: FresnelParameters;
  108998. private _emissiveFresnelParameters;
  108999. /**
  109000. * Define the emissive fresnel parameters of the material.
  109001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109002. */
  109003. emissiveFresnelParameters: FresnelParameters;
  109004. private _useReflectionFresnelFromSpecular;
  109005. /**
  109006. * If true automatically deducts the fresnels values from the material specularity.
  109007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109008. */
  109009. useReflectionFresnelFromSpecular: boolean;
  109010. private _useGlossinessFromSpecularMapAlpha;
  109011. /**
  109012. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109013. */
  109014. useGlossinessFromSpecularMapAlpha: boolean;
  109015. private _maxSimultaneousLights;
  109016. /**
  109017. * Defines the maximum number of lights that can be used in the material
  109018. */
  109019. maxSimultaneousLights: number;
  109020. private _invertNormalMapX;
  109021. /**
  109022. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109023. */
  109024. invertNormalMapX: boolean;
  109025. private _invertNormalMapY;
  109026. /**
  109027. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109028. */
  109029. invertNormalMapY: boolean;
  109030. private _twoSidedLighting;
  109031. /**
  109032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109033. */
  109034. twoSidedLighting: boolean;
  109035. /**
  109036. * Default configuration related to image processing available in the standard Material.
  109037. */
  109038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109039. /**
  109040. * Gets the image processing configuration used either in this material.
  109041. */
  109042. /**
  109043. * Sets the Default image processing configuration used either in the this material.
  109044. *
  109045. * If sets to null, the scene one is in use.
  109046. */
  109047. imageProcessingConfiguration: ImageProcessingConfiguration;
  109048. /**
  109049. * Keep track of the image processing observer to allow dispose and replace.
  109050. */
  109051. private _imageProcessingObserver;
  109052. /**
  109053. * Attaches a new image processing configuration to the Standard Material.
  109054. * @param configuration
  109055. */
  109056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109057. /**
  109058. * Gets wether the color curves effect is enabled.
  109059. */
  109060. /**
  109061. * Sets wether the color curves effect is enabled.
  109062. */
  109063. cameraColorCurvesEnabled: boolean;
  109064. /**
  109065. * Gets wether the color grading effect is enabled.
  109066. */
  109067. /**
  109068. * Gets wether the color grading effect is enabled.
  109069. */
  109070. cameraColorGradingEnabled: boolean;
  109071. /**
  109072. * Gets wether tonemapping is enabled or not.
  109073. */
  109074. /**
  109075. * Sets wether tonemapping is enabled or not
  109076. */
  109077. cameraToneMappingEnabled: boolean;
  109078. /**
  109079. * The camera exposure used on this material.
  109080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109081. * This corresponds to a photographic exposure.
  109082. */
  109083. /**
  109084. * The camera exposure used on this material.
  109085. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109086. * This corresponds to a photographic exposure.
  109087. */
  109088. cameraExposure: number;
  109089. /**
  109090. * Gets The camera contrast used on this material.
  109091. */
  109092. /**
  109093. * Sets The camera contrast used on this material.
  109094. */
  109095. cameraContrast: number;
  109096. /**
  109097. * Gets the Color Grading 2D Lookup Texture.
  109098. */
  109099. /**
  109100. * Sets the Color Grading 2D Lookup Texture.
  109101. */
  109102. cameraColorGradingTexture: Nullable<BaseTexture>;
  109103. /**
  109104. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109105. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109106. * 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;
  109107. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109108. */
  109109. /**
  109110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109112. * 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;
  109113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109114. */
  109115. cameraColorCurves: Nullable<ColorCurves>;
  109116. /**
  109117. * Custom callback helping to override the default shader used in the material.
  109118. */
  109119. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109120. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109121. protected _worldViewProjectionMatrix: Matrix;
  109122. protected _globalAmbientColor: Color3;
  109123. protected _useLogarithmicDepth: boolean;
  109124. protected _rebuildInParallel: boolean;
  109125. /**
  109126. * Instantiates a new standard material.
  109127. * This is the default material used in Babylon. It is the best trade off between quality
  109128. * and performances.
  109129. * @see http://doc.babylonjs.com/babylon101/materials
  109130. * @param name Define the name of the material in the scene
  109131. * @param scene Define the scene the material belong to
  109132. */
  109133. constructor(name: string, scene: Scene);
  109134. /**
  109135. * Gets a boolean indicating that current material needs to register RTT
  109136. */
  109137. readonly hasRenderTargetTextures: boolean;
  109138. /**
  109139. * Gets the current class name of the material e.g. "StandardMaterial"
  109140. * Mainly use in serialization.
  109141. * @returns the class name
  109142. */
  109143. getClassName(): string;
  109144. /**
  109145. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109146. * You can try switching to logarithmic depth.
  109147. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109148. */
  109149. useLogarithmicDepth: boolean;
  109150. /**
  109151. * Specifies if the material will require alpha blending
  109152. * @returns a boolean specifying if alpha blending is needed
  109153. */
  109154. needAlphaBlending(): boolean;
  109155. /**
  109156. * Specifies if this material should be rendered in alpha test mode
  109157. * @returns a boolean specifying if an alpha test is needed.
  109158. */
  109159. needAlphaTesting(): boolean;
  109160. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109161. /**
  109162. * Get the texture used for alpha test purpose.
  109163. * @returns the diffuse texture in case of the standard material.
  109164. */
  109165. getAlphaTestTexture(): Nullable<BaseTexture>;
  109166. /**
  109167. * Get if the submesh is ready to be used and all its information available.
  109168. * Child classes can use it to update shaders
  109169. * @param mesh defines the mesh to check
  109170. * @param subMesh defines which submesh to check
  109171. * @param useInstances specifies that instances should be used
  109172. * @returns a boolean indicating that the submesh is ready or not
  109173. */
  109174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109175. /**
  109176. * Builds the material UBO layouts.
  109177. * Used internally during the effect preparation.
  109178. */
  109179. buildUniformLayout(): void;
  109180. /**
  109181. * Unbinds the material from the mesh
  109182. */
  109183. unbind(): void;
  109184. /**
  109185. * Binds the submesh to this material by preparing the effect and shader to draw
  109186. * @param world defines the world transformation matrix
  109187. * @param mesh defines the mesh containing the submesh
  109188. * @param subMesh defines the submesh to bind the material to
  109189. */
  109190. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109191. /**
  109192. * Get the list of animatables in the material.
  109193. * @returns the list of animatables object used in the material
  109194. */
  109195. getAnimatables(): IAnimatable[];
  109196. /**
  109197. * Gets the active textures from the material
  109198. * @returns an array of textures
  109199. */
  109200. getActiveTextures(): BaseTexture[];
  109201. /**
  109202. * Specifies if the material uses a texture
  109203. * @param texture defines the texture to check against the material
  109204. * @returns a boolean specifying if the material uses the texture
  109205. */
  109206. hasTexture(texture: BaseTexture): boolean;
  109207. /**
  109208. * Disposes the material
  109209. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109210. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109211. */
  109212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109213. /**
  109214. * Makes a duplicate of the material, and gives it a new name
  109215. * @param name defines the new name for the duplicated material
  109216. * @returns the cloned material
  109217. */
  109218. clone(name: string): StandardMaterial;
  109219. /**
  109220. * Serializes this material in a JSON representation
  109221. * @returns the serialized material object
  109222. */
  109223. serialize(): any;
  109224. /**
  109225. * Creates a standard material from parsed material data
  109226. * @param source defines the JSON representation of the material
  109227. * @param scene defines the hosting scene
  109228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109229. * @returns a new standard material
  109230. */
  109231. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109232. /**
  109233. * Are diffuse textures enabled in the application.
  109234. */
  109235. static DiffuseTextureEnabled: boolean;
  109236. /**
  109237. * Are ambient textures enabled in the application.
  109238. */
  109239. static AmbientTextureEnabled: boolean;
  109240. /**
  109241. * Are opacity textures enabled in the application.
  109242. */
  109243. static OpacityTextureEnabled: boolean;
  109244. /**
  109245. * Are reflection textures enabled in the application.
  109246. */
  109247. static ReflectionTextureEnabled: boolean;
  109248. /**
  109249. * Are emissive textures enabled in the application.
  109250. */
  109251. static EmissiveTextureEnabled: boolean;
  109252. /**
  109253. * Are specular textures enabled in the application.
  109254. */
  109255. static SpecularTextureEnabled: boolean;
  109256. /**
  109257. * Are bump textures enabled in the application.
  109258. */
  109259. static BumpTextureEnabled: boolean;
  109260. /**
  109261. * Are lightmap textures enabled in the application.
  109262. */
  109263. static LightmapTextureEnabled: boolean;
  109264. /**
  109265. * Are refraction textures enabled in the application.
  109266. */
  109267. static RefractionTextureEnabled: boolean;
  109268. /**
  109269. * Are color grading textures enabled in the application.
  109270. */
  109271. static ColorGradingTextureEnabled: boolean;
  109272. /**
  109273. * Are fresnels enabled in the application.
  109274. */
  109275. static FresnelEnabled: boolean;
  109276. }
  109277. }
  109278. declare module BABYLON {
  109279. /** @hidden */
  109280. export var imageProcessingPixelShader: {
  109281. name: string;
  109282. shader: string;
  109283. };
  109284. }
  109285. declare module BABYLON {
  109286. /**
  109287. * ImageProcessingPostProcess
  109288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109289. */
  109290. export class ImageProcessingPostProcess extends PostProcess {
  109291. /**
  109292. * Default configuration related to image processing available in the PBR Material.
  109293. */
  109294. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109295. /**
  109296. * Gets the image processing configuration used either in this material.
  109297. */
  109298. /**
  109299. * Sets the Default image processing configuration used either in the this material.
  109300. *
  109301. * If sets to null, the scene one is in use.
  109302. */
  109303. imageProcessingConfiguration: ImageProcessingConfiguration;
  109304. /**
  109305. * Keep track of the image processing observer to allow dispose and replace.
  109306. */
  109307. private _imageProcessingObserver;
  109308. /**
  109309. * Attaches a new image processing configuration to the PBR Material.
  109310. * @param configuration
  109311. */
  109312. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109313. /**
  109314. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109315. */
  109316. /**
  109317. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109318. */
  109319. colorCurves: Nullable<ColorCurves>;
  109320. /**
  109321. * Gets wether the color curves effect is enabled.
  109322. */
  109323. /**
  109324. * Sets wether the color curves effect is enabled.
  109325. */
  109326. colorCurvesEnabled: boolean;
  109327. /**
  109328. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109329. */
  109330. /**
  109331. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109332. */
  109333. colorGradingTexture: Nullable<BaseTexture>;
  109334. /**
  109335. * Gets wether the color grading effect is enabled.
  109336. */
  109337. /**
  109338. * Gets wether the color grading effect is enabled.
  109339. */
  109340. colorGradingEnabled: boolean;
  109341. /**
  109342. * Gets exposure used in the effect.
  109343. */
  109344. /**
  109345. * Sets exposure used in the effect.
  109346. */
  109347. exposure: number;
  109348. /**
  109349. * Gets wether tonemapping is enabled or not.
  109350. */
  109351. /**
  109352. * Sets wether tonemapping is enabled or not
  109353. */
  109354. toneMappingEnabled: boolean;
  109355. /**
  109356. * Gets the type of tone mapping effect.
  109357. */
  109358. /**
  109359. * Sets the type of tone mapping effect.
  109360. */
  109361. toneMappingType: number;
  109362. /**
  109363. * Gets contrast used in the effect.
  109364. */
  109365. /**
  109366. * Sets contrast used in the effect.
  109367. */
  109368. contrast: number;
  109369. /**
  109370. * Gets Vignette stretch size.
  109371. */
  109372. /**
  109373. * Sets Vignette stretch size.
  109374. */
  109375. vignetteStretch: number;
  109376. /**
  109377. * Gets Vignette centre X Offset.
  109378. */
  109379. /**
  109380. * Sets Vignette centre X Offset.
  109381. */
  109382. vignetteCentreX: number;
  109383. /**
  109384. * Gets Vignette centre Y Offset.
  109385. */
  109386. /**
  109387. * Sets Vignette centre Y Offset.
  109388. */
  109389. vignetteCentreY: number;
  109390. /**
  109391. * Gets Vignette weight or intensity of the vignette effect.
  109392. */
  109393. /**
  109394. * Sets Vignette weight or intensity of the vignette effect.
  109395. */
  109396. vignetteWeight: number;
  109397. /**
  109398. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109399. * if vignetteEnabled is set to true.
  109400. */
  109401. /**
  109402. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109403. * if vignetteEnabled is set to true.
  109404. */
  109405. vignetteColor: Color4;
  109406. /**
  109407. * Gets Camera field of view used by the Vignette effect.
  109408. */
  109409. /**
  109410. * Sets Camera field of view used by the Vignette effect.
  109411. */
  109412. vignetteCameraFov: number;
  109413. /**
  109414. * Gets the vignette blend mode allowing different kind of effect.
  109415. */
  109416. /**
  109417. * Sets the vignette blend mode allowing different kind of effect.
  109418. */
  109419. vignetteBlendMode: number;
  109420. /**
  109421. * Gets wether the vignette effect is enabled.
  109422. */
  109423. /**
  109424. * Sets wether the vignette effect is enabled.
  109425. */
  109426. vignetteEnabled: boolean;
  109427. private _fromLinearSpace;
  109428. /**
  109429. * Gets wether the input of the processing is in Gamma or Linear Space.
  109430. */
  109431. /**
  109432. * Sets wether the input of the processing is in Gamma or Linear Space.
  109433. */
  109434. fromLinearSpace: boolean;
  109435. /**
  109436. * Defines cache preventing GC.
  109437. */
  109438. private _defines;
  109439. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109440. /**
  109441. * "ImageProcessingPostProcess"
  109442. * @returns "ImageProcessingPostProcess"
  109443. */
  109444. getClassName(): string;
  109445. protected _updateParameters(): void;
  109446. dispose(camera?: Camera): void;
  109447. }
  109448. }
  109449. declare module BABYLON {
  109450. /**
  109451. * Class containing static functions to help procedurally build meshes
  109452. */
  109453. export class GroundBuilder {
  109454. /**
  109455. * Creates a ground mesh
  109456. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109457. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109459. * @param name defines the name of the mesh
  109460. * @param options defines the options used to create the mesh
  109461. * @param scene defines the hosting scene
  109462. * @returns the ground mesh
  109463. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109464. */
  109465. static CreateGround(name: string, options: {
  109466. width?: number;
  109467. height?: number;
  109468. subdivisions?: number;
  109469. subdivisionsX?: number;
  109470. subdivisionsY?: number;
  109471. updatable?: boolean;
  109472. }, scene: any): Mesh;
  109473. /**
  109474. * Creates a tiled ground mesh
  109475. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109476. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109477. * * 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
  109478. * * 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
  109479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109480. * @param name defines the name of the mesh
  109481. * @param options defines the options used to create the mesh
  109482. * @param scene defines the hosting scene
  109483. * @returns the tiled ground mesh
  109484. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109485. */
  109486. static CreateTiledGround(name: string, options: {
  109487. xmin: number;
  109488. zmin: number;
  109489. xmax: number;
  109490. zmax: number;
  109491. subdivisions?: {
  109492. w: number;
  109493. h: number;
  109494. };
  109495. precision?: {
  109496. w: number;
  109497. h: number;
  109498. };
  109499. updatable?: boolean;
  109500. }, scene?: Nullable<Scene>): Mesh;
  109501. /**
  109502. * Creates a ground mesh from a height map
  109503. * * The parameter `url` sets the URL of the height map image resource.
  109504. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109505. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109506. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109507. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109508. * * 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.
  109509. * * 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).
  109510. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109512. * @param name defines the name of the mesh
  109513. * @param url defines the url to the height map
  109514. * @param options defines the options used to create the mesh
  109515. * @param scene defines the hosting scene
  109516. * @returns the ground mesh
  109517. * @see https://doc.babylonjs.com/babylon101/height_map
  109518. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109519. */
  109520. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109521. width?: number;
  109522. height?: number;
  109523. subdivisions?: number;
  109524. minHeight?: number;
  109525. maxHeight?: number;
  109526. colorFilter?: Color3;
  109527. alphaFilter?: number;
  109528. updatable?: boolean;
  109529. onReady?: (mesh: GroundMesh) => void;
  109530. }, scene?: Nullable<Scene>): GroundMesh;
  109531. }
  109532. }
  109533. declare module BABYLON {
  109534. /**
  109535. * Class containing static functions to help procedurally build meshes
  109536. */
  109537. export class TorusBuilder {
  109538. /**
  109539. * Creates a torus mesh
  109540. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109541. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109542. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109546. * @param name defines the name of the mesh
  109547. * @param options defines the options used to create the mesh
  109548. * @param scene defines the hosting scene
  109549. * @returns the torus mesh
  109550. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109551. */
  109552. static CreateTorus(name: string, options: {
  109553. diameter?: number;
  109554. thickness?: number;
  109555. tessellation?: number;
  109556. updatable?: boolean;
  109557. sideOrientation?: number;
  109558. frontUVs?: Vector4;
  109559. backUVs?: Vector4;
  109560. }, scene: any): Mesh;
  109561. }
  109562. }
  109563. declare module BABYLON {
  109564. /**
  109565. * Class containing static functions to help procedurally build meshes
  109566. */
  109567. export class CylinderBuilder {
  109568. /**
  109569. * Creates a cylinder or a cone mesh
  109570. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109571. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109572. * * 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.
  109573. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109574. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109575. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109576. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109577. * * 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).
  109578. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109579. * * 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).
  109580. * * 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
  109581. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109582. * * 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
  109583. * * 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.
  109584. * * If `enclose` is false, a ring surface is one element.
  109585. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109586. * * 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
  109587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109590. * @param name defines the name of the mesh
  109591. * @param options defines the options used to create the mesh
  109592. * @param scene defines the hosting scene
  109593. * @returns the cylinder mesh
  109594. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109595. */
  109596. static CreateCylinder(name: string, options: {
  109597. height?: number;
  109598. diameterTop?: number;
  109599. diameterBottom?: number;
  109600. diameter?: number;
  109601. tessellation?: number;
  109602. subdivisions?: number;
  109603. arc?: number;
  109604. faceColors?: Color4[];
  109605. faceUV?: Vector4[];
  109606. updatable?: boolean;
  109607. hasRings?: boolean;
  109608. enclose?: boolean;
  109609. cap?: number;
  109610. sideOrientation?: number;
  109611. frontUVs?: Vector4;
  109612. backUVs?: Vector4;
  109613. }, scene: any): Mesh;
  109614. }
  109615. }
  109616. declare module BABYLON {
  109617. /**
  109618. * Options to modify the vr teleportation behavior.
  109619. */
  109620. export interface VRTeleportationOptions {
  109621. /**
  109622. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109623. */
  109624. floorMeshName?: string;
  109625. /**
  109626. * A list of meshes to be used as the teleportation floor. (default: empty)
  109627. */
  109628. floorMeshes?: Mesh[];
  109629. }
  109630. /**
  109631. * Options to modify the vr experience helper's behavior.
  109632. */
  109633. export interface VRExperienceHelperOptions extends WebVROptions {
  109634. /**
  109635. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109636. */
  109637. createDeviceOrientationCamera?: boolean;
  109638. /**
  109639. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109640. */
  109641. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109642. /**
  109643. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109644. */
  109645. laserToggle?: boolean;
  109646. /**
  109647. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109648. */
  109649. floorMeshes?: Mesh[];
  109650. /**
  109651. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109652. */
  109653. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109654. }
  109655. /**
  109656. * Event containing information after VR has been entered
  109657. */
  109658. export class OnAfterEnteringVRObservableEvent {
  109659. /**
  109660. * If entering vr was successful
  109661. */
  109662. success: boolean;
  109663. }
  109664. /**
  109665. * Helps to quickly add VR support to an existing scene.
  109666. * See http://doc.babylonjs.com/how_to/webvr_helper
  109667. */
  109668. export class VRExperienceHelper {
  109669. /** Options to modify the vr experience helper's behavior. */
  109670. webVROptions: VRExperienceHelperOptions;
  109671. private _scene;
  109672. private _position;
  109673. private _btnVR;
  109674. private _btnVRDisplayed;
  109675. private _webVRsupported;
  109676. private _webVRready;
  109677. private _webVRrequesting;
  109678. private _webVRpresenting;
  109679. private _hasEnteredVR;
  109680. private _fullscreenVRpresenting;
  109681. private _inputElement;
  109682. private _webVRCamera;
  109683. private _vrDeviceOrientationCamera;
  109684. private _deviceOrientationCamera;
  109685. private _existingCamera;
  109686. private _onKeyDown;
  109687. private _onVrDisplayPresentChange;
  109688. private _onVRDisplayChanged;
  109689. private _onVRRequestPresentStart;
  109690. private _onVRRequestPresentComplete;
  109691. /**
  109692. * 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)
  109693. */
  109694. enableGazeEvenWhenNoPointerLock: boolean;
  109695. /**
  109696. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109697. */
  109698. exitVROnDoubleTap: boolean;
  109699. /**
  109700. * Observable raised right before entering VR.
  109701. */
  109702. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109703. /**
  109704. * Observable raised when entering VR has completed.
  109705. */
  109706. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  109707. /**
  109708. * Observable raised when exiting VR.
  109709. */
  109710. onExitingVRObservable: Observable<VRExperienceHelper>;
  109711. /**
  109712. * Observable raised when controller mesh is loaded.
  109713. */
  109714. onControllerMeshLoadedObservable: Observable<WebVRController>;
  109715. /** Return this.onEnteringVRObservable
  109716. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  109717. */
  109718. readonly onEnteringVR: Observable<VRExperienceHelper>;
  109719. /** Return this.onExitingVRObservable
  109720. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  109721. */
  109722. readonly onExitingVR: Observable<VRExperienceHelper>;
  109723. /** Return this.onControllerMeshLoadedObservable
  109724. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  109725. */
  109726. readonly onControllerMeshLoaded: Observable<WebVRController>;
  109727. private _rayLength;
  109728. private _useCustomVRButton;
  109729. private _teleportationRequested;
  109730. private _teleportActive;
  109731. private _floorMeshName;
  109732. private _floorMeshesCollection;
  109733. private _rotationAllowed;
  109734. private _teleportBackwardsVector;
  109735. private _teleportationTarget;
  109736. private _isDefaultTeleportationTarget;
  109737. private _postProcessMove;
  109738. private _teleportationFillColor;
  109739. private _teleportationBorderColor;
  109740. private _rotationAngle;
  109741. private _haloCenter;
  109742. private _cameraGazer;
  109743. private _padSensibilityUp;
  109744. private _padSensibilityDown;
  109745. private _leftController;
  109746. private _rightController;
  109747. /**
  109748. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  109749. */
  109750. onNewMeshSelected: Observable<AbstractMesh>;
  109751. /**
  109752. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  109753. * This observable will provide the mesh and the controller used to select the mesh
  109754. */
  109755. onMeshSelectedWithController: Observable<{
  109756. mesh: AbstractMesh;
  109757. controller: WebVRController;
  109758. }>;
  109759. /**
  109760. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  109761. */
  109762. onNewMeshPicked: Observable<PickingInfo>;
  109763. private _circleEase;
  109764. /**
  109765. * Observable raised before camera teleportation
  109766. */
  109767. onBeforeCameraTeleport: Observable<Vector3>;
  109768. /**
  109769. * Observable raised after camera teleportation
  109770. */
  109771. onAfterCameraTeleport: Observable<Vector3>;
  109772. /**
  109773. * Observable raised when current selected mesh gets unselected
  109774. */
  109775. onSelectedMeshUnselected: Observable<AbstractMesh>;
  109776. private _raySelectionPredicate;
  109777. /**
  109778. * To be optionaly changed by user to define custom ray selection
  109779. */
  109780. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  109781. /**
  109782. * To be optionaly changed by user to define custom selection logic (after ray selection)
  109783. */
  109784. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  109785. /**
  109786. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  109787. */
  109788. teleportationEnabled: boolean;
  109789. private _defaultHeight;
  109790. private _teleportationInitialized;
  109791. private _interactionsEnabled;
  109792. private _interactionsRequested;
  109793. private _displayGaze;
  109794. private _displayLaserPointer;
  109795. /**
  109796. * The mesh used to display where the user is going to teleport.
  109797. */
  109798. /**
  109799. * Sets the mesh to be used to display where the user is going to teleport.
  109800. */
  109801. teleportationTarget: Mesh;
  109802. /**
  109803. * 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
  109804. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109805. * See http://doc.babylonjs.com/resources/baking_transformations
  109806. */
  109807. gazeTrackerMesh: Mesh;
  109808. /**
  109809. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109810. */
  109811. updateGazeTrackerScale: boolean;
  109812. /**
  109813. * If the gaze trackers color should be updated when selecting meshes
  109814. */
  109815. updateGazeTrackerColor: boolean;
  109816. /**
  109817. * If the controller laser color should be updated when selecting meshes
  109818. */
  109819. updateControllerLaserColor: boolean;
  109820. /**
  109821. * The gaze tracking mesh corresponding to the left controller
  109822. */
  109823. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109824. /**
  109825. * The gaze tracking mesh corresponding to the right controller
  109826. */
  109827. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109828. /**
  109829. * If the ray of the gaze should be displayed.
  109830. */
  109831. /**
  109832. * Sets if the ray of the gaze should be displayed.
  109833. */
  109834. displayGaze: boolean;
  109835. /**
  109836. * If the ray of the LaserPointer should be displayed.
  109837. */
  109838. /**
  109839. * Sets if the ray of the LaserPointer should be displayed.
  109840. */
  109841. displayLaserPointer: boolean;
  109842. /**
  109843. * The deviceOrientationCamera used as the camera when not in VR.
  109844. */
  109845. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109846. /**
  109847. * Based on the current WebVR support, returns the current VR camera used.
  109848. */
  109849. readonly currentVRCamera: Nullable<Camera>;
  109850. /**
  109851. * The webVRCamera which is used when in VR.
  109852. */
  109853. readonly webVRCamera: WebVRFreeCamera;
  109854. /**
  109855. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109856. */
  109857. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109858. /**
  109859. * The html button that is used to trigger entering into VR.
  109860. */
  109861. readonly vrButton: Nullable<HTMLButtonElement>;
  109862. private readonly _teleportationRequestInitiated;
  109863. /**
  109864. * Defines wether or not Pointer lock should be requested when switching to
  109865. * full screen.
  109866. */
  109867. requestPointerLockOnFullScreen: boolean;
  109868. /**
  109869. * Instantiates a VRExperienceHelper.
  109870. * Helps to quickly add VR support to an existing scene.
  109871. * @param scene The scene the VRExperienceHelper belongs to.
  109872. * @param webVROptions Options to modify the vr experience helper's behavior.
  109873. */
  109874. constructor(scene: Scene,
  109875. /** Options to modify the vr experience helper's behavior. */
  109876. webVROptions?: VRExperienceHelperOptions);
  109877. private _onDefaultMeshLoaded;
  109878. private _onResize;
  109879. private _onFullscreenChange;
  109880. /**
  109881. * Gets a value indicating if we are currently in VR mode.
  109882. */
  109883. readonly isInVRMode: boolean;
  109884. private onVrDisplayPresentChange;
  109885. private onVRDisplayChanged;
  109886. private moveButtonToBottomRight;
  109887. private displayVRButton;
  109888. private updateButtonVisibility;
  109889. private _cachedAngularSensibility;
  109890. /**
  109891. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109892. * Otherwise, will use the fullscreen API.
  109893. */
  109894. enterVR(): void;
  109895. /**
  109896. * Attempt to exit VR, or fullscreen.
  109897. */
  109898. exitVR(): void;
  109899. /**
  109900. * The position of the vr experience helper.
  109901. */
  109902. /**
  109903. * Sets the position of the vr experience helper.
  109904. */
  109905. position: Vector3;
  109906. /**
  109907. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109908. */
  109909. enableInteractions(): void;
  109910. private readonly _noControllerIsActive;
  109911. private beforeRender;
  109912. private _isTeleportationFloor;
  109913. /**
  109914. * Adds a floor mesh to be used for teleportation.
  109915. * @param floorMesh the mesh to be used for teleportation.
  109916. */
  109917. addFloorMesh(floorMesh: Mesh): void;
  109918. /**
  109919. * Removes a floor mesh from being used for teleportation.
  109920. * @param floorMesh the mesh to be removed.
  109921. */
  109922. removeFloorMesh(floorMesh: Mesh): void;
  109923. /**
  109924. * Enables interactions and teleportation using the VR controllers and gaze.
  109925. * @param vrTeleportationOptions options to modify teleportation behavior.
  109926. */
  109927. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109928. private _onNewGamepadConnected;
  109929. private _tryEnableInteractionOnController;
  109930. private _onNewGamepadDisconnected;
  109931. private _enableInteractionOnController;
  109932. private _checkTeleportWithRay;
  109933. private _checkRotate;
  109934. private _checkTeleportBackwards;
  109935. private _enableTeleportationOnController;
  109936. private _createTeleportationCircles;
  109937. private _displayTeleportationTarget;
  109938. private _hideTeleportationTarget;
  109939. private _rotateCamera;
  109940. private _moveTeleportationSelectorTo;
  109941. private _workingVector;
  109942. private _workingQuaternion;
  109943. private _workingMatrix;
  109944. /**
  109945. * Teleports the users feet to the desired location
  109946. * @param location The location where the user's feet should be placed
  109947. */
  109948. teleportCamera(location: Vector3): void;
  109949. private _convertNormalToDirectionOfRay;
  109950. private _castRayAndSelectObject;
  109951. private _notifySelectedMeshUnselected;
  109952. /**
  109953. * Sets the color of the laser ray from the vr controllers.
  109954. * @param color new color for the ray.
  109955. */
  109956. changeLaserColor(color: Color3): void;
  109957. /**
  109958. * Sets the color of the ray from the vr headsets gaze.
  109959. * @param color new color for the ray.
  109960. */
  109961. changeGazeColor(color: Color3): void;
  109962. /**
  109963. * Exits VR and disposes of the vr experience helper
  109964. */
  109965. dispose(): void;
  109966. /**
  109967. * Gets the name of the VRExperienceHelper class
  109968. * @returns "VRExperienceHelper"
  109969. */
  109970. getClassName(): string;
  109971. }
  109972. }
  109973. declare module BABYLON {
  109974. /**
  109975. * States of the webXR experience
  109976. */
  109977. export enum WebXRState {
  109978. /**
  109979. * Transitioning to being in XR mode
  109980. */
  109981. ENTERING_XR = 0,
  109982. /**
  109983. * Transitioning to non XR mode
  109984. */
  109985. EXITING_XR = 1,
  109986. /**
  109987. * In XR mode and presenting
  109988. */
  109989. IN_XR = 2,
  109990. /**
  109991. * Not entered XR mode
  109992. */
  109993. NOT_IN_XR = 3
  109994. }
  109995. /**
  109996. * Abstraction of the XR render target
  109997. */
  109998. export interface WebXRRenderTarget extends IDisposable {
  109999. /**
  110000. * xrpresent context of the canvas which can be used to display/mirror xr content
  110001. */
  110002. canvasContext: WebGLRenderingContext;
  110003. /**
  110004. * xr layer for the canvas
  110005. */
  110006. xrLayer: Nullable<XRWebGLLayer>;
  110007. /**
  110008. * Initializes the xr layer for the session
  110009. * @param xrSession xr session
  110010. * @returns a promise that will resolve once the XR Layer has been created
  110011. */
  110012. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110013. }
  110014. }
  110015. declare module BABYLON {
  110016. /**
  110017. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110018. */
  110019. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110020. private _engine;
  110021. private _canvas;
  110022. /**
  110023. * xrpresent context of the canvas which can be used to display/mirror xr content
  110024. */
  110025. canvasContext: WebGLRenderingContext;
  110026. /**
  110027. * xr layer for the canvas
  110028. */
  110029. xrLayer: Nullable<XRWebGLLayer>;
  110030. /**
  110031. * Initializes the xr layer for the session
  110032. * @param xrSession xr session
  110033. * @returns a promise that will resolve once the XR Layer has been created
  110034. */
  110035. initializeXRLayerAsync(xrSession: any): any;
  110036. /**
  110037. * Initializes the canvas to be added/removed upon entering/exiting xr
  110038. * @param engine the Babylon engine
  110039. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110040. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110041. */
  110042. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  110043. /**
  110044. * Disposes of the object
  110045. */
  110046. dispose(): void;
  110047. private _setManagedOutputCanvas;
  110048. private _addCanvas;
  110049. private _removeCanvas;
  110050. }
  110051. }
  110052. declare module BABYLON {
  110053. /**
  110054. * Manages an XRSession to work with Babylon's engine
  110055. * @see https://doc.babylonjs.com/how_to/webxr
  110056. */
  110057. export class WebXRSessionManager implements IDisposable {
  110058. private scene;
  110059. /**
  110060. * Fires every time a new xrFrame arrives which can be used to update the camera
  110061. */
  110062. onXRFrameObservable: Observable<any>;
  110063. /**
  110064. * Fires when the xr session is ended either by the device or manually done
  110065. */
  110066. onXRSessionEnded: Observable<any>;
  110067. /**
  110068. * Underlying xr session
  110069. */
  110070. session: XRSession;
  110071. /**
  110072. * Type of reference space used when creating the session
  110073. */
  110074. referenceSpace: XRReferenceSpace;
  110075. /**
  110076. * Current XR frame
  110077. */
  110078. currentFrame: Nullable<XRFrame>;
  110079. private _xrNavigator;
  110080. private baseLayer;
  110081. private _rttProvider;
  110082. private _sessionEnded;
  110083. /**
  110084. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110085. * @param scene The scene which the session should be created for
  110086. */
  110087. constructor(scene: Scene);
  110088. /**
  110089. * Initializes the manager
  110090. * After initialization enterXR can be called to start an XR session
  110091. * @returns Promise which resolves after it is initialized
  110092. */
  110093. initializeAsync(): Promise<void>;
  110094. /**
  110095. * Initializes an xr session
  110096. * @param xrSessionMode mode to initialize
  110097. * @param optionalFeatures defines optional values to pass to the session builder
  110098. * @returns a promise which will resolve once the session has been initialized
  110099. */
  110100. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  110101. /**
  110102. * Sets the reference space on the xr session
  110103. * @param referenceSpace space to set
  110104. * @returns a promise that will resolve once the reference space has been set
  110105. */
  110106. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110107. /**
  110108. * Updates the render state of the session
  110109. * @param state state to set
  110110. * @returns a promise that resolves once the render state has been updated
  110111. */
  110112. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110113. /**
  110114. * Starts rendering to the xr layer
  110115. * @returns a promise that will resolve once rendering has started
  110116. */
  110117. startRenderingToXRAsync(): Promise<void>;
  110118. /**
  110119. * Gets the correct render target texture to be rendered this frame for this eye
  110120. * @param eye the eye for which to get the render target
  110121. * @returns the render target for the specified eye
  110122. */
  110123. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110124. /**
  110125. * Stops the xrSession and restores the renderloop
  110126. * @returns Promise which resolves after it exits XR
  110127. */
  110128. exitXRAsync(): Promise<void>;
  110129. /**
  110130. * Checks if a session would be supported for the creation options specified
  110131. * @param sessionMode session mode to check if supported eg. immersive-vr
  110132. * @returns true if supported
  110133. */
  110134. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110135. /**
  110136. * Creates a WebXRRenderTarget object for the XR session
  110137. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110138. * @returns a WebXR render target to which the session can render
  110139. */
  110140. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  110141. /**
  110142. * @hidden
  110143. * Converts the render layer of xrSession to a render target
  110144. * @param session session to create render target for
  110145. * @param scene scene the new render target should be created for
  110146. */
  110147. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110148. /**
  110149. * Disposes of the session manager
  110150. */
  110151. dispose(): void;
  110152. }
  110153. }
  110154. declare module BABYLON {
  110155. /**
  110156. * WebXR Camera which holds the views for the xrSession
  110157. * @see https://doc.babylonjs.com/how_to/webxr
  110158. */
  110159. export class WebXRCamera extends FreeCamera {
  110160. private static _TmpMatrix;
  110161. /**
  110162. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110163. * @param name the name of the camera
  110164. * @param scene the scene to add the camera to
  110165. */
  110166. constructor(name: string, scene: Scene);
  110167. private _updateNumberOfRigCameras;
  110168. /** @hidden */
  110169. _updateForDualEyeDebugging(): void;
  110170. /**
  110171. * Updates the cameras position from the current pose information of the XR session
  110172. * @param xrSessionManager the session containing pose information
  110173. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110174. */
  110175. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110176. }
  110177. }
  110178. declare module BABYLON {
  110179. /**
  110180. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110181. * @see https://doc.babylonjs.com/how_to/webxr
  110182. */
  110183. export class WebXRExperienceHelper implements IDisposable {
  110184. private scene;
  110185. /**
  110186. * 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
  110187. */
  110188. container: AbstractMesh;
  110189. /**
  110190. * Camera used to render xr content
  110191. */
  110192. camera: WebXRCamera;
  110193. /**
  110194. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110195. */
  110196. state: WebXRState;
  110197. private _setState;
  110198. private static _TmpVector;
  110199. /**
  110200. * Fires when the state of the experience helper has changed
  110201. */
  110202. onStateChangedObservable: Observable<WebXRState>;
  110203. /** Session manager used to keep track of xr session */
  110204. sessionManager: WebXRSessionManager;
  110205. private _nonVRCamera;
  110206. private _originalSceneAutoClear;
  110207. private _supported;
  110208. /**
  110209. * Creates the experience helper
  110210. * @param scene the scene to attach the experience helper to
  110211. * @returns a promise for the experience helper
  110212. */
  110213. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110214. /**
  110215. * Creates a WebXRExperienceHelper
  110216. * @param scene The scene the helper should be created in
  110217. */
  110218. private constructor();
  110219. /**
  110220. * Exits XR mode and returns the scene to its original state
  110221. * @returns promise that resolves after xr mode has exited
  110222. */
  110223. exitXRAsync(): Promise<void>;
  110224. /**
  110225. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110226. * @param sessionMode options for the XR session
  110227. * @param referenceSpaceType frame of reference of the XR session
  110228. * @param renderTarget the output canvas that will be used to enter XR mode
  110229. * @returns promise that resolves after xr mode has entered
  110230. */
  110231. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  110232. /**
  110233. * Updates the global position of the camera by moving the camera's container
  110234. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110235. * @param position The desired global position of the camera
  110236. */
  110237. setPositionOfCameraUsingContainer(position: Vector3): void;
  110238. /**
  110239. * Rotates the xr camera by rotating the camera's container around the camera's position
  110240. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110241. * @param rotation the desired quaternion rotation to apply to the camera
  110242. */
  110243. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110244. /**
  110245. * Disposes of the experience helper
  110246. */
  110247. dispose(): void;
  110248. }
  110249. }
  110250. declare module BABYLON {
  110251. /**
  110252. * Button which can be used to enter a different mode of XR
  110253. */
  110254. export class WebXREnterExitUIButton {
  110255. /** button element */
  110256. element: HTMLElement;
  110257. /** XR initialization options for the button */
  110258. sessionMode: XRSessionMode;
  110259. /** Reference space type */
  110260. referenceSpaceType: XRReferenceSpaceType;
  110261. /**
  110262. * Creates a WebXREnterExitUIButton
  110263. * @param element button element
  110264. * @param sessionMode XR initialization session mode
  110265. * @param referenceSpaceType the type of reference space to be used
  110266. */
  110267. constructor(
  110268. /** button element */
  110269. element: HTMLElement,
  110270. /** XR initialization options for the button */
  110271. sessionMode: XRSessionMode,
  110272. /** Reference space type */
  110273. referenceSpaceType: XRReferenceSpaceType);
  110274. /**
  110275. * Overwritable function which can be used to update the button's visuals when the state changes
  110276. * @param activeButton the current active button in the UI
  110277. */
  110278. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110279. }
  110280. /**
  110281. * Options to create the webXR UI
  110282. */
  110283. export class WebXREnterExitUIOptions {
  110284. /**
  110285. * Context to enter xr with
  110286. */
  110287. renderTarget?: Nullable<WebXRRenderTarget>;
  110288. /**
  110289. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110290. */
  110291. customButtons?: Array<WebXREnterExitUIButton>;
  110292. }
  110293. /**
  110294. * UI to allow the user to enter/exit XR mode
  110295. */
  110296. export class WebXREnterExitUI implements IDisposable {
  110297. private scene;
  110298. private _overlay;
  110299. private _buttons;
  110300. private _activeButton;
  110301. /**
  110302. * Fired every time the active button is changed.
  110303. *
  110304. * When xr is entered via a button that launches xr that button will be the callback parameter
  110305. *
  110306. * When exiting xr the callback parameter will be null)
  110307. */
  110308. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110309. /**
  110310. * Creates UI to allow the user to enter/exit XR mode
  110311. * @param scene the scene to add the ui to
  110312. * @param helper the xr experience helper to enter/exit xr with
  110313. * @param options options to configure the UI
  110314. * @returns the created ui
  110315. */
  110316. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110317. private constructor();
  110318. private _updateButtons;
  110319. /**
  110320. * Disposes of the object
  110321. */
  110322. dispose(): void;
  110323. }
  110324. }
  110325. declare module BABYLON {
  110326. /**
  110327. * Represents an XR input
  110328. */
  110329. export class WebXRController {
  110330. private scene;
  110331. /** The underlying input source for the controller */
  110332. inputSource: XRInputSource;
  110333. private parentContainer;
  110334. /**
  110335. * 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
  110336. */
  110337. grip?: AbstractMesh;
  110338. /**
  110339. * Pointer which can be used to select objects or attach a visible laser to
  110340. */
  110341. pointer: AbstractMesh;
  110342. private _gamepadMode;
  110343. /**
  110344. * If available, this is the gamepad object related to this controller.
  110345. * Using this object it is possible to get click events and trackpad changes of the
  110346. * webxr controller that is currently being used.
  110347. */
  110348. gamepadController?: WebVRController;
  110349. /**
  110350. * Event that fires when the controller is removed/disposed
  110351. */
  110352. onDisposeObservable: Observable<{}>;
  110353. private _tmpMatrix;
  110354. private _tmpQuaternion;
  110355. private _tmpVector;
  110356. /**
  110357. * Creates the controller
  110358. * @see https://doc.babylonjs.com/how_to/webxr
  110359. * @param scene the scene which the controller should be associated to
  110360. * @param inputSource the underlying input source for the controller
  110361. * @param parentContainer parent that the controller meshes should be children of
  110362. */
  110363. constructor(scene: Scene,
  110364. /** The underlying input source for the controller */
  110365. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110366. /**
  110367. * Updates the controller pose based on the given XRFrame
  110368. * @param xrFrame xr frame to update the pose with
  110369. * @param referenceSpace reference space to use
  110370. */
  110371. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110372. /**
  110373. * Gets a world space ray coming from the controller
  110374. * @param result the resulting ray
  110375. */
  110376. getWorldPointerRayToRef(result: Ray): void;
  110377. /**
  110378. * Get the scene associated with this controller
  110379. * @returns the scene object
  110380. */
  110381. getScene(): Scene;
  110382. /**
  110383. * Disposes of the object
  110384. */
  110385. dispose(): void;
  110386. }
  110387. }
  110388. declare module BABYLON {
  110389. /**
  110390. * XR input used to track XR inputs such as controllers/rays
  110391. */
  110392. export class WebXRInput implements IDisposable {
  110393. /**
  110394. * Base experience the input listens to
  110395. */
  110396. baseExperience: WebXRExperienceHelper;
  110397. /**
  110398. * XR controllers being tracked
  110399. */
  110400. controllers: Array<WebXRController>;
  110401. private _frameObserver;
  110402. private _stateObserver;
  110403. /**
  110404. * Event when a controller has been connected/added
  110405. */
  110406. onControllerAddedObservable: Observable<WebXRController>;
  110407. /**
  110408. * Event when a controller has been removed/disconnected
  110409. */
  110410. onControllerRemovedObservable: Observable<WebXRController>;
  110411. /**
  110412. * Initializes the WebXRInput
  110413. * @param baseExperience experience helper which the input should be created for
  110414. */
  110415. constructor(
  110416. /**
  110417. * Base experience the input listens to
  110418. */
  110419. baseExperience: WebXRExperienceHelper);
  110420. private _onInputSourcesChange;
  110421. private _addAndRemoveControllers;
  110422. /**
  110423. * Disposes of the object
  110424. */
  110425. dispose(): void;
  110426. }
  110427. }
  110428. declare module BABYLON {
  110429. /**
  110430. * Enables teleportation
  110431. */
  110432. export class WebXRControllerTeleportation {
  110433. private _teleportationFillColor;
  110434. private _teleportationBorderColor;
  110435. private _tmpRay;
  110436. private _tmpVector;
  110437. /**
  110438. * Creates a WebXRControllerTeleportation
  110439. * @param input input manager to add teleportation to
  110440. * @param floorMeshes floormeshes which can be teleported to
  110441. */
  110442. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110443. }
  110444. }
  110445. declare module BABYLON {
  110446. /**
  110447. * Handles pointer input automatically for the pointer of XR controllers
  110448. */
  110449. export class WebXRControllerPointerSelection {
  110450. private static _idCounter;
  110451. private _tmpRay;
  110452. /**
  110453. * Creates a WebXRControllerPointerSelection
  110454. * @param input input manager to setup pointer selection
  110455. */
  110456. constructor(input: WebXRInput);
  110457. private _convertNormalToDirectionOfRay;
  110458. private _updatePointerDistance;
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. /**
  110463. * Class used to represent data loading progression
  110464. */
  110465. export class SceneLoaderProgressEvent {
  110466. /** defines if data length to load can be evaluated */
  110467. readonly lengthComputable: boolean;
  110468. /** defines the loaded data length */
  110469. readonly loaded: number;
  110470. /** defines the data length to load */
  110471. readonly total: number;
  110472. /**
  110473. * Create a new progress event
  110474. * @param lengthComputable defines if data length to load can be evaluated
  110475. * @param loaded defines the loaded data length
  110476. * @param total defines the data length to load
  110477. */
  110478. constructor(
  110479. /** defines if data length to load can be evaluated */
  110480. lengthComputable: boolean,
  110481. /** defines the loaded data length */
  110482. loaded: number,
  110483. /** defines the data length to load */
  110484. total: number);
  110485. /**
  110486. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110487. * @param event defines the source event
  110488. * @returns a new SceneLoaderProgressEvent
  110489. */
  110490. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110491. }
  110492. /**
  110493. * Interface used by SceneLoader plugins to define supported file extensions
  110494. */
  110495. export interface ISceneLoaderPluginExtensions {
  110496. /**
  110497. * Defines the list of supported extensions
  110498. */
  110499. [extension: string]: {
  110500. isBinary: boolean;
  110501. };
  110502. }
  110503. /**
  110504. * Interface used by SceneLoader plugin factory
  110505. */
  110506. export interface ISceneLoaderPluginFactory {
  110507. /**
  110508. * Defines the name of the factory
  110509. */
  110510. name: string;
  110511. /**
  110512. * Function called to create a new plugin
  110513. * @return the new plugin
  110514. */
  110515. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110516. /**
  110517. * The callback that returns true if the data can be directly loaded.
  110518. * @param data string containing the file data
  110519. * @returns if the data can be loaded directly
  110520. */
  110521. canDirectLoad?(data: string): boolean;
  110522. }
  110523. /**
  110524. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110525. */
  110526. export interface ISceneLoaderPluginBase {
  110527. /**
  110528. * The friendly name of this plugin.
  110529. */
  110530. name: string;
  110531. /**
  110532. * The file extensions supported by this plugin.
  110533. */
  110534. extensions: string | ISceneLoaderPluginExtensions;
  110535. /**
  110536. * The callback called when loading from a url.
  110537. * @param scene scene loading this url
  110538. * @param url url to load
  110539. * @param onSuccess callback called when the file successfully loads
  110540. * @param onProgress callback called while file is loading (if the server supports this mode)
  110541. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110542. * @param onError callback called when the file fails to load
  110543. * @returns a file request object
  110544. */
  110545. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110546. /**
  110547. * The callback called when loading from a file object.
  110548. * @param scene scene loading this file
  110549. * @param file defines the file to load
  110550. * @param onSuccess defines the callback to call when data is loaded
  110551. * @param onProgress defines the callback to call during loading process
  110552. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110553. * @param onError defines the callback to call when an error occurs
  110554. * @returns a file request object
  110555. */
  110556. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110557. /**
  110558. * The callback that returns true if the data can be directly loaded.
  110559. * @param data string containing the file data
  110560. * @returns if the data can be loaded directly
  110561. */
  110562. canDirectLoad?(data: string): boolean;
  110563. /**
  110564. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110565. * @param scene scene loading this data
  110566. * @param data string containing the data
  110567. * @returns data to pass to the plugin
  110568. */
  110569. directLoad?(scene: Scene, data: string): any;
  110570. /**
  110571. * The callback that allows custom handling of the root url based on the response url.
  110572. * @param rootUrl the original root url
  110573. * @param responseURL the response url if available
  110574. * @returns the new root url
  110575. */
  110576. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110577. }
  110578. /**
  110579. * Interface used to define a SceneLoader plugin
  110580. */
  110581. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110582. /**
  110583. * Import meshes into a scene.
  110584. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110585. * @param scene The scene to import into
  110586. * @param data The data to import
  110587. * @param rootUrl The root url for scene and resources
  110588. * @param meshes The meshes array to import into
  110589. * @param particleSystems The particle systems array to import into
  110590. * @param skeletons The skeletons array to import into
  110591. * @param onError The callback when import fails
  110592. * @returns True if successful or false otherwise
  110593. */
  110594. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110595. /**
  110596. * Load into a scene.
  110597. * @param scene The scene to load into
  110598. * @param data The data to import
  110599. * @param rootUrl The root url for scene and resources
  110600. * @param onError The callback when import fails
  110601. * @returns True if successful or false otherwise
  110602. */
  110603. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110604. /**
  110605. * Load into an asset container.
  110606. * @param scene The scene to load into
  110607. * @param data The data to import
  110608. * @param rootUrl The root url for scene and resources
  110609. * @param onError The callback when import fails
  110610. * @returns The loaded asset container
  110611. */
  110612. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110613. }
  110614. /**
  110615. * Interface used to define an async SceneLoader plugin
  110616. */
  110617. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110618. /**
  110619. * Import meshes into a scene.
  110620. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110621. * @param scene The scene to import into
  110622. * @param data The data to import
  110623. * @param rootUrl The root url for scene and resources
  110624. * @param onProgress The callback when the load progresses
  110625. * @param fileName Defines the name of the file to load
  110626. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110627. */
  110628. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110629. meshes: AbstractMesh[];
  110630. particleSystems: IParticleSystem[];
  110631. skeletons: Skeleton[];
  110632. animationGroups: AnimationGroup[];
  110633. }>;
  110634. /**
  110635. * Load into a scene.
  110636. * @param scene The scene to load into
  110637. * @param data The data to import
  110638. * @param rootUrl The root url for scene and resources
  110639. * @param onProgress The callback when the load progresses
  110640. * @param fileName Defines the name of the file to load
  110641. * @returns Nothing
  110642. */
  110643. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110644. /**
  110645. * Load into an asset container.
  110646. * @param scene The scene to load into
  110647. * @param data The data to import
  110648. * @param rootUrl The root url for scene and resources
  110649. * @param onProgress The callback when the load progresses
  110650. * @param fileName Defines the name of the file to load
  110651. * @returns The loaded asset container
  110652. */
  110653. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110654. }
  110655. /**
  110656. * Class used to load scene from various file formats using registered plugins
  110657. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110658. */
  110659. export class SceneLoader {
  110660. /**
  110661. * No logging while loading
  110662. */
  110663. static readonly NO_LOGGING: number;
  110664. /**
  110665. * Minimal logging while loading
  110666. */
  110667. static readonly MINIMAL_LOGGING: number;
  110668. /**
  110669. * Summary logging while loading
  110670. */
  110671. static readonly SUMMARY_LOGGING: number;
  110672. /**
  110673. * Detailled logging while loading
  110674. */
  110675. static readonly DETAILED_LOGGING: number;
  110676. /**
  110677. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110678. */
  110679. static ForceFullSceneLoadingForIncremental: boolean;
  110680. /**
  110681. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110682. */
  110683. static ShowLoadingScreen: boolean;
  110684. /**
  110685. * Defines the current logging level (while loading the scene)
  110686. * @ignorenaming
  110687. */
  110688. static loggingLevel: number;
  110689. /**
  110690. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110691. */
  110692. static CleanBoneMatrixWeights: boolean;
  110693. /**
  110694. * Event raised when a plugin is used to load a scene
  110695. */
  110696. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110697. private static _registeredPlugins;
  110698. private static _getDefaultPlugin;
  110699. private static _getPluginForExtension;
  110700. private static _getPluginForDirectLoad;
  110701. private static _getPluginForFilename;
  110702. private static _getDirectLoad;
  110703. private static _loadData;
  110704. private static _getFileInfo;
  110705. /**
  110706. * Gets a plugin that can load the given extension
  110707. * @param extension defines the extension to load
  110708. * @returns a plugin or null if none works
  110709. */
  110710. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110711. /**
  110712. * Gets a boolean indicating that the given extension can be loaded
  110713. * @param extension defines the extension to load
  110714. * @returns true if the extension is supported
  110715. */
  110716. static IsPluginForExtensionAvailable(extension: string): boolean;
  110717. /**
  110718. * Adds a new plugin to the list of registered plugins
  110719. * @param plugin defines the plugin to add
  110720. */
  110721. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110722. /**
  110723. * Import meshes into a scene
  110724. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110725. * @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)
  110726. * @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)
  110727. * @param scene the instance of BABYLON.Scene to append to
  110728. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110729. * @param onProgress a callback with a progress event for each file being loaded
  110730. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110731. * @param pluginExtension the extension used to determine the plugin
  110732. * @returns The loaded plugin
  110733. */
  110734. 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>;
  110735. /**
  110736. * Import meshes into a scene
  110737. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110738. * @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)
  110739. * @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)
  110740. * @param scene the instance of BABYLON.Scene to append to
  110741. * @param onProgress a callback with a progress event for each file being loaded
  110742. * @param pluginExtension the extension used to determine the plugin
  110743. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110744. */
  110745. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110746. meshes: AbstractMesh[];
  110747. particleSystems: IParticleSystem[];
  110748. skeletons: Skeleton[];
  110749. animationGroups: AnimationGroup[];
  110750. }>;
  110751. /**
  110752. * Load a scene
  110753. * @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)
  110754. * @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)
  110755. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110756. * @param onSuccess a callback with the scene when import succeeds
  110757. * @param onProgress a callback with a progress event for each file being loaded
  110758. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110759. * @param pluginExtension the extension used to determine the plugin
  110760. * @returns The loaded plugin
  110761. */
  110762. 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>;
  110763. /**
  110764. * Load a scene
  110765. * @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)
  110766. * @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)
  110767. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110768. * @param onProgress a callback with a progress event for each file being loaded
  110769. * @param pluginExtension the extension used to determine the plugin
  110770. * @returns The loaded scene
  110771. */
  110772. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110773. /**
  110774. * Append a scene
  110775. * @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)
  110776. * @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)
  110777. * @param scene is the instance of BABYLON.Scene to append to
  110778. * @param onSuccess a callback with the scene when import succeeds
  110779. * @param onProgress a callback with a progress event for each file being loaded
  110780. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110781. * @param pluginExtension the extension used to determine the plugin
  110782. * @returns The loaded plugin
  110783. */
  110784. 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>;
  110785. /**
  110786. * Append a scene
  110787. * @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)
  110788. * @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)
  110789. * @param scene is the instance of BABYLON.Scene to append to
  110790. * @param onProgress a callback with a progress event for each file being loaded
  110791. * @param pluginExtension the extension used to determine the plugin
  110792. * @returns The given scene
  110793. */
  110794. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110795. /**
  110796. * Load a scene into an asset container
  110797. * @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)
  110798. * @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)
  110799. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110800. * @param onSuccess a callback with the scene when import succeeds
  110801. * @param onProgress a callback with a progress event for each file being loaded
  110802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110803. * @param pluginExtension the extension used to determine the plugin
  110804. * @returns The loaded plugin
  110805. */
  110806. 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>;
  110807. /**
  110808. * Load a scene into an asset container
  110809. * @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)
  110810. * @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)
  110811. * @param scene is the instance of Scene to append to
  110812. * @param onProgress a callback with a progress event for each file being loaded
  110813. * @param pluginExtension the extension used to determine the plugin
  110814. * @returns The loaded asset container
  110815. */
  110816. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110817. }
  110818. }
  110819. declare module BABYLON {
  110820. /**
  110821. * Generic Controller
  110822. */
  110823. export class GenericController extends WebVRController {
  110824. /**
  110825. * Base Url for the controller model.
  110826. */
  110827. static readonly MODEL_BASE_URL: string;
  110828. /**
  110829. * File name for the controller model.
  110830. */
  110831. static readonly MODEL_FILENAME: string;
  110832. /**
  110833. * Creates a new GenericController from a gamepad
  110834. * @param vrGamepad the gamepad that the controller should be created from
  110835. */
  110836. constructor(vrGamepad: any);
  110837. /**
  110838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110839. * @param scene scene in which to add meshes
  110840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110841. */
  110842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110843. /**
  110844. * Called once for each button that changed state since the last frame
  110845. * @param buttonIdx Which button index changed
  110846. * @param state New state of the button
  110847. * @param changes Which properties on the state changed since last frame
  110848. */
  110849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110850. }
  110851. }
  110852. declare module BABYLON {
  110853. /**
  110854. * Defines the WindowsMotionController object that the state of the windows motion controller
  110855. */
  110856. export class WindowsMotionController extends WebVRController {
  110857. /**
  110858. * The base url used to load the left and right controller models
  110859. */
  110860. static MODEL_BASE_URL: string;
  110861. /**
  110862. * The name of the left controller model file
  110863. */
  110864. static MODEL_LEFT_FILENAME: string;
  110865. /**
  110866. * The name of the right controller model file
  110867. */
  110868. static MODEL_RIGHT_FILENAME: string;
  110869. /**
  110870. * The controller name prefix for this controller type
  110871. */
  110872. static readonly GAMEPAD_ID_PREFIX: string;
  110873. /**
  110874. * The controller id pattern for this controller type
  110875. */
  110876. private static readonly GAMEPAD_ID_PATTERN;
  110877. private _loadedMeshInfo;
  110878. private readonly _mapping;
  110879. /**
  110880. * Fired when the trackpad on this controller is clicked
  110881. */
  110882. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110883. /**
  110884. * Fired when the trackpad on this controller is modified
  110885. */
  110886. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110887. /**
  110888. * The current x and y values of this controller's trackpad
  110889. */
  110890. trackpad: StickValues;
  110891. /**
  110892. * Creates a new WindowsMotionController from a gamepad
  110893. * @param vrGamepad the gamepad that the controller should be created from
  110894. */
  110895. constructor(vrGamepad: any);
  110896. /**
  110897. * Fired when the trigger on this controller is modified
  110898. */
  110899. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110900. /**
  110901. * Fired when the menu button on this controller is modified
  110902. */
  110903. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110904. /**
  110905. * Fired when the grip button on this controller is modified
  110906. */
  110907. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110908. /**
  110909. * Fired when the thumbstick button on this controller is modified
  110910. */
  110911. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110912. /**
  110913. * Fired when the touchpad button on this controller is modified
  110914. */
  110915. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110916. /**
  110917. * Fired when the touchpad values on this controller are modified
  110918. */
  110919. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110920. private _updateTrackpad;
  110921. /**
  110922. * Called once per frame by the engine.
  110923. */
  110924. update(): void;
  110925. /**
  110926. * Called once for each button that changed state since the last frame
  110927. * @param buttonIdx Which button index changed
  110928. * @param state New state of the button
  110929. * @param changes Which properties on the state changed since last frame
  110930. */
  110931. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110932. /**
  110933. * Moves the buttons on the controller mesh based on their current state
  110934. * @param buttonName the name of the button to move
  110935. * @param buttonValue the value of the button which determines the buttons new position
  110936. */
  110937. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110938. /**
  110939. * Moves the axis on the controller mesh based on its current state
  110940. * @param axis the index of the axis
  110941. * @param axisValue the value of the axis which determines the meshes new position
  110942. * @hidden
  110943. */
  110944. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110945. /**
  110946. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110947. * @param scene scene in which to add meshes
  110948. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110949. */
  110950. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110951. /**
  110952. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110953. * can be transformed by button presses and axes values, based on this._mapping.
  110954. *
  110955. * @param scene scene in which the meshes exist
  110956. * @param meshes list of meshes that make up the controller model to process
  110957. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110958. */
  110959. private processModel;
  110960. private createMeshInfo;
  110961. /**
  110962. * Gets the ray of the controller in the direction the controller is pointing
  110963. * @param length the length the resulting ray should be
  110964. * @returns a ray in the direction the controller is pointing
  110965. */
  110966. getForwardRay(length?: number): Ray;
  110967. /**
  110968. * Disposes of the controller
  110969. */
  110970. dispose(): void;
  110971. }
  110972. }
  110973. declare module BABYLON {
  110974. /**
  110975. * Oculus Touch Controller
  110976. */
  110977. export class OculusTouchController extends WebVRController {
  110978. /**
  110979. * Base Url for the controller model.
  110980. */
  110981. static MODEL_BASE_URL: string;
  110982. /**
  110983. * File name for the left controller model.
  110984. */
  110985. static MODEL_LEFT_FILENAME: string;
  110986. /**
  110987. * File name for the right controller model.
  110988. */
  110989. static MODEL_RIGHT_FILENAME: string;
  110990. /**
  110991. * Base Url for the Quest controller model.
  110992. */
  110993. static QUEST_MODEL_BASE_URL: string;
  110994. /**
  110995. * @hidden
  110996. * If the controllers are running on a device that needs the updated Quest controller models
  110997. */
  110998. static _IsQuest: boolean;
  110999. /**
  111000. * Fired when the secondary trigger on this controller is modified
  111001. */
  111002. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111003. /**
  111004. * Fired when the thumb rest on this controller is modified
  111005. */
  111006. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111007. /**
  111008. * Creates a new OculusTouchController from a gamepad
  111009. * @param vrGamepad the gamepad that the controller should be created from
  111010. */
  111011. constructor(vrGamepad: any);
  111012. /**
  111013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111014. * @param scene scene in which to add meshes
  111015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111016. */
  111017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111018. /**
  111019. * Fired when the A button on this controller is modified
  111020. */
  111021. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111022. /**
  111023. * Fired when the B button on this controller is modified
  111024. */
  111025. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111026. /**
  111027. * Fired when the X button on this controller is modified
  111028. */
  111029. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111030. /**
  111031. * Fired when the Y button on this controller is modified
  111032. */
  111033. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111034. /**
  111035. * Called once for each button that changed state since the last frame
  111036. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111037. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111038. * 2) secondary trigger (same)
  111039. * 3) A (right) X (left), touch, pressed = value
  111040. * 4) B / Y
  111041. * 5) thumb rest
  111042. * @param buttonIdx Which button index changed
  111043. * @param state New state of the button
  111044. * @param changes Which properties on the state changed since last frame
  111045. */
  111046. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111047. }
  111048. }
  111049. declare module BABYLON {
  111050. /**
  111051. * Vive Controller
  111052. */
  111053. export class ViveController extends WebVRController {
  111054. /**
  111055. * Base Url for the controller model.
  111056. */
  111057. static MODEL_BASE_URL: string;
  111058. /**
  111059. * File name for the controller model.
  111060. */
  111061. static MODEL_FILENAME: string;
  111062. /**
  111063. * Creates a new ViveController from a gamepad
  111064. * @param vrGamepad the gamepad that the controller should be created from
  111065. */
  111066. constructor(vrGamepad: any);
  111067. /**
  111068. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111069. * @param scene scene in which to add meshes
  111070. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111071. */
  111072. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111073. /**
  111074. * Fired when the left button on this controller is modified
  111075. */
  111076. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111077. /**
  111078. * Fired when the right button on this controller is modified
  111079. */
  111080. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111081. /**
  111082. * Fired when the menu button on this controller is modified
  111083. */
  111084. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111085. /**
  111086. * Called once for each button that changed state since the last frame
  111087. * Vive mapping:
  111088. * 0: touchpad
  111089. * 1: trigger
  111090. * 2: left AND right buttons
  111091. * 3: menu button
  111092. * @param buttonIdx Which button index changed
  111093. * @param state New state of the button
  111094. * @param changes Which properties on the state changed since last frame
  111095. */
  111096. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111102. */
  111103. export class WebXRControllerModelLoader {
  111104. /**
  111105. * Creates the WebXRControllerModelLoader
  111106. * @param input xr input that creates the controllers
  111107. */
  111108. constructor(input: WebXRInput);
  111109. }
  111110. }
  111111. declare module BABYLON {
  111112. /**
  111113. * Contains an array of blocks representing the octree
  111114. */
  111115. export interface IOctreeContainer<T> {
  111116. /**
  111117. * Blocks within the octree
  111118. */
  111119. blocks: Array<OctreeBlock<T>>;
  111120. }
  111121. /**
  111122. * Class used to store a cell in an octree
  111123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111124. */
  111125. export class OctreeBlock<T> {
  111126. /**
  111127. * Gets the content of the current block
  111128. */
  111129. entries: T[];
  111130. /**
  111131. * Gets the list of block children
  111132. */
  111133. blocks: Array<OctreeBlock<T>>;
  111134. private _depth;
  111135. private _maxDepth;
  111136. private _capacity;
  111137. private _minPoint;
  111138. private _maxPoint;
  111139. private _boundingVectors;
  111140. private _creationFunc;
  111141. /**
  111142. * Creates a new block
  111143. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111144. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111145. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111146. * @param depth defines the current depth of this block in the octree
  111147. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111148. * @param creationFunc defines a callback to call when an element is added to the block
  111149. */
  111150. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111151. /**
  111152. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111153. */
  111154. readonly capacity: number;
  111155. /**
  111156. * Gets the minimum vector (in world space) of the block's bounding box
  111157. */
  111158. readonly minPoint: Vector3;
  111159. /**
  111160. * Gets the maximum vector (in world space) of the block's bounding box
  111161. */
  111162. readonly maxPoint: Vector3;
  111163. /**
  111164. * Add a new element to this block
  111165. * @param entry defines the element to add
  111166. */
  111167. addEntry(entry: T): void;
  111168. /**
  111169. * Remove an element from this block
  111170. * @param entry defines the element to remove
  111171. */
  111172. removeEntry(entry: T): void;
  111173. /**
  111174. * Add an array of elements to this block
  111175. * @param entries defines the array of elements to add
  111176. */
  111177. addEntries(entries: T[]): void;
  111178. /**
  111179. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111180. * @param frustumPlanes defines the frustum planes to test
  111181. * @param selection defines the array to store current content if selection is positive
  111182. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111183. */
  111184. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111185. /**
  111186. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111187. * @param sphereCenter defines the bounding sphere center
  111188. * @param sphereRadius defines the bounding sphere radius
  111189. * @param selection defines the array to store current content if selection is positive
  111190. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111191. */
  111192. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111193. /**
  111194. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111195. * @param ray defines the ray to test with
  111196. * @param selection defines the array to store current content if selection is positive
  111197. */
  111198. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111199. /**
  111200. * Subdivide the content into child blocks (this block will then be empty)
  111201. */
  111202. createInnerBlocks(): void;
  111203. /**
  111204. * @hidden
  111205. */
  111206. 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;
  111207. }
  111208. }
  111209. declare module BABYLON {
  111210. /**
  111211. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111213. */
  111214. export class Octree<T> {
  111215. /** 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.) */
  111216. maxDepth: number;
  111217. /**
  111218. * Blocks within the octree containing objects
  111219. */
  111220. blocks: Array<OctreeBlock<T>>;
  111221. /**
  111222. * Content stored in the octree
  111223. */
  111224. dynamicContent: T[];
  111225. private _maxBlockCapacity;
  111226. private _selectionContent;
  111227. private _creationFunc;
  111228. /**
  111229. * Creates a octree
  111230. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111231. * @param creationFunc function to be used to instatiate the octree
  111232. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111233. * @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.)
  111234. */
  111235. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111236. /** 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.) */
  111237. maxDepth?: number);
  111238. /**
  111239. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111240. * @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);
  111241. * @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);
  111242. * @param entries meshes to be added to the octree blocks
  111243. */
  111244. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111245. /**
  111246. * Adds a mesh to the octree
  111247. * @param entry Mesh to add to the octree
  111248. */
  111249. addMesh(entry: T): void;
  111250. /**
  111251. * Remove an element from the octree
  111252. * @param entry defines the element to remove
  111253. */
  111254. removeMesh(entry: T): void;
  111255. /**
  111256. * Selects an array of meshes within the frustum
  111257. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111258. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111259. * @returns array of meshes within the frustum
  111260. */
  111261. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111262. /**
  111263. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111264. * @param sphereCenter defines the bounding sphere center
  111265. * @param sphereRadius defines the bounding sphere radius
  111266. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111267. * @returns an array of objects that intersect the sphere
  111268. */
  111269. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111270. /**
  111271. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111272. * @param ray defines the ray to test with
  111273. * @returns array of intersected objects
  111274. */
  111275. intersectsRay(ray: Ray): SmartArray<T>;
  111276. /**
  111277. * Adds a mesh into the octree block if it intersects the block
  111278. */
  111279. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111280. /**
  111281. * Adds a submesh into the octree block if it intersects the block
  111282. */
  111283. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111284. }
  111285. }
  111286. declare module BABYLON {
  111287. interface Scene {
  111288. /**
  111289. * @hidden
  111290. * Backing Filed
  111291. */
  111292. _selectionOctree: Octree<AbstractMesh>;
  111293. /**
  111294. * Gets the octree used to boost mesh selection (picking)
  111295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111296. */
  111297. selectionOctree: Octree<AbstractMesh>;
  111298. /**
  111299. * Creates or updates the octree used to boost selection (picking)
  111300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111301. * @param maxCapacity defines the maximum capacity per leaf
  111302. * @param maxDepth defines the maximum depth of the octree
  111303. * @returns an octree of AbstractMesh
  111304. */
  111305. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111306. }
  111307. interface AbstractMesh {
  111308. /**
  111309. * @hidden
  111310. * Backing Field
  111311. */
  111312. _submeshesOctree: Octree<SubMesh>;
  111313. /**
  111314. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111315. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111316. * @param maxCapacity defines the maximum size of each block (64 by default)
  111317. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111318. * @returns the new octree
  111319. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111321. */
  111322. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111323. }
  111324. /**
  111325. * Defines the octree scene component responsible to manage any octrees
  111326. * in a given scene.
  111327. */
  111328. export class OctreeSceneComponent {
  111329. /**
  111330. * The component name help to identify the component in the list of scene components.
  111331. */
  111332. readonly name: string;
  111333. /**
  111334. * The scene the component belongs to.
  111335. */
  111336. scene: Scene;
  111337. /**
  111338. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111339. */
  111340. readonly checksIsEnabled: boolean;
  111341. /**
  111342. * Creates a new instance of the component for the given scene
  111343. * @param scene Defines the scene to register the component in
  111344. */
  111345. constructor(scene: Scene);
  111346. /**
  111347. * Registers the component in a given scene
  111348. */
  111349. register(): void;
  111350. /**
  111351. * Return the list of active meshes
  111352. * @returns the list of active meshes
  111353. */
  111354. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111355. /**
  111356. * Return the list of active sub meshes
  111357. * @param mesh The mesh to get the candidates sub meshes from
  111358. * @returns the list of active sub meshes
  111359. */
  111360. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111361. private _tempRay;
  111362. /**
  111363. * Return the list of sub meshes intersecting with a given local ray
  111364. * @param mesh defines the mesh to find the submesh for
  111365. * @param localRay defines the ray in local space
  111366. * @returns the list of intersecting sub meshes
  111367. */
  111368. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111369. /**
  111370. * Return the list of sub meshes colliding with a collider
  111371. * @param mesh defines the mesh to find the submesh for
  111372. * @param collider defines the collider to evaluate the collision against
  111373. * @returns the list of colliding sub meshes
  111374. */
  111375. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111376. /**
  111377. * Rebuilds the elements related to this component in case of
  111378. * context lost for instance.
  111379. */
  111380. rebuild(): void;
  111381. /**
  111382. * Disposes the component and the associated ressources.
  111383. */
  111384. dispose(): void;
  111385. }
  111386. }
  111387. declare module BABYLON {
  111388. /**
  111389. * Renders a layer on top of an existing scene
  111390. */
  111391. export class UtilityLayerRenderer implements IDisposable {
  111392. /** the original scene that will be rendered on top of */
  111393. originalScene: Scene;
  111394. private _pointerCaptures;
  111395. private _lastPointerEvents;
  111396. private static _DefaultUtilityLayer;
  111397. private static _DefaultKeepDepthUtilityLayer;
  111398. private _sharedGizmoLight;
  111399. private _renderCamera;
  111400. /**
  111401. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111402. * @returns the camera that is used when rendering the utility layer
  111403. */
  111404. getRenderCamera(): Nullable<Camera>;
  111405. /**
  111406. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111407. * @param cam the camera that should be used when rendering the utility layer
  111408. */
  111409. setRenderCamera(cam: Nullable<Camera>): void;
  111410. /**
  111411. * @hidden
  111412. * Light which used by gizmos to get light shading
  111413. */
  111414. _getSharedGizmoLight(): HemisphericLight;
  111415. /**
  111416. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111417. */
  111418. pickUtilitySceneFirst: boolean;
  111419. /**
  111420. * 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)
  111421. */
  111422. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111423. /**
  111424. * 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)
  111425. */
  111426. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111427. /**
  111428. * The scene that is rendered on top of the original scene
  111429. */
  111430. utilityLayerScene: Scene;
  111431. /**
  111432. * If the utility layer should automatically be rendered on top of existing scene
  111433. */
  111434. shouldRender: boolean;
  111435. /**
  111436. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111437. */
  111438. onlyCheckPointerDownEvents: boolean;
  111439. /**
  111440. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111441. */
  111442. processAllEvents: boolean;
  111443. /**
  111444. * Observable raised when the pointer move from the utility layer scene to the main scene
  111445. */
  111446. onPointerOutObservable: Observable<number>;
  111447. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111448. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111449. private _afterRenderObserver;
  111450. private _sceneDisposeObserver;
  111451. private _originalPointerObserver;
  111452. /**
  111453. * Instantiates a UtilityLayerRenderer
  111454. * @param originalScene the original scene that will be rendered on top of
  111455. * @param handleEvents boolean indicating if the utility layer should handle events
  111456. */
  111457. constructor(
  111458. /** the original scene that will be rendered on top of */
  111459. originalScene: Scene, handleEvents?: boolean);
  111460. private _notifyObservers;
  111461. /**
  111462. * Renders the utility layers scene on top of the original scene
  111463. */
  111464. render(): void;
  111465. /**
  111466. * Disposes of the renderer
  111467. */
  111468. dispose(): void;
  111469. private _updateCamera;
  111470. }
  111471. }
  111472. declare module BABYLON {
  111473. /**
  111474. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111475. */
  111476. export class Gizmo implements IDisposable {
  111477. /** The utility layer the gizmo will be added to */
  111478. gizmoLayer: UtilityLayerRenderer;
  111479. /**
  111480. * The root mesh of the gizmo
  111481. */
  111482. _rootMesh: Mesh;
  111483. private _attachedMesh;
  111484. /**
  111485. * Ratio for the scale of the gizmo (Default: 1)
  111486. */
  111487. scaleRatio: number;
  111488. /**
  111489. * If a custom mesh has been set (Default: false)
  111490. */
  111491. protected _customMeshSet: boolean;
  111492. /**
  111493. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111494. * * When set, interactions will be enabled
  111495. */
  111496. attachedMesh: Nullable<AbstractMesh>;
  111497. /**
  111498. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111499. * @param mesh The mesh to replace the default mesh of the gizmo
  111500. */
  111501. setCustomMesh(mesh: Mesh): void;
  111502. /**
  111503. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111504. */
  111505. updateGizmoRotationToMatchAttachedMesh: boolean;
  111506. /**
  111507. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111508. */
  111509. updateGizmoPositionToMatchAttachedMesh: boolean;
  111510. /**
  111511. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111512. */
  111513. updateScale: boolean;
  111514. protected _interactionsEnabled: boolean;
  111515. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111516. private _beforeRenderObserver;
  111517. private _tempVector;
  111518. /**
  111519. * Creates a gizmo
  111520. * @param gizmoLayer The utility layer the gizmo will be added to
  111521. */
  111522. constructor(
  111523. /** The utility layer the gizmo will be added to */
  111524. gizmoLayer?: UtilityLayerRenderer);
  111525. /**
  111526. * Updates the gizmo to match the attached mesh's position/rotation
  111527. */
  111528. protected _update(): void;
  111529. /**
  111530. * Disposes of the gizmo
  111531. */
  111532. dispose(): void;
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * Single plane drag gizmo
  111538. */
  111539. export class PlaneDragGizmo extends Gizmo {
  111540. /**
  111541. * Drag behavior responsible for the gizmos dragging interactions
  111542. */
  111543. dragBehavior: PointerDragBehavior;
  111544. private _pointerObserver;
  111545. /**
  111546. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111547. */
  111548. snapDistance: number;
  111549. /**
  111550. * Event that fires each time the gizmo snaps to a new location.
  111551. * * snapDistance is the the change in distance
  111552. */
  111553. onSnapObservable: Observable<{
  111554. snapDistance: number;
  111555. }>;
  111556. private _plane;
  111557. private _coloredMaterial;
  111558. private _hoverMaterial;
  111559. private _isEnabled;
  111560. private _parent;
  111561. /** @hidden */
  111562. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111563. /** @hidden */
  111564. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111565. /**
  111566. * Creates a PlaneDragGizmo
  111567. * @param gizmoLayer The utility layer the gizmo will be added to
  111568. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111569. * @param color The color of the gizmo
  111570. */
  111571. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111572. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111573. /**
  111574. * If the gizmo is enabled
  111575. */
  111576. isEnabled: boolean;
  111577. /**
  111578. * Disposes of the gizmo
  111579. */
  111580. dispose(): void;
  111581. }
  111582. }
  111583. declare module BABYLON {
  111584. /**
  111585. * Gizmo that enables dragging a mesh along 3 axis
  111586. */
  111587. export class PositionGizmo extends Gizmo {
  111588. /**
  111589. * Internal gizmo used for interactions on the x axis
  111590. */
  111591. xGizmo: AxisDragGizmo;
  111592. /**
  111593. * Internal gizmo used for interactions on the y axis
  111594. */
  111595. yGizmo: AxisDragGizmo;
  111596. /**
  111597. * Internal gizmo used for interactions on the z axis
  111598. */
  111599. zGizmo: AxisDragGizmo;
  111600. /**
  111601. * Internal gizmo used for interactions on the yz plane
  111602. */
  111603. xPlaneGizmo: PlaneDragGizmo;
  111604. /**
  111605. * Internal gizmo used for interactions on the xz plane
  111606. */
  111607. yPlaneGizmo: PlaneDragGizmo;
  111608. /**
  111609. * Internal gizmo used for interactions on the xy plane
  111610. */
  111611. zPlaneGizmo: PlaneDragGizmo;
  111612. /**
  111613. * private variables
  111614. */
  111615. private _meshAttached;
  111616. private _updateGizmoRotationToMatchAttachedMesh;
  111617. private _snapDistance;
  111618. private _scaleRatio;
  111619. /** Fires an event when any of it's sub gizmos are dragged */
  111620. onDragStartObservable: Observable<unknown>;
  111621. /** Fires an event when any of it's sub gizmos are released from dragging */
  111622. onDragEndObservable: Observable<unknown>;
  111623. /**
  111624. * If set to true, planar drag is enabled
  111625. */
  111626. private _planarGizmoEnabled;
  111627. attachedMesh: Nullable<AbstractMesh>;
  111628. /**
  111629. * Creates a PositionGizmo
  111630. * @param gizmoLayer The utility layer the gizmo will be added to
  111631. */
  111632. constructor(gizmoLayer?: UtilityLayerRenderer);
  111633. /**
  111634. * If the planar drag gizmo is enabled
  111635. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  111636. */
  111637. planarGizmoEnabled: boolean;
  111638. updateGizmoRotationToMatchAttachedMesh: boolean;
  111639. /**
  111640. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111641. */
  111642. snapDistance: number;
  111643. /**
  111644. * Ratio for the scale of the gizmo (Default: 1)
  111645. */
  111646. scaleRatio: number;
  111647. /**
  111648. * Disposes of the gizmo
  111649. */
  111650. dispose(): void;
  111651. /**
  111652. * CustomMeshes are not supported by this gizmo
  111653. * @param mesh The mesh to replace the default mesh of the gizmo
  111654. */
  111655. setCustomMesh(mesh: Mesh): void;
  111656. }
  111657. }
  111658. declare module BABYLON {
  111659. /**
  111660. * Single axis drag gizmo
  111661. */
  111662. export class AxisDragGizmo extends Gizmo {
  111663. /**
  111664. * Drag behavior responsible for the gizmos dragging interactions
  111665. */
  111666. dragBehavior: PointerDragBehavior;
  111667. private _pointerObserver;
  111668. /**
  111669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111670. */
  111671. snapDistance: number;
  111672. /**
  111673. * Event that fires each time the gizmo snaps to a new location.
  111674. * * snapDistance is the the change in distance
  111675. */
  111676. onSnapObservable: Observable<{
  111677. snapDistance: number;
  111678. }>;
  111679. private _isEnabled;
  111680. private _parent;
  111681. private _arrow;
  111682. private _coloredMaterial;
  111683. private _hoverMaterial;
  111684. /** @hidden */
  111685. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  111686. /** @hidden */
  111687. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111688. /**
  111689. * Creates an AxisDragGizmo
  111690. * @param gizmoLayer The utility layer the gizmo will be added to
  111691. * @param dragAxis The axis which the gizmo will be able to drag on
  111692. * @param color The color of the gizmo
  111693. */
  111694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111696. /**
  111697. * If the gizmo is enabled
  111698. */
  111699. isEnabled: boolean;
  111700. /**
  111701. * Disposes of the gizmo
  111702. */
  111703. dispose(): void;
  111704. }
  111705. }
  111706. declare module BABYLON.Debug {
  111707. /**
  111708. * The Axes viewer will show 3 axes in a specific point in space
  111709. */
  111710. export class AxesViewer {
  111711. private _xAxis;
  111712. private _yAxis;
  111713. private _zAxis;
  111714. private _scaleLinesFactor;
  111715. private _instanced;
  111716. /**
  111717. * Gets the hosting scene
  111718. */
  111719. scene: Scene;
  111720. /**
  111721. * Gets or sets a number used to scale line length
  111722. */
  111723. scaleLines: number;
  111724. /** Gets the node hierarchy used to render x-axis */
  111725. readonly xAxis: TransformNode;
  111726. /** Gets the node hierarchy used to render y-axis */
  111727. readonly yAxis: TransformNode;
  111728. /** Gets the node hierarchy used to render z-axis */
  111729. readonly zAxis: TransformNode;
  111730. /**
  111731. * Creates a new AxesViewer
  111732. * @param scene defines the hosting scene
  111733. * @param scaleLines defines a number used to scale line length (1 by default)
  111734. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  111735. * @param xAxis defines the node hierarchy used to render the x-axis
  111736. * @param yAxis defines the node hierarchy used to render the y-axis
  111737. * @param zAxis defines the node hierarchy used to render the z-axis
  111738. */
  111739. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  111740. /**
  111741. * Force the viewer to update
  111742. * @param position defines the position of the viewer
  111743. * @param xaxis defines the x axis of the viewer
  111744. * @param yaxis defines the y axis of the viewer
  111745. * @param zaxis defines the z axis of the viewer
  111746. */
  111747. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  111748. /**
  111749. * Creates an instance of this axes viewer.
  111750. * @returns a new axes viewer with instanced meshes
  111751. */
  111752. createInstance(): AxesViewer;
  111753. /** Releases resources */
  111754. dispose(): void;
  111755. private static _SetRenderingGroupId;
  111756. }
  111757. }
  111758. declare module BABYLON.Debug {
  111759. /**
  111760. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  111761. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  111762. */
  111763. export class BoneAxesViewer extends AxesViewer {
  111764. /**
  111765. * Gets or sets the target mesh where to display the axes viewer
  111766. */
  111767. mesh: Nullable<Mesh>;
  111768. /**
  111769. * Gets or sets the target bone where to display the axes viewer
  111770. */
  111771. bone: Nullable<Bone>;
  111772. /** Gets current position */
  111773. pos: Vector3;
  111774. /** Gets direction of X axis */
  111775. xaxis: Vector3;
  111776. /** Gets direction of Y axis */
  111777. yaxis: Vector3;
  111778. /** Gets direction of Z axis */
  111779. zaxis: Vector3;
  111780. /**
  111781. * Creates a new BoneAxesViewer
  111782. * @param scene defines the hosting scene
  111783. * @param bone defines the target bone
  111784. * @param mesh defines the target mesh
  111785. * @param scaleLines defines a scaling factor for line length (1 by default)
  111786. */
  111787. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  111788. /**
  111789. * Force the viewer to update
  111790. */
  111791. update(): void;
  111792. /** Releases resources */
  111793. dispose(): void;
  111794. }
  111795. }
  111796. declare module BABYLON {
  111797. /**
  111798. * Interface used to define scene explorer extensibility option
  111799. */
  111800. export interface IExplorerExtensibilityOption {
  111801. /**
  111802. * Define the option label
  111803. */
  111804. label: string;
  111805. /**
  111806. * Defines the action to execute on click
  111807. */
  111808. action: (entity: any) => void;
  111809. }
  111810. /**
  111811. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111812. */
  111813. export interface IExplorerExtensibilityGroup {
  111814. /**
  111815. * Defines a predicate to test if a given type mut be extended
  111816. */
  111817. predicate: (entity: any) => boolean;
  111818. /**
  111819. * Gets the list of options added to a type
  111820. */
  111821. entries: IExplorerExtensibilityOption[];
  111822. }
  111823. /**
  111824. * Interface used to define the options to use to create the Inspector
  111825. */
  111826. export interface IInspectorOptions {
  111827. /**
  111828. * Display in overlay mode (default: false)
  111829. */
  111830. overlay?: boolean;
  111831. /**
  111832. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111833. */
  111834. globalRoot?: HTMLElement;
  111835. /**
  111836. * Display the Scene explorer
  111837. */
  111838. showExplorer?: boolean;
  111839. /**
  111840. * Display the property inspector
  111841. */
  111842. showInspector?: boolean;
  111843. /**
  111844. * Display in embed mode (both panes on the right)
  111845. */
  111846. embedMode?: boolean;
  111847. /**
  111848. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111849. */
  111850. handleResize?: boolean;
  111851. /**
  111852. * Allow the panes to popup (default: true)
  111853. */
  111854. enablePopup?: boolean;
  111855. /**
  111856. * Allow the panes to be closed by users (default: true)
  111857. */
  111858. enableClose?: boolean;
  111859. /**
  111860. * Optional list of extensibility entries
  111861. */
  111862. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111863. /**
  111864. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111865. */
  111866. inspectorURL?: string;
  111867. }
  111868. interface Scene {
  111869. /**
  111870. * @hidden
  111871. * Backing field
  111872. */
  111873. _debugLayer: DebugLayer;
  111874. /**
  111875. * Gets the debug layer (aka Inspector) associated with the scene
  111876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111877. */
  111878. debugLayer: DebugLayer;
  111879. }
  111880. /**
  111881. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111882. * what is happening in your scene
  111883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111884. */
  111885. export class DebugLayer {
  111886. /**
  111887. * Define the url to get the inspector script from.
  111888. * By default it uses the babylonjs CDN.
  111889. * @ignoreNaming
  111890. */
  111891. static InspectorURL: string;
  111892. private _scene;
  111893. private BJSINSPECTOR;
  111894. private _onPropertyChangedObservable?;
  111895. /**
  111896. * Observable triggered when a property is changed through the inspector.
  111897. */
  111898. readonly onPropertyChangedObservable: any;
  111899. /**
  111900. * Instantiates a new debug layer.
  111901. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111902. * what is happening in your scene
  111903. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111904. * @param scene Defines the scene to inspect
  111905. */
  111906. constructor(scene: Scene);
  111907. /** Creates the inspector window. */
  111908. private _createInspector;
  111909. /**
  111910. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111911. * @param entity defines the entity to select
  111912. * @param lineContainerTitle defines the specific block to highlight
  111913. */
  111914. select(entity: any, lineContainerTitle?: string): void;
  111915. /** Get the inspector from bundle or global */
  111916. private _getGlobalInspector;
  111917. /**
  111918. * Get if the inspector is visible or not.
  111919. * @returns true if visible otherwise, false
  111920. */
  111921. isVisible(): boolean;
  111922. /**
  111923. * Hide the inspector and close its window.
  111924. */
  111925. hide(): void;
  111926. /**
  111927. * Launch the debugLayer.
  111928. * @param config Define the configuration of the inspector
  111929. * @return a promise fulfilled when the debug layer is visible
  111930. */
  111931. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111932. }
  111933. }
  111934. declare module BABYLON {
  111935. /**
  111936. * Class containing static functions to help procedurally build meshes
  111937. */
  111938. export class BoxBuilder {
  111939. /**
  111940. * Creates a box mesh
  111941. * * The parameter `size` sets the size (float) of each box side (default 1)
  111942. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111943. * * 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)
  111944. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111948. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111949. * @param name defines the name of the mesh
  111950. * @param options defines the options used to create the mesh
  111951. * @param scene defines the hosting scene
  111952. * @returns the box mesh
  111953. */
  111954. static CreateBox(name: string, options: {
  111955. size?: number;
  111956. width?: number;
  111957. height?: number;
  111958. depth?: number;
  111959. faceUV?: Vector4[];
  111960. faceColors?: Color4[];
  111961. sideOrientation?: number;
  111962. frontUVs?: Vector4;
  111963. backUVs?: Vector4;
  111964. wrap?: boolean;
  111965. topBaseAt?: number;
  111966. bottomBaseAt?: number;
  111967. updatable?: boolean;
  111968. }, scene?: Nullable<Scene>): Mesh;
  111969. }
  111970. }
  111971. declare module BABYLON {
  111972. /**
  111973. * Class containing static functions to help procedurally build meshes
  111974. */
  111975. export class SphereBuilder {
  111976. /**
  111977. * Creates a sphere mesh
  111978. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111979. * * 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`)
  111980. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111981. * * 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
  111982. * * 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)
  111983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111986. * @param name defines the name of the mesh
  111987. * @param options defines the options used to create the mesh
  111988. * @param scene defines the hosting scene
  111989. * @returns the sphere mesh
  111990. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111991. */
  111992. static CreateSphere(name: string, options: {
  111993. segments?: number;
  111994. diameter?: number;
  111995. diameterX?: number;
  111996. diameterY?: number;
  111997. diameterZ?: number;
  111998. arc?: number;
  111999. slice?: number;
  112000. sideOrientation?: number;
  112001. frontUVs?: Vector4;
  112002. backUVs?: Vector4;
  112003. updatable?: boolean;
  112004. }, scene?: Nullable<Scene>): Mesh;
  112005. }
  112006. }
  112007. declare module BABYLON.Debug {
  112008. /**
  112009. * Used to show the physics impostor around the specific mesh
  112010. */
  112011. export class PhysicsViewer {
  112012. /** @hidden */
  112013. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112014. /** @hidden */
  112015. protected _meshes: Array<Nullable<AbstractMesh>>;
  112016. /** @hidden */
  112017. protected _scene: Nullable<Scene>;
  112018. /** @hidden */
  112019. protected _numMeshes: number;
  112020. /** @hidden */
  112021. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112022. private _renderFunction;
  112023. private _utilityLayer;
  112024. private _debugBoxMesh;
  112025. private _debugSphereMesh;
  112026. private _debugCylinderMesh;
  112027. private _debugMaterial;
  112028. private _debugMeshMeshes;
  112029. /**
  112030. * Creates a new PhysicsViewer
  112031. * @param scene defines the hosting scene
  112032. */
  112033. constructor(scene: Scene);
  112034. /** @hidden */
  112035. protected _updateDebugMeshes(): void;
  112036. /**
  112037. * Renders a specified physic impostor
  112038. * @param impostor defines the impostor to render
  112039. * @param targetMesh defines the mesh represented by the impostor
  112040. * @returns the new debug mesh used to render the impostor
  112041. */
  112042. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112043. /**
  112044. * Hides a specified physic impostor
  112045. * @param impostor defines the impostor to hide
  112046. */
  112047. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112048. private _getDebugMaterial;
  112049. private _getDebugBoxMesh;
  112050. private _getDebugSphereMesh;
  112051. private _getDebugCylinderMesh;
  112052. private _getDebugMeshMesh;
  112053. private _getDebugMesh;
  112054. /** Releases all resources */
  112055. dispose(): void;
  112056. }
  112057. }
  112058. declare module BABYLON {
  112059. /**
  112060. * Class containing static functions to help procedurally build meshes
  112061. */
  112062. export class LinesBuilder {
  112063. /**
  112064. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112065. * * 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
  112066. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112067. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112068. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112069. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112071. * * 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
  112072. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112075. * @param name defines the name of the new line system
  112076. * @param options defines the options used to create the line system
  112077. * @param scene defines the hosting scene
  112078. * @returns a new line system mesh
  112079. */
  112080. static CreateLineSystem(name: string, options: {
  112081. lines: Vector3[][];
  112082. updatable?: boolean;
  112083. instance?: Nullable<LinesMesh>;
  112084. colors?: Nullable<Color4[][]>;
  112085. useVertexAlpha?: boolean;
  112086. }, scene: Nullable<Scene>): LinesMesh;
  112087. /**
  112088. * Creates a line mesh
  112089. * 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
  112090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112091. * * The parameter `points` is an array successive Vector3
  112092. * * 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
  112093. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112094. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112095. * * When updating an instance, remember that only point positions can change, not the number of points
  112096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112098. * @param name defines the name of the new line system
  112099. * @param options defines the options used to create the line system
  112100. * @param scene defines the hosting scene
  112101. * @returns a new line mesh
  112102. */
  112103. static CreateLines(name: string, options: {
  112104. points: Vector3[];
  112105. updatable?: boolean;
  112106. instance?: Nullable<LinesMesh>;
  112107. colors?: Color4[];
  112108. useVertexAlpha?: boolean;
  112109. }, scene?: Nullable<Scene>): LinesMesh;
  112110. /**
  112111. * Creates a dashed line mesh
  112112. * * 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
  112113. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112114. * * The parameter `points` is an array successive Vector3
  112115. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112116. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112117. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112118. * * 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
  112119. * * When updating an instance, remember that only point positions can change, not the number of points
  112120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112121. * @param name defines the name of the mesh
  112122. * @param options defines the options used to create the mesh
  112123. * @param scene defines the hosting scene
  112124. * @returns the dashed line mesh
  112125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112126. */
  112127. static CreateDashedLines(name: string, options: {
  112128. points: Vector3[];
  112129. dashSize?: number;
  112130. gapSize?: number;
  112131. dashNb?: number;
  112132. updatable?: boolean;
  112133. instance?: LinesMesh;
  112134. }, scene?: Nullable<Scene>): LinesMesh;
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112140. * in order to better appreciate the issue one might have.
  112141. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112142. */
  112143. export class RayHelper {
  112144. /**
  112145. * Defines the ray we are currently tryin to visualize.
  112146. */
  112147. ray: Nullable<Ray>;
  112148. private _renderPoints;
  112149. private _renderLine;
  112150. private _renderFunction;
  112151. private _scene;
  112152. private _updateToMeshFunction;
  112153. private _attachedToMesh;
  112154. private _meshSpaceDirection;
  112155. private _meshSpaceOrigin;
  112156. /**
  112157. * Helper function to create a colored helper in a scene in one line.
  112158. * @param ray Defines the ray we are currently tryin to visualize
  112159. * @param scene Defines the scene the ray is used in
  112160. * @param color Defines the color we want to see the ray in
  112161. * @returns The newly created ray helper.
  112162. */
  112163. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112164. /**
  112165. * Instantiate a new ray helper.
  112166. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112167. * in order to better appreciate the issue one might have.
  112168. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112169. * @param ray Defines the ray we are currently tryin to visualize
  112170. */
  112171. constructor(ray: Ray);
  112172. /**
  112173. * Shows the ray we are willing to debug.
  112174. * @param scene Defines the scene the ray needs to be rendered in
  112175. * @param color Defines the color the ray needs to be rendered in
  112176. */
  112177. show(scene: Scene, color?: Color3): void;
  112178. /**
  112179. * Hides the ray we are debugging.
  112180. */
  112181. hide(): void;
  112182. private _render;
  112183. /**
  112184. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112185. * @param mesh Defines the mesh we want the helper attached to
  112186. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112187. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112188. * @param length Defines the length of the ray
  112189. */
  112190. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112191. /**
  112192. * Detach the ray helper from the mesh it has previously been attached to.
  112193. */
  112194. detachFromMesh(): void;
  112195. private _updateToMesh;
  112196. /**
  112197. * Dispose the helper and release its associated resources.
  112198. */
  112199. dispose(): void;
  112200. }
  112201. }
  112202. declare module BABYLON.Debug {
  112203. /**
  112204. * Class used to render a debug view of a given skeleton
  112205. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112206. */
  112207. export class SkeletonViewer {
  112208. /** defines the skeleton to render */
  112209. skeleton: Skeleton;
  112210. /** defines the mesh attached to the skeleton */
  112211. mesh: AbstractMesh;
  112212. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112213. autoUpdateBonesMatrices: boolean;
  112214. /** defines the rendering group id to use with the viewer */
  112215. renderingGroupId: number;
  112216. /** Gets or sets the color used to render the skeleton */
  112217. color: Color3;
  112218. private _scene;
  112219. private _debugLines;
  112220. private _debugMesh;
  112221. private _isEnabled;
  112222. private _renderFunction;
  112223. private _utilityLayer;
  112224. /**
  112225. * Returns the mesh used to render the bones
  112226. */
  112227. readonly debugMesh: Nullable<LinesMesh>;
  112228. /**
  112229. * Creates a new SkeletonViewer
  112230. * @param skeleton defines the skeleton to render
  112231. * @param mesh defines the mesh attached to the skeleton
  112232. * @param scene defines the hosting scene
  112233. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112234. * @param renderingGroupId defines the rendering group id to use with the viewer
  112235. */
  112236. constructor(
  112237. /** defines the skeleton to render */
  112238. skeleton: Skeleton,
  112239. /** defines the mesh attached to the skeleton */
  112240. mesh: AbstractMesh, scene: Scene,
  112241. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112242. autoUpdateBonesMatrices?: boolean,
  112243. /** defines the rendering group id to use with the viewer */
  112244. renderingGroupId?: number);
  112245. /** Gets or sets a boolean indicating if the viewer is enabled */
  112246. isEnabled: boolean;
  112247. private _getBonePosition;
  112248. private _getLinesForBonesWithLength;
  112249. private _getLinesForBonesNoLength;
  112250. /** Update the viewer to sync with current skeleton state */
  112251. update(): void;
  112252. /** Release associated resources */
  112253. dispose(): void;
  112254. }
  112255. }
  112256. declare module BABYLON {
  112257. /**
  112258. * Options to create the null engine
  112259. */
  112260. export class NullEngineOptions {
  112261. /**
  112262. * Render width (Default: 512)
  112263. */
  112264. renderWidth: number;
  112265. /**
  112266. * Render height (Default: 256)
  112267. */
  112268. renderHeight: number;
  112269. /**
  112270. * Texture size (Default: 512)
  112271. */
  112272. textureSize: number;
  112273. /**
  112274. * If delta time between frames should be constant
  112275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112276. */
  112277. deterministicLockstep: boolean;
  112278. /**
  112279. * Maximum about of steps between frames (Default: 4)
  112280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112281. */
  112282. lockstepMaxSteps: number;
  112283. }
  112284. /**
  112285. * The null engine class provides support for headless version of babylon.js.
  112286. * This can be used in server side scenario or for testing purposes
  112287. */
  112288. export class NullEngine extends Engine {
  112289. private _options;
  112290. /**
  112291. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112292. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112293. * @returns true if engine is in deterministic lock step mode
  112294. */
  112295. isDeterministicLockStep(): boolean;
  112296. /**
  112297. * Gets the max steps when engine is running in deterministic lock step
  112298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112299. * @returns the max steps
  112300. */
  112301. getLockstepMaxSteps(): number;
  112302. /**
  112303. * Gets the current hardware scaling level.
  112304. * By default the hardware scaling level is computed from the window device ratio.
  112305. * 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.
  112306. * @returns a number indicating the current hardware scaling level
  112307. */
  112308. getHardwareScalingLevel(): number;
  112309. constructor(options?: NullEngineOptions);
  112310. /**
  112311. * Creates a vertex buffer
  112312. * @param vertices the data for the vertex buffer
  112313. * @returns the new WebGL static buffer
  112314. */
  112315. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112316. /**
  112317. * Creates a new index buffer
  112318. * @param indices defines the content of the index buffer
  112319. * @param updatable defines if the index buffer must be updatable
  112320. * @returns a new webGL buffer
  112321. */
  112322. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112323. /**
  112324. * Clear the current render buffer or the current render target (if any is set up)
  112325. * @param color defines the color to use
  112326. * @param backBuffer defines if the back buffer must be cleared
  112327. * @param depth defines if the depth buffer must be cleared
  112328. * @param stencil defines if the stencil buffer must be cleared
  112329. */
  112330. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112331. /**
  112332. * Gets the current render width
  112333. * @param useScreen defines if screen size must be used (or the current render target if any)
  112334. * @returns a number defining the current render width
  112335. */
  112336. getRenderWidth(useScreen?: boolean): number;
  112337. /**
  112338. * Gets the current render height
  112339. * @param useScreen defines if screen size must be used (or the current render target if any)
  112340. * @returns a number defining the current render height
  112341. */
  112342. getRenderHeight(useScreen?: boolean): number;
  112343. /**
  112344. * Set the WebGL's viewport
  112345. * @param viewport defines the viewport element to be used
  112346. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112347. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112348. */
  112349. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112350. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112351. /**
  112352. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112353. * @param pipelineContext defines the pipeline context to use
  112354. * @param uniformsNames defines the list of uniform names
  112355. * @returns an array of webGL uniform locations
  112356. */
  112357. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112358. /**
  112359. * Gets the lsit of active attributes for a given webGL program
  112360. * @param pipelineContext defines the pipeline context to use
  112361. * @param attributesNames defines the list of attribute names to get
  112362. * @returns an array of indices indicating the offset of each attribute
  112363. */
  112364. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112365. /**
  112366. * Binds an effect to the webGL context
  112367. * @param effect defines the effect to bind
  112368. */
  112369. bindSamplers(effect: Effect): void;
  112370. /**
  112371. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112372. * @param effect defines the effect to activate
  112373. */
  112374. enableEffect(effect: Effect): void;
  112375. /**
  112376. * Set various states to the webGL context
  112377. * @param culling defines backface culling state
  112378. * @param zOffset defines the value to apply to zOffset (0 by default)
  112379. * @param force defines if states must be applied even if cache is up to date
  112380. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112381. */
  112382. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112383. /**
  112384. * Set the value of an uniform to an array of int32
  112385. * @param uniform defines the webGL uniform location where to store the value
  112386. * @param array defines the array of int32 to store
  112387. */
  112388. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112389. /**
  112390. * Set the value of an uniform to an array of int32 (stored as vec2)
  112391. * @param uniform defines the webGL uniform location where to store the value
  112392. * @param array defines the array of int32 to store
  112393. */
  112394. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112395. /**
  112396. * Set the value of an uniform to an array of int32 (stored as vec3)
  112397. * @param uniform defines the webGL uniform location where to store the value
  112398. * @param array defines the array of int32 to store
  112399. */
  112400. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112401. /**
  112402. * Set the value of an uniform to an array of int32 (stored as vec4)
  112403. * @param uniform defines the webGL uniform location where to store the value
  112404. * @param array defines the array of int32 to store
  112405. */
  112406. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112407. /**
  112408. * Set the value of an uniform to an array of float32
  112409. * @param uniform defines the webGL uniform location where to store the value
  112410. * @param array defines the array of float32 to store
  112411. */
  112412. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112413. /**
  112414. * Set the value of an uniform to an array of float32 (stored as vec2)
  112415. * @param uniform defines the webGL uniform location where to store the value
  112416. * @param array defines the array of float32 to store
  112417. */
  112418. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112419. /**
  112420. * Set the value of an uniform to an array of float32 (stored as vec3)
  112421. * @param uniform defines the webGL uniform location where to store the value
  112422. * @param array defines the array of float32 to store
  112423. */
  112424. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112425. /**
  112426. * Set the value of an uniform to an array of float32 (stored as vec4)
  112427. * @param uniform defines the webGL uniform location where to store the value
  112428. * @param array defines the array of float32 to store
  112429. */
  112430. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112431. /**
  112432. * Set the value of an uniform to an array of number
  112433. * @param uniform defines the webGL uniform location where to store the value
  112434. * @param array defines the array of number to store
  112435. */
  112436. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112437. /**
  112438. * Set the value of an uniform to an array of number (stored as vec2)
  112439. * @param uniform defines the webGL uniform location where to store the value
  112440. * @param array defines the array of number to store
  112441. */
  112442. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112443. /**
  112444. * Set the value of an uniform to an array of number (stored as vec3)
  112445. * @param uniform defines the webGL uniform location where to store the value
  112446. * @param array defines the array of number to store
  112447. */
  112448. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112449. /**
  112450. * Set the value of an uniform to an array of number (stored as vec4)
  112451. * @param uniform defines the webGL uniform location where to store the value
  112452. * @param array defines the array of number to store
  112453. */
  112454. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112455. /**
  112456. * Set the value of an uniform to an array of float32 (stored as matrices)
  112457. * @param uniform defines the webGL uniform location where to store the value
  112458. * @param matrices defines the array of float32 to store
  112459. */
  112460. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112461. /**
  112462. * Set the value of an uniform to a matrix (3x3)
  112463. * @param uniform defines the webGL uniform location where to store the value
  112464. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112465. */
  112466. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112467. /**
  112468. * Set the value of an uniform to a matrix (2x2)
  112469. * @param uniform defines the webGL uniform location where to store the value
  112470. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112471. */
  112472. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112473. /**
  112474. * Set the value of an uniform to a number (float)
  112475. * @param uniform defines the webGL uniform location where to store the value
  112476. * @param value defines the float number to store
  112477. */
  112478. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112479. /**
  112480. * Set the value of an uniform to a vec2
  112481. * @param uniform defines the webGL uniform location where to store the value
  112482. * @param x defines the 1st component of the value
  112483. * @param y defines the 2nd component of the value
  112484. */
  112485. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112486. /**
  112487. * Set the value of an uniform to a vec3
  112488. * @param uniform defines the webGL uniform location where to store the value
  112489. * @param x defines the 1st component of the value
  112490. * @param y defines the 2nd component of the value
  112491. * @param z defines the 3rd component of the value
  112492. */
  112493. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112494. /**
  112495. * Set the value of an uniform to a boolean
  112496. * @param uniform defines the webGL uniform location where to store the value
  112497. * @param bool defines the boolean to store
  112498. */
  112499. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112500. /**
  112501. * Set the value of an uniform to a vec4
  112502. * @param uniform defines the webGL uniform location where to store the value
  112503. * @param x defines the 1st component of the value
  112504. * @param y defines the 2nd component of the value
  112505. * @param z defines the 3rd component of the value
  112506. * @param w defines the 4th component of the value
  112507. */
  112508. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112509. /**
  112510. * Sets the current alpha mode
  112511. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112512. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112513. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112514. */
  112515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112516. /**
  112517. * Bind webGl buffers directly to the webGL context
  112518. * @param vertexBuffers defines the vertex buffer to bind
  112519. * @param indexBuffer defines the index buffer to bind
  112520. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112521. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112522. * @param effect defines the effect associated with the vertex buffer
  112523. */
  112524. bindBuffers(vertexBuffers: {
  112525. [key: string]: VertexBuffer;
  112526. }, indexBuffer: DataBuffer, effect: Effect): void;
  112527. /**
  112528. * Force the entire cache to be cleared
  112529. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112530. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112531. */
  112532. wipeCaches(bruteForce?: boolean): void;
  112533. /**
  112534. * Send a draw order
  112535. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112536. * @param indexStart defines the starting index
  112537. * @param indexCount defines the number of index to draw
  112538. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112539. */
  112540. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112541. /**
  112542. * Draw a list of indexed primitives
  112543. * @param fillMode defines the primitive to use
  112544. * @param indexStart defines the starting index
  112545. * @param indexCount defines the number of index to draw
  112546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112547. */
  112548. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112549. /**
  112550. * Draw a list of unindexed primitives
  112551. * @param fillMode defines the primitive to use
  112552. * @param verticesStart defines the index of first vertex to draw
  112553. * @param verticesCount defines the count of vertices to draw
  112554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112555. */
  112556. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112557. /** @hidden */
  112558. _createTexture(): WebGLTexture;
  112559. /** @hidden */
  112560. _releaseTexture(texture: InternalTexture): void;
  112561. /**
  112562. * Usually called from Texture.ts.
  112563. * Passed information to create a WebGLTexture
  112564. * @param urlArg defines a value which contains one of the following:
  112565. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112566. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112567. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112569. * @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)
  112570. * @param scene needed for loading to the correct scene
  112571. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112572. * @param onLoad optional callback to be called upon successful completion
  112573. * @param onError optional callback to be called upon failure
  112574. * @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
  112575. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112576. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112577. * @param forcedExtension defines the extension to use to pick the right loader
  112578. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112579. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112580. */
  112581. 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;
  112582. /**
  112583. * Creates a new render target texture
  112584. * @param size defines the size of the texture
  112585. * @param options defines the options used to create the texture
  112586. * @returns a new render target texture stored in an InternalTexture
  112587. */
  112588. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112589. /**
  112590. * Update the sampling mode of a given texture
  112591. * @param samplingMode defines the required sampling mode
  112592. * @param texture defines the texture to update
  112593. */
  112594. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112595. /**
  112596. * Binds the frame buffer to the specified texture.
  112597. * @param texture The texture to render to or null for the default canvas
  112598. * @param faceIndex The face of the texture to render to in case of cube texture
  112599. * @param requiredWidth The width of the target to render to
  112600. * @param requiredHeight The height of the target to render to
  112601. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112602. * @param depthStencilTexture The depth stencil texture to use to render
  112603. * @param lodLevel defines le lod level to bind to the frame buffer
  112604. */
  112605. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112606. /**
  112607. * Unbind the current render target texture from the webGL context
  112608. * @param texture defines the render target texture to unbind
  112609. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112610. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112611. */
  112612. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112613. /**
  112614. * Creates a dynamic vertex buffer
  112615. * @param vertices the data for the dynamic vertex buffer
  112616. * @returns the new WebGL dynamic buffer
  112617. */
  112618. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  112619. /**
  112620. * Update the content of a dynamic texture
  112621. * @param texture defines the texture to update
  112622. * @param canvas defines the canvas containing the source
  112623. * @param invertY defines if data must be stored with Y axis inverted
  112624. * @param premulAlpha defines if alpha is stored as premultiplied
  112625. * @param format defines the format of the data
  112626. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112627. */
  112628. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  112629. /**
  112630. * Gets a boolean indicating if all created effects are ready
  112631. * @returns true if all effects are ready
  112632. */
  112633. areAllEffectsReady(): boolean;
  112634. /**
  112635. * @hidden
  112636. * Get the current error code of the webGL context
  112637. * @returns the error code
  112638. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112639. */
  112640. getError(): number;
  112641. /** @hidden */
  112642. _getUnpackAlignement(): number;
  112643. /** @hidden */
  112644. _unpackFlipY(value: boolean): void;
  112645. /**
  112646. * Update a dynamic index buffer
  112647. * @param indexBuffer defines the target index buffer
  112648. * @param indices defines the data to update
  112649. * @param offset defines the offset in the target index buffer where update should start
  112650. */
  112651. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  112652. /**
  112653. * Updates a dynamic vertex buffer.
  112654. * @param vertexBuffer the vertex buffer to update
  112655. * @param vertices the data used to update the vertex buffer
  112656. * @param byteOffset the byte offset of the data (optional)
  112657. * @param byteLength the byte length of the data (optional)
  112658. */
  112659. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  112660. /** @hidden */
  112661. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  112662. /** @hidden */
  112663. _bindTexture(channel: number, texture: InternalTexture): void;
  112664. protected _deleteBuffer(buffer: WebGLBuffer): void;
  112665. /**
  112666. * 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
  112667. */
  112668. releaseEffects(): void;
  112669. displayLoadingUI(): void;
  112670. hideLoadingUI(): void;
  112671. /** @hidden */
  112672. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112673. /** @hidden */
  112674. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112675. /** @hidden */
  112676. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112677. /** @hidden */
  112678. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112679. }
  112680. }
  112681. declare module BABYLON {
  112682. /** @hidden */
  112683. export class _OcclusionDataStorage {
  112684. /** @hidden */
  112685. occlusionInternalRetryCounter: number;
  112686. /** @hidden */
  112687. isOcclusionQueryInProgress: boolean;
  112688. /** @hidden */
  112689. isOccluded: boolean;
  112690. /** @hidden */
  112691. occlusionRetryCount: number;
  112692. /** @hidden */
  112693. occlusionType: number;
  112694. /** @hidden */
  112695. occlusionQueryAlgorithmType: number;
  112696. }
  112697. interface Engine {
  112698. /**
  112699. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  112700. * @return the new query
  112701. */
  112702. createQuery(): WebGLQuery;
  112703. /**
  112704. * Delete and release a webGL query
  112705. * @param query defines the query to delete
  112706. * @return the current engine
  112707. */
  112708. deleteQuery(query: WebGLQuery): Engine;
  112709. /**
  112710. * Check if a given query has resolved and got its value
  112711. * @param query defines the query to check
  112712. * @returns true if the query got its value
  112713. */
  112714. isQueryResultAvailable(query: WebGLQuery): boolean;
  112715. /**
  112716. * Gets the value of a given query
  112717. * @param query defines the query to check
  112718. * @returns the value of the query
  112719. */
  112720. getQueryResult(query: WebGLQuery): number;
  112721. /**
  112722. * Initiates an occlusion query
  112723. * @param algorithmType defines the algorithm to use
  112724. * @param query defines the query to use
  112725. * @returns the current engine
  112726. * @see http://doc.babylonjs.com/features/occlusionquery
  112727. */
  112728. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  112729. /**
  112730. * Ends an occlusion query
  112731. * @see http://doc.babylonjs.com/features/occlusionquery
  112732. * @param algorithmType defines the algorithm to use
  112733. * @returns the current engine
  112734. */
  112735. endOcclusionQuery(algorithmType: number): Engine;
  112736. /**
  112737. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  112738. * Please note that only one query can be issued at a time
  112739. * @returns a time token used to track the time span
  112740. */
  112741. startTimeQuery(): Nullable<_TimeToken>;
  112742. /**
  112743. * Ends a time query
  112744. * @param token defines the token used to measure the time span
  112745. * @returns the time spent (in ns)
  112746. */
  112747. endTimeQuery(token: _TimeToken): int;
  112748. /** @hidden */
  112749. _currentNonTimestampToken: Nullable<_TimeToken>;
  112750. /** @hidden */
  112751. _createTimeQuery(): WebGLQuery;
  112752. /** @hidden */
  112753. _deleteTimeQuery(query: WebGLQuery): void;
  112754. /** @hidden */
  112755. _getGlAlgorithmType(algorithmType: number): number;
  112756. /** @hidden */
  112757. _getTimeQueryResult(query: WebGLQuery): any;
  112758. /** @hidden */
  112759. _getTimeQueryAvailability(query: WebGLQuery): any;
  112760. }
  112761. interface AbstractMesh {
  112762. /**
  112763. * Backing filed
  112764. * @hidden
  112765. */
  112766. __occlusionDataStorage: _OcclusionDataStorage;
  112767. /**
  112768. * Access property
  112769. * @hidden
  112770. */
  112771. _occlusionDataStorage: _OcclusionDataStorage;
  112772. /**
  112773. * 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.
  112774. * The default value is -1 which means don't break the query and wait till the result
  112775. * @see http://doc.babylonjs.com/features/occlusionquery
  112776. */
  112777. occlusionRetryCount: number;
  112778. /**
  112779. * 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:
  112780. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  112781. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  112782. * * 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.
  112783. * @see http://doc.babylonjs.com/features/occlusionquery
  112784. */
  112785. occlusionType: number;
  112786. /**
  112787. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  112788. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  112789. * * 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.
  112790. * @see http://doc.babylonjs.com/features/occlusionquery
  112791. */
  112792. occlusionQueryAlgorithmType: number;
  112793. /**
  112794. * 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
  112795. * @see http://doc.babylonjs.com/features/occlusionquery
  112796. */
  112797. isOccluded: boolean;
  112798. /**
  112799. * Flag to check the progress status of the query
  112800. * @see http://doc.babylonjs.com/features/occlusionquery
  112801. */
  112802. isOcclusionQueryInProgress: boolean;
  112803. }
  112804. }
  112805. declare module BABYLON {
  112806. /** @hidden */
  112807. export var _forceTransformFeedbackToBundle: boolean;
  112808. interface Engine {
  112809. /**
  112810. * Creates a webGL transform feedback object
  112811. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112812. * @returns the webGL transform feedback object
  112813. */
  112814. createTransformFeedback(): WebGLTransformFeedback;
  112815. /**
  112816. * Delete a webGL transform feedback object
  112817. * @param value defines the webGL transform feedback object to delete
  112818. */
  112819. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112820. /**
  112821. * Bind a webGL transform feedback object to the webgl context
  112822. * @param value defines the webGL transform feedback object to bind
  112823. */
  112824. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112825. /**
  112826. * Begins a transform feedback operation
  112827. * @param usePoints defines if points or triangles must be used
  112828. */
  112829. beginTransformFeedback(usePoints: boolean): void;
  112830. /**
  112831. * Ends a transform feedback operation
  112832. */
  112833. endTransformFeedback(): void;
  112834. /**
  112835. * Specify the varyings to use with transform feedback
  112836. * @param program defines the associated webGL program
  112837. * @param value defines the list of strings representing the varying names
  112838. */
  112839. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112840. /**
  112841. * Bind a webGL buffer for a transform feedback operation
  112842. * @param value defines the webGL buffer to bind
  112843. */
  112844. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112845. }
  112846. }
  112847. declare module BABYLON {
  112848. /**
  112849. * Creation options of the multi render target texture.
  112850. */
  112851. export interface IMultiRenderTargetOptions {
  112852. /**
  112853. * Define if the texture needs to create mip maps after render.
  112854. */
  112855. generateMipMaps?: boolean;
  112856. /**
  112857. * Define the types of all the draw buffers we want to create
  112858. */
  112859. types?: number[];
  112860. /**
  112861. * Define the sampling modes of all the draw buffers we want to create
  112862. */
  112863. samplingModes?: number[];
  112864. /**
  112865. * Define if a depth buffer is required
  112866. */
  112867. generateDepthBuffer?: boolean;
  112868. /**
  112869. * Define if a stencil buffer is required
  112870. */
  112871. generateStencilBuffer?: boolean;
  112872. /**
  112873. * Define if a depth texture is required instead of a depth buffer
  112874. */
  112875. generateDepthTexture?: boolean;
  112876. /**
  112877. * Define the number of desired draw buffers
  112878. */
  112879. textureCount?: number;
  112880. /**
  112881. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112882. */
  112883. doNotChangeAspectRatio?: boolean;
  112884. /**
  112885. * Define the default type of the buffers we are creating
  112886. */
  112887. defaultType?: number;
  112888. }
  112889. /**
  112890. * A multi render target, like a render target provides the ability to render to a texture.
  112891. * Unlike the render target, it can render to several draw buffers in one draw.
  112892. * This is specially interesting in deferred rendering or for any effects requiring more than
  112893. * just one color from a single pass.
  112894. */
  112895. export class MultiRenderTarget extends RenderTargetTexture {
  112896. private _internalTextures;
  112897. private _textures;
  112898. private _multiRenderTargetOptions;
  112899. /**
  112900. * Get if draw buffers are currently supported by the used hardware and browser.
  112901. */
  112902. readonly isSupported: boolean;
  112903. /**
  112904. * Get the list of textures generated by the multi render target.
  112905. */
  112906. readonly textures: Texture[];
  112907. /**
  112908. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112909. */
  112910. readonly depthTexture: Texture;
  112911. /**
  112912. * Set the wrapping mode on U of all the textures we are rendering to.
  112913. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112914. */
  112915. wrapU: number;
  112916. /**
  112917. * Set the wrapping mode on V of all the textures we are rendering to.
  112918. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112919. */
  112920. wrapV: number;
  112921. /**
  112922. * Instantiate a new multi render target texture.
  112923. * A multi render target, like a render target provides the ability to render to a texture.
  112924. * Unlike the render target, it can render to several draw buffers in one draw.
  112925. * This is specially interesting in deferred rendering or for any effects requiring more than
  112926. * just one color from a single pass.
  112927. * @param name Define the name of the texture
  112928. * @param size Define the size of the buffers to render to
  112929. * @param count Define the number of target we are rendering into
  112930. * @param scene Define the scene the texture belongs to
  112931. * @param options Define the options used to create the multi render target
  112932. */
  112933. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112934. /** @hidden */
  112935. _rebuild(): void;
  112936. private _createInternalTextures;
  112937. private _createTextures;
  112938. /**
  112939. * Define the number of samples used if MSAA is enabled.
  112940. */
  112941. samples: number;
  112942. /**
  112943. * Resize all the textures in the multi render target.
  112944. * Be carrefull as it will recreate all the data in the new texture.
  112945. * @param size Define the new size
  112946. */
  112947. resize(size: any): void;
  112948. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112949. /**
  112950. * Dispose the render targets and their associated resources
  112951. */
  112952. dispose(): void;
  112953. /**
  112954. * Release all the underlying texture used as draw buffers.
  112955. */
  112956. releaseInternalTextures(): void;
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. interface ThinEngine {
  112961. /**
  112962. * Unbind a list of render target textures from the webGL context
  112963. * This is used only when drawBuffer extension or webGL2 are active
  112964. * @param textures defines the render target textures to unbind
  112965. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112966. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112967. */
  112968. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112969. /**
  112970. * Create a multi render target texture
  112971. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112972. * @param size defines the size of the texture
  112973. * @param options defines the creation options
  112974. * @returns the cube texture as an InternalTexture
  112975. */
  112976. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112977. /**
  112978. * Update the sample count for a given multiple render target texture
  112979. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112980. * @param textures defines the textures to update
  112981. * @param samples defines the sample count to set
  112982. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112983. */
  112984. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112985. }
  112986. }
  112987. declare module BABYLON {
  112988. /**
  112989. * Class used to define an additional view for the engine
  112990. * @see https://doc.babylonjs.com/how_to/multi_canvases
  112991. */
  112992. export class EngineView {
  112993. /** Defines the canvas where to render the view */
  112994. target: HTMLCanvasElement;
  112995. /** Defines an optional camera used to render the view (will use active camera else) */
  112996. camera?: Camera;
  112997. }
  112998. interface Engine {
  112999. /**
  113000. * Gets or sets the HTML element to use for attaching events
  113001. */
  113002. inputElement: Nullable<HTMLElement>;
  113003. /**
  113004. * Gets the current engine view
  113005. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113006. */
  113007. activeView: Nullable<EngineView>;
  113008. /** Gets or sets the list of views */
  113009. views: EngineView[];
  113010. /**
  113011. * Register a new child canvas
  113012. * @param canvas defines the canvas to register
  113013. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113014. * @returns the associated view
  113015. */
  113016. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113017. /**
  113018. * Remove a registered child canvas
  113019. * @param canvas defines the canvas to remove
  113020. * @returns the current engine
  113021. */
  113022. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113023. }
  113024. }
  113025. declare module BABYLON {
  113026. /**
  113027. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113028. */
  113029. export interface CubeMapInfo {
  113030. /**
  113031. * The pixel array for the front face.
  113032. * This is stored in format, left to right, up to down format.
  113033. */
  113034. front: Nullable<ArrayBufferView>;
  113035. /**
  113036. * The pixel array for the back face.
  113037. * This is stored in format, left to right, up to down format.
  113038. */
  113039. back: Nullable<ArrayBufferView>;
  113040. /**
  113041. * The pixel array for the left face.
  113042. * This is stored in format, left to right, up to down format.
  113043. */
  113044. left: Nullable<ArrayBufferView>;
  113045. /**
  113046. * The pixel array for the right face.
  113047. * This is stored in format, left to right, up to down format.
  113048. */
  113049. right: Nullable<ArrayBufferView>;
  113050. /**
  113051. * The pixel array for the up face.
  113052. * This is stored in format, left to right, up to down format.
  113053. */
  113054. up: Nullable<ArrayBufferView>;
  113055. /**
  113056. * The pixel array for the down face.
  113057. * This is stored in format, left to right, up to down format.
  113058. */
  113059. down: Nullable<ArrayBufferView>;
  113060. /**
  113061. * The size of the cubemap stored.
  113062. *
  113063. * Each faces will be size * size pixels.
  113064. */
  113065. size: number;
  113066. /**
  113067. * The format of the texture.
  113068. *
  113069. * RGBA, RGB.
  113070. */
  113071. format: number;
  113072. /**
  113073. * The type of the texture data.
  113074. *
  113075. * UNSIGNED_INT, FLOAT.
  113076. */
  113077. type: number;
  113078. /**
  113079. * Specifies whether the texture is in gamma space.
  113080. */
  113081. gammaSpace: boolean;
  113082. }
  113083. /**
  113084. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113085. */
  113086. export class PanoramaToCubeMapTools {
  113087. private static FACE_FRONT;
  113088. private static FACE_BACK;
  113089. private static FACE_RIGHT;
  113090. private static FACE_LEFT;
  113091. private static FACE_DOWN;
  113092. private static FACE_UP;
  113093. /**
  113094. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113095. *
  113096. * @param float32Array The source data.
  113097. * @param inputWidth The width of the input panorama.
  113098. * @param inputHeight The height of the input panorama.
  113099. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113100. * @return The cubemap data
  113101. */
  113102. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113103. private static CreateCubemapTexture;
  113104. private static CalcProjectionSpherical;
  113105. }
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * Helper class dealing with the extraction of spherical polynomial dataArray
  113110. * from a cube map.
  113111. */
  113112. export class CubeMapToSphericalPolynomialTools {
  113113. private static FileFaces;
  113114. /**
  113115. * Converts a texture to the according Spherical Polynomial data.
  113116. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113117. *
  113118. * @param texture The texture to extract the information from.
  113119. * @return The Spherical Polynomial data.
  113120. */
  113121. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113122. /**
  113123. * Converts a cubemap to the according Spherical Polynomial data.
  113124. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113125. *
  113126. * @param cubeInfo The Cube map to extract the information from.
  113127. * @return The Spherical Polynomial data.
  113128. */
  113129. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113130. }
  113131. }
  113132. declare module BABYLON {
  113133. interface BaseTexture {
  113134. /**
  113135. * Get the polynomial representation of the texture data.
  113136. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113137. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113138. */
  113139. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113140. }
  113141. }
  113142. declare module BABYLON {
  113143. /** @hidden */
  113144. export var rgbdEncodePixelShader: {
  113145. name: string;
  113146. shader: string;
  113147. };
  113148. }
  113149. declare module BABYLON {
  113150. /** @hidden */
  113151. export var rgbdDecodePixelShader: {
  113152. name: string;
  113153. shader: string;
  113154. };
  113155. }
  113156. declare module BABYLON {
  113157. /**
  113158. * Raw texture data and descriptor sufficient for WebGL texture upload
  113159. */
  113160. export interface EnvironmentTextureInfo {
  113161. /**
  113162. * Version of the environment map
  113163. */
  113164. version: number;
  113165. /**
  113166. * Width of image
  113167. */
  113168. width: number;
  113169. /**
  113170. * Irradiance information stored in the file.
  113171. */
  113172. irradiance: any;
  113173. /**
  113174. * Specular information stored in the file.
  113175. */
  113176. specular: any;
  113177. }
  113178. /**
  113179. * Defines One Image in the file. It requires only the position in the file
  113180. * as well as the length.
  113181. */
  113182. interface BufferImageData {
  113183. /**
  113184. * Length of the image data.
  113185. */
  113186. length: number;
  113187. /**
  113188. * Position of the data from the null terminator delimiting the end of the JSON.
  113189. */
  113190. position: number;
  113191. }
  113192. /**
  113193. * Defines the specular data enclosed in the file.
  113194. * This corresponds to the version 1 of the data.
  113195. */
  113196. export interface EnvironmentTextureSpecularInfoV1 {
  113197. /**
  113198. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113199. */
  113200. specularDataPosition?: number;
  113201. /**
  113202. * This contains all the images data needed to reconstruct the cubemap.
  113203. */
  113204. mipmaps: Array<BufferImageData>;
  113205. /**
  113206. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113207. */
  113208. lodGenerationScale: number;
  113209. }
  113210. /**
  113211. * Sets of helpers addressing the serialization and deserialization of environment texture
  113212. * stored in a BabylonJS env file.
  113213. * Those files are usually stored as .env files.
  113214. */
  113215. export class EnvironmentTextureTools {
  113216. /**
  113217. * Magic number identifying the env file.
  113218. */
  113219. private static _MagicBytes;
  113220. /**
  113221. * Gets the environment info from an env file.
  113222. * @param data The array buffer containing the .env bytes.
  113223. * @returns the environment file info (the json header) if successfully parsed.
  113224. */
  113225. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113226. /**
  113227. * Creates an environment texture from a loaded cube texture.
  113228. * @param texture defines the cube texture to convert in env file
  113229. * @return a promise containing the environment data if succesfull.
  113230. */
  113231. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113232. /**
  113233. * Creates a JSON representation of the spherical data.
  113234. * @param texture defines the texture containing the polynomials
  113235. * @return the JSON representation of the spherical info
  113236. */
  113237. private static _CreateEnvTextureIrradiance;
  113238. /**
  113239. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113240. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113241. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113242. * @return the views described by info providing access to the underlying buffer
  113243. */
  113244. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113245. /**
  113246. * Uploads the texture info contained in the env file to the GPU.
  113247. * @param texture defines the internal texture to upload to
  113248. * @param arrayBuffer defines the buffer cotaining the data to load
  113249. * @param info defines the texture info retrieved through the GetEnvInfo method
  113250. * @returns a promise
  113251. */
  113252. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113253. private static _OnImageReadyAsync;
  113254. /**
  113255. * Uploads the levels of image data to the GPU.
  113256. * @param texture defines the internal texture to upload to
  113257. * @param imageData defines the array buffer views of image data [mipmap][face]
  113258. * @returns a promise
  113259. */
  113260. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113261. /**
  113262. * Uploads spherical polynomials information to the texture.
  113263. * @param texture defines the texture we are trying to upload the information to
  113264. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113265. */
  113266. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113267. /** @hidden */
  113268. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113269. }
  113270. }
  113271. declare module BABYLON {
  113272. /**
  113273. * Contains position and normal vectors for a vertex
  113274. */
  113275. export class PositionNormalVertex {
  113276. /** the position of the vertex (defaut: 0,0,0) */
  113277. position: Vector3;
  113278. /** the normal of the vertex (defaut: 0,1,0) */
  113279. normal: Vector3;
  113280. /**
  113281. * Creates a PositionNormalVertex
  113282. * @param position the position of the vertex (defaut: 0,0,0)
  113283. * @param normal the normal of the vertex (defaut: 0,1,0)
  113284. */
  113285. constructor(
  113286. /** the position of the vertex (defaut: 0,0,0) */
  113287. position?: Vector3,
  113288. /** the normal of the vertex (defaut: 0,1,0) */
  113289. normal?: Vector3);
  113290. /**
  113291. * Clones the PositionNormalVertex
  113292. * @returns the cloned PositionNormalVertex
  113293. */
  113294. clone(): PositionNormalVertex;
  113295. }
  113296. /**
  113297. * Contains position, normal and uv vectors for a vertex
  113298. */
  113299. export class PositionNormalTextureVertex {
  113300. /** the position of the vertex (defaut: 0,0,0) */
  113301. position: Vector3;
  113302. /** the normal of the vertex (defaut: 0,1,0) */
  113303. normal: Vector3;
  113304. /** the uv of the vertex (default: 0,0) */
  113305. uv: Vector2;
  113306. /**
  113307. * Creates a PositionNormalTextureVertex
  113308. * @param position the position of the vertex (defaut: 0,0,0)
  113309. * @param normal the normal of the vertex (defaut: 0,1,0)
  113310. * @param uv the uv of the vertex (default: 0,0)
  113311. */
  113312. constructor(
  113313. /** the position of the vertex (defaut: 0,0,0) */
  113314. position?: Vector3,
  113315. /** the normal of the vertex (defaut: 0,1,0) */
  113316. normal?: Vector3,
  113317. /** the uv of the vertex (default: 0,0) */
  113318. uv?: Vector2);
  113319. /**
  113320. * Clones the PositionNormalTextureVertex
  113321. * @returns the cloned PositionNormalTextureVertex
  113322. */
  113323. clone(): PositionNormalTextureVertex;
  113324. }
  113325. }
  113326. declare module BABYLON {
  113327. /** @hidden */
  113328. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113329. private _genericAttributeLocation;
  113330. private _varyingLocationCount;
  113331. private _varyingLocationMap;
  113332. private _replacements;
  113333. private _textureCount;
  113334. private _uniforms;
  113335. lineProcessor(line: string): string;
  113336. attributeProcessor(attribute: string): string;
  113337. varyingProcessor(varying: string, isFragment: boolean): string;
  113338. uniformProcessor(uniform: string): string;
  113339. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113340. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113341. }
  113342. }
  113343. declare module BABYLON {
  113344. /**
  113345. * Container for accessors for natively-stored mesh data buffers.
  113346. */
  113347. class NativeDataBuffer extends DataBuffer {
  113348. /**
  113349. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113350. */
  113351. nativeIndexBuffer?: any;
  113352. /**
  113353. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113354. */
  113355. nativeVertexBuffer?: any;
  113356. }
  113357. /** @hidden */
  113358. class NativeTexture extends InternalTexture {
  113359. getInternalTexture(): InternalTexture;
  113360. getViewCount(): number;
  113361. }
  113362. /** @hidden */
  113363. export class NativeEngine extends Engine {
  113364. private readonly _native;
  113365. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113366. private readonly INVALID_HANDLE;
  113367. getHardwareScalingLevel(): number;
  113368. constructor();
  113369. /**
  113370. * Can be used to override the current requestAnimationFrame requester.
  113371. * @hidden
  113372. */
  113373. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113374. /**
  113375. * Override default engine behavior.
  113376. * @param color
  113377. * @param backBuffer
  113378. * @param depth
  113379. * @param stencil
  113380. */
  113381. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113382. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113383. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113384. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113385. recordVertexArrayObject(vertexBuffers: {
  113386. [key: string]: VertexBuffer;
  113387. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113388. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113389. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113390. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113391. /**
  113392. * Draw a list of indexed primitives
  113393. * @param fillMode defines the primitive to use
  113394. * @param indexStart defines the starting index
  113395. * @param indexCount defines the number of index to draw
  113396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113397. */
  113398. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113399. /**
  113400. * Draw a list of unindexed primitives
  113401. * @param fillMode defines the primitive to use
  113402. * @param verticesStart defines the index of first vertex to draw
  113403. * @param verticesCount defines the count of vertices to draw
  113404. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113405. */
  113406. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113407. createPipelineContext(): IPipelineContext;
  113408. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113409. /** @hidden */
  113410. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113411. /** @hidden */
  113412. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113413. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113415. protected _setProgram(program: WebGLProgram): void;
  113416. _releaseEffect(effect: Effect): void;
  113417. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113418. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113419. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113420. bindSamplers(effect: Effect): void;
  113421. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113422. getRenderWidth(useScreen?: boolean): number;
  113423. getRenderHeight(useScreen?: boolean): number;
  113424. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113425. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113426. /**
  113427. * Set the z offset to apply to current rendering
  113428. * @param value defines the offset to apply
  113429. */
  113430. setZOffset(value: number): void;
  113431. /**
  113432. * Gets the current value of the zOffset
  113433. * @returns the current zOffset state
  113434. */
  113435. getZOffset(): number;
  113436. /**
  113437. * Enable or disable depth buffering
  113438. * @param enable defines the state to set
  113439. */
  113440. setDepthBuffer(enable: boolean): void;
  113441. /**
  113442. * Gets a boolean indicating if depth writing is enabled
  113443. * @returns the current depth writing state
  113444. */
  113445. getDepthWrite(): boolean;
  113446. /**
  113447. * Enable or disable depth writing
  113448. * @param enable defines the state to set
  113449. */
  113450. setDepthWrite(enable: boolean): void;
  113451. /**
  113452. * Enable or disable color writing
  113453. * @param enable defines the state to set
  113454. */
  113455. setColorWrite(enable: boolean): void;
  113456. /**
  113457. * Gets a boolean indicating if color writing is enabled
  113458. * @returns the current color writing state
  113459. */
  113460. getColorWrite(): boolean;
  113461. /**
  113462. * Sets alpha constants used by some alpha blending modes
  113463. * @param r defines the red component
  113464. * @param g defines the green component
  113465. * @param b defines the blue component
  113466. * @param a defines the alpha component
  113467. */
  113468. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113469. /**
  113470. * Sets the current alpha mode
  113471. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113472. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113474. */
  113475. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113476. /**
  113477. * Gets the current alpha mode
  113478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113479. * @returns the current alpha mode
  113480. */
  113481. getAlphaMode(): number;
  113482. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113483. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113484. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113485. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113486. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113487. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113488. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113489. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113490. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113491. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113492. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113493. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113494. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113495. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113496. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113497. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113498. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113499. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113500. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113501. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113502. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113503. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113504. wipeCaches(bruteForce?: boolean): void;
  113505. _createTexture(): WebGLTexture;
  113506. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113507. /**
  113508. * Usually called from BABYLON.Texture.ts.
  113509. * Passed information to create a WebGLTexture
  113510. * @param urlArg defines a value which contains one of the following:
  113511. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113512. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113513. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113515. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113516. * @param scene needed for loading to the correct scene
  113517. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113518. * @param onLoad optional callback to be called upon successful completion
  113519. * @param onError optional callback to be called upon failure
  113520. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113521. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113522. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113523. * @param forcedExtension defines the extension to use to pick the right loader
  113524. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113525. */
  113526. 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;
  113527. /**
  113528. * Creates a cube texture
  113529. * @param rootUrl defines the url where the files to load is located
  113530. * @param scene defines the current scene
  113531. * @param files defines the list of files to load (1 per face)
  113532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113533. * @param onLoad defines an optional callback raised when the texture is loaded
  113534. * @param onError defines an optional callback raised if there is an issue to load the texture
  113535. * @param format defines the format of the data
  113536. * @param forcedExtension defines the extension to use to pick the right loader
  113537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113541. * @returns the cube texture as an InternalTexture
  113542. */
  113543. 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;
  113544. private _getSamplingFilter;
  113545. private static _GetNativeTextureFormat;
  113546. createRenderTargetTexture(size: number | {
  113547. width: number;
  113548. height: number;
  113549. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113550. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113551. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113552. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113553. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113554. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113555. /**
  113556. * Updates a dynamic vertex buffer.
  113557. * @param vertexBuffer the vertex buffer to update
  113558. * @param data the data used to update the vertex buffer
  113559. * @param byteOffset the byte offset of the data (optional)
  113560. * @param byteLength the byte length of the data (optional)
  113561. */
  113562. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113563. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113564. private _updateAnisotropicLevel;
  113565. private _getAddressMode;
  113566. /** @hidden */
  113567. _bindTexture(channel: number, texture: InternalTexture): void;
  113568. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113569. releaseEffects(): void;
  113570. /** @hidden */
  113571. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113572. /** @hidden */
  113573. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113574. /** @hidden */
  113575. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113576. /** @hidden */
  113577. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113578. }
  113579. }
  113580. declare module BABYLON {
  113581. /**
  113582. * Gather the list of clipboard event types as constants.
  113583. */
  113584. export class ClipboardEventTypes {
  113585. /**
  113586. * The clipboard event is fired when a copy command is active (pressed).
  113587. */
  113588. static readonly COPY: number;
  113589. /**
  113590. * The clipboard event is fired when a cut command is active (pressed).
  113591. */
  113592. static readonly CUT: number;
  113593. /**
  113594. * The clipboard event is fired when a paste command is active (pressed).
  113595. */
  113596. static readonly PASTE: number;
  113597. }
  113598. /**
  113599. * This class is used to store clipboard related info for the onClipboardObservable event.
  113600. */
  113601. export class ClipboardInfo {
  113602. /**
  113603. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113604. */
  113605. type: number;
  113606. /**
  113607. * Defines the related dom event
  113608. */
  113609. event: ClipboardEvent;
  113610. /**
  113611. *Creates an instance of ClipboardInfo.
  113612. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  113613. * @param event Defines the related dom event
  113614. */
  113615. constructor(
  113616. /**
  113617. * Defines the type of event (BABYLON.ClipboardEventTypes)
  113618. */
  113619. type: number,
  113620. /**
  113621. * Defines the related dom event
  113622. */
  113623. event: ClipboardEvent);
  113624. /**
  113625. * Get the clipboard event's type from the keycode.
  113626. * @param keyCode Defines the keyCode for the current keyboard event.
  113627. * @return {number}
  113628. */
  113629. static GetTypeFromCharacter(keyCode: number): number;
  113630. }
  113631. }
  113632. declare module BABYLON {
  113633. /**
  113634. * Google Daydream controller
  113635. */
  113636. export class DaydreamController extends WebVRController {
  113637. /**
  113638. * Base Url for the controller model.
  113639. */
  113640. static MODEL_BASE_URL: string;
  113641. /**
  113642. * File name for the controller model.
  113643. */
  113644. static MODEL_FILENAME: string;
  113645. /**
  113646. * Gamepad Id prefix used to identify Daydream Controller.
  113647. */
  113648. static readonly GAMEPAD_ID_PREFIX: string;
  113649. /**
  113650. * Creates a new DaydreamController from a gamepad
  113651. * @param vrGamepad the gamepad that the controller should be created from
  113652. */
  113653. constructor(vrGamepad: any);
  113654. /**
  113655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113656. * @param scene scene in which to add meshes
  113657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113658. */
  113659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113660. /**
  113661. * Called once for each button that changed state since the last frame
  113662. * @param buttonIdx Which button index changed
  113663. * @param state New state of the button
  113664. * @param changes Which properties on the state changed since last frame
  113665. */
  113666. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113667. }
  113668. }
  113669. declare module BABYLON {
  113670. /**
  113671. * Gear VR Controller
  113672. */
  113673. export class GearVRController extends WebVRController {
  113674. /**
  113675. * Base Url for the controller model.
  113676. */
  113677. static MODEL_BASE_URL: string;
  113678. /**
  113679. * File name for the controller model.
  113680. */
  113681. static MODEL_FILENAME: string;
  113682. /**
  113683. * Gamepad Id prefix used to identify this controller.
  113684. */
  113685. static readonly GAMEPAD_ID_PREFIX: string;
  113686. private readonly _buttonIndexToObservableNameMap;
  113687. /**
  113688. * Creates a new GearVRController from a gamepad
  113689. * @param vrGamepad the gamepad that the controller should be created from
  113690. */
  113691. constructor(vrGamepad: any);
  113692. /**
  113693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113694. * @param scene scene in which to add meshes
  113695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113696. */
  113697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113698. /**
  113699. * Called once for each button that changed state since the last frame
  113700. * @param buttonIdx Which button index changed
  113701. * @param state New state of the button
  113702. * @param changes Which properties on the state changed since last frame
  113703. */
  113704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113705. }
  113706. }
  113707. declare module BABYLON {
  113708. /**
  113709. * Class containing static functions to help procedurally build meshes
  113710. */
  113711. export class PolyhedronBuilder {
  113712. /**
  113713. * Creates a polyhedron mesh
  113714. * * 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
  113715. * * The parameter `size` (positive float, default 1) sets the polygon size
  113716. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  113717. * * 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`
  113718. * * 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
  113719. * * 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)`)
  113720. * * 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
  113721. * * 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
  113722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113725. * @param name defines the name of the mesh
  113726. * @param options defines the options used to create the mesh
  113727. * @param scene defines the hosting scene
  113728. * @returns the polyhedron mesh
  113729. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  113730. */
  113731. static CreatePolyhedron(name: string, options: {
  113732. type?: number;
  113733. size?: number;
  113734. sizeX?: number;
  113735. sizeY?: number;
  113736. sizeZ?: number;
  113737. custom?: any;
  113738. faceUV?: Vector4[];
  113739. faceColors?: Color4[];
  113740. flat?: boolean;
  113741. updatable?: boolean;
  113742. sideOrientation?: number;
  113743. frontUVs?: Vector4;
  113744. backUVs?: Vector4;
  113745. }, scene?: Nullable<Scene>): Mesh;
  113746. }
  113747. }
  113748. declare module BABYLON {
  113749. /**
  113750. * Gizmo that enables scaling a mesh along 3 axis
  113751. */
  113752. export class ScaleGizmo extends Gizmo {
  113753. /**
  113754. * Internal gizmo used for interactions on the x axis
  113755. */
  113756. xGizmo: AxisScaleGizmo;
  113757. /**
  113758. * Internal gizmo used for interactions on the y axis
  113759. */
  113760. yGizmo: AxisScaleGizmo;
  113761. /**
  113762. * Internal gizmo used for interactions on the z axis
  113763. */
  113764. zGizmo: AxisScaleGizmo;
  113765. /**
  113766. * Internal gizmo used to scale all axis equally
  113767. */
  113768. uniformScaleGizmo: AxisScaleGizmo;
  113769. private _meshAttached;
  113770. private _updateGizmoRotationToMatchAttachedMesh;
  113771. private _snapDistance;
  113772. private _scaleRatio;
  113773. private _uniformScalingMesh;
  113774. private _octahedron;
  113775. /** Fires an event when any of it's sub gizmos are dragged */
  113776. onDragStartObservable: Observable<unknown>;
  113777. /** Fires an event when any of it's sub gizmos are released from dragging */
  113778. onDragEndObservable: Observable<unknown>;
  113779. attachedMesh: Nullable<AbstractMesh>;
  113780. /**
  113781. * Creates a ScaleGizmo
  113782. * @param gizmoLayer The utility layer the gizmo will be added to
  113783. */
  113784. constructor(gizmoLayer?: UtilityLayerRenderer);
  113785. updateGizmoRotationToMatchAttachedMesh: boolean;
  113786. /**
  113787. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113788. */
  113789. snapDistance: number;
  113790. /**
  113791. * Ratio for the scale of the gizmo (Default: 1)
  113792. */
  113793. scaleRatio: number;
  113794. /**
  113795. * Disposes of the gizmo
  113796. */
  113797. dispose(): void;
  113798. }
  113799. }
  113800. declare module BABYLON {
  113801. /**
  113802. * Single axis scale gizmo
  113803. */
  113804. export class AxisScaleGizmo extends Gizmo {
  113805. /**
  113806. * Drag behavior responsible for the gizmos dragging interactions
  113807. */
  113808. dragBehavior: PointerDragBehavior;
  113809. private _pointerObserver;
  113810. /**
  113811. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113812. */
  113813. snapDistance: number;
  113814. /**
  113815. * Event that fires each time the gizmo snaps to a new location.
  113816. * * snapDistance is the the change in distance
  113817. */
  113818. onSnapObservable: Observable<{
  113819. snapDistance: number;
  113820. }>;
  113821. /**
  113822. * If the scaling operation should be done on all axis (default: false)
  113823. */
  113824. uniformScaling: boolean;
  113825. private _isEnabled;
  113826. private _parent;
  113827. private _arrow;
  113828. private _coloredMaterial;
  113829. private _hoverMaterial;
  113830. /**
  113831. * Creates an AxisScaleGizmo
  113832. * @param gizmoLayer The utility layer the gizmo will be added to
  113833. * @param dragAxis The axis which the gizmo will be able to scale on
  113834. * @param color The color of the gizmo
  113835. */
  113836. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113837. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113838. /**
  113839. * If the gizmo is enabled
  113840. */
  113841. isEnabled: boolean;
  113842. /**
  113843. * Disposes of the gizmo
  113844. */
  113845. dispose(): void;
  113846. /**
  113847. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113848. * @param mesh The mesh to replace the default mesh of the gizmo
  113849. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113850. */
  113851. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113852. }
  113853. }
  113854. declare module BABYLON {
  113855. /**
  113856. * Bounding box gizmo
  113857. */
  113858. export class BoundingBoxGizmo extends Gizmo {
  113859. private _lineBoundingBox;
  113860. private _rotateSpheresParent;
  113861. private _scaleBoxesParent;
  113862. private _boundingDimensions;
  113863. private _renderObserver;
  113864. private _pointerObserver;
  113865. private _scaleDragSpeed;
  113866. private _tmpQuaternion;
  113867. private _tmpVector;
  113868. private _tmpRotationMatrix;
  113869. /**
  113870. * 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)
  113871. */
  113872. ignoreChildren: boolean;
  113873. /**
  113874. * 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)
  113875. */
  113876. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113877. /**
  113878. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113879. */
  113880. rotationSphereSize: number;
  113881. /**
  113882. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113883. */
  113884. scaleBoxSize: number;
  113885. /**
  113886. * 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)
  113887. */
  113888. fixedDragMeshScreenSize: boolean;
  113889. /**
  113890. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113891. */
  113892. fixedDragMeshScreenSizeDistanceFactor: number;
  113893. /**
  113894. * Fired when a rotation sphere or scale box is dragged
  113895. */
  113896. onDragStartObservable: Observable<{}>;
  113897. /**
  113898. * Fired when a scale box is dragged
  113899. */
  113900. onScaleBoxDragObservable: Observable<{}>;
  113901. /**
  113902. * Fired when a scale box drag is ended
  113903. */
  113904. onScaleBoxDragEndObservable: Observable<{}>;
  113905. /**
  113906. * Fired when a rotation sphere is dragged
  113907. */
  113908. onRotationSphereDragObservable: Observable<{}>;
  113909. /**
  113910. * Fired when a rotation sphere drag is ended
  113911. */
  113912. onRotationSphereDragEndObservable: Observable<{}>;
  113913. /**
  113914. * 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)
  113915. */
  113916. scalePivot: Nullable<Vector3>;
  113917. /**
  113918. * Mesh used as a pivot to rotate the attached mesh
  113919. */
  113920. private _anchorMesh;
  113921. private _existingMeshScale;
  113922. private _dragMesh;
  113923. private pointerDragBehavior;
  113924. private coloredMaterial;
  113925. private hoverColoredMaterial;
  113926. /**
  113927. * Sets the color of the bounding box gizmo
  113928. * @param color the color to set
  113929. */
  113930. setColor(color: Color3): void;
  113931. /**
  113932. * Creates an BoundingBoxGizmo
  113933. * @param gizmoLayer The utility layer the gizmo will be added to
  113934. * @param color The color of the gizmo
  113935. */
  113936. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113937. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113938. private _selectNode;
  113939. /**
  113940. * Updates the bounding box information for the Gizmo
  113941. */
  113942. updateBoundingBox(): void;
  113943. private _updateRotationSpheres;
  113944. private _updateScaleBoxes;
  113945. /**
  113946. * Enables rotation on the specified axis and disables rotation on the others
  113947. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113948. */
  113949. setEnabledRotationAxis(axis: string): void;
  113950. /**
  113951. * Enables/disables scaling
  113952. * @param enable if scaling should be enabled
  113953. */
  113954. setEnabledScaling(enable: boolean): void;
  113955. private _updateDummy;
  113956. /**
  113957. * Enables a pointer drag behavior on the bounding box of the gizmo
  113958. */
  113959. enableDragBehavior(): void;
  113960. /**
  113961. * Disposes of the gizmo
  113962. */
  113963. dispose(): void;
  113964. /**
  113965. * 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)
  113966. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113967. * @returns the bounding box mesh with the passed in mesh as a child
  113968. */
  113969. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113970. /**
  113971. * CustomMeshes are not supported by this gizmo
  113972. * @param mesh The mesh to replace the default mesh of the gizmo
  113973. */
  113974. setCustomMesh(mesh: Mesh): void;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /**
  113979. * Single plane rotation gizmo
  113980. */
  113981. export class PlaneRotationGizmo extends Gizmo {
  113982. /**
  113983. * Drag behavior responsible for the gizmos dragging interactions
  113984. */
  113985. dragBehavior: PointerDragBehavior;
  113986. private _pointerObserver;
  113987. /**
  113988. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113989. */
  113990. snapDistance: number;
  113991. /**
  113992. * Event that fires each time the gizmo snaps to a new location.
  113993. * * snapDistance is the the change in distance
  113994. */
  113995. onSnapObservable: Observable<{
  113996. snapDistance: number;
  113997. }>;
  113998. private _isEnabled;
  113999. private _parent;
  114000. /**
  114001. * Creates a PlaneRotationGizmo
  114002. * @param gizmoLayer The utility layer the gizmo will be added to
  114003. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114004. * @param color The color of the gizmo
  114005. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114006. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114007. */
  114008. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114010. /**
  114011. * If the gizmo is enabled
  114012. */
  114013. isEnabled: boolean;
  114014. /**
  114015. * Disposes of the gizmo
  114016. */
  114017. dispose(): void;
  114018. }
  114019. }
  114020. declare module BABYLON {
  114021. /**
  114022. * Gizmo that enables rotating a mesh along 3 axis
  114023. */
  114024. export class RotationGizmo extends Gizmo {
  114025. /**
  114026. * Internal gizmo used for interactions on the x axis
  114027. */
  114028. xGizmo: PlaneRotationGizmo;
  114029. /**
  114030. * Internal gizmo used for interactions on the y axis
  114031. */
  114032. yGizmo: PlaneRotationGizmo;
  114033. /**
  114034. * Internal gizmo used for interactions on the z axis
  114035. */
  114036. zGizmo: PlaneRotationGizmo;
  114037. /** Fires an event when any of it's sub gizmos are dragged */
  114038. onDragStartObservable: Observable<unknown>;
  114039. /** Fires an event when any of it's sub gizmos are released from dragging */
  114040. onDragEndObservable: Observable<unknown>;
  114041. private _meshAttached;
  114042. attachedMesh: Nullable<AbstractMesh>;
  114043. /**
  114044. * Creates a RotationGizmo
  114045. * @param gizmoLayer The utility layer the gizmo will be added to
  114046. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114047. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114048. */
  114049. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114050. updateGizmoRotationToMatchAttachedMesh: boolean;
  114051. /**
  114052. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114053. */
  114054. snapDistance: number;
  114055. /**
  114056. * Ratio for the scale of the gizmo (Default: 1)
  114057. */
  114058. scaleRatio: number;
  114059. /**
  114060. * Disposes of the gizmo
  114061. */
  114062. dispose(): void;
  114063. /**
  114064. * CustomMeshes are not supported by this gizmo
  114065. * @param mesh The mesh to replace the default mesh of the gizmo
  114066. */
  114067. setCustomMesh(mesh: Mesh): void;
  114068. }
  114069. }
  114070. declare module BABYLON {
  114071. /**
  114072. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114073. */
  114074. export class GizmoManager implements IDisposable {
  114075. private scene;
  114076. /**
  114077. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114078. */
  114079. gizmos: {
  114080. positionGizmo: Nullable<PositionGizmo>;
  114081. rotationGizmo: Nullable<RotationGizmo>;
  114082. scaleGizmo: Nullable<ScaleGizmo>;
  114083. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114084. };
  114085. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114086. clearGizmoOnEmptyPointerEvent: boolean;
  114087. /** Fires an event when the manager is attached to a mesh */
  114088. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114089. private _gizmosEnabled;
  114090. private _pointerObserver;
  114091. private _attachedMesh;
  114092. private _boundingBoxColor;
  114093. private _defaultUtilityLayer;
  114094. private _defaultKeepDepthUtilityLayer;
  114095. /**
  114096. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114097. */
  114098. boundingBoxDragBehavior: SixDofDragBehavior;
  114099. /**
  114100. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114101. */
  114102. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114103. /**
  114104. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114105. */
  114106. usePointerToAttachGizmos: boolean;
  114107. /**
  114108. * Utility layer that the bounding box gizmo belongs to
  114109. */
  114110. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114111. /**
  114112. * Utility layer that all gizmos besides bounding box belong to
  114113. */
  114114. readonly utilityLayer: UtilityLayerRenderer;
  114115. /**
  114116. * Instatiates a gizmo manager
  114117. * @param scene the scene to overlay the gizmos on top of
  114118. */
  114119. constructor(scene: Scene);
  114120. /**
  114121. * Attaches a set of gizmos to the specified mesh
  114122. * @param mesh The mesh the gizmo's should be attached to
  114123. */
  114124. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114125. /**
  114126. * If the position gizmo is enabled
  114127. */
  114128. positionGizmoEnabled: boolean;
  114129. /**
  114130. * If the rotation gizmo is enabled
  114131. */
  114132. rotationGizmoEnabled: boolean;
  114133. /**
  114134. * If the scale gizmo is enabled
  114135. */
  114136. scaleGizmoEnabled: boolean;
  114137. /**
  114138. * If the boundingBox gizmo is enabled
  114139. */
  114140. boundingBoxGizmoEnabled: boolean;
  114141. /**
  114142. * Disposes of the gizmo manager
  114143. */
  114144. dispose(): void;
  114145. }
  114146. }
  114147. declare module BABYLON {
  114148. /**
  114149. * A directional light is defined by a direction (what a surprise!).
  114150. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114151. * 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.
  114152. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114153. */
  114154. export class DirectionalLight extends ShadowLight {
  114155. private _shadowFrustumSize;
  114156. /**
  114157. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114158. */
  114159. /**
  114160. * Specifies a fix frustum size for the shadow generation.
  114161. */
  114162. shadowFrustumSize: number;
  114163. private _shadowOrthoScale;
  114164. /**
  114165. * Gets the shadow projection scale against the optimal computed one.
  114166. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114167. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114168. */
  114169. /**
  114170. * Sets the shadow projection scale against the optimal computed one.
  114171. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114172. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114173. */
  114174. shadowOrthoScale: number;
  114175. /**
  114176. * Automatically compute the projection matrix to best fit (including all the casters)
  114177. * on each frame.
  114178. */
  114179. autoUpdateExtends: boolean;
  114180. private _orthoLeft;
  114181. private _orthoRight;
  114182. private _orthoTop;
  114183. private _orthoBottom;
  114184. /**
  114185. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114186. * The directional light is emitted from everywhere in the given direction.
  114187. * It can cast shadows.
  114188. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114189. * @param name The friendly name of the light
  114190. * @param direction The direction of the light
  114191. * @param scene The scene the light belongs to
  114192. */
  114193. constructor(name: string, direction: Vector3, scene: Scene);
  114194. /**
  114195. * Returns the string "DirectionalLight".
  114196. * @return The class name
  114197. */
  114198. getClassName(): string;
  114199. /**
  114200. * Returns the integer 1.
  114201. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114202. */
  114203. getTypeID(): number;
  114204. /**
  114205. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114206. * Returns the DirectionalLight Shadow projection matrix.
  114207. */
  114208. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114209. /**
  114210. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114211. * Returns the DirectionalLight Shadow projection matrix.
  114212. */
  114213. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114214. /**
  114215. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114216. * Returns the DirectionalLight Shadow projection matrix.
  114217. */
  114218. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114219. protected _buildUniformLayout(): void;
  114220. /**
  114221. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114222. * @param effect The effect to update
  114223. * @param lightIndex The index of the light in the effect to update
  114224. * @returns The directional light
  114225. */
  114226. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114227. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114228. /**
  114229. * Gets the minZ used for shadow according to both the scene and the light.
  114230. *
  114231. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114232. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114233. * @param activeCamera The camera we are returning the min for
  114234. * @returns the depth min z
  114235. */
  114236. getDepthMinZ(activeCamera: Camera): number;
  114237. /**
  114238. * Gets the maxZ used for shadow according to both the scene and the light.
  114239. *
  114240. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114241. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114242. * @param activeCamera The camera we are returning the max for
  114243. * @returns the depth max z
  114244. */
  114245. getDepthMaxZ(activeCamera: Camera): number;
  114246. /**
  114247. * Prepares the list of defines specific to the light type.
  114248. * @param defines the list of defines
  114249. * @param lightIndex defines the index of the light for the effect
  114250. */
  114251. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114252. }
  114253. }
  114254. declare module BABYLON {
  114255. /**
  114256. * Class containing static functions to help procedurally build meshes
  114257. */
  114258. export class HemisphereBuilder {
  114259. /**
  114260. * Creates a hemisphere mesh
  114261. * @param name defines the name of the mesh
  114262. * @param options defines the options used to create the mesh
  114263. * @param scene defines the hosting scene
  114264. * @returns the hemisphere mesh
  114265. */
  114266. static CreateHemisphere(name: string, options: {
  114267. segments?: number;
  114268. diameter?: number;
  114269. sideOrientation?: number;
  114270. }, scene: any): Mesh;
  114271. }
  114272. }
  114273. declare module BABYLON {
  114274. /**
  114275. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114276. * These values define a cone of light starting from the position, emitting toward the direction.
  114277. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114278. * and the exponent defines the speed of the decay of the light with distance (reach).
  114279. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114280. */
  114281. export class SpotLight extends ShadowLight {
  114282. private _angle;
  114283. private _innerAngle;
  114284. private _cosHalfAngle;
  114285. private _lightAngleScale;
  114286. private _lightAngleOffset;
  114287. /**
  114288. * Gets the cone angle of the spot light in Radians.
  114289. */
  114290. /**
  114291. * Sets the cone angle of the spot light in Radians.
  114292. */
  114293. angle: number;
  114294. /**
  114295. * Only used in gltf falloff mode, this defines the angle where
  114296. * the directional falloff will start before cutting at angle which could be seen
  114297. * as outer angle.
  114298. */
  114299. /**
  114300. * Only used in gltf falloff mode, this defines the angle where
  114301. * the directional falloff will start before cutting at angle which could be seen
  114302. * as outer angle.
  114303. */
  114304. innerAngle: number;
  114305. private _shadowAngleScale;
  114306. /**
  114307. * Allows scaling the angle of the light for shadow generation only.
  114308. */
  114309. /**
  114310. * Allows scaling the angle of the light for shadow generation only.
  114311. */
  114312. shadowAngleScale: number;
  114313. /**
  114314. * The light decay speed with the distance from the emission spot.
  114315. */
  114316. exponent: number;
  114317. private _projectionTextureMatrix;
  114318. /**
  114319. * Allows reading the projecton texture
  114320. */
  114321. readonly projectionTextureMatrix: Matrix;
  114322. protected _projectionTextureLightNear: number;
  114323. /**
  114324. * Gets the near clip of the Spotlight for texture projection.
  114325. */
  114326. /**
  114327. * Sets the near clip of the Spotlight for texture projection.
  114328. */
  114329. projectionTextureLightNear: number;
  114330. protected _projectionTextureLightFar: number;
  114331. /**
  114332. * Gets the far clip of the Spotlight for texture projection.
  114333. */
  114334. /**
  114335. * Sets the far clip of the Spotlight for texture projection.
  114336. */
  114337. projectionTextureLightFar: number;
  114338. protected _projectionTextureUpDirection: Vector3;
  114339. /**
  114340. * Gets the Up vector of the Spotlight for texture projection.
  114341. */
  114342. /**
  114343. * Sets the Up vector of the Spotlight for texture projection.
  114344. */
  114345. projectionTextureUpDirection: Vector3;
  114346. private _projectionTexture;
  114347. /**
  114348. * Gets the projection texture of the light.
  114349. */
  114350. /**
  114351. * Sets the projection texture of the light.
  114352. */
  114353. projectionTexture: Nullable<BaseTexture>;
  114354. private _projectionTextureViewLightDirty;
  114355. private _projectionTextureProjectionLightDirty;
  114356. private _projectionTextureDirty;
  114357. private _projectionTextureViewTargetVector;
  114358. private _projectionTextureViewLightMatrix;
  114359. private _projectionTextureProjectionLightMatrix;
  114360. private _projectionTextureScalingMatrix;
  114361. /**
  114362. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114363. * It can cast shadows.
  114364. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114365. * @param name The light friendly name
  114366. * @param position The position of the spot light in the scene
  114367. * @param direction The direction of the light in the scene
  114368. * @param angle The cone angle of the light in Radians
  114369. * @param exponent The light decay speed with the distance from the emission spot
  114370. * @param scene The scene the lights belongs to
  114371. */
  114372. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114373. /**
  114374. * Returns the string "SpotLight".
  114375. * @returns the class name
  114376. */
  114377. getClassName(): string;
  114378. /**
  114379. * Returns the integer 2.
  114380. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114381. */
  114382. getTypeID(): number;
  114383. /**
  114384. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114385. */
  114386. protected _setDirection(value: Vector3): void;
  114387. /**
  114388. * Overrides the position setter to recompute the projection texture view light Matrix.
  114389. */
  114390. protected _setPosition(value: Vector3): void;
  114391. /**
  114392. * 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.
  114393. * Returns the SpotLight.
  114394. */
  114395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114396. protected _computeProjectionTextureViewLightMatrix(): void;
  114397. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114398. /**
  114399. * Main function for light texture projection matrix computing.
  114400. */
  114401. protected _computeProjectionTextureMatrix(): void;
  114402. protected _buildUniformLayout(): void;
  114403. private _computeAngleValues;
  114404. /**
  114405. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114406. * @param effect The effect to update
  114407. * @param lightIndex The index of the light in the effect to update
  114408. * @returns The spot light
  114409. */
  114410. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114411. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114412. /**
  114413. * Disposes the light and the associated resources.
  114414. */
  114415. dispose(): void;
  114416. /**
  114417. * Prepares the list of defines specific to the light type.
  114418. * @param defines the list of defines
  114419. * @param lightIndex defines the index of the light for the effect
  114420. */
  114421. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114422. }
  114423. }
  114424. declare module BABYLON {
  114425. /**
  114426. * Gizmo that enables viewing a light
  114427. */
  114428. export class LightGizmo extends Gizmo {
  114429. private _lightMesh;
  114430. private _material;
  114431. private cachedPosition;
  114432. private cachedForward;
  114433. /**
  114434. * Creates a LightGizmo
  114435. * @param gizmoLayer The utility layer the gizmo will be added to
  114436. */
  114437. constructor(gizmoLayer?: UtilityLayerRenderer);
  114438. private _light;
  114439. /**
  114440. * The light that the gizmo is attached to
  114441. */
  114442. light: Nullable<Light>;
  114443. /**
  114444. * Gets the material used to render the light gizmo
  114445. */
  114446. readonly material: StandardMaterial;
  114447. /**
  114448. * @hidden
  114449. * Updates the gizmo to match the attached mesh's position/rotation
  114450. */
  114451. protected _update(): void;
  114452. private static _Scale;
  114453. /**
  114454. * Creates the lines for a light mesh
  114455. */
  114456. private static _createLightLines;
  114457. /**
  114458. * Disposes of the light gizmo
  114459. */
  114460. dispose(): void;
  114461. private static _CreateHemisphericLightMesh;
  114462. private static _CreatePointLightMesh;
  114463. private static _CreateSpotLightMesh;
  114464. private static _CreateDirectionalLightMesh;
  114465. }
  114466. }
  114467. declare module BABYLON {
  114468. /** @hidden */
  114469. export var backgroundFragmentDeclaration: {
  114470. name: string;
  114471. shader: string;
  114472. };
  114473. }
  114474. declare module BABYLON {
  114475. /** @hidden */
  114476. export var backgroundUboDeclaration: {
  114477. name: string;
  114478. shader: string;
  114479. };
  114480. }
  114481. declare module BABYLON {
  114482. /** @hidden */
  114483. export var backgroundPixelShader: {
  114484. name: string;
  114485. shader: string;
  114486. };
  114487. }
  114488. declare module BABYLON {
  114489. /** @hidden */
  114490. export var backgroundVertexDeclaration: {
  114491. name: string;
  114492. shader: string;
  114493. };
  114494. }
  114495. declare module BABYLON {
  114496. /** @hidden */
  114497. export var backgroundVertexShader: {
  114498. name: string;
  114499. shader: string;
  114500. };
  114501. }
  114502. declare module BABYLON {
  114503. /**
  114504. * Background material used to create an efficient environement around your scene.
  114505. */
  114506. export class BackgroundMaterial extends PushMaterial {
  114507. /**
  114508. * Standard reflectance value at parallel view angle.
  114509. */
  114510. static StandardReflectance0: number;
  114511. /**
  114512. * Standard reflectance value at grazing angle.
  114513. */
  114514. static StandardReflectance90: number;
  114515. protected _primaryColor: Color3;
  114516. /**
  114517. * Key light Color (multiply against the environement texture)
  114518. */
  114519. primaryColor: Color3;
  114520. protected __perceptualColor: Nullable<Color3>;
  114521. /**
  114522. * Experimental Internal Use Only.
  114523. *
  114524. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114525. * This acts as a helper to set the primary color to a more "human friendly" value.
  114526. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114527. * output color as close as possible from the chosen value.
  114528. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114529. * part of lighting setup.)
  114530. */
  114531. _perceptualColor: Nullable<Color3>;
  114532. protected _primaryColorShadowLevel: float;
  114533. /**
  114534. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114535. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114536. */
  114537. primaryColorShadowLevel: float;
  114538. protected _primaryColorHighlightLevel: float;
  114539. /**
  114540. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114541. * The primary color is used at the level chosen to define what the white area would look.
  114542. */
  114543. primaryColorHighlightLevel: float;
  114544. protected _reflectionTexture: Nullable<BaseTexture>;
  114545. /**
  114546. * Reflection Texture used in the material.
  114547. * Should be author in a specific way for the best result (refer to the documentation).
  114548. */
  114549. reflectionTexture: Nullable<BaseTexture>;
  114550. protected _reflectionBlur: float;
  114551. /**
  114552. * Reflection Texture level of blur.
  114553. *
  114554. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114555. * texture twice.
  114556. */
  114557. reflectionBlur: float;
  114558. protected _diffuseTexture: Nullable<BaseTexture>;
  114559. /**
  114560. * Diffuse Texture used in the material.
  114561. * Should be author in a specific way for the best result (refer to the documentation).
  114562. */
  114563. diffuseTexture: Nullable<BaseTexture>;
  114564. protected _shadowLights: Nullable<IShadowLight[]>;
  114565. /**
  114566. * Specify the list of lights casting shadow on the material.
  114567. * All scene shadow lights will be included if null.
  114568. */
  114569. shadowLights: Nullable<IShadowLight[]>;
  114570. protected _shadowLevel: float;
  114571. /**
  114572. * Helps adjusting the shadow to a softer level if required.
  114573. * 0 means black shadows and 1 means no shadows.
  114574. */
  114575. shadowLevel: float;
  114576. protected _sceneCenter: Vector3;
  114577. /**
  114578. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114579. * It is usually zero but might be interesting to modify according to your setup.
  114580. */
  114581. sceneCenter: Vector3;
  114582. protected _opacityFresnel: boolean;
  114583. /**
  114584. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114585. * This helps ensuring a nice transition when the camera goes under the ground.
  114586. */
  114587. opacityFresnel: boolean;
  114588. protected _reflectionFresnel: boolean;
  114589. /**
  114590. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114591. * This helps adding a mirror texture on the ground.
  114592. */
  114593. reflectionFresnel: boolean;
  114594. protected _reflectionFalloffDistance: number;
  114595. /**
  114596. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  114597. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  114598. */
  114599. reflectionFalloffDistance: number;
  114600. protected _reflectionAmount: number;
  114601. /**
  114602. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  114603. */
  114604. reflectionAmount: number;
  114605. protected _reflectionReflectance0: number;
  114606. /**
  114607. * This specifies the weight of the reflection at grazing angle.
  114608. */
  114609. reflectionReflectance0: number;
  114610. protected _reflectionReflectance90: number;
  114611. /**
  114612. * This specifies the weight of the reflection at a perpendicular point of view.
  114613. */
  114614. reflectionReflectance90: number;
  114615. /**
  114616. * Sets the reflection reflectance fresnel values according to the default standard
  114617. * empirically know to work well :-)
  114618. */
  114619. reflectionStandardFresnelWeight: number;
  114620. protected _useRGBColor: boolean;
  114621. /**
  114622. * Helps to directly use the maps channels instead of their level.
  114623. */
  114624. useRGBColor: boolean;
  114625. protected _enableNoise: boolean;
  114626. /**
  114627. * This helps reducing the banding effect that could occur on the background.
  114628. */
  114629. enableNoise: boolean;
  114630. /**
  114631. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114632. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  114633. * Recommended to be keep at 1.0 except for special cases.
  114634. */
  114635. fovMultiplier: number;
  114636. private _fovMultiplier;
  114637. /**
  114638. * Enable the FOV adjustment feature controlled by fovMultiplier.
  114639. */
  114640. useEquirectangularFOV: boolean;
  114641. private _maxSimultaneousLights;
  114642. /**
  114643. * Number of Simultaneous lights allowed on the material.
  114644. */
  114645. maxSimultaneousLights: int;
  114646. /**
  114647. * Default configuration related to image processing available in the Background Material.
  114648. */
  114649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114650. /**
  114651. * Keep track of the image processing observer to allow dispose and replace.
  114652. */
  114653. private _imageProcessingObserver;
  114654. /**
  114655. * Attaches a new image processing configuration to the PBR Material.
  114656. * @param configuration (if null the scene configuration will be use)
  114657. */
  114658. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114659. /**
  114660. * Gets the image processing configuration used either in this material.
  114661. */
  114662. /**
  114663. * Sets the Default image processing configuration used either in the this material.
  114664. *
  114665. * If sets to null, the scene one is in use.
  114666. */
  114667. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  114668. /**
  114669. * Gets wether the color curves effect is enabled.
  114670. */
  114671. /**
  114672. * Sets wether the color curves effect is enabled.
  114673. */
  114674. cameraColorCurvesEnabled: boolean;
  114675. /**
  114676. * Gets wether the color grading effect is enabled.
  114677. */
  114678. /**
  114679. * Gets wether the color grading effect is enabled.
  114680. */
  114681. cameraColorGradingEnabled: boolean;
  114682. /**
  114683. * Gets wether tonemapping is enabled or not.
  114684. */
  114685. /**
  114686. * Sets wether tonemapping is enabled or not
  114687. */
  114688. cameraToneMappingEnabled: boolean;
  114689. /**
  114690. * The camera exposure used on this material.
  114691. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114692. * This corresponds to a photographic exposure.
  114693. */
  114694. /**
  114695. * The camera exposure used on this material.
  114696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114697. * This corresponds to a photographic exposure.
  114698. */
  114699. cameraExposure: float;
  114700. /**
  114701. * Gets The camera contrast used on this material.
  114702. */
  114703. /**
  114704. * Sets The camera contrast used on this material.
  114705. */
  114706. cameraContrast: float;
  114707. /**
  114708. * Gets the Color Grading 2D Lookup Texture.
  114709. */
  114710. /**
  114711. * Sets the Color Grading 2D Lookup Texture.
  114712. */
  114713. cameraColorGradingTexture: Nullable<BaseTexture>;
  114714. /**
  114715. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114716. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114717. * 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;
  114718. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114719. */
  114720. /**
  114721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114723. * 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;
  114724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114725. */
  114726. cameraColorCurves: Nullable<ColorCurves>;
  114727. /**
  114728. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  114729. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  114730. */
  114731. switchToBGR: boolean;
  114732. private _renderTargets;
  114733. private _reflectionControls;
  114734. private _white;
  114735. private _primaryShadowColor;
  114736. private _primaryHighlightColor;
  114737. /**
  114738. * Instantiates a Background Material in the given scene
  114739. * @param name The friendly name of the material
  114740. * @param scene The scene to add the material to
  114741. */
  114742. constructor(name: string, scene: Scene);
  114743. /**
  114744. * Gets a boolean indicating that current material needs to register RTT
  114745. */
  114746. readonly hasRenderTargetTextures: boolean;
  114747. /**
  114748. * The entire material has been created in order to prevent overdraw.
  114749. * @returns false
  114750. */
  114751. needAlphaTesting(): boolean;
  114752. /**
  114753. * The entire material has been created in order to prevent overdraw.
  114754. * @returns true if blending is enable
  114755. */
  114756. needAlphaBlending(): boolean;
  114757. /**
  114758. * Checks wether the material is ready to be rendered for a given mesh.
  114759. * @param mesh The mesh to render
  114760. * @param subMesh The submesh to check against
  114761. * @param useInstances Specify wether or not the material is used with instances
  114762. * @returns true if all the dependencies are ready (Textures, Effects...)
  114763. */
  114764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114765. /**
  114766. * Compute the primary color according to the chosen perceptual color.
  114767. */
  114768. private _computePrimaryColorFromPerceptualColor;
  114769. /**
  114770. * Compute the highlights and shadow colors according to their chosen levels.
  114771. */
  114772. private _computePrimaryColors;
  114773. /**
  114774. * Build the uniform buffer used in the material.
  114775. */
  114776. buildUniformLayout(): void;
  114777. /**
  114778. * Unbind the material.
  114779. */
  114780. unbind(): void;
  114781. /**
  114782. * Bind only the world matrix to the material.
  114783. * @param world The world matrix to bind.
  114784. */
  114785. bindOnlyWorldMatrix(world: Matrix): void;
  114786. /**
  114787. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  114788. * @param world The world matrix to bind.
  114789. * @param subMesh The submesh to bind for.
  114790. */
  114791. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114792. /**
  114793. * Checks to see if a texture is used in the material.
  114794. * @param texture - Base texture to use.
  114795. * @returns - Boolean specifying if a texture is used in the material.
  114796. */
  114797. hasTexture(texture: BaseTexture): boolean;
  114798. /**
  114799. * Dispose the material.
  114800. * @param forceDisposeEffect Force disposal of the associated effect.
  114801. * @param forceDisposeTextures Force disposal of the associated textures.
  114802. */
  114803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114804. /**
  114805. * Clones the material.
  114806. * @param name The cloned name.
  114807. * @returns The cloned material.
  114808. */
  114809. clone(name: string): BackgroundMaterial;
  114810. /**
  114811. * Serializes the current material to its JSON representation.
  114812. * @returns The JSON representation.
  114813. */
  114814. serialize(): any;
  114815. /**
  114816. * Gets the class name of the material
  114817. * @returns "BackgroundMaterial"
  114818. */
  114819. getClassName(): string;
  114820. /**
  114821. * Parse a JSON input to create back a background material.
  114822. * @param source The JSON data to parse
  114823. * @param scene The scene to create the parsed material in
  114824. * @param rootUrl The root url of the assets the material depends upon
  114825. * @returns the instantiated BackgroundMaterial.
  114826. */
  114827. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  114828. }
  114829. }
  114830. declare module BABYLON {
  114831. /**
  114832. * Represents the different options available during the creation of
  114833. * a Environment helper.
  114834. *
  114835. * This can control the default ground, skybox and image processing setup of your scene.
  114836. */
  114837. export interface IEnvironmentHelperOptions {
  114838. /**
  114839. * Specifies wether or not to create a ground.
  114840. * True by default.
  114841. */
  114842. createGround: boolean;
  114843. /**
  114844. * Specifies the ground size.
  114845. * 15 by default.
  114846. */
  114847. groundSize: number;
  114848. /**
  114849. * The texture used on the ground for the main color.
  114850. * Comes from the BabylonJS CDN by default.
  114851. *
  114852. * Remarks: Can be either a texture or a url.
  114853. */
  114854. groundTexture: string | BaseTexture;
  114855. /**
  114856. * The color mixed in the ground texture by default.
  114857. * BabylonJS clearColor by default.
  114858. */
  114859. groundColor: Color3;
  114860. /**
  114861. * Specifies the ground opacity.
  114862. * 1 by default.
  114863. */
  114864. groundOpacity: number;
  114865. /**
  114866. * Enables the ground to receive shadows.
  114867. * True by default.
  114868. */
  114869. enableGroundShadow: boolean;
  114870. /**
  114871. * Helps preventing the shadow to be fully black on the ground.
  114872. * 0.5 by default.
  114873. */
  114874. groundShadowLevel: number;
  114875. /**
  114876. * Creates a mirror texture attach to the ground.
  114877. * false by default.
  114878. */
  114879. enableGroundMirror: boolean;
  114880. /**
  114881. * Specifies the ground mirror size ratio.
  114882. * 0.3 by default as the default kernel is 64.
  114883. */
  114884. groundMirrorSizeRatio: number;
  114885. /**
  114886. * Specifies the ground mirror blur kernel size.
  114887. * 64 by default.
  114888. */
  114889. groundMirrorBlurKernel: number;
  114890. /**
  114891. * Specifies the ground mirror visibility amount.
  114892. * 1 by default
  114893. */
  114894. groundMirrorAmount: number;
  114895. /**
  114896. * Specifies the ground mirror reflectance weight.
  114897. * This uses the standard weight of the background material to setup the fresnel effect
  114898. * of the mirror.
  114899. * 1 by default.
  114900. */
  114901. groundMirrorFresnelWeight: number;
  114902. /**
  114903. * Specifies the ground mirror Falloff distance.
  114904. * This can helps reducing the size of the reflection.
  114905. * 0 by Default.
  114906. */
  114907. groundMirrorFallOffDistance: number;
  114908. /**
  114909. * Specifies the ground mirror texture type.
  114910. * Unsigned Int by Default.
  114911. */
  114912. groundMirrorTextureType: number;
  114913. /**
  114914. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114915. * the shown objects.
  114916. */
  114917. groundYBias: number;
  114918. /**
  114919. * Specifies wether or not to create a skybox.
  114920. * True by default.
  114921. */
  114922. createSkybox: boolean;
  114923. /**
  114924. * Specifies the skybox size.
  114925. * 20 by default.
  114926. */
  114927. skyboxSize: number;
  114928. /**
  114929. * The texture used on the skybox for the main color.
  114930. * Comes from the BabylonJS CDN by default.
  114931. *
  114932. * Remarks: Can be either a texture or a url.
  114933. */
  114934. skyboxTexture: string | BaseTexture;
  114935. /**
  114936. * The color mixed in the skybox texture by default.
  114937. * BabylonJS clearColor by default.
  114938. */
  114939. skyboxColor: Color3;
  114940. /**
  114941. * The background rotation around the Y axis of the scene.
  114942. * This helps aligning the key lights of your scene with the background.
  114943. * 0 by default.
  114944. */
  114945. backgroundYRotation: number;
  114946. /**
  114947. * Compute automatically the size of the elements to best fit with the scene.
  114948. */
  114949. sizeAuto: boolean;
  114950. /**
  114951. * Default position of the rootMesh if autoSize is not true.
  114952. */
  114953. rootPosition: Vector3;
  114954. /**
  114955. * Sets up the image processing in the scene.
  114956. * true by default.
  114957. */
  114958. setupImageProcessing: boolean;
  114959. /**
  114960. * The texture used as your environment texture in the scene.
  114961. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114962. *
  114963. * Remarks: Can be either a texture or a url.
  114964. */
  114965. environmentTexture: string | BaseTexture;
  114966. /**
  114967. * The value of the exposure to apply to the scene.
  114968. * 0.6 by default if setupImageProcessing is true.
  114969. */
  114970. cameraExposure: number;
  114971. /**
  114972. * The value of the contrast to apply to the scene.
  114973. * 1.6 by default if setupImageProcessing is true.
  114974. */
  114975. cameraContrast: number;
  114976. /**
  114977. * Specifies wether or not tonemapping should be enabled in the scene.
  114978. * true by default if setupImageProcessing is true.
  114979. */
  114980. toneMappingEnabled: boolean;
  114981. }
  114982. /**
  114983. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114984. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114985. * It also helps with the default setup of your imageProcessing configuration.
  114986. */
  114987. export class EnvironmentHelper {
  114988. /**
  114989. * Default ground texture URL.
  114990. */
  114991. private static _groundTextureCDNUrl;
  114992. /**
  114993. * Default skybox texture URL.
  114994. */
  114995. private static _skyboxTextureCDNUrl;
  114996. /**
  114997. * Default environment texture URL.
  114998. */
  114999. private static _environmentTextureCDNUrl;
  115000. /**
  115001. * Creates the default options for the helper.
  115002. */
  115003. private static _getDefaultOptions;
  115004. private _rootMesh;
  115005. /**
  115006. * Gets the root mesh created by the helper.
  115007. */
  115008. readonly rootMesh: Mesh;
  115009. private _skybox;
  115010. /**
  115011. * Gets the skybox created by the helper.
  115012. */
  115013. readonly skybox: Nullable<Mesh>;
  115014. private _skyboxTexture;
  115015. /**
  115016. * Gets the skybox texture created by the helper.
  115017. */
  115018. readonly skyboxTexture: Nullable<BaseTexture>;
  115019. private _skyboxMaterial;
  115020. /**
  115021. * Gets the skybox material created by the helper.
  115022. */
  115023. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115024. private _ground;
  115025. /**
  115026. * Gets the ground mesh created by the helper.
  115027. */
  115028. readonly ground: Nullable<Mesh>;
  115029. private _groundTexture;
  115030. /**
  115031. * Gets the ground texture created by the helper.
  115032. */
  115033. readonly groundTexture: Nullable<BaseTexture>;
  115034. private _groundMirror;
  115035. /**
  115036. * Gets the ground mirror created by the helper.
  115037. */
  115038. readonly groundMirror: Nullable<MirrorTexture>;
  115039. /**
  115040. * Gets the ground mirror render list to helps pushing the meshes
  115041. * you wish in the ground reflection.
  115042. */
  115043. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115044. private _groundMaterial;
  115045. /**
  115046. * Gets the ground material created by the helper.
  115047. */
  115048. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115049. /**
  115050. * Stores the creation options.
  115051. */
  115052. private readonly _scene;
  115053. private _options;
  115054. /**
  115055. * This observable will be notified with any error during the creation of the environment,
  115056. * mainly texture creation errors.
  115057. */
  115058. onErrorObservable: Observable<{
  115059. message?: string;
  115060. exception?: any;
  115061. }>;
  115062. /**
  115063. * constructor
  115064. * @param options Defines the options we want to customize the helper
  115065. * @param scene The scene to add the material to
  115066. */
  115067. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115068. /**
  115069. * Updates the background according to the new options
  115070. * @param options
  115071. */
  115072. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115073. /**
  115074. * Sets the primary color of all the available elements.
  115075. * @param color the main color to affect to the ground and the background
  115076. */
  115077. setMainColor(color: Color3): void;
  115078. /**
  115079. * Setup the image processing according to the specified options.
  115080. */
  115081. private _setupImageProcessing;
  115082. /**
  115083. * Setup the environment texture according to the specified options.
  115084. */
  115085. private _setupEnvironmentTexture;
  115086. /**
  115087. * Setup the background according to the specified options.
  115088. */
  115089. private _setupBackground;
  115090. /**
  115091. * Get the scene sizes according to the setup.
  115092. */
  115093. private _getSceneSize;
  115094. /**
  115095. * Setup the ground according to the specified options.
  115096. */
  115097. private _setupGround;
  115098. /**
  115099. * Setup the ground material according to the specified options.
  115100. */
  115101. private _setupGroundMaterial;
  115102. /**
  115103. * Setup the ground diffuse texture according to the specified options.
  115104. */
  115105. private _setupGroundDiffuseTexture;
  115106. /**
  115107. * Setup the ground mirror texture according to the specified options.
  115108. */
  115109. private _setupGroundMirrorTexture;
  115110. /**
  115111. * Setup the ground to receive the mirror texture.
  115112. */
  115113. private _setupMirrorInGroundMaterial;
  115114. /**
  115115. * Setup the skybox according to the specified options.
  115116. */
  115117. private _setupSkybox;
  115118. /**
  115119. * Setup the skybox material according to the specified options.
  115120. */
  115121. private _setupSkyboxMaterial;
  115122. /**
  115123. * Setup the skybox reflection texture according to the specified options.
  115124. */
  115125. private _setupSkyboxReflectionTexture;
  115126. private _errorHandler;
  115127. /**
  115128. * Dispose all the elements created by the Helper.
  115129. */
  115130. dispose(): void;
  115131. }
  115132. }
  115133. declare module BABYLON {
  115134. /**
  115135. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115136. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115137. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115138. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115139. */
  115140. export class PhotoDome extends TransformNode {
  115141. /**
  115142. * Define the image as a Monoscopic panoramic 360 image.
  115143. */
  115144. static readonly MODE_MONOSCOPIC: number;
  115145. /**
  115146. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115147. */
  115148. static readonly MODE_TOPBOTTOM: number;
  115149. /**
  115150. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115151. */
  115152. static readonly MODE_SIDEBYSIDE: number;
  115153. private _useDirectMapping;
  115154. /**
  115155. * The texture being displayed on the sphere
  115156. */
  115157. protected _photoTexture: Texture;
  115158. /**
  115159. * Gets or sets the texture being displayed on the sphere
  115160. */
  115161. photoTexture: Texture;
  115162. /**
  115163. * Observable raised when an error occured while loading the 360 image
  115164. */
  115165. onLoadErrorObservable: Observable<string>;
  115166. /**
  115167. * The skybox material
  115168. */
  115169. protected _material: BackgroundMaterial;
  115170. /**
  115171. * The surface used for the skybox
  115172. */
  115173. protected _mesh: Mesh;
  115174. /**
  115175. * Gets the mesh used for the skybox.
  115176. */
  115177. readonly mesh: Mesh;
  115178. /**
  115179. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115180. * Also see the options.resolution property.
  115181. */
  115182. fovMultiplier: number;
  115183. private _imageMode;
  115184. /**
  115185. * Gets or set the current video mode for the video. It can be:
  115186. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115187. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115188. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115189. */
  115190. imageMode: number;
  115191. /**
  115192. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115193. * @param name Element's name, child elements will append suffixes for their own names.
  115194. * @param urlsOfPhoto defines the url of the photo to display
  115195. * @param options defines an object containing optional or exposed sub element properties
  115196. * @param onError defines a callback called when an error occured while loading the texture
  115197. */
  115198. constructor(name: string, urlOfPhoto: string, options: {
  115199. resolution?: number;
  115200. size?: number;
  115201. useDirectMapping?: boolean;
  115202. faceForward?: boolean;
  115203. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115204. private _onBeforeCameraRenderObserver;
  115205. private _changeImageMode;
  115206. /**
  115207. * Releases resources associated with this node.
  115208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115210. */
  115211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115212. }
  115213. }
  115214. declare module BABYLON {
  115215. /**
  115216. * Class used to host RGBD texture specific utilities
  115217. */
  115218. export class RGBDTextureTools {
  115219. /**
  115220. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115221. * @param texture the texture to expand.
  115222. */
  115223. static ExpandRGBDTexture(texture: Texture): void;
  115224. }
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * Class used to host texture specific utilities
  115229. */
  115230. export class BRDFTextureTools {
  115231. /**
  115232. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115233. * @param scene defines the hosting scene
  115234. * @returns the environment BRDF texture
  115235. */
  115236. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115237. private static _environmentBRDFBase64Texture;
  115238. }
  115239. }
  115240. declare module BABYLON {
  115241. /**
  115242. * @hidden
  115243. */
  115244. export interface IMaterialClearCoatDefines {
  115245. CLEARCOAT: boolean;
  115246. CLEARCOAT_DEFAULTIOR: boolean;
  115247. CLEARCOAT_TEXTURE: boolean;
  115248. CLEARCOAT_TEXTUREDIRECTUV: number;
  115249. CLEARCOAT_BUMP: boolean;
  115250. CLEARCOAT_BUMPDIRECTUV: number;
  115251. CLEARCOAT_TINT: boolean;
  115252. CLEARCOAT_TINT_TEXTURE: boolean;
  115253. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115254. /** @hidden */
  115255. _areTexturesDirty: boolean;
  115256. }
  115257. /**
  115258. * Define the code related to the clear coat parameters of the pbr material.
  115259. */
  115260. export class PBRClearCoatConfiguration {
  115261. /**
  115262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115263. * The default fits with a polyurethane material.
  115264. */
  115265. private static readonly _DefaultIndexOfRefraction;
  115266. private _isEnabled;
  115267. /**
  115268. * Defines if the clear coat is enabled in the material.
  115269. */
  115270. isEnabled: boolean;
  115271. /**
  115272. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115273. */
  115274. intensity: number;
  115275. /**
  115276. * Defines the clear coat layer roughness.
  115277. */
  115278. roughness: number;
  115279. private _indexOfRefraction;
  115280. /**
  115281. * Defines the index of refraction of the clear coat.
  115282. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115283. * The default fits with a polyurethane material.
  115284. * Changing the default value is more performance intensive.
  115285. */
  115286. indexOfRefraction: number;
  115287. private _texture;
  115288. /**
  115289. * Stores the clear coat values in a texture.
  115290. */
  115291. texture: Nullable<BaseTexture>;
  115292. private _bumpTexture;
  115293. /**
  115294. * Define the clear coat specific bump texture.
  115295. */
  115296. bumpTexture: Nullable<BaseTexture>;
  115297. private _isTintEnabled;
  115298. /**
  115299. * Defines if the clear coat tint is enabled in the material.
  115300. */
  115301. isTintEnabled: boolean;
  115302. /**
  115303. * Defines the clear coat tint of the material.
  115304. * This is only use if tint is enabled
  115305. */
  115306. tintColor: Color3;
  115307. /**
  115308. * Defines the distance at which the tint color should be found in the
  115309. * clear coat media.
  115310. * This is only use if tint is enabled
  115311. */
  115312. tintColorAtDistance: number;
  115313. /**
  115314. * Defines the clear coat layer thickness.
  115315. * This is only use if tint is enabled
  115316. */
  115317. tintThickness: number;
  115318. private _tintTexture;
  115319. /**
  115320. * Stores the clear tint values in a texture.
  115321. * rgb is tint
  115322. * a is a thickness factor
  115323. */
  115324. tintTexture: Nullable<BaseTexture>;
  115325. /** @hidden */
  115326. private _internalMarkAllSubMeshesAsTexturesDirty;
  115327. /** @hidden */
  115328. _markAllSubMeshesAsTexturesDirty(): void;
  115329. /**
  115330. * Instantiate a new istance of clear coat configuration.
  115331. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115332. */
  115333. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115334. /**
  115335. * Gets wehter the submesh is ready to be used or not.
  115336. * @param defines the list of "defines" to update.
  115337. * @param scene defines the scene the material belongs to.
  115338. * @param engine defines the engine the material belongs to.
  115339. * @param disableBumpMap defines wether the material disables bump or not.
  115340. * @returns - boolean indicating that the submesh is ready or not.
  115341. */
  115342. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115343. /**
  115344. * Checks to see if a texture is used in the material.
  115345. * @param defines the list of "defines" to update.
  115346. * @param scene defines the scene to the material belongs to.
  115347. */
  115348. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115349. /**
  115350. * Binds the material data.
  115351. * @param uniformBuffer defines the Uniform buffer to fill in.
  115352. * @param scene defines the scene the material belongs to.
  115353. * @param engine defines the engine the material belongs to.
  115354. * @param disableBumpMap defines wether the material disables bump or not.
  115355. * @param isFrozen defines wether the material is frozen or not.
  115356. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115357. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115358. */
  115359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115360. /**
  115361. * Checks to see if a texture is used in the material.
  115362. * @param texture - Base texture to use.
  115363. * @returns - Boolean specifying if a texture is used in the material.
  115364. */
  115365. hasTexture(texture: BaseTexture): boolean;
  115366. /**
  115367. * Returns an array of the actively used textures.
  115368. * @param activeTextures Array of BaseTextures
  115369. */
  115370. getActiveTextures(activeTextures: BaseTexture[]): void;
  115371. /**
  115372. * Returns the animatable textures.
  115373. * @param animatables Array of animatable textures.
  115374. */
  115375. getAnimatables(animatables: IAnimatable[]): void;
  115376. /**
  115377. * Disposes the resources of the material.
  115378. * @param forceDisposeTextures - Forces the disposal of all textures.
  115379. */
  115380. dispose(forceDisposeTextures?: boolean): void;
  115381. /**
  115382. * Get the current class name of the texture useful for serialization or dynamic coding.
  115383. * @returns "PBRClearCoatConfiguration"
  115384. */
  115385. getClassName(): string;
  115386. /**
  115387. * Add fallbacks to the effect fallbacks list.
  115388. * @param defines defines the Base texture to use.
  115389. * @param fallbacks defines the current fallback list.
  115390. * @param currentRank defines the current fallback rank.
  115391. * @returns the new fallback rank.
  115392. */
  115393. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115394. /**
  115395. * Add the required uniforms to the current list.
  115396. * @param uniforms defines the current uniform list.
  115397. */
  115398. static AddUniforms(uniforms: string[]): void;
  115399. /**
  115400. * Add the required samplers to the current list.
  115401. * @param samplers defines the current sampler list.
  115402. */
  115403. static AddSamplers(samplers: string[]): void;
  115404. /**
  115405. * Add the required uniforms to the current buffer.
  115406. * @param uniformBuffer defines the current uniform buffer.
  115407. */
  115408. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115409. /**
  115410. * Makes a duplicate of the current configuration into another one.
  115411. * @param clearCoatConfiguration define the config where to copy the info
  115412. */
  115413. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115414. /**
  115415. * Serializes this clear coat configuration.
  115416. * @returns - An object with the serialized config.
  115417. */
  115418. serialize(): any;
  115419. /**
  115420. * Parses a anisotropy Configuration from a serialized object.
  115421. * @param source - Serialized object.
  115422. * @param scene Defines the scene we are parsing for
  115423. * @param rootUrl Defines the rootUrl to load from
  115424. */
  115425. parse(source: any, scene: Scene, rootUrl: string): void;
  115426. }
  115427. }
  115428. declare module BABYLON {
  115429. /**
  115430. * @hidden
  115431. */
  115432. export interface IMaterialAnisotropicDefines {
  115433. ANISOTROPIC: boolean;
  115434. ANISOTROPIC_TEXTURE: boolean;
  115435. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115436. MAINUV1: boolean;
  115437. _areTexturesDirty: boolean;
  115438. _needUVs: boolean;
  115439. }
  115440. /**
  115441. * Define the code related to the anisotropic parameters of the pbr material.
  115442. */
  115443. export class PBRAnisotropicConfiguration {
  115444. private _isEnabled;
  115445. /**
  115446. * Defines if the anisotropy is enabled in the material.
  115447. */
  115448. isEnabled: boolean;
  115449. /**
  115450. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115451. */
  115452. intensity: number;
  115453. /**
  115454. * Defines if the effect is along the tangents, bitangents or in between.
  115455. * By default, the effect is "strectching" the highlights along the tangents.
  115456. */
  115457. direction: Vector2;
  115458. private _texture;
  115459. /**
  115460. * Stores the anisotropy values in a texture.
  115461. * rg is direction (like normal from -1 to 1)
  115462. * b is a intensity
  115463. */
  115464. texture: Nullable<BaseTexture>;
  115465. /** @hidden */
  115466. private _internalMarkAllSubMeshesAsTexturesDirty;
  115467. /** @hidden */
  115468. _markAllSubMeshesAsTexturesDirty(): void;
  115469. /**
  115470. * Instantiate a new istance of anisotropy configuration.
  115471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115472. */
  115473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115474. /**
  115475. * Specifies that the submesh is ready to be used.
  115476. * @param defines the list of "defines" to update.
  115477. * @param scene defines the scene the material belongs to.
  115478. * @returns - boolean indicating that the submesh is ready or not.
  115479. */
  115480. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115481. /**
  115482. * Checks to see if a texture is used in the material.
  115483. * @param defines the list of "defines" to update.
  115484. * @param mesh the mesh we are preparing the defines for.
  115485. * @param scene defines the scene the material belongs to.
  115486. */
  115487. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115488. /**
  115489. * Binds the material data.
  115490. * @param uniformBuffer defines the Uniform buffer to fill in.
  115491. * @param scene defines the scene the material belongs to.
  115492. * @param isFrozen defines wether the material is frozen or not.
  115493. */
  115494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115495. /**
  115496. * Checks to see if a texture is used in the material.
  115497. * @param texture - Base texture to use.
  115498. * @returns - Boolean specifying if a texture is used in the material.
  115499. */
  115500. hasTexture(texture: BaseTexture): boolean;
  115501. /**
  115502. * Returns an array of the actively used textures.
  115503. * @param activeTextures Array of BaseTextures
  115504. */
  115505. getActiveTextures(activeTextures: BaseTexture[]): void;
  115506. /**
  115507. * Returns the animatable textures.
  115508. * @param animatables Array of animatable textures.
  115509. */
  115510. getAnimatables(animatables: IAnimatable[]): void;
  115511. /**
  115512. * Disposes the resources of the material.
  115513. * @param forceDisposeTextures - Forces the disposal of all textures.
  115514. */
  115515. dispose(forceDisposeTextures?: boolean): void;
  115516. /**
  115517. * Get the current class name of the texture useful for serialization or dynamic coding.
  115518. * @returns "PBRAnisotropicConfiguration"
  115519. */
  115520. getClassName(): string;
  115521. /**
  115522. * Add fallbacks to the effect fallbacks list.
  115523. * @param defines defines the Base texture to use.
  115524. * @param fallbacks defines the current fallback list.
  115525. * @param currentRank defines the current fallback rank.
  115526. * @returns the new fallback rank.
  115527. */
  115528. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115529. /**
  115530. * Add the required uniforms to the current list.
  115531. * @param uniforms defines the current uniform list.
  115532. */
  115533. static AddUniforms(uniforms: string[]): void;
  115534. /**
  115535. * Add the required uniforms to the current buffer.
  115536. * @param uniformBuffer defines the current uniform buffer.
  115537. */
  115538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115539. /**
  115540. * Add the required samplers to the current list.
  115541. * @param samplers defines the current sampler list.
  115542. */
  115543. static AddSamplers(samplers: string[]): void;
  115544. /**
  115545. * Makes a duplicate of the current configuration into another one.
  115546. * @param anisotropicConfiguration define the config where to copy the info
  115547. */
  115548. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115549. /**
  115550. * Serializes this anisotropy configuration.
  115551. * @returns - An object with the serialized config.
  115552. */
  115553. serialize(): any;
  115554. /**
  115555. * Parses a anisotropy Configuration from a serialized object.
  115556. * @param source - Serialized object.
  115557. * @param scene Defines the scene we are parsing for
  115558. * @param rootUrl Defines the rootUrl to load from
  115559. */
  115560. parse(source: any, scene: Scene, rootUrl: string): void;
  115561. }
  115562. }
  115563. declare module BABYLON {
  115564. /**
  115565. * @hidden
  115566. */
  115567. export interface IMaterialBRDFDefines {
  115568. BRDF_V_HEIGHT_CORRELATED: boolean;
  115569. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115570. SPHERICAL_HARMONICS: boolean;
  115571. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115572. /** @hidden */
  115573. _areMiscDirty: boolean;
  115574. }
  115575. /**
  115576. * Define the code related to the BRDF parameters of the pbr material.
  115577. */
  115578. export class PBRBRDFConfiguration {
  115579. /**
  115580. * Default value used for the energy conservation.
  115581. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115582. */
  115583. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115584. /**
  115585. * Default value used for the Smith Visibility Height Correlated mode.
  115586. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115587. */
  115588. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115589. /**
  115590. * Default value used for the IBL diffuse part.
  115591. * This can help switching back to the polynomials mode globally which is a tiny bit
  115592. * less GPU intensive at the drawback of a lower quality.
  115593. */
  115594. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  115595. /**
  115596. * Default value used for activating energy conservation for the specular workflow.
  115597. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115598. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115599. */
  115600. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  115601. private _useEnergyConservation;
  115602. /**
  115603. * Defines if the material uses energy conservation.
  115604. */
  115605. useEnergyConservation: boolean;
  115606. private _useSmithVisibilityHeightCorrelated;
  115607. /**
  115608. * LEGACY Mode set to false
  115609. * Defines if the material uses height smith correlated visibility term.
  115610. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  115611. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  115612. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  115613. * Not relying on height correlated will also disable energy conservation.
  115614. */
  115615. useSmithVisibilityHeightCorrelated: boolean;
  115616. private _useSphericalHarmonics;
  115617. /**
  115618. * LEGACY Mode set to false
  115619. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  115620. * diffuse part of the IBL.
  115621. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  115622. * to the ground truth.
  115623. */
  115624. useSphericalHarmonics: boolean;
  115625. private _useSpecularGlossinessInputEnergyConservation;
  115626. /**
  115627. * Defines if the material uses energy conservation, when the specular workflow is active.
  115628. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  115629. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  115630. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  115631. */
  115632. useSpecularGlossinessInputEnergyConservation: boolean;
  115633. /** @hidden */
  115634. private _internalMarkAllSubMeshesAsMiscDirty;
  115635. /** @hidden */
  115636. _markAllSubMeshesAsMiscDirty(): void;
  115637. /**
  115638. * Instantiate a new istance of clear coat configuration.
  115639. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  115640. */
  115641. constructor(markAllSubMeshesAsMiscDirty: () => void);
  115642. /**
  115643. * Checks to see if a texture is used in the material.
  115644. * @param defines the list of "defines" to update.
  115645. */
  115646. prepareDefines(defines: IMaterialBRDFDefines): void;
  115647. /**
  115648. * Get the current class name of the texture useful for serialization or dynamic coding.
  115649. * @returns "PBRClearCoatConfiguration"
  115650. */
  115651. getClassName(): string;
  115652. /**
  115653. * Makes a duplicate of the current configuration into another one.
  115654. * @param brdfConfiguration define the config where to copy the info
  115655. */
  115656. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  115657. /**
  115658. * Serializes this BRDF configuration.
  115659. * @returns - An object with the serialized config.
  115660. */
  115661. serialize(): any;
  115662. /**
  115663. * Parses a anisotropy Configuration from a serialized object.
  115664. * @param source - Serialized object.
  115665. * @param scene Defines the scene we are parsing for
  115666. * @param rootUrl Defines the rootUrl to load from
  115667. */
  115668. parse(source: any, scene: Scene, rootUrl: string): void;
  115669. }
  115670. }
  115671. declare module BABYLON {
  115672. /**
  115673. * @hidden
  115674. */
  115675. export interface IMaterialSheenDefines {
  115676. SHEEN: boolean;
  115677. SHEEN_TEXTURE: boolean;
  115678. SHEEN_TEXTUREDIRECTUV: number;
  115679. SHEEN_LINKWITHALBEDO: boolean;
  115680. /** @hidden */
  115681. _areTexturesDirty: boolean;
  115682. }
  115683. /**
  115684. * Define the code related to the Sheen parameters of the pbr material.
  115685. */
  115686. export class PBRSheenConfiguration {
  115687. private _isEnabled;
  115688. /**
  115689. * Defines if the material uses sheen.
  115690. */
  115691. isEnabled: boolean;
  115692. private _linkSheenWithAlbedo;
  115693. /**
  115694. * Defines if the sheen is linked to the sheen color.
  115695. */
  115696. linkSheenWithAlbedo: boolean;
  115697. /**
  115698. * Defines the sheen intensity.
  115699. */
  115700. intensity: number;
  115701. /**
  115702. * Defines the sheen color.
  115703. */
  115704. color: Color3;
  115705. private _texture;
  115706. /**
  115707. * Stores the sheen tint values in a texture.
  115708. * rgb is tint
  115709. * a is a intensity
  115710. */
  115711. texture: Nullable<BaseTexture>;
  115712. /** @hidden */
  115713. private _internalMarkAllSubMeshesAsTexturesDirty;
  115714. /** @hidden */
  115715. _markAllSubMeshesAsTexturesDirty(): void;
  115716. /**
  115717. * Instantiate a new istance of clear coat configuration.
  115718. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115719. */
  115720. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115721. /**
  115722. * Specifies that the submesh is ready to be used.
  115723. * @param defines the list of "defines" to update.
  115724. * @param scene defines the scene the material belongs to.
  115725. * @returns - boolean indicating that the submesh is ready or not.
  115726. */
  115727. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  115728. /**
  115729. * Checks to see if a texture is used in the material.
  115730. * @param defines the list of "defines" to update.
  115731. * @param scene defines the scene the material belongs to.
  115732. */
  115733. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  115734. /**
  115735. * Binds the material data.
  115736. * @param uniformBuffer defines the Uniform buffer to fill in.
  115737. * @param scene defines the scene the material belongs to.
  115738. * @param isFrozen defines wether the material is frozen or not.
  115739. */
  115740. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115741. /**
  115742. * Checks to see if a texture is used in the material.
  115743. * @param texture - Base texture to use.
  115744. * @returns - Boolean specifying if a texture is used in the material.
  115745. */
  115746. hasTexture(texture: BaseTexture): boolean;
  115747. /**
  115748. * Returns an array of the actively used textures.
  115749. * @param activeTextures Array of BaseTextures
  115750. */
  115751. getActiveTextures(activeTextures: BaseTexture[]): void;
  115752. /**
  115753. * Returns the animatable textures.
  115754. * @param animatables Array of animatable textures.
  115755. */
  115756. getAnimatables(animatables: IAnimatable[]): void;
  115757. /**
  115758. * Disposes the resources of the material.
  115759. * @param forceDisposeTextures - Forces the disposal of all textures.
  115760. */
  115761. dispose(forceDisposeTextures?: boolean): void;
  115762. /**
  115763. * Get the current class name of the texture useful for serialization or dynamic coding.
  115764. * @returns "PBRSheenConfiguration"
  115765. */
  115766. getClassName(): string;
  115767. /**
  115768. * Add fallbacks to the effect fallbacks list.
  115769. * @param defines defines the Base texture to use.
  115770. * @param fallbacks defines the current fallback list.
  115771. * @param currentRank defines the current fallback rank.
  115772. * @returns the new fallback rank.
  115773. */
  115774. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115775. /**
  115776. * Add the required uniforms to the current list.
  115777. * @param uniforms defines the current uniform list.
  115778. */
  115779. static AddUniforms(uniforms: string[]): void;
  115780. /**
  115781. * Add the required uniforms to the current buffer.
  115782. * @param uniformBuffer defines the current uniform buffer.
  115783. */
  115784. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115785. /**
  115786. * Add the required samplers to the current list.
  115787. * @param samplers defines the current sampler list.
  115788. */
  115789. static AddSamplers(samplers: string[]): void;
  115790. /**
  115791. * Makes a duplicate of the current configuration into another one.
  115792. * @param sheenConfiguration define the config where to copy the info
  115793. */
  115794. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  115795. /**
  115796. * Serializes this BRDF configuration.
  115797. * @returns - An object with the serialized config.
  115798. */
  115799. serialize(): any;
  115800. /**
  115801. * Parses a anisotropy Configuration from a serialized object.
  115802. * @param source - Serialized object.
  115803. * @param scene Defines the scene we are parsing for
  115804. * @param rootUrl Defines the rootUrl to load from
  115805. */
  115806. parse(source: any, scene: Scene, rootUrl: string): void;
  115807. }
  115808. }
  115809. declare module BABYLON {
  115810. /**
  115811. * @hidden
  115812. */
  115813. export interface IMaterialSubSurfaceDefines {
  115814. SUBSURFACE: boolean;
  115815. SS_REFRACTION: boolean;
  115816. SS_TRANSLUCENCY: boolean;
  115817. SS_SCATERRING: boolean;
  115818. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115819. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115820. SS_REFRACTIONMAP_3D: boolean;
  115821. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115822. SS_LODINREFRACTIONALPHA: boolean;
  115823. SS_GAMMAREFRACTION: boolean;
  115824. SS_RGBDREFRACTION: boolean;
  115825. SS_LINEARSPECULARREFRACTION: boolean;
  115826. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115827. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115828. /** @hidden */
  115829. _areTexturesDirty: boolean;
  115830. }
  115831. /**
  115832. * Define the code related to the sub surface parameters of the pbr material.
  115833. */
  115834. export class PBRSubSurfaceConfiguration {
  115835. private _isRefractionEnabled;
  115836. /**
  115837. * Defines if the refraction is enabled in the material.
  115838. */
  115839. isRefractionEnabled: boolean;
  115840. private _isTranslucencyEnabled;
  115841. /**
  115842. * Defines if the translucency is enabled in the material.
  115843. */
  115844. isTranslucencyEnabled: boolean;
  115845. private _isScatteringEnabled;
  115846. /**
  115847. * Defines the refraction intensity of the material.
  115848. * The refraction when enabled replaces the Diffuse part of the material.
  115849. * The intensity helps transitionning between diffuse and refraction.
  115850. */
  115851. refractionIntensity: number;
  115852. /**
  115853. * Defines the translucency intensity of the material.
  115854. * When translucency has been enabled, this defines how much of the "translucency"
  115855. * is addded to the diffuse part of the material.
  115856. */
  115857. translucencyIntensity: number;
  115858. /**
  115859. * Defines the scattering intensity of the material.
  115860. * When scattering has been enabled, this defines how much of the "scattered light"
  115861. * is addded to the diffuse part of the material.
  115862. */
  115863. scatteringIntensity: number;
  115864. private _thicknessTexture;
  115865. /**
  115866. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115867. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115868. * 0 would mean minimumThickness
  115869. * 1 would mean maximumThickness
  115870. * The other channels might be use as a mask to vary the different effects intensity.
  115871. */
  115872. thicknessTexture: Nullable<BaseTexture>;
  115873. private _refractionTexture;
  115874. /**
  115875. * Defines the texture to use for refraction.
  115876. */
  115877. refractionTexture: Nullable<BaseTexture>;
  115878. private _indexOfRefraction;
  115879. /**
  115880. * Defines the index of refraction used in the material.
  115881. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115882. */
  115883. indexOfRefraction: number;
  115884. private _invertRefractionY;
  115885. /**
  115886. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115887. */
  115888. invertRefractionY: boolean;
  115889. private _linkRefractionWithTransparency;
  115890. /**
  115891. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115892. * Materials half opaque for instance using refraction could benefit from this control.
  115893. */
  115894. linkRefractionWithTransparency: boolean;
  115895. /**
  115896. * Defines the minimum thickness stored in the thickness map.
  115897. * If no thickness map is defined, this value will be used to simulate thickness.
  115898. */
  115899. minimumThickness: number;
  115900. /**
  115901. * Defines the maximum thickness stored in the thickness map.
  115902. */
  115903. maximumThickness: number;
  115904. /**
  115905. * Defines the volume tint of the material.
  115906. * This is used for both translucency and scattering.
  115907. */
  115908. tintColor: Color3;
  115909. /**
  115910. * Defines the distance at which the tint color should be found in the media.
  115911. * This is used for refraction only.
  115912. */
  115913. tintColorAtDistance: number;
  115914. /**
  115915. * Defines how far each channel transmit through the media.
  115916. * It is defined as a color to simplify it selection.
  115917. */
  115918. diffusionDistance: Color3;
  115919. private _useMaskFromThicknessTexture;
  115920. /**
  115921. * Stores the intensity of the different subsurface effects in the thickness texture.
  115922. * * the green channel is the translucency intensity.
  115923. * * the blue channel is the scattering intensity.
  115924. * * the alpha channel is the refraction intensity.
  115925. */
  115926. useMaskFromThicknessTexture: boolean;
  115927. /** @hidden */
  115928. private _internalMarkAllSubMeshesAsTexturesDirty;
  115929. /** @hidden */
  115930. _markAllSubMeshesAsTexturesDirty(): void;
  115931. /**
  115932. * Instantiate a new istance of sub surface configuration.
  115933. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115934. */
  115935. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115936. /**
  115937. * Gets wehter the submesh is ready to be used or not.
  115938. * @param defines the list of "defines" to update.
  115939. * @param scene defines the scene the material belongs to.
  115940. * @returns - boolean indicating that the submesh is ready or not.
  115941. */
  115942. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115943. /**
  115944. * Checks to see if a texture is used in the material.
  115945. * @param defines the list of "defines" to update.
  115946. * @param scene defines the scene to the material belongs to.
  115947. */
  115948. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115949. /**
  115950. * Binds the material data.
  115951. * @param uniformBuffer defines the Uniform buffer to fill in.
  115952. * @param scene defines the scene the material belongs to.
  115953. * @param engine defines the engine the material belongs to.
  115954. * @param isFrozen defines wether the material is frozen or not.
  115955. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115956. */
  115957. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115958. /**
  115959. * Unbinds the material from the mesh.
  115960. * @param activeEffect defines the effect that should be unbound from.
  115961. * @returns true if unbound, otherwise false
  115962. */
  115963. unbind(activeEffect: Effect): boolean;
  115964. /**
  115965. * Returns the texture used for refraction or null if none is used.
  115966. * @param scene defines the scene the material belongs to.
  115967. * @returns - Refraction texture if present. If no refraction texture and refraction
  115968. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115969. */
  115970. private _getRefractionTexture;
  115971. /**
  115972. * Returns true if alpha blending should be disabled.
  115973. */
  115974. readonly disableAlphaBlending: boolean;
  115975. /**
  115976. * Fills the list of render target textures.
  115977. * @param renderTargets the list of render targets to update
  115978. */
  115979. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115980. /**
  115981. * Checks to see if a texture is used in the material.
  115982. * @param texture - Base texture to use.
  115983. * @returns - Boolean specifying if a texture is used in the material.
  115984. */
  115985. hasTexture(texture: BaseTexture): boolean;
  115986. /**
  115987. * Gets a boolean indicating that current material needs to register RTT
  115988. * @returns true if this uses a render target otherwise false.
  115989. */
  115990. hasRenderTargetTextures(): boolean;
  115991. /**
  115992. * Returns an array of the actively used textures.
  115993. * @param activeTextures Array of BaseTextures
  115994. */
  115995. getActiveTextures(activeTextures: BaseTexture[]): void;
  115996. /**
  115997. * Returns the animatable textures.
  115998. * @param animatables Array of animatable textures.
  115999. */
  116000. getAnimatables(animatables: IAnimatable[]): void;
  116001. /**
  116002. * Disposes the resources of the material.
  116003. * @param forceDisposeTextures - Forces the disposal of all textures.
  116004. */
  116005. dispose(forceDisposeTextures?: boolean): void;
  116006. /**
  116007. * Get the current class name of the texture useful for serialization or dynamic coding.
  116008. * @returns "PBRSubSurfaceConfiguration"
  116009. */
  116010. getClassName(): string;
  116011. /**
  116012. * Add fallbacks to the effect fallbacks list.
  116013. * @param defines defines the Base texture to use.
  116014. * @param fallbacks defines the current fallback list.
  116015. * @param currentRank defines the current fallback rank.
  116016. * @returns the new fallback rank.
  116017. */
  116018. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116019. /**
  116020. * Add the required uniforms to the current list.
  116021. * @param uniforms defines the current uniform list.
  116022. */
  116023. static AddUniforms(uniforms: string[]): void;
  116024. /**
  116025. * Add the required samplers to the current list.
  116026. * @param samplers defines the current sampler list.
  116027. */
  116028. static AddSamplers(samplers: string[]): void;
  116029. /**
  116030. * Add the required uniforms to the current buffer.
  116031. * @param uniformBuffer defines the current uniform buffer.
  116032. */
  116033. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116034. /**
  116035. * Makes a duplicate of the current configuration into another one.
  116036. * @param configuration define the config where to copy the info
  116037. */
  116038. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116039. /**
  116040. * Serializes this Sub Surface configuration.
  116041. * @returns - An object with the serialized config.
  116042. */
  116043. serialize(): any;
  116044. /**
  116045. * Parses a anisotropy Configuration from a serialized object.
  116046. * @param source - Serialized object.
  116047. * @param scene Defines the scene we are parsing for
  116048. * @param rootUrl Defines the rootUrl to load from
  116049. */
  116050. parse(source: any, scene: Scene, rootUrl: string): void;
  116051. }
  116052. }
  116053. declare module BABYLON {
  116054. /** @hidden */
  116055. export var pbrFragmentDeclaration: {
  116056. name: string;
  116057. shader: string;
  116058. };
  116059. }
  116060. declare module BABYLON {
  116061. /** @hidden */
  116062. export var pbrUboDeclaration: {
  116063. name: string;
  116064. shader: string;
  116065. };
  116066. }
  116067. declare module BABYLON {
  116068. /** @hidden */
  116069. export var pbrFragmentExtraDeclaration: {
  116070. name: string;
  116071. shader: string;
  116072. };
  116073. }
  116074. declare module BABYLON {
  116075. /** @hidden */
  116076. export var pbrFragmentSamplersDeclaration: {
  116077. name: string;
  116078. shader: string;
  116079. };
  116080. }
  116081. declare module BABYLON {
  116082. /** @hidden */
  116083. export var pbrHelperFunctions: {
  116084. name: string;
  116085. shader: string;
  116086. };
  116087. }
  116088. declare module BABYLON {
  116089. /** @hidden */
  116090. export var harmonicsFunctions: {
  116091. name: string;
  116092. shader: string;
  116093. };
  116094. }
  116095. declare module BABYLON {
  116096. /** @hidden */
  116097. export var pbrDirectLightingSetupFunctions: {
  116098. name: string;
  116099. shader: string;
  116100. };
  116101. }
  116102. declare module BABYLON {
  116103. /** @hidden */
  116104. export var pbrDirectLightingFalloffFunctions: {
  116105. name: string;
  116106. shader: string;
  116107. };
  116108. }
  116109. declare module BABYLON {
  116110. /** @hidden */
  116111. export var pbrBRDFFunctions: {
  116112. name: string;
  116113. shader: string;
  116114. };
  116115. }
  116116. declare module BABYLON {
  116117. /** @hidden */
  116118. export var pbrDirectLightingFunctions: {
  116119. name: string;
  116120. shader: string;
  116121. };
  116122. }
  116123. declare module BABYLON {
  116124. /** @hidden */
  116125. export var pbrIBLFunctions: {
  116126. name: string;
  116127. shader: string;
  116128. };
  116129. }
  116130. declare module BABYLON {
  116131. /** @hidden */
  116132. export var pbrDebug: {
  116133. name: string;
  116134. shader: string;
  116135. };
  116136. }
  116137. declare module BABYLON {
  116138. /** @hidden */
  116139. export var pbrPixelShader: {
  116140. name: string;
  116141. shader: string;
  116142. };
  116143. }
  116144. declare module BABYLON {
  116145. /** @hidden */
  116146. export var pbrVertexDeclaration: {
  116147. name: string;
  116148. shader: string;
  116149. };
  116150. }
  116151. declare module BABYLON {
  116152. /** @hidden */
  116153. export var pbrVertexShader: {
  116154. name: string;
  116155. shader: string;
  116156. };
  116157. }
  116158. declare module BABYLON {
  116159. /**
  116160. * Manages the defines for the PBR Material.
  116161. * @hidden
  116162. */
  116163. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116164. PBR: boolean;
  116165. MAINUV1: boolean;
  116166. MAINUV2: boolean;
  116167. UV1: boolean;
  116168. UV2: boolean;
  116169. ALBEDO: boolean;
  116170. ALBEDODIRECTUV: number;
  116171. VERTEXCOLOR: boolean;
  116172. AMBIENT: boolean;
  116173. AMBIENTDIRECTUV: number;
  116174. AMBIENTINGRAYSCALE: boolean;
  116175. OPACITY: boolean;
  116176. VERTEXALPHA: boolean;
  116177. OPACITYDIRECTUV: number;
  116178. OPACITYRGB: boolean;
  116179. ALPHATEST: boolean;
  116180. DEPTHPREPASS: boolean;
  116181. ALPHABLEND: boolean;
  116182. ALPHAFROMALBEDO: boolean;
  116183. ALPHATESTVALUE: string;
  116184. SPECULAROVERALPHA: boolean;
  116185. RADIANCEOVERALPHA: boolean;
  116186. ALPHAFRESNEL: boolean;
  116187. LINEARALPHAFRESNEL: boolean;
  116188. PREMULTIPLYALPHA: boolean;
  116189. EMISSIVE: boolean;
  116190. EMISSIVEDIRECTUV: number;
  116191. REFLECTIVITY: boolean;
  116192. REFLECTIVITYDIRECTUV: number;
  116193. SPECULARTERM: boolean;
  116194. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116195. MICROSURFACEAUTOMATIC: boolean;
  116196. LODBASEDMICROSFURACE: boolean;
  116197. MICROSURFACEMAP: boolean;
  116198. MICROSURFACEMAPDIRECTUV: number;
  116199. METALLICWORKFLOW: boolean;
  116200. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116201. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116202. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116203. AOSTOREINMETALMAPRED: boolean;
  116204. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116205. ENVIRONMENTBRDF: boolean;
  116206. ENVIRONMENTBRDF_RGBD: boolean;
  116207. NORMAL: boolean;
  116208. TANGENT: boolean;
  116209. BUMP: boolean;
  116210. BUMPDIRECTUV: number;
  116211. OBJECTSPACE_NORMALMAP: boolean;
  116212. PARALLAX: boolean;
  116213. PARALLAXOCCLUSION: boolean;
  116214. NORMALXYSCALE: boolean;
  116215. LIGHTMAP: boolean;
  116216. LIGHTMAPDIRECTUV: number;
  116217. USELIGHTMAPASSHADOWMAP: boolean;
  116218. GAMMALIGHTMAP: boolean;
  116219. RGBDLIGHTMAP: boolean;
  116220. REFLECTION: boolean;
  116221. REFLECTIONMAP_3D: boolean;
  116222. REFLECTIONMAP_SPHERICAL: boolean;
  116223. REFLECTIONMAP_PLANAR: boolean;
  116224. REFLECTIONMAP_CUBIC: boolean;
  116225. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116226. REFLECTIONMAP_PROJECTION: boolean;
  116227. REFLECTIONMAP_SKYBOX: boolean;
  116228. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116229. REFLECTIONMAP_EXPLICIT: boolean;
  116230. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116231. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116232. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116233. INVERTCUBICMAP: boolean;
  116234. USESPHERICALFROMREFLECTIONMAP: boolean;
  116235. USEIRRADIANCEMAP: boolean;
  116236. SPHERICAL_HARMONICS: boolean;
  116237. USESPHERICALINVERTEX: boolean;
  116238. REFLECTIONMAP_OPPOSITEZ: boolean;
  116239. LODINREFLECTIONALPHA: boolean;
  116240. GAMMAREFLECTION: boolean;
  116241. RGBDREFLECTION: boolean;
  116242. LINEARSPECULARREFLECTION: boolean;
  116243. RADIANCEOCCLUSION: boolean;
  116244. HORIZONOCCLUSION: boolean;
  116245. INSTANCES: boolean;
  116246. NUM_BONE_INFLUENCERS: number;
  116247. BonesPerMesh: number;
  116248. BONETEXTURE: boolean;
  116249. NONUNIFORMSCALING: boolean;
  116250. MORPHTARGETS: boolean;
  116251. MORPHTARGETS_NORMAL: boolean;
  116252. MORPHTARGETS_TANGENT: boolean;
  116253. MORPHTARGETS_UV: boolean;
  116254. NUM_MORPH_INFLUENCERS: number;
  116255. IMAGEPROCESSING: boolean;
  116256. VIGNETTE: boolean;
  116257. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116258. VIGNETTEBLENDMODEOPAQUE: boolean;
  116259. TONEMAPPING: boolean;
  116260. TONEMAPPING_ACES: boolean;
  116261. CONTRAST: boolean;
  116262. COLORCURVES: boolean;
  116263. COLORGRADING: boolean;
  116264. COLORGRADING3D: boolean;
  116265. SAMPLER3DGREENDEPTH: boolean;
  116266. SAMPLER3DBGRMAP: boolean;
  116267. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116268. EXPOSURE: boolean;
  116269. MULTIVIEW: boolean;
  116270. USEPHYSICALLIGHTFALLOFF: boolean;
  116271. USEGLTFLIGHTFALLOFF: boolean;
  116272. TWOSIDEDLIGHTING: boolean;
  116273. SHADOWFLOAT: boolean;
  116274. CLIPPLANE: boolean;
  116275. CLIPPLANE2: boolean;
  116276. CLIPPLANE3: boolean;
  116277. CLIPPLANE4: boolean;
  116278. POINTSIZE: boolean;
  116279. FOG: boolean;
  116280. LOGARITHMICDEPTH: boolean;
  116281. FORCENORMALFORWARD: boolean;
  116282. SPECULARAA: boolean;
  116283. CLEARCOAT: boolean;
  116284. CLEARCOAT_DEFAULTIOR: boolean;
  116285. CLEARCOAT_TEXTURE: boolean;
  116286. CLEARCOAT_TEXTUREDIRECTUV: number;
  116287. CLEARCOAT_BUMP: boolean;
  116288. CLEARCOAT_BUMPDIRECTUV: number;
  116289. CLEARCOAT_TINT: boolean;
  116290. CLEARCOAT_TINT_TEXTURE: boolean;
  116291. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116292. ANISOTROPIC: boolean;
  116293. ANISOTROPIC_TEXTURE: boolean;
  116294. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116295. BRDF_V_HEIGHT_CORRELATED: boolean;
  116296. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116297. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116298. SHEEN: boolean;
  116299. SHEEN_TEXTURE: boolean;
  116300. SHEEN_TEXTUREDIRECTUV: number;
  116301. SHEEN_LINKWITHALBEDO: boolean;
  116302. SUBSURFACE: boolean;
  116303. SS_REFRACTION: boolean;
  116304. SS_TRANSLUCENCY: boolean;
  116305. SS_SCATERRING: boolean;
  116306. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116307. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116308. SS_REFRACTIONMAP_3D: boolean;
  116309. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116310. SS_LODINREFRACTIONALPHA: boolean;
  116311. SS_GAMMAREFRACTION: boolean;
  116312. SS_RGBDREFRACTION: boolean;
  116313. SS_LINEARSPECULARREFRACTION: boolean;
  116314. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116315. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116316. UNLIT: boolean;
  116317. DEBUGMODE: number;
  116318. /**
  116319. * Initializes the PBR Material defines.
  116320. */
  116321. constructor();
  116322. /**
  116323. * Resets the PBR Material defines.
  116324. */
  116325. reset(): void;
  116326. }
  116327. /**
  116328. * The Physically based material base class of BJS.
  116329. *
  116330. * This offers the main features of a standard PBR material.
  116331. * For more information, please refer to the documentation :
  116332. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116333. */
  116334. export abstract class PBRBaseMaterial extends PushMaterial {
  116335. /**
  116336. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116337. */
  116338. static readonly PBRMATERIAL_OPAQUE: number;
  116339. /**
  116340. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116341. */
  116342. static readonly PBRMATERIAL_ALPHATEST: number;
  116343. /**
  116344. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116345. */
  116346. static readonly PBRMATERIAL_ALPHABLEND: number;
  116347. /**
  116348. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116349. * They are also discarded below the alpha cutoff threshold to improve performances.
  116350. */
  116351. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116352. /**
  116353. * Defines the default value of how much AO map is occluding the analytical lights
  116354. * (point spot...).
  116355. */
  116356. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116357. /**
  116358. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116359. */
  116360. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116361. /**
  116362. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116363. * to enhance interoperability with other engines.
  116364. */
  116365. static readonly LIGHTFALLOFF_GLTF: number;
  116366. /**
  116367. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116368. * to enhance interoperability with other materials.
  116369. */
  116370. static readonly LIGHTFALLOFF_STANDARD: number;
  116371. /**
  116372. * Intensity of the direct lights e.g. the four lights available in your scene.
  116373. * This impacts both the direct diffuse and specular highlights.
  116374. */
  116375. protected _directIntensity: number;
  116376. /**
  116377. * Intensity of the emissive part of the material.
  116378. * This helps controlling the emissive effect without modifying the emissive color.
  116379. */
  116380. protected _emissiveIntensity: number;
  116381. /**
  116382. * Intensity of the environment e.g. how much the environment will light the object
  116383. * either through harmonics for rough material or through the refelction for shiny ones.
  116384. */
  116385. protected _environmentIntensity: number;
  116386. /**
  116387. * This is a special control allowing the reduction of the specular highlights coming from the
  116388. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116389. */
  116390. protected _specularIntensity: number;
  116391. /**
  116392. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116393. */
  116394. private _lightingInfos;
  116395. /**
  116396. * Debug Control allowing disabling the bump map on this material.
  116397. */
  116398. protected _disableBumpMap: boolean;
  116399. /**
  116400. * AKA Diffuse Texture in standard nomenclature.
  116401. */
  116402. protected _albedoTexture: Nullable<BaseTexture>;
  116403. /**
  116404. * AKA Occlusion Texture in other nomenclature.
  116405. */
  116406. protected _ambientTexture: Nullable<BaseTexture>;
  116407. /**
  116408. * AKA Occlusion Texture Intensity in other nomenclature.
  116409. */
  116410. protected _ambientTextureStrength: number;
  116411. /**
  116412. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116413. * 1 means it completely occludes it
  116414. * 0 mean it has no impact
  116415. */
  116416. protected _ambientTextureImpactOnAnalyticalLights: number;
  116417. /**
  116418. * Stores the alpha values in a texture.
  116419. */
  116420. protected _opacityTexture: Nullable<BaseTexture>;
  116421. /**
  116422. * Stores the reflection values in a texture.
  116423. */
  116424. protected _reflectionTexture: Nullable<BaseTexture>;
  116425. /**
  116426. * Stores the emissive values in a texture.
  116427. */
  116428. protected _emissiveTexture: Nullable<BaseTexture>;
  116429. /**
  116430. * AKA Specular texture in other nomenclature.
  116431. */
  116432. protected _reflectivityTexture: Nullable<BaseTexture>;
  116433. /**
  116434. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116435. */
  116436. protected _metallicTexture: Nullable<BaseTexture>;
  116437. /**
  116438. * Specifies the metallic scalar of the metallic/roughness workflow.
  116439. * Can also be used to scale the metalness values of the metallic texture.
  116440. */
  116441. protected _metallic: Nullable<number>;
  116442. /**
  116443. * Specifies the roughness scalar of the metallic/roughness workflow.
  116444. * Can also be used to scale the roughness values of the metallic texture.
  116445. */
  116446. protected _roughness: Nullable<number>;
  116447. /**
  116448. * Specifies the an F0 factor to help configuring the material F0.
  116449. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116450. * to 0.5 the previously hard coded value stays the same.
  116451. * Can also be used to scale the F0 values of the metallic texture.
  116452. */
  116453. protected _metallicF0Factor: number;
  116454. /**
  116455. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116456. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116457. * your expectation as it multiplies with the texture data.
  116458. */
  116459. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116460. /**
  116461. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116462. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116463. */
  116464. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116465. /**
  116466. * Stores surface normal data used to displace a mesh in a texture.
  116467. */
  116468. protected _bumpTexture: Nullable<BaseTexture>;
  116469. /**
  116470. * Stores the pre-calculated light information of a mesh in a texture.
  116471. */
  116472. protected _lightmapTexture: Nullable<BaseTexture>;
  116473. /**
  116474. * The color of a material in ambient lighting.
  116475. */
  116476. protected _ambientColor: Color3;
  116477. /**
  116478. * AKA Diffuse Color in other nomenclature.
  116479. */
  116480. protected _albedoColor: Color3;
  116481. /**
  116482. * AKA Specular Color in other nomenclature.
  116483. */
  116484. protected _reflectivityColor: Color3;
  116485. /**
  116486. * The color applied when light is reflected from a material.
  116487. */
  116488. protected _reflectionColor: Color3;
  116489. /**
  116490. * The color applied when light is emitted from a material.
  116491. */
  116492. protected _emissiveColor: Color3;
  116493. /**
  116494. * AKA Glossiness in other nomenclature.
  116495. */
  116496. protected _microSurface: number;
  116497. /**
  116498. * Specifies that the material will use the light map as a show map.
  116499. */
  116500. protected _useLightmapAsShadowmap: boolean;
  116501. /**
  116502. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116503. * makes the reflect vector face the model (under horizon).
  116504. */
  116505. protected _useHorizonOcclusion: boolean;
  116506. /**
  116507. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116508. * too much the area relying on ambient texture to define their ambient occlusion.
  116509. */
  116510. protected _useRadianceOcclusion: boolean;
  116511. /**
  116512. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116513. */
  116514. protected _useAlphaFromAlbedoTexture: boolean;
  116515. /**
  116516. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116517. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116518. */
  116519. protected _useSpecularOverAlpha: boolean;
  116520. /**
  116521. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116522. */
  116523. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116524. /**
  116525. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116526. */
  116527. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116528. /**
  116529. * Specifies if the metallic texture contains the roughness information in its green channel.
  116530. */
  116531. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116532. /**
  116533. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116534. */
  116535. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116536. /**
  116537. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116538. */
  116539. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116540. /**
  116541. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116542. */
  116543. protected _useAmbientInGrayScale: boolean;
  116544. /**
  116545. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116546. * The material will try to infer what glossiness each pixel should be.
  116547. */
  116548. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116549. /**
  116550. * Defines the falloff type used in this material.
  116551. * It by default is Physical.
  116552. */
  116553. protected _lightFalloff: number;
  116554. /**
  116555. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116556. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116557. */
  116558. protected _useRadianceOverAlpha: boolean;
  116559. /**
  116560. * Allows using an object space normal map (instead of tangent space).
  116561. */
  116562. protected _useObjectSpaceNormalMap: boolean;
  116563. /**
  116564. * Allows using the bump map in parallax mode.
  116565. */
  116566. protected _useParallax: boolean;
  116567. /**
  116568. * Allows using the bump map in parallax occlusion mode.
  116569. */
  116570. protected _useParallaxOcclusion: boolean;
  116571. /**
  116572. * Controls the scale bias of the parallax mode.
  116573. */
  116574. protected _parallaxScaleBias: number;
  116575. /**
  116576. * If sets to true, disables all the lights affecting the material.
  116577. */
  116578. protected _disableLighting: boolean;
  116579. /**
  116580. * Number of Simultaneous lights allowed on the material.
  116581. */
  116582. protected _maxSimultaneousLights: number;
  116583. /**
  116584. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116585. */
  116586. protected _invertNormalMapX: boolean;
  116587. /**
  116588. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116589. */
  116590. protected _invertNormalMapY: boolean;
  116591. /**
  116592. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116593. */
  116594. protected _twoSidedLighting: boolean;
  116595. /**
  116596. * Defines the alpha limits in alpha test mode.
  116597. */
  116598. protected _alphaCutOff: number;
  116599. /**
  116600. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116601. */
  116602. protected _forceAlphaTest: boolean;
  116603. /**
  116604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116605. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116606. */
  116607. protected _useAlphaFresnel: boolean;
  116608. /**
  116609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116610. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116611. */
  116612. protected _useLinearAlphaFresnel: boolean;
  116613. /**
  116614. * The transparency mode of the material.
  116615. */
  116616. protected _transparencyMode: Nullable<number>;
  116617. /**
  116618. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  116619. * from cos thetav and roughness:
  116620. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  116621. */
  116622. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  116623. /**
  116624. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116625. */
  116626. protected _forceIrradianceInFragment: boolean;
  116627. /**
  116628. * Force normal to face away from face.
  116629. */
  116630. protected _forceNormalForward: boolean;
  116631. /**
  116632. * Enables specular anti aliasing in the PBR shader.
  116633. * It will both interacts on the Geometry for analytical and IBL lighting.
  116634. * It also prefilter the roughness map based on the bump values.
  116635. */
  116636. protected _enableSpecularAntiAliasing: boolean;
  116637. /**
  116638. * Default configuration related to image processing available in the PBR Material.
  116639. */
  116640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116641. /**
  116642. * Keep track of the image processing observer to allow dispose and replace.
  116643. */
  116644. private _imageProcessingObserver;
  116645. /**
  116646. * Attaches a new image processing configuration to the PBR Material.
  116647. * @param configuration
  116648. */
  116649. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116650. /**
  116651. * Stores the available render targets.
  116652. */
  116653. private _renderTargets;
  116654. /**
  116655. * Sets the global ambient color for the material used in lighting calculations.
  116656. */
  116657. private _globalAmbientColor;
  116658. /**
  116659. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  116660. */
  116661. private _useLogarithmicDepth;
  116662. /**
  116663. * If set to true, no lighting calculations will be applied.
  116664. */
  116665. private _unlit;
  116666. private _debugMode;
  116667. /**
  116668. * @hidden
  116669. * This is reserved for the inspector.
  116670. * Defines the material debug mode.
  116671. * It helps seeing only some components of the material while troubleshooting.
  116672. */
  116673. debugMode: number;
  116674. /**
  116675. * @hidden
  116676. * This is reserved for the inspector.
  116677. * Specify from where on screen the debug mode should start.
  116678. * The value goes from -1 (full screen) to 1 (not visible)
  116679. * It helps with side by side comparison against the final render
  116680. * This defaults to -1
  116681. */
  116682. private debugLimit;
  116683. /**
  116684. * @hidden
  116685. * This is reserved for the inspector.
  116686. * As the default viewing range might not be enough (if the ambient is really small for instance)
  116687. * You can use the factor to better multiply the final value.
  116688. */
  116689. private debugFactor;
  116690. /**
  116691. * Defines the clear coat layer parameters for the material.
  116692. */
  116693. readonly clearCoat: PBRClearCoatConfiguration;
  116694. /**
  116695. * Defines the anisotropic parameters for the material.
  116696. */
  116697. readonly anisotropy: PBRAnisotropicConfiguration;
  116698. /**
  116699. * Defines the BRDF parameters for the material.
  116700. */
  116701. readonly brdf: PBRBRDFConfiguration;
  116702. /**
  116703. * Defines the Sheen parameters for the material.
  116704. */
  116705. readonly sheen: PBRSheenConfiguration;
  116706. /**
  116707. * Defines the SubSurface parameters for the material.
  116708. */
  116709. readonly subSurface: PBRSubSurfaceConfiguration;
  116710. /**
  116711. * Custom callback helping to override the default shader used in the material.
  116712. */
  116713. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  116714. protected _rebuildInParallel: boolean;
  116715. /**
  116716. * Instantiates a new PBRMaterial instance.
  116717. *
  116718. * @param name The material name
  116719. * @param scene The scene the material will be use in.
  116720. */
  116721. constructor(name: string, scene: Scene);
  116722. /**
  116723. * Gets a boolean indicating that current material needs to register RTT
  116724. */
  116725. readonly hasRenderTargetTextures: boolean;
  116726. /**
  116727. * Gets the name of the material class.
  116728. */
  116729. getClassName(): string;
  116730. /**
  116731. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116732. */
  116733. /**
  116734. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  116735. */
  116736. useLogarithmicDepth: boolean;
  116737. /**
  116738. * Gets the current transparency mode.
  116739. */
  116740. /**
  116741. * Sets the transparency mode of the material.
  116742. *
  116743. * | Value | Type | Description |
  116744. * | ----- | ----------------------------------- | ----------- |
  116745. * | 0 | OPAQUE | |
  116746. * | 1 | ALPHATEST | |
  116747. * | 2 | ALPHABLEND | |
  116748. * | 3 | ALPHATESTANDBLEND | |
  116749. *
  116750. */
  116751. transparencyMode: Nullable<number>;
  116752. /**
  116753. * Returns true if alpha blending should be disabled.
  116754. */
  116755. private readonly _disableAlphaBlending;
  116756. /**
  116757. * Specifies whether or not this material should be rendered in alpha blend mode.
  116758. */
  116759. needAlphaBlending(): boolean;
  116760. /**
  116761. * Specifies if the mesh will require alpha blending.
  116762. * @param mesh - BJS mesh.
  116763. */
  116764. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  116765. /**
  116766. * Specifies whether or not this material should be rendered in alpha test mode.
  116767. */
  116768. needAlphaTesting(): boolean;
  116769. /**
  116770. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  116771. */
  116772. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  116773. /**
  116774. * Gets the texture used for the alpha test.
  116775. */
  116776. getAlphaTestTexture(): Nullable<BaseTexture>;
  116777. /**
  116778. * Specifies that the submesh is ready to be used.
  116779. * @param mesh - BJS mesh.
  116780. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  116781. * @param useInstances - Specifies that instances should be used.
  116782. * @returns - boolean indicating that the submesh is ready or not.
  116783. */
  116784. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116785. /**
  116786. * Specifies if the material uses metallic roughness workflow.
  116787. * @returns boolean specifiying if the material uses metallic roughness workflow.
  116788. */
  116789. isMetallicWorkflow(): boolean;
  116790. private _prepareEffect;
  116791. private _prepareDefines;
  116792. /**
  116793. * Force shader compilation
  116794. */
  116795. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  116796. /**
  116797. * Initializes the uniform buffer layout for the shader.
  116798. */
  116799. buildUniformLayout(): void;
  116800. /**
  116801. * Unbinds the material from the mesh
  116802. */
  116803. unbind(): void;
  116804. /**
  116805. * Binds the submesh data.
  116806. * @param world - The world matrix.
  116807. * @param mesh - The BJS mesh.
  116808. * @param subMesh - A submesh of the BJS mesh.
  116809. */
  116810. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116811. /**
  116812. * Returns the animatable textures.
  116813. * @returns - Array of animatable textures.
  116814. */
  116815. getAnimatables(): IAnimatable[];
  116816. /**
  116817. * Returns the texture used for reflections.
  116818. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  116819. */
  116820. private _getReflectionTexture;
  116821. /**
  116822. * Returns an array of the actively used textures.
  116823. * @returns - Array of BaseTextures
  116824. */
  116825. getActiveTextures(): BaseTexture[];
  116826. /**
  116827. * Checks to see if a texture is used in the material.
  116828. * @param texture - Base texture to use.
  116829. * @returns - Boolean specifying if a texture is used in the material.
  116830. */
  116831. hasTexture(texture: BaseTexture): boolean;
  116832. /**
  116833. * Disposes the resources of the material.
  116834. * @param forceDisposeEffect - Forces the disposal of effects.
  116835. * @param forceDisposeTextures - Forces the disposal of all textures.
  116836. */
  116837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * The Physically based material of BJS.
  116843. *
  116844. * This offers the main features of a standard PBR material.
  116845. * For more information, please refer to the documentation :
  116846. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116847. */
  116848. export class PBRMaterial extends PBRBaseMaterial {
  116849. /**
  116850. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116851. */
  116852. static readonly PBRMATERIAL_OPAQUE: number;
  116853. /**
  116854. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116855. */
  116856. static readonly PBRMATERIAL_ALPHATEST: number;
  116857. /**
  116858. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116859. */
  116860. static readonly PBRMATERIAL_ALPHABLEND: number;
  116861. /**
  116862. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116863. * They are also discarded below the alpha cutoff threshold to improve performances.
  116864. */
  116865. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116866. /**
  116867. * Defines the default value of how much AO map is occluding the analytical lights
  116868. * (point spot...).
  116869. */
  116870. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116871. /**
  116872. * Intensity of the direct lights e.g. the four lights available in your scene.
  116873. * This impacts both the direct diffuse and specular highlights.
  116874. */
  116875. directIntensity: number;
  116876. /**
  116877. * Intensity of the emissive part of the material.
  116878. * This helps controlling the emissive effect without modifying the emissive color.
  116879. */
  116880. emissiveIntensity: number;
  116881. /**
  116882. * Intensity of the environment e.g. how much the environment will light the object
  116883. * either through harmonics for rough material or through the refelction for shiny ones.
  116884. */
  116885. environmentIntensity: number;
  116886. /**
  116887. * This is a special control allowing the reduction of the specular highlights coming from the
  116888. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116889. */
  116890. specularIntensity: number;
  116891. /**
  116892. * Debug Control allowing disabling the bump map on this material.
  116893. */
  116894. disableBumpMap: boolean;
  116895. /**
  116896. * AKA Diffuse Texture in standard nomenclature.
  116897. */
  116898. albedoTexture: BaseTexture;
  116899. /**
  116900. * AKA Occlusion Texture in other nomenclature.
  116901. */
  116902. ambientTexture: BaseTexture;
  116903. /**
  116904. * AKA Occlusion Texture Intensity in other nomenclature.
  116905. */
  116906. ambientTextureStrength: number;
  116907. /**
  116908. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116909. * 1 means it completely occludes it
  116910. * 0 mean it has no impact
  116911. */
  116912. ambientTextureImpactOnAnalyticalLights: number;
  116913. /**
  116914. * Stores the alpha values in a texture.
  116915. */
  116916. opacityTexture: BaseTexture;
  116917. /**
  116918. * Stores the reflection values in a texture.
  116919. */
  116920. reflectionTexture: Nullable<BaseTexture>;
  116921. /**
  116922. * Stores the emissive values in a texture.
  116923. */
  116924. emissiveTexture: BaseTexture;
  116925. /**
  116926. * AKA Specular texture in other nomenclature.
  116927. */
  116928. reflectivityTexture: BaseTexture;
  116929. /**
  116930. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116931. */
  116932. metallicTexture: BaseTexture;
  116933. /**
  116934. * Specifies the metallic scalar of the metallic/roughness workflow.
  116935. * Can also be used to scale the metalness values of the metallic texture.
  116936. */
  116937. metallic: Nullable<number>;
  116938. /**
  116939. * Specifies the roughness scalar of the metallic/roughness workflow.
  116940. * Can also be used to scale the roughness values of the metallic texture.
  116941. */
  116942. roughness: Nullable<number>;
  116943. /**
  116944. * Specifies the an F0 factor to help configuring the material F0.
  116945. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116946. * to 0.5 the previously hard coded value stays the same.
  116947. * Can also be used to scale the F0 values of the metallic texture.
  116948. */
  116949. metallicF0Factor: number;
  116950. /**
  116951. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116952. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116953. * your expectation as it multiplies with the texture data.
  116954. */
  116955. useMetallicF0FactorFromMetallicTexture: boolean;
  116956. /**
  116957. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116958. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116959. */
  116960. microSurfaceTexture: BaseTexture;
  116961. /**
  116962. * Stores surface normal data used to displace a mesh in a texture.
  116963. */
  116964. bumpTexture: BaseTexture;
  116965. /**
  116966. * Stores the pre-calculated light information of a mesh in a texture.
  116967. */
  116968. lightmapTexture: BaseTexture;
  116969. /**
  116970. * Stores the refracted light information in a texture.
  116971. */
  116972. refractionTexture: Nullable<BaseTexture>;
  116973. /**
  116974. * The color of a material in ambient lighting.
  116975. */
  116976. ambientColor: Color3;
  116977. /**
  116978. * AKA Diffuse Color in other nomenclature.
  116979. */
  116980. albedoColor: Color3;
  116981. /**
  116982. * AKA Specular Color in other nomenclature.
  116983. */
  116984. reflectivityColor: Color3;
  116985. /**
  116986. * The color reflected from the material.
  116987. */
  116988. reflectionColor: Color3;
  116989. /**
  116990. * The color emitted from the material.
  116991. */
  116992. emissiveColor: Color3;
  116993. /**
  116994. * AKA Glossiness in other nomenclature.
  116995. */
  116996. microSurface: number;
  116997. /**
  116998. * source material index of refraction (IOR)' / 'destination material IOR.
  116999. */
  117000. indexOfRefraction: number;
  117001. /**
  117002. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117003. */
  117004. invertRefractionY: boolean;
  117005. /**
  117006. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117007. * Materials half opaque for instance using refraction could benefit from this control.
  117008. */
  117009. linkRefractionWithTransparency: boolean;
  117010. /**
  117011. * If true, the light map contains occlusion information instead of lighting info.
  117012. */
  117013. useLightmapAsShadowmap: boolean;
  117014. /**
  117015. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117016. */
  117017. useAlphaFromAlbedoTexture: boolean;
  117018. /**
  117019. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117020. */
  117021. forceAlphaTest: boolean;
  117022. /**
  117023. * Defines the alpha limits in alpha test mode.
  117024. */
  117025. alphaCutOff: number;
  117026. /**
  117027. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117029. */
  117030. useSpecularOverAlpha: boolean;
  117031. /**
  117032. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117033. */
  117034. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117035. /**
  117036. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117037. */
  117038. useRoughnessFromMetallicTextureAlpha: boolean;
  117039. /**
  117040. * Specifies if the metallic texture contains the roughness information in its green channel.
  117041. */
  117042. useRoughnessFromMetallicTextureGreen: boolean;
  117043. /**
  117044. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117045. */
  117046. useMetallnessFromMetallicTextureBlue: boolean;
  117047. /**
  117048. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117049. */
  117050. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117051. /**
  117052. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117053. */
  117054. useAmbientInGrayScale: boolean;
  117055. /**
  117056. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117057. * The material will try to infer what glossiness each pixel should be.
  117058. */
  117059. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117060. /**
  117061. * BJS is using an harcoded light falloff based on a manually sets up range.
  117062. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117063. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117064. */
  117065. /**
  117066. * BJS is using an harcoded light falloff based on a manually sets up range.
  117067. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117068. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117069. */
  117070. usePhysicalLightFalloff: boolean;
  117071. /**
  117072. * In order to support the falloff compatibility with gltf, a special mode has been added
  117073. * to reproduce the gltf light falloff.
  117074. */
  117075. /**
  117076. * In order to support the falloff compatibility with gltf, a special mode has been added
  117077. * to reproduce the gltf light falloff.
  117078. */
  117079. useGLTFLightFalloff: boolean;
  117080. /**
  117081. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117082. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117083. */
  117084. useRadianceOverAlpha: boolean;
  117085. /**
  117086. * Allows using an object space normal map (instead of tangent space).
  117087. */
  117088. useObjectSpaceNormalMap: boolean;
  117089. /**
  117090. * Allows using the bump map in parallax mode.
  117091. */
  117092. useParallax: boolean;
  117093. /**
  117094. * Allows using the bump map in parallax occlusion mode.
  117095. */
  117096. useParallaxOcclusion: boolean;
  117097. /**
  117098. * Controls the scale bias of the parallax mode.
  117099. */
  117100. parallaxScaleBias: number;
  117101. /**
  117102. * If sets to true, disables all the lights affecting the material.
  117103. */
  117104. disableLighting: boolean;
  117105. /**
  117106. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117107. */
  117108. forceIrradianceInFragment: boolean;
  117109. /**
  117110. * Number of Simultaneous lights allowed on the material.
  117111. */
  117112. maxSimultaneousLights: number;
  117113. /**
  117114. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117115. */
  117116. invertNormalMapX: boolean;
  117117. /**
  117118. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117119. */
  117120. invertNormalMapY: boolean;
  117121. /**
  117122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117123. */
  117124. twoSidedLighting: boolean;
  117125. /**
  117126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117127. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117128. */
  117129. useAlphaFresnel: boolean;
  117130. /**
  117131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117132. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117133. */
  117134. useLinearAlphaFresnel: boolean;
  117135. /**
  117136. * Let user defines the brdf lookup texture used for IBL.
  117137. * A default 8bit version is embedded but you could point at :
  117138. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117139. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117140. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117141. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117142. */
  117143. environmentBRDFTexture: Nullable<BaseTexture>;
  117144. /**
  117145. * Force normal to face away from face.
  117146. */
  117147. forceNormalForward: boolean;
  117148. /**
  117149. * Enables specular anti aliasing in the PBR shader.
  117150. * It will both interacts on the Geometry for analytical and IBL lighting.
  117151. * It also prefilter the roughness map based on the bump values.
  117152. */
  117153. enableSpecularAntiAliasing: boolean;
  117154. /**
  117155. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117156. * makes the reflect vector face the model (under horizon).
  117157. */
  117158. useHorizonOcclusion: boolean;
  117159. /**
  117160. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117161. * too much the area relying on ambient texture to define their ambient occlusion.
  117162. */
  117163. useRadianceOcclusion: boolean;
  117164. /**
  117165. * If set to true, no lighting calculations will be applied.
  117166. */
  117167. unlit: boolean;
  117168. /**
  117169. * Gets the image processing configuration used either in this material.
  117170. */
  117171. /**
  117172. * Sets the Default image processing configuration used either in the this material.
  117173. *
  117174. * If sets to null, the scene one is in use.
  117175. */
  117176. imageProcessingConfiguration: ImageProcessingConfiguration;
  117177. /**
  117178. * Gets wether the color curves effect is enabled.
  117179. */
  117180. /**
  117181. * Sets wether the color curves effect is enabled.
  117182. */
  117183. cameraColorCurvesEnabled: boolean;
  117184. /**
  117185. * Gets wether the color grading effect is enabled.
  117186. */
  117187. /**
  117188. * Gets wether the color grading effect is enabled.
  117189. */
  117190. cameraColorGradingEnabled: boolean;
  117191. /**
  117192. * Gets wether tonemapping is enabled or not.
  117193. */
  117194. /**
  117195. * Sets wether tonemapping is enabled or not
  117196. */
  117197. cameraToneMappingEnabled: boolean;
  117198. /**
  117199. * The camera exposure used on this material.
  117200. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117201. * This corresponds to a photographic exposure.
  117202. */
  117203. /**
  117204. * The camera exposure used on this material.
  117205. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117206. * This corresponds to a photographic exposure.
  117207. */
  117208. cameraExposure: number;
  117209. /**
  117210. * Gets The camera contrast used on this material.
  117211. */
  117212. /**
  117213. * Sets The camera contrast used on this material.
  117214. */
  117215. cameraContrast: number;
  117216. /**
  117217. * Gets the Color Grading 2D Lookup Texture.
  117218. */
  117219. /**
  117220. * Sets the Color Grading 2D Lookup Texture.
  117221. */
  117222. cameraColorGradingTexture: Nullable<BaseTexture>;
  117223. /**
  117224. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117225. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117226. * 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;
  117227. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117228. */
  117229. /**
  117230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117232. * 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;
  117233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117234. */
  117235. cameraColorCurves: Nullable<ColorCurves>;
  117236. /**
  117237. * Instantiates a new PBRMaterial instance.
  117238. *
  117239. * @param name The material name
  117240. * @param scene The scene the material will be use in.
  117241. */
  117242. constructor(name: string, scene: Scene);
  117243. /**
  117244. * Returns the name of this material class.
  117245. */
  117246. getClassName(): string;
  117247. /**
  117248. * Makes a duplicate of the current material.
  117249. * @param name - name to use for the new material.
  117250. */
  117251. clone(name: string): PBRMaterial;
  117252. /**
  117253. * Serializes this PBR Material.
  117254. * @returns - An object with the serialized material.
  117255. */
  117256. serialize(): any;
  117257. /**
  117258. * Parses a PBR Material from a serialized object.
  117259. * @param source - Serialized object.
  117260. * @param scene - BJS scene instance.
  117261. * @param rootUrl - url for the scene object
  117262. * @returns - PBRMaterial
  117263. */
  117264. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117265. }
  117266. }
  117267. declare module BABYLON {
  117268. /**
  117269. * Direct draw surface info
  117270. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117271. */
  117272. export interface DDSInfo {
  117273. /**
  117274. * Width of the texture
  117275. */
  117276. width: number;
  117277. /**
  117278. * Width of the texture
  117279. */
  117280. height: number;
  117281. /**
  117282. * Number of Mipmaps for the texture
  117283. * @see https://en.wikipedia.org/wiki/Mipmap
  117284. */
  117285. mipmapCount: number;
  117286. /**
  117287. * If the textures format is a known fourCC format
  117288. * @see https://www.fourcc.org/
  117289. */
  117290. isFourCC: boolean;
  117291. /**
  117292. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117293. */
  117294. isRGB: boolean;
  117295. /**
  117296. * If the texture is a lumincance format
  117297. */
  117298. isLuminance: boolean;
  117299. /**
  117300. * If this is a cube texture
  117301. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117302. */
  117303. isCube: boolean;
  117304. /**
  117305. * If the texture is a compressed format eg. FOURCC_DXT1
  117306. */
  117307. isCompressed: boolean;
  117308. /**
  117309. * The dxgiFormat of the texture
  117310. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117311. */
  117312. dxgiFormat: number;
  117313. /**
  117314. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117315. */
  117316. textureType: number;
  117317. /**
  117318. * Sphericle polynomial created for the dds texture
  117319. */
  117320. sphericalPolynomial?: SphericalPolynomial;
  117321. }
  117322. /**
  117323. * Class used to provide DDS decompression tools
  117324. */
  117325. export class DDSTools {
  117326. /**
  117327. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117328. */
  117329. static StoreLODInAlphaChannel: boolean;
  117330. /**
  117331. * Gets DDS information from an array buffer
  117332. * @param arrayBuffer defines the array buffer to read data from
  117333. * @returns the DDS information
  117334. */
  117335. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117336. private static _FloatView;
  117337. private static _Int32View;
  117338. private static _ToHalfFloat;
  117339. private static _FromHalfFloat;
  117340. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117341. private static _GetHalfFloatRGBAArrayBuffer;
  117342. private static _GetFloatRGBAArrayBuffer;
  117343. private static _GetFloatAsUIntRGBAArrayBuffer;
  117344. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117345. private static _GetRGBAArrayBuffer;
  117346. private static _ExtractLongWordOrder;
  117347. private static _GetRGBArrayBuffer;
  117348. private static _GetLuminanceArrayBuffer;
  117349. /**
  117350. * Uploads DDS Levels to a Babylon Texture
  117351. * @hidden
  117352. */
  117353. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117354. }
  117355. interface ThinEngine {
  117356. /**
  117357. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117358. * @param rootUrl defines the url where the file to load is located
  117359. * @param scene defines the current scene
  117360. * @param lodScale defines scale to apply to the mip map selection
  117361. * @param lodOffset defines offset to apply to the mip map selection
  117362. * @param onLoad defines an optional callback raised when the texture is loaded
  117363. * @param onError defines an optional callback raised if there is an issue to load the texture
  117364. * @param format defines the format of the data
  117365. * @param forcedExtension defines the extension to use to pick the right loader
  117366. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117367. * @returns the cube texture as an InternalTexture
  117368. */
  117369. 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;
  117370. }
  117371. }
  117372. declare module BABYLON {
  117373. /**
  117374. * Implementation of the DDS Texture Loader.
  117375. * @hidden
  117376. */
  117377. export class _DDSTextureLoader implements IInternalTextureLoader {
  117378. /**
  117379. * Defines wether the loader supports cascade loading the different faces.
  117380. */
  117381. readonly supportCascades: boolean;
  117382. /**
  117383. * This returns if the loader support the current file information.
  117384. * @param extension defines the file extension of the file being loaded
  117385. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117386. * @param fallback defines the fallback internal texture if any
  117387. * @param isBase64 defines whether the texture is encoded as a base64
  117388. * @param isBuffer defines whether the texture data are stored as a buffer
  117389. * @returns true if the loader can load the specified file
  117390. */
  117391. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117392. /**
  117393. * Transform the url before loading if required.
  117394. * @param rootUrl the url of the texture
  117395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117396. * @returns the transformed texture
  117397. */
  117398. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117399. /**
  117400. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117401. * @param rootUrl the url of the texture
  117402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117403. * @returns the fallback texture
  117404. */
  117405. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117406. /**
  117407. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117408. * @param data contains the texture data
  117409. * @param texture defines the BabylonJS internal texture
  117410. * @param createPolynomials will be true if polynomials have been requested
  117411. * @param onLoad defines the callback to trigger once the texture is ready
  117412. * @param onError defines the callback to trigger in case of error
  117413. */
  117414. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117415. /**
  117416. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117417. * @param data contains the texture data
  117418. * @param texture defines the BabylonJS internal texture
  117419. * @param callback defines the method to call once ready to upload
  117420. */
  117421. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117422. }
  117423. }
  117424. declare module BABYLON {
  117425. /**
  117426. * Implementation of the ENV Texture Loader.
  117427. * @hidden
  117428. */
  117429. export class _ENVTextureLoader implements IInternalTextureLoader {
  117430. /**
  117431. * Defines wether the loader supports cascade loading the different faces.
  117432. */
  117433. readonly supportCascades: boolean;
  117434. /**
  117435. * This returns if the loader support the current file information.
  117436. * @param extension defines the file extension of the file being loaded
  117437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117438. * @param fallback defines the fallback internal texture if any
  117439. * @param isBase64 defines whether the texture is encoded as a base64
  117440. * @param isBuffer defines whether the texture data are stored as a buffer
  117441. * @returns true if the loader can load the specified file
  117442. */
  117443. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117444. /**
  117445. * Transform the url before loading if required.
  117446. * @param rootUrl the url of the texture
  117447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117448. * @returns the transformed texture
  117449. */
  117450. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117451. /**
  117452. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117453. * @param rootUrl the url of the texture
  117454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117455. * @returns the fallback texture
  117456. */
  117457. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117458. /**
  117459. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117460. * @param data contains the texture data
  117461. * @param texture defines the BabylonJS internal texture
  117462. * @param createPolynomials will be true if polynomials have been requested
  117463. * @param onLoad defines the callback to trigger once the texture is ready
  117464. * @param onError defines the callback to trigger in case of error
  117465. */
  117466. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117467. /**
  117468. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117469. * @param data contains the texture data
  117470. * @param texture defines the BabylonJS internal texture
  117471. * @param callback defines the method to call once ready to upload
  117472. */
  117473. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117474. }
  117475. }
  117476. declare module BABYLON {
  117477. /**
  117478. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117479. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117480. */
  117481. export class KhronosTextureContainer {
  117482. /** contents of the KTX container file */
  117483. arrayBuffer: any;
  117484. private static HEADER_LEN;
  117485. private static COMPRESSED_2D;
  117486. private static COMPRESSED_3D;
  117487. private static TEX_2D;
  117488. private static TEX_3D;
  117489. /**
  117490. * Gets the openGL type
  117491. */
  117492. glType: number;
  117493. /**
  117494. * Gets the openGL type size
  117495. */
  117496. glTypeSize: number;
  117497. /**
  117498. * Gets the openGL format
  117499. */
  117500. glFormat: number;
  117501. /**
  117502. * Gets the openGL internal format
  117503. */
  117504. glInternalFormat: number;
  117505. /**
  117506. * Gets the base internal format
  117507. */
  117508. glBaseInternalFormat: number;
  117509. /**
  117510. * Gets image width in pixel
  117511. */
  117512. pixelWidth: number;
  117513. /**
  117514. * Gets image height in pixel
  117515. */
  117516. pixelHeight: number;
  117517. /**
  117518. * Gets image depth in pixels
  117519. */
  117520. pixelDepth: number;
  117521. /**
  117522. * Gets the number of array elements
  117523. */
  117524. numberOfArrayElements: number;
  117525. /**
  117526. * Gets the number of faces
  117527. */
  117528. numberOfFaces: number;
  117529. /**
  117530. * Gets the number of mipmap levels
  117531. */
  117532. numberOfMipmapLevels: number;
  117533. /**
  117534. * Gets the bytes of key value data
  117535. */
  117536. bytesOfKeyValueData: number;
  117537. /**
  117538. * Gets the load type
  117539. */
  117540. loadType: number;
  117541. /**
  117542. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117543. */
  117544. isInvalid: boolean;
  117545. /**
  117546. * Creates a new KhronosTextureContainer
  117547. * @param arrayBuffer contents of the KTX container file
  117548. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117549. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117550. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117551. */
  117552. constructor(
  117553. /** contents of the KTX container file */
  117554. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117555. /**
  117556. * Uploads KTX content to a Babylon Texture.
  117557. * It is assumed that the texture has already been created & is currently bound
  117558. * @hidden
  117559. */
  117560. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117561. private _upload2DCompressedLevels;
  117562. }
  117563. }
  117564. declare module BABYLON {
  117565. /**
  117566. * Implementation of the KTX Texture Loader.
  117567. * @hidden
  117568. */
  117569. export class _KTXTextureLoader implements IInternalTextureLoader {
  117570. /**
  117571. * Defines wether the loader supports cascade loading the different faces.
  117572. */
  117573. readonly supportCascades: boolean;
  117574. /**
  117575. * This returns if the loader support the current file information.
  117576. * @param extension defines the file extension of the file being loaded
  117577. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117578. * @param fallback defines the fallback internal texture if any
  117579. * @param isBase64 defines whether the texture is encoded as a base64
  117580. * @param isBuffer defines whether the texture data are stored as a buffer
  117581. * @returns true if the loader can load the specified file
  117582. */
  117583. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117584. /**
  117585. * Transform the url before loading if required.
  117586. * @param rootUrl the url of the texture
  117587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117588. * @returns the transformed texture
  117589. */
  117590. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117591. /**
  117592. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117593. * @param rootUrl the url of the texture
  117594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117595. * @returns the fallback texture
  117596. */
  117597. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117598. /**
  117599. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117600. * @param data contains the texture data
  117601. * @param texture defines the BabylonJS internal texture
  117602. * @param createPolynomials will be true if polynomials have been requested
  117603. * @param onLoad defines the callback to trigger once the texture is ready
  117604. * @param onError defines the callback to trigger in case of error
  117605. */
  117606. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117607. /**
  117608. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117609. * @param data contains the texture data
  117610. * @param texture defines the BabylonJS internal texture
  117611. * @param callback defines the method to call once ready to upload
  117612. */
  117613. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  117614. }
  117615. }
  117616. declare module BABYLON {
  117617. /**
  117618. * Options for the default xr helper
  117619. */
  117620. export class WebXRDefaultExperienceOptions {
  117621. /**
  117622. * Floor meshes that should be used for teleporting
  117623. */
  117624. floorMeshes: Array<AbstractMesh>;
  117625. /**
  117626. * Enable or disable default UI to enter XR
  117627. */
  117628. disableDefaultUI: boolean;
  117629. }
  117630. /**
  117631. * Default experience which provides a similar setup to the previous webVRExperience
  117632. */
  117633. export class WebXRDefaultExperience {
  117634. /**
  117635. * Base experience
  117636. */
  117637. baseExperience: WebXRExperienceHelper;
  117638. /**
  117639. * Input experience extension
  117640. */
  117641. input: WebXRInput;
  117642. /**
  117643. * Loads the controller models
  117644. */
  117645. controllerModelLoader: WebXRControllerModelLoader;
  117646. /**
  117647. * Enables laser pointer and selection
  117648. */
  117649. pointerSelection: WebXRControllerPointerSelection;
  117650. /**
  117651. * Enables teleportation
  117652. */
  117653. teleportation: WebXRControllerTeleportation;
  117654. /**
  117655. * Enables ui for enetering/exiting xr
  117656. */
  117657. enterExitUI: WebXREnterExitUI;
  117658. /**
  117659. * Default target xr should render to
  117660. */
  117661. renderTarget: WebXRRenderTarget;
  117662. /**
  117663. * Creates the default xr experience
  117664. * @param scene scene
  117665. * @param options options for basic configuration
  117666. * @returns resulting WebXRDefaultExperience
  117667. */
  117668. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117669. private constructor();
  117670. /**
  117671. * DIsposes of the experience helper
  117672. */
  117673. dispose(): void;
  117674. }
  117675. }
  117676. declare module BABYLON {
  117677. /** @hidden */
  117678. export var _forceSceneHelpersToBundle: boolean;
  117679. interface Scene {
  117680. /**
  117681. * Creates a default light for the scene.
  117682. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  117683. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  117684. */
  117685. createDefaultLight(replace?: boolean): void;
  117686. /**
  117687. * Creates a default camera for the scene.
  117688. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  117689. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117690. * @param replace has default false, when true replaces the active camera in the scene
  117691. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  117692. */
  117693. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117694. /**
  117695. * Creates a default camera and a default light.
  117696. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  117697. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  117698. * @param replace has the default false, when true replaces the active camera/light in the scene
  117699. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  117700. */
  117701. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  117702. /**
  117703. * Creates a new sky box
  117704. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  117705. * @param environmentTexture defines the texture to use as environment texture
  117706. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  117707. * @param scale defines the overall scale of the skybox
  117708. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  117709. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  117710. * @returns a new mesh holding the sky box
  117711. */
  117712. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  117713. /**
  117714. * Creates a new environment
  117715. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  117716. * @param options defines the options you can use to configure the environment
  117717. * @returns the new EnvironmentHelper
  117718. */
  117719. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  117720. /**
  117721. * Creates a new VREXperienceHelper
  117722. * @see http://doc.babylonjs.com/how_to/webvr_helper
  117723. * @param webVROptions defines the options used to create the new VREXperienceHelper
  117724. * @returns a new VREXperienceHelper
  117725. */
  117726. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  117727. /**
  117728. * Creates a new WebXRDefaultExperience
  117729. * @see http://doc.babylonjs.com/how_to/webxr
  117730. * @param options experience options
  117731. * @returns a promise for a new WebXRDefaultExperience
  117732. */
  117733. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117734. }
  117735. }
  117736. declare module BABYLON {
  117737. /**
  117738. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  117739. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  117740. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  117741. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117742. */
  117743. export class VideoDome extends TransformNode {
  117744. /**
  117745. * Define the video source as a Monoscopic panoramic 360 video.
  117746. */
  117747. static readonly MODE_MONOSCOPIC: number;
  117748. /**
  117749. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117750. */
  117751. static readonly MODE_TOPBOTTOM: number;
  117752. /**
  117753. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117754. */
  117755. static readonly MODE_SIDEBYSIDE: number;
  117756. private _halfDome;
  117757. private _useDirectMapping;
  117758. /**
  117759. * The video texture being displayed on the sphere
  117760. */
  117761. protected _videoTexture: VideoTexture;
  117762. /**
  117763. * Gets the video texture being displayed on the sphere
  117764. */
  117765. readonly videoTexture: VideoTexture;
  117766. /**
  117767. * The skybox material
  117768. */
  117769. protected _material: BackgroundMaterial;
  117770. /**
  117771. * The surface used for the skybox
  117772. */
  117773. protected _mesh: Mesh;
  117774. /**
  117775. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  117776. */
  117777. private _halfDomeMask;
  117778. /**
  117779. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117780. * Also see the options.resolution property.
  117781. */
  117782. fovMultiplier: number;
  117783. private _videoMode;
  117784. /**
  117785. * Gets or set the current video mode for the video. It can be:
  117786. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  117787. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  117788. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  117789. */
  117790. videoMode: number;
  117791. /**
  117792. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  117793. *
  117794. */
  117795. /**
  117796. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  117797. */
  117798. halfDome: boolean;
  117799. /**
  117800. * Oberserver used in Stereoscopic VR Mode.
  117801. */
  117802. private _onBeforeCameraRenderObserver;
  117803. /**
  117804. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  117805. * @param name Element's name, child elements will append suffixes for their own names.
  117806. * @param urlsOrVideo defines the url(s) or the video element to use
  117807. * @param options An object containing optional or exposed sub element properties
  117808. */
  117809. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  117810. resolution?: number;
  117811. clickToPlay?: boolean;
  117812. autoPlay?: boolean;
  117813. loop?: boolean;
  117814. size?: number;
  117815. poster?: string;
  117816. faceForward?: boolean;
  117817. useDirectMapping?: boolean;
  117818. halfDomeMode?: boolean;
  117819. }, scene: Scene);
  117820. private _changeVideoMode;
  117821. /**
  117822. * Releases resources associated with this node.
  117823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117825. */
  117826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117827. }
  117828. }
  117829. declare module BABYLON {
  117830. /**
  117831. * This class can be used to get instrumentation data from a Babylon engine
  117832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117833. */
  117834. export class EngineInstrumentation implements IDisposable {
  117835. /**
  117836. * Define the instrumented engine.
  117837. */
  117838. engine: Engine;
  117839. private _captureGPUFrameTime;
  117840. private _gpuFrameTimeToken;
  117841. private _gpuFrameTime;
  117842. private _captureShaderCompilationTime;
  117843. private _shaderCompilationTime;
  117844. private _onBeginFrameObserver;
  117845. private _onEndFrameObserver;
  117846. private _onBeforeShaderCompilationObserver;
  117847. private _onAfterShaderCompilationObserver;
  117848. /**
  117849. * Gets the perf counter used for GPU frame time
  117850. */
  117851. readonly gpuFrameTimeCounter: PerfCounter;
  117852. /**
  117853. * Gets the GPU frame time capture status
  117854. */
  117855. /**
  117856. * Enable or disable the GPU frame time capture
  117857. */
  117858. captureGPUFrameTime: boolean;
  117859. /**
  117860. * Gets the perf counter used for shader compilation time
  117861. */
  117862. readonly shaderCompilationTimeCounter: PerfCounter;
  117863. /**
  117864. * Gets the shader compilation time capture status
  117865. */
  117866. /**
  117867. * Enable or disable the shader compilation time capture
  117868. */
  117869. captureShaderCompilationTime: boolean;
  117870. /**
  117871. * Instantiates a new engine instrumentation.
  117872. * This class can be used to get instrumentation data from a Babylon engine
  117873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117874. * @param engine Defines the engine to instrument
  117875. */
  117876. constructor(
  117877. /**
  117878. * Define the instrumented engine.
  117879. */
  117880. engine: Engine);
  117881. /**
  117882. * Dispose and release associated resources.
  117883. */
  117884. dispose(): void;
  117885. }
  117886. }
  117887. declare module BABYLON {
  117888. /**
  117889. * This class can be used to get instrumentation data from a Babylon engine
  117890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117891. */
  117892. export class SceneInstrumentation implements IDisposable {
  117893. /**
  117894. * Defines the scene to instrument
  117895. */
  117896. scene: Scene;
  117897. private _captureActiveMeshesEvaluationTime;
  117898. private _activeMeshesEvaluationTime;
  117899. private _captureRenderTargetsRenderTime;
  117900. private _renderTargetsRenderTime;
  117901. private _captureFrameTime;
  117902. private _frameTime;
  117903. private _captureRenderTime;
  117904. private _renderTime;
  117905. private _captureInterFrameTime;
  117906. private _interFrameTime;
  117907. private _captureParticlesRenderTime;
  117908. private _particlesRenderTime;
  117909. private _captureSpritesRenderTime;
  117910. private _spritesRenderTime;
  117911. private _capturePhysicsTime;
  117912. private _physicsTime;
  117913. private _captureAnimationsTime;
  117914. private _animationsTime;
  117915. private _captureCameraRenderTime;
  117916. private _cameraRenderTime;
  117917. private _onBeforeActiveMeshesEvaluationObserver;
  117918. private _onAfterActiveMeshesEvaluationObserver;
  117919. private _onBeforeRenderTargetsRenderObserver;
  117920. private _onAfterRenderTargetsRenderObserver;
  117921. private _onAfterRenderObserver;
  117922. private _onBeforeDrawPhaseObserver;
  117923. private _onAfterDrawPhaseObserver;
  117924. private _onBeforeAnimationsObserver;
  117925. private _onBeforeParticlesRenderingObserver;
  117926. private _onAfterParticlesRenderingObserver;
  117927. private _onBeforeSpritesRenderingObserver;
  117928. private _onAfterSpritesRenderingObserver;
  117929. private _onBeforePhysicsObserver;
  117930. private _onAfterPhysicsObserver;
  117931. private _onAfterAnimationsObserver;
  117932. private _onBeforeCameraRenderObserver;
  117933. private _onAfterCameraRenderObserver;
  117934. /**
  117935. * Gets the perf counter used for active meshes evaluation time
  117936. */
  117937. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117938. /**
  117939. * Gets the active meshes evaluation time capture status
  117940. */
  117941. /**
  117942. * Enable or disable the active meshes evaluation time capture
  117943. */
  117944. captureActiveMeshesEvaluationTime: boolean;
  117945. /**
  117946. * Gets the perf counter used for render targets render time
  117947. */
  117948. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117949. /**
  117950. * Gets the render targets render time capture status
  117951. */
  117952. /**
  117953. * Enable or disable the render targets render time capture
  117954. */
  117955. captureRenderTargetsRenderTime: boolean;
  117956. /**
  117957. * Gets the perf counter used for particles render time
  117958. */
  117959. readonly particlesRenderTimeCounter: PerfCounter;
  117960. /**
  117961. * Gets the particles render time capture status
  117962. */
  117963. /**
  117964. * Enable or disable the particles render time capture
  117965. */
  117966. captureParticlesRenderTime: boolean;
  117967. /**
  117968. * Gets the perf counter used for sprites render time
  117969. */
  117970. readonly spritesRenderTimeCounter: PerfCounter;
  117971. /**
  117972. * Gets the sprites render time capture status
  117973. */
  117974. /**
  117975. * Enable or disable the sprites render time capture
  117976. */
  117977. captureSpritesRenderTime: boolean;
  117978. /**
  117979. * Gets the perf counter used for physics time
  117980. */
  117981. readonly physicsTimeCounter: PerfCounter;
  117982. /**
  117983. * Gets the physics time capture status
  117984. */
  117985. /**
  117986. * Enable or disable the physics time capture
  117987. */
  117988. capturePhysicsTime: boolean;
  117989. /**
  117990. * Gets the perf counter used for animations time
  117991. */
  117992. readonly animationsTimeCounter: PerfCounter;
  117993. /**
  117994. * Gets the animations time capture status
  117995. */
  117996. /**
  117997. * Enable or disable the animations time capture
  117998. */
  117999. captureAnimationsTime: boolean;
  118000. /**
  118001. * Gets the perf counter used for frame time capture
  118002. */
  118003. readonly frameTimeCounter: PerfCounter;
  118004. /**
  118005. * Gets the frame time capture status
  118006. */
  118007. /**
  118008. * Enable or disable the frame time capture
  118009. */
  118010. captureFrameTime: boolean;
  118011. /**
  118012. * Gets the perf counter used for inter-frames time capture
  118013. */
  118014. readonly interFrameTimeCounter: PerfCounter;
  118015. /**
  118016. * Gets the inter-frames time capture status
  118017. */
  118018. /**
  118019. * Enable or disable the inter-frames time capture
  118020. */
  118021. captureInterFrameTime: boolean;
  118022. /**
  118023. * Gets the perf counter used for render time capture
  118024. */
  118025. readonly renderTimeCounter: PerfCounter;
  118026. /**
  118027. * Gets the render time capture status
  118028. */
  118029. /**
  118030. * Enable or disable the render time capture
  118031. */
  118032. captureRenderTime: boolean;
  118033. /**
  118034. * Gets the perf counter used for camera render time capture
  118035. */
  118036. readonly cameraRenderTimeCounter: PerfCounter;
  118037. /**
  118038. * Gets the camera render time capture status
  118039. */
  118040. /**
  118041. * Enable or disable the camera render time capture
  118042. */
  118043. captureCameraRenderTime: boolean;
  118044. /**
  118045. * Gets the perf counter used for draw calls
  118046. */
  118047. readonly drawCallsCounter: PerfCounter;
  118048. /**
  118049. * Instantiates a new scene instrumentation.
  118050. * This class can be used to get instrumentation data from a Babylon engine
  118051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118052. * @param scene Defines the scene to instrument
  118053. */
  118054. constructor(
  118055. /**
  118056. * Defines the scene to instrument
  118057. */
  118058. scene: Scene);
  118059. /**
  118060. * Dispose and release associated resources.
  118061. */
  118062. dispose(): void;
  118063. }
  118064. }
  118065. declare module BABYLON {
  118066. /** @hidden */
  118067. export var glowMapGenerationPixelShader: {
  118068. name: string;
  118069. shader: string;
  118070. };
  118071. }
  118072. declare module BABYLON {
  118073. /** @hidden */
  118074. export var glowMapGenerationVertexShader: {
  118075. name: string;
  118076. shader: string;
  118077. };
  118078. }
  118079. declare module BABYLON {
  118080. /**
  118081. * Effect layer options. This helps customizing the behaviour
  118082. * of the effect layer.
  118083. */
  118084. export interface IEffectLayerOptions {
  118085. /**
  118086. * Multiplication factor apply to the canvas size to compute the render target size
  118087. * used to generated the objects (the smaller the faster).
  118088. */
  118089. mainTextureRatio: number;
  118090. /**
  118091. * Enforces a fixed size texture to ensure effect stability across devices.
  118092. */
  118093. mainTextureFixedSize?: number;
  118094. /**
  118095. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118096. */
  118097. alphaBlendingMode: number;
  118098. /**
  118099. * The camera attached to the layer.
  118100. */
  118101. camera: Nullable<Camera>;
  118102. /**
  118103. * The rendering group to draw the layer in.
  118104. */
  118105. renderingGroupId: number;
  118106. }
  118107. /**
  118108. * The effect layer Helps adding post process effect blended with the main pass.
  118109. *
  118110. * This can be for instance use to generate glow or higlight effects on the scene.
  118111. *
  118112. * The effect layer class can not be used directly and is intented to inherited from to be
  118113. * customized per effects.
  118114. */
  118115. export abstract class EffectLayer {
  118116. private _vertexBuffers;
  118117. private _indexBuffer;
  118118. private _cachedDefines;
  118119. private _effectLayerMapGenerationEffect;
  118120. private _effectLayerOptions;
  118121. private _mergeEffect;
  118122. protected _scene: Scene;
  118123. protected _engine: Engine;
  118124. protected _maxSize: number;
  118125. protected _mainTextureDesiredSize: ISize;
  118126. protected _mainTexture: RenderTargetTexture;
  118127. protected _shouldRender: boolean;
  118128. protected _postProcesses: PostProcess[];
  118129. protected _textures: BaseTexture[];
  118130. protected _emissiveTextureAndColor: {
  118131. texture: Nullable<BaseTexture>;
  118132. color: Color4;
  118133. };
  118134. /**
  118135. * The name of the layer
  118136. */
  118137. name: string;
  118138. /**
  118139. * The clear color of the texture used to generate the glow map.
  118140. */
  118141. neutralColor: Color4;
  118142. /**
  118143. * Specifies wether the highlight layer is enabled or not.
  118144. */
  118145. isEnabled: boolean;
  118146. /**
  118147. * Gets the camera attached to the layer.
  118148. */
  118149. readonly camera: Nullable<Camera>;
  118150. /**
  118151. * Gets the rendering group id the layer should render in.
  118152. */
  118153. renderingGroupId: number;
  118154. /**
  118155. * An event triggered when the effect layer has been disposed.
  118156. */
  118157. onDisposeObservable: Observable<EffectLayer>;
  118158. /**
  118159. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118160. */
  118161. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118162. /**
  118163. * An event triggered when the generated texture is being merged in the scene.
  118164. */
  118165. onBeforeComposeObservable: Observable<EffectLayer>;
  118166. /**
  118167. * An event triggered when the mesh is rendered into the effect render target.
  118168. */
  118169. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118170. /**
  118171. * An event triggered after the mesh has been rendered into the effect render target.
  118172. */
  118173. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118174. /**
  118175. * An event triggered when the generated texture has been merged in the scene.
  118176. */
  118177. onAfterComposeObservable: Observable<EffectLayer>;
  118178. /**
  118179. * An event triggered when the efffect layer changes its size.
  118180. */
  118181. onSizeChangedObservable: Observable<EffectLayer>;
  118182. /** @hidden */
  118183. static _SceneComponentInitialization: (scene: Scene) => void;
  118184. /**
  118185. * Instantiates a new effect Layer and references it in the scene.
  118186. * @param name The name of the layer
  118187. * @param scene The scene to use the layer in
  118188. */
  118189. constructor(
  118190. /** The Friendly of the effect in the scene */
  118191. name: string, scene: Scene);
  118192. /**
  118193. * Get the effect name of the layer.
  118194. * @return The effect name
  118195. */
  118196. abstract getEffectName(): string;
  118197. /**
  118198. * Checks for the readiness of the element composing the layer.
  118199. * @param subMesh the mesh to check for
  118200. * @param useInstances specify wether or not to use instances to render the mesh
  118201. * @return true if ready otherwise, false
  118202. */
  118203. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118204. /**
  118205. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118206. * @returns true if the effect requires stencil during the main canvas render pass.
  118207. */
  118208. abstract needStencil(): boolean;
  118209. /**
  118210. * Create the merge effect. This is the shader use to blit the information back
  118211. * to the main canvas at the end of the scene rendering.
  118212. * @returns The effect containing the shader used to merge the effect on the main canvas
  118213. */
  118214. protected abstract _createMergeEffect(): Effect;
  118215. /**
  118216. * Creates the render target textures and post processes used in the effect layer.
  118217. */
  118218. protected abstract _createTextureAndPostProcesses(): void;
  118219. /**
  118220. * Implementation specific of rendering the generating effect on the main canvas.
  118221. * @param effect The effect used to render through
  118222. */
  118223. protected abstract _internalRender(effect: Effect): void;
  118224. /**
  118225. * Sets the required values for both the emissive texture and and the main color.
  118226. */
  118227. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118228. /**
  118229. * Free any resources and references associated to a mesh.
  118230. * Internal use
  118231. * @param mesh The mesh to free.
  118232. */
  118233. abstract _disposeMesh(mesh: Mesh): void;
  118234. /**
  118235. * Serializes this layer (Glow or Highlight for example)
  118236. * @returns a serialized layer object
  118237. */
  118238. abstract serialize?(): any;
  118239. /**
  118240. * Initializes the effect layer with the required options.
  118241. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118242. */
  118243. protected _init(options: Partial<IEffectLayerOptions>): void;
  118244. /**
  118245. * Generates the index buffer of the full screen quad blending to the main canvas.
  118246. */
  118247. private _generateIndexBuffer;
  118248. /**
  118249. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118250. */
  118251. private _generateVertexBuffer;
  118252. /**
  118253. * Sets the main texture desired size which is the closest power of two
  118254. * of the engine canvas size.
  118255. */
  118256. private _setMainTextureSize;
  118257. /**
  118258. * Creates the main texture for the effect layer.
  118259. */
  118260. protected _createMainTexture(): void;
  118261. /**
  118262. * Adds specific effects defines.
  118263. * @param defines The defines to add specifics to.
  118264. */
  118265. protected _addCustomEffectDefines(defines: string[]): void;
  118266. /**
  118267. * Checks for the readiness of the element composing the layer.
  118268. * @param subMesh the mesh to check for
  118269. * @param useInstances specify wether or not to use instances to render the mesh
  118270. * @param emissiveTexture the associated emissive texture used to generate the glow
  118271. * @return true if ready otherwise, false
  118272. */
  118273. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118274. /**
  118275. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118276. */
  118277. render(): void;
  118278. /**
  118279. * Determine if a given mesh will be used in the current effect.
  118280. * @param mesh mesh to test
  118281. * @returns true if the mesh will be used
  118282. */
  118283. hasMesh(mesh: AbstractMesh): boolean;
  118284. /**
  118285. * Returns true if the layer contains information to display, otherwise false.
  118286. * @returns true if the glow layer should be rendered
  118287. */
  118288. shouldRender(): boolean;
  118289. /**
  118290. * Returns true if the mesh should render, otherwise false.
  118291. * @param mesh The mesh to render
  118292. * @returns true if it should render otherwise false
  118293. */
  118294. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118295. /**
  118296. * Returns true if the mesh can be rendered, otherwise false.
  118297. * @param mesh The mesh to render
  118298. * @param material The material used on the mesh
  118299. * @returns true if it can be rendered otherwise false
  118300. */
  118301. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118302. /**
  118303. * Returns true if the mesh should render, otherwise false.
  118304. * @param mesh The mesh to render
  118305. * @returns true if it should render otherwise false
  118306. */
  118307. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118308. /**
  118309. * Renders the submesh passed in parameter to the generation map.
  118310. */
  118311. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118312. /**
  118313. * Defines wether the current material of the mesh should be use to render the effect.
  118314. * @param mesh defines the current mesh to render
  118315. */
  118316. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118317. /**
  118318. * Rebuild the required buffers.
  118319. * @hidden Internal use only.
  118320. */
  118321. _rebuild(): void;
  118322. /**
  118323. * Dispose only the render target textures and post process.
  118324. */
  118325. private _disposeTextureAndPostProcesses;
  118326. /**
  118327. * Dispose the highlight layer and free resources.
  118328. */
  118329. dispose(): void;
  118330. /**
  118331. * Gets the class name of the effect layer
  118332. * @returns the string with the class name of the effect layer
  118333. */
  118334. getClassName(): string;
  118335. /**
  118336. * Creates an effect layer from parsed effect layer data
  118337. * @param parsedEffectLayer defines effect layer data
  118338. * @param scene defines the current scene
  118339. * @param rootUrl defines the root URL containing the effect layer information
  118340. * @returns a parsed effect Layer
  118341. */
  118342. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118343. }
  118344. }
  118345. declare module BABYLON {
  118346. interface AbstractScene {
  118347. /**
  118348. * The list of effect layers (highlights/glow) added to the scene
  118349. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118350. * @see http://doc.babylonjs.com/how_to/glow_layer
  118351. */
  118352. effectLayers: Array<EffectLayer>;
  118353. /**
  118354. * Removes the given effect layer from this scene.
  118355. * @param toRemove defines the effect layer to remove
  118356. * @returns the index of the removed effect layer
  118357. */
  118358. removeEffectLayer(toRemove: EffectLayer): number;
  118359. /**
  118360. * Adds the given effect layer to this scene
  118361. * @param newEffectLayer defines the effect layer to add
  118362. */
  118363. addEffectLayer(newEffectLayer: EffectLayer): void;
  118364. }
  118365. /**
  118366. * Defines the layer scene component responsible to manage any effect layers
  118367. * in a given scene.
  118368. */
  118369. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118370. /**
  118371. * The component name helpfull to identify the component in the list of scene components.
  118372. */
  118373. readonly name: string;
  118374. /**
  118375. * The scene the component belongs to.
  118376. */
  118377. scene: Scene;
  118378. private _engine;
  118379. private _renderEffects;
  118380. private _needStencil;
  118381. private _previousStencilState;
  118382. /**
  118383. * Creates a new instance of the component for the given scene
  118384. * @param scene Defines the scene to register the component in
  118385. */
  118386. constructor(scene: Scene);
  118387. /**
  118388. * Registers the component in a given scene
  118389. */
  118390. register(): void;
  118391. /**
  118392. * Rebuilds the elements related to this component in case of
  118393. * context lost for instance.
  118394. */
  118395. rebuild(): void;
  118396. /**
  118397. * Serializes the component data to the specified json object
  118398. * @param serializationObject The object to serialize to
  118399. */
  118400. serialize(serializationObject: any): void;
  118401. /**
  118402. * Adds all the elements from the container to the scene
  118403. * @param container the container holding the elements
  118404. */
  118405. addFromContainer(container: AbstractScene): void;
  118406. /**
  118407. * Removes all the elements in the container from the scene
  118408. * @param container contains the elements to remove
  118409. * @param dispose if the removed element should be disposed (default: false)
  118410. */
  118411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118412. /**
  118413. * Disposes the component and the associated ressources.
  118414. */
  118415. dispose(): void;
  118416. private _isReadyForMesh;
  118417. private _renderMainTexture;
  118418. private _setStencil;
  118419. private _setStencilBack;
  118420. private _draw;
  118421. private _drawCamera;
  118422. private _drawRenderingGroup;
  118423. }
  118424. }
  118425. declare module BABYLON {
  118426. /** @hidden */
  118427. export var glowMapMergePixelShader: {
  118428. name: string;
  118429. shader: string;
  118430. };
  118431. }
  118432. declare module BABYLON {
  118433. /** @hidden */
  118434. export var glowMapMergeVertexShader: {
  118435. name: string;
  118436. shader: string;
  118437. };
  118438. }
  118439. declare module BABYLON {
  118440. interface AbstractScene {
  118441. /**
  118442. * Return a the first highlight layer of the scene with a given name.
  118443. * @param name The name of the highlight layer to look for.
  118444. * @return The highlight layer if found otherwise null.
  118445. */
  118446. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118447. }
  118448. /**
  118449. * Glow layer options. This helps customizing the behaviour
  118450. * of the glow layer.
  118451. */
  118452. export interface IGlowLayerOptions {
  118453. /**
  118454. * Multiplication factor apply to the canvas size to compute the render target size
  118455. * used to generated the glowing objects (the smaller the faster).
  118456. */
  118457. mainTextureRatio: number;
  118458. /**
  118459. * Enforces a fixed size texture to ensure resize independant blur.
  118460. */
  118461. mainTextureFixedSize?: number;
  118462. /**
  118463. * How big is the kernel of the blur texture.
  118464. */
  118465. blurKernelSize: number;
  118466. /**
  118467. * The camera attached to the layer.
  118468. */
  118469. camera: Nullable<Camera>;
  118470. /**
  118471. * Enable MSAA by chosing the number of samples.
  118472. */
  118473. mainTextureSamples?: number;
  118474. /**
  118475. * The rendering group to draw the layer in.
  118476. */
  118477. renderingGroupId: number;
  118478. }
  118479. /**
  118480. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118481. *
  118482. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118483. *
  118484. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118485. */
  118486. export class GlowLayer extends EffectLayer {
  118487. /**
  118488. * Effect Name of the layer.
  118489. */
  118490. static readonly EffectName: string;
  118491. /**
  118492. * The default blur kernel size used for the glow.
  118493. */
  118494. static DefaultBlurKernelSize: number;
  118495. /**
  118496. * The default texture size ratio used for the glow.
  118497. */
  118498. static DefaultTextureRatio: number;
  118499. /**
  118500. * Sets the kernel size of the blur.
  118501. */
  118502. /**
  118503. * Gets the kernel size of the blur.
  118504. */
  118505. blurKernelSize: number;
  118506. /**
  118507. * Sets the glow intensity.
  118508. */
  118509. /**
  118510. * Gets the glow intensity.
  118511. */
  118512. intensity: number;
  118513. private _options;
  118514. private _intensity;
  118515. private _horizontalBlurPostprocess1;
  118516. private _verticalBlurPostprocess1;
  118517. private _horizontalBlurPostprocess2;
  118518. private _verticalBlurPostprocess2;
  118519. private _blurTexture1;
  118520. private _blurTexture2;
  118521. private _postProcesses1;
  118522. private _postProcesses2;
  118523. private _includedOnlyMeshes;
  118524. private _excludedMeshes;
  118525. private _meshesUsingTheirOwnMaterials;
  118526. /**
  118527. * Callback used to let the user override the color selection on a per mesh basis
  118528. */
  118529. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118530. /**
  118531. * Callback used to let the user override the texture selection on a per mesh basis
  118532. */
  118533. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118534. /**
  118535. * Instantiates a new glow Layer and references it to the scene.
  118536. * @param name The name of the layer
  118537. * @param scene The scene to use the layer in
  118538. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118539. */
  118540. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118541. /**
  118542. * Get the effect name of the layer.
  118543. * @return The effect name
  118544. */
  118545. getEffectName(): string;
  118546. /**
  118547. * Create the merge effect. This is the shader use to blit the information back
  118548. * to the main canvas at the end of the scene rendering.
  118549. */
  118550. protected _createMergeEffect(): Effect;
  118551. /**
  118552. * Creates the render target textures and post processes used in the glow layer.
  118553. */
  118554. protected _createTextureAndPostProcesses(): void;
  118555. /**
  118556. * Checks for the readiness of the element composing the layer.
  118557. * @param subMesh the mesh to check for
  118558. * @param useInstances specify wether or not to use instances to render the mesh
  118559. * @param emissiveTexture the associated emissive texture used to generate the glow
  118560. * @return true if ready otherwise, false
  118561. */
  118562. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118563. /**
  118564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118565. */
  118566. needStencil(): boolean;
  118567. /**
  118568. * Returns true if the mesh can be rendered, otherwise false.
  118569. * @param mesh The mesh to render
  118570. * @param material The material used on the mesh
  118571. * @returns true if it can be rendered otherwise false
  118572. */
  118573. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118574. /**
  118575. * Implementation specific of rendering the generating effect on the main canvas.
  118576. * @param effect The effect used to render through
  118577. */
  118578. protected _internalRender(effect: Effect): void;
  118579. /**
  118580. * Sets the required values for both the emissive texture and and the main color.
  118581. */
  118582. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118583. /**
  118584. * Returns true if the mesh should render, otherwise false.
  118585. * @param mesh The mesh to render
  118586. * @returns true if it should render otherwise false
  118587. */
  118588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118589. /**
  118590. * Adds specific effects defines.
  118591. * @param defines The defines to add specifics to.
  118592. */
  118593. protected _addCustomEffectDefines(defines: string[]): void;
  118594. /**
  118595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118596. * @param mesh The mesh to exclude from the glow layer
  118597. */
  118598. addExcludedMesh(mesh: Mesh): void;
  118599. /**
  118600. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118601. * @param mesh The mesh to remove
  118602. */
  118603. removeExcludedMesh(mesh: Mesh): void;
  118604. /**
  118605. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118606. * @param mesh The mesh to include in the glow layer
  118607. */
  118608. addIncludedOnlyMesh(mesh: Mesh): void;
  118609. /**
  118610. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118611. * @param mesh The mesh to remove
  118612. */
  118613. removeIncludedOnlyMesh(mesh: Mesh): void;
  118614. /**
  118615. * Determine if a given mesh will be used in the glow layer
  118616. * @param mesh The mesh to test
  118617. * @returns true if the mesh will be highlighted by the current glow layer
  118618. */
  118619. hasMesh(mesh: AbstractMesh): boolean;
  118620. /**
  118621. * Defines wether the current material of the mesh should be use to render the effect.
  118622. * @param mesh defines the current mesh to render
  118623. */
  118624. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118625. /**
  118626. * Add a mesh to be rendered through its own material and not with emissive only.
  118627. * @param mesh The mesh for which we need to use its material
  118628. */
  118629. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118630. /**
  118631. * Remove a mesh from being rendered through its own material and not with emissive only.
  118632. * @param mesh The mesh for which we need to not use its material
  118633. */
  118634. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118635. /**
  118636. * Free any resources and references associated to a mesh.
  118637. * Internal use
  118638. * @param mesh The mesh to free.
  118639. * @hidden
  118640. */
  118641. _disposeMesh(mesh: Mesh): void;
  118642. /**
  118643. * Gets the class name of the effect layer
  118644. * @returns the string with the class name of the effect layer
  118645. */
  118646. getClassName(): string;
  118647. /**
  118648. * Serializes this glow layer
  118649. * @returns a serialized glow layer object
  118650. */
  118651. serialize(): any;
  118652. /**
  118653. * Creates a Glow Layer from parsed glow layer data
  118654. * @param parsedGlowLayer defines glow layer data
  118655. * @param scene defines the current scene
  118656. * @param rootUrl defines the root URL containing the glow layer information
  118657. * @returns a parsed Glow Layer
  118658. */
  118659. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  118660. }
  118661. }
  118662. declare module BABYLON {
  118663. /** @hidden */
  118664. export var glowBlurPostProcessPixelShader: {
  118665. name: string;
  118666. shader: string;
  118667. };
  118668. }
  118669. declare module BABYLON {
  118670. interface AbstractScene {
  118671. /**
  118672. * Return a the first highlight layer of the scene with a given name.
  118673. * @param name The name of the highlight layer to look for.
  118674. * @return The highlight layer if found otherwise null.
  118675. */
  118676. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  118677. }
  118678. /**
  118679. * Highlight layer options. This helps customizing the behaviour
  118680. * of the highlight layer.
  118681. */
  118682. export interface IHighlightLayerOptions {
  118683. /**
  118684. * Multiplication factor apply to the canvas size to compute the render target size
  118685. * used to generated the glowing objects (the smaller the faster).
  118686. */
  118687. mainTextureRatio: number;
  118688. /**
  118689. * Enforces a fixed size texture to ensure resize independant blur.
  118690. */
  118691. mainTextureFixedSize?: number;
  118692. /**
  118693. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  118694. * of the picture to blur (the smaller the faster).
  118695. */
  118696. blurTextureSizeRatio: number;
  118697. /**
  118698. * How big in texel of the blur texture is the vertical blur.
  118699. */
  118700. blurVerticalSize: number;
  118701. /**
  118702. * How big in texel of the blur texture is the horizontal blur.
  118703. */
  118704. blurHorizontalSize: number;
  118705. /**
  118706. * Alpha blending mode used to apply the blur. Default is combine.
  118707. */
  118708. alphaBlendingMode: number;
  118709. /**
  118710. * The camera attached to the layer.
  118711. */
  118712. camera: Nullable<Camera>;
  118713. /**
  118714. * Should we display highlight as a solid stroke?
  118715. */
  118716. isStroke?: boolean;
  118717. /**
  118718. * The rendering group to draw the layer in.
  118719. */
  118720. renderingGroupId: number;
  118721. }
  118722. /**
  118723. * The highlight layer Helps adding a glow effect around a mesh.
  118724. *
  118725. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  118726. * glowy meshes to your scene.
  118727. *
  118728. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  118729. */
  118730. export class HighlightLayer extends EffectLayer {
  118731. name: string;
  118732. /**
  118733. * Effect Name of the highlight layer.
  118734. */
  118735. static readonly EffectName: string;
  118736. /**
  118737. * The neutral color used during the preparation of the glow effect.
  118738. * This is black by default as the blend operation is a blend operation.
  118739. */
  118740. static NeutralColor: Color4;
  118741. /**
  118742. * Stencil value used for glowing meshes.
  118743. */
  118744. static GlowingMeshStencilReference: number;
  118745. /**
  118746. * Stencil value used for the other meshes in the scene.
  118747. */
  118748. static NormalMeshStencilReference: number;
  118749. /**
  118750. * Specifies whether or not the inner glow is ACTIVE in the layer.
  118751. */
  118752. innerGlow: boolean;
  118753. /**
  118754. * Specifies whether or not the outer glow is ACTIVE in the layer.
  118755. */
  118756. outerGlow: boolean;
  118757. /**
  118758. * Specifies the horizontal size of the blur.
  118759. */
  118760. /**
  118761. * Gets the horizontal size of the blur.
  118762. */
  118763. blurHorizontalSize: number;
  118764. /**
  118765. * Specifies the vertical size of the blur.
  118766. */
  118767. /**
  118768. * Gets the vertical size of the blur.
  118769. */
  118770. blurVerticalSize: number;
  118771. /**
  118772. * An event triggered when the highlight layer is being blurred.
  118773. */
  118774. onBeforeBlurObservable: Observable<HighlightLayer>;
  118775. /**
  118776. * An event triggered when the highlight layer has been blurred.
  118777. */
  118778. onAfterBlurObservable: Observable<HighlightLayer>;
  118779. private _instanceGlowingMeshStencilReference;
  118780. private _options;
  118781. private _downSamplePostprocess;
  118782. private _horizontalBlurPostprocess;
  118783. private _verticalBlurPostprocess;
  118784. private _blurTexture;
  118785. private _meshes;
  118786. private _excludedMeshes;
  118787. /**
  118788. * Instantiates a new highlight Layer and references it to the scene..
  118789. * @param name The name of the layer
  118790. * @param scene The scene to use the layer in
  118791. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  118792. */
  118793. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  118794. /**
  118795. * Get the effect name of the layer.
  118796. * @return The effect name
  118797. */
  118798. getEffectName(): string;
  118799. /**
  118800. * Create the merge effect. This is the shader use to blit the information back
  118801. * to the main canvas at the end of the scene rendering.
  118802. */
  118803. protected _createMergeEffect(): Effect;
  118804. /**
  118805. * Creates the render target textures and post processes used in the highlight layer.
  118806. */
  118807. protected _createTextureAndPostProcesses(): void;
  118808. /**
  118809. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118810. */
  118811. needStencil(): boolean;
  118812. /**
  118813. * Checks for the readiness of the element composing the layer.
  118814. * @param subMesh the mesh to check for
  118815. * @param useInstances specify wether or not to use instances to render the mesh
  118816. * @param emissiveTexture the associated emissive texture used to generate the glow
  118817. * @return true if ready otherwise, false
  118818. */
  118819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118820. /**
  118821. * Implementation specific of rendering the generating effect on the main canvas.
  118822. * @param effect The effect used to render through
  118823. */
  118824. protected _internalRender(effect: Effect): void;
  118825. /**
  118826. * Returns true if the layer contains information to display, otherwise false.
  118827. */
  118828. shouldRender(): boolean;
  118829. /**
  118830. * Returns true if the mesh should render, otherwise false.
  118831. * @param mesh The mesh to render
  118832. * @returns true if it should render otherwise false
  118833. */
  118834. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118835. /**
  118836. * Sets the required values for both the emissive texture and and the main color.
  118837. */
  118838. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118839. /**
  118840. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  118841. * @param mesh The mesh to exclude from the highlight layer
  118842. */
  118843. addExcludedMesh(mesh: Mesh): void;
  118844. /**
  118845. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  118846. * @param mesh The mesh to highlight
  118847. */
  118848. removeExcludedMesh(mesh: Mesh): void;
  118849. /**
  118850. * Determine if a given mesh will be highlighted by the current HighlightLayer
  118851. * @param mesh mesh to test
  118852. * @returns true if the mesh will be highlighted by the current HighlightLayer
  118853. */
  118854. hasMesh(mesh: AbstractMesh): boolean;
  118855. /**
  118856. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  118857. * @param mesh The mesh to highlight
  118858. * @param color The color of the highlight
  118859. * @param glowEmissiveOnly Extract the glow from the emissive texture
  118860. */
  118861. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  118862. /**
  118863. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118864. * @param mesh The mesh to highlight
  118865. */
  118866. removeMesh(mesh: Mesh): void;
  118867. /**
  118868. * Force the stencil to the normal expected value for none glowing parts
  118869. */
  118870. private _defaultStencilReference;
  118871. /**
  118872. * Free any resources and references associated to a mesh.
  118873. * Internal use
  118874. * @param mesh The mesh to free.
  118875. * @hidden
  118876. */
  118877. _disposeMesh(mesh: Mesh): void;
  118878. /**
  118879. * Dispose the highlight layer and free resources.
  118880. */
  118881. dispose(): void;
  118882. /**
  118883. * Gets the class name of the effect layer
  118884. * @returns the string with the class name of the effect layer
  118885. */
  118886. getClassName(): string;
  118887. /**
  118888. * Serializes this Highlight layer
  118889. * @returns a serialized Highlight layer object
  118890. */
  118891. serialize(): any;
  118892. /**
  118893. * Creates a Highlight layer from parsed Highlight layer data
  118894. * @param parsedHightlightLayer defines the Highlight layer data
  118895. * @param scene defines the current scene
  118896. * @param rootUrl defines the root URL containing the Highlight layer information
  118897. * @returns a parsed Highlight layer
  118898. */
  118899. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118900. }
  118901. }
  118902. declare module BABYLON {
  118903. interface AbstractScene {
  118904. /**
  118905. * The list of layers (background and foreground) of the scene
  118906. */
  118907. layers: Array<Layer>;
  118908. }
  118909. /**
  118910. * Defines the layer scene component responsible to manage any layers
  118911. * in a given scene.
  118912. */
  118913. export class LayerSceneComponent implements ISceneComponent {
  118914. /**
  118915. * The component name helpfull to identify the component in the list of scene components.
  118916. */
  118917. readonly name: string;
  118918. /**
  118919. * The scene the component belongs to.
  118920. */
  118921. scene: Scene;
  118922. private _engine;
  118923. /**
  118924. * Creates a new instance of the component for the given scene
  118925. * @param scene Defines the scene to register the component in
  118926. */
  118927. constructor(scene: Scene);
  118928. /**
  118929. * Registers the component in a given scene
  118930. */
  118931. register(): void;
  118932. /**
  118933. * Rebuilds the elements related to this component in case of
  118934. * context lost for instance.
  118935. */
  118936. rebuild(): void;
  118937. /**
  118938. * Disposes the component and the associated ressources.
  118939. */
  118940. dispose(): void;
  118941. private _draw;
  118942. private _drawCameraPredicate;
  118943. private _drawCameraBackground;
  118944. private _drawCameraForeground;
  118945. private _drawRenderTargetPredicate;
  118946. private _drawRenderTargetBackground;
  118947. private _drawRenderTargetForeground;
  118948. /**
  118949. * Adds all the elements from the container to the scene
  118950. * @param container the container holding the elements
  118951. */
  118952. addFromContainer(container: AbstractScene): void;
  118953. /**
  118954. * Removes all the elements in the container from the scene
  118955. * @param container contains the elements to remove
  118956. * @param dispose if the removed element should be disposed (default: false)
  118957. */
  118958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /** @hidden */
  118963. export var layerPixelShader: {
  118964. name: string;
  118965. shader: string;
  118966. };
  118967. }
  118968. declare module BABYLON {
  118969. /** @hidden */
  118970. export var layerVertexShader: {
  118971. name: string;
  118972. shader: string;
  118973. };
  118974. }
  118975. declare module BABYLON {
  118976. /**
  118977. * This represents a full screen 2d layer.
  118978. * This can be useful to display a picture in the background of your scene for instance.
  118979. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118980. */
  118981. export class Layer {
  118982. /**
  118983. * Define the name of the layer.
  118984. */
  118985. name: string;
  118986. /**
  118987. * Define the texture the layer should display.
  118988. */
  118989. texture: Nullable<Texture>;
  118990. /**
  118991. * Is the layer in background or foreground.
  118992. */
  118993. isBackground: boolean;
  118994. /**
  118995. * Define the color of the layer (instead of texture).
  118996. */
  118997. color: Color4;
  118998. /**
  118999. * Define the scale of the layer in order to zoom in out of the texture.
  119000. */
  119001. scale: Vector2;
  119002. /**
  119003. * Define an offset for the layer in order to shift the texture.
  119004. */
  119005. offset: Vector2;
  119006. /**
  119007. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119008. */
  119009. alphaBlendingMode: number;
  119010. /**
  119011. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119012. * Alpha test will not mix with the background color in case of transparency.
  119013. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119014. */
  119015. alphaTest: boolean;
  119016. /**
  119017. * Define a mask to restrict the layer to only some of the scene cameras.
  119018. */
  119019. layerMask: number;
  119020. /**
  119021. * Define the list of render target the layer is visible into.
  119022. */
  119023. renderTargetTextures: RenderTargetTexture[];
  119024. /**
  119025. * Define if the layer is only used in renderTarget or if it also
  119026. * renders in the main frame buffer of the canvas.
  119027. */
  119028. renderOnlyInRenderTargetTextures: boolean;
  119029. private _scene;
  119030. private _vertexBuffers;
  119031. private _indexBuffer;
  119032. private _effect;
  119033. private _alphaTestEffect;
  119034. /**
  119035. * An event triggered when the layer is disposed.
  119036. */
  119037. onDisposeObservable: Observable<Layer>;
  119038. private _onDisposeObserver;
  119039. /**
  119040. * Back compatibility with callback before the onDisposeObservable existed.
  119041. * The set callback will be triggered when the layer has been disposed.
  119042. */
  119043. onDispose: () => void;
  119044. /**
  119045. * An event triggered before rendering the scene
  119046. */
  119047. onBeforeRenderObservable: Observable<Layer>;
  119048. private _onBeforeRenderObserver;
  119049. /**
  119050. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119051. * The set callback will be triggered just before rendering the layer.
  119052. */
  119053. onBeforeRender: () => void;
  119054. /**
  119055. * An event triggered after rendering the scene
  119056. */
  119057. onAfterRenderObservable: Observable<Layer>;
  119058. private _onAfterRenderObserver;
  119059. /**
  119060. * Back compatibility with callback before the onAfterRenderObservable existed.
  119061. * The set callback will be triggered just after rendering the layer.
  119062. */
  119063. onAfterRender: () => void;
  119064. /**
  119065. * Instantiates a new layer.
  119066. * This represents a full screen 2d layer.
  119067. * This can be useful to display a picture in the background of your scene for instance.
  119068. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119069. * @param name Define the name of the layer in the scene
  119070. * @param imgUrl Define the url of the texture to display in the layer
  119071. * @param scene Define the scene the layer belongs to
  119072. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119073. * @param color Defines a color for the layer
  119074. */
  119075. constructor(
  119076. /**
  119077. * Define the name of the layer.
  119078. */
  119079. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119080. private _createIndexBuffer;
  119081. /** @hidden */
  119082. _rebuild(): void;
  119083. /**
  119084. * Renders the layer in the scene.
  119085. */
  119086. render(): void;
  119087. /**
  119088. * Disposes and releases the associated ressources.
  119089. */
  119090. dispose(): void;
  119091. }
  119092. }
  119093. declare module BABYLON {
  119094. /** @hidden */
  119095. export var lensFlarePixelShader: {
  119096. name: string;
  119097. shader: string;
  119098. };
  119099. }
  119100. declare module BABYLON {
  119101. /** @hidden */
  119102. export var lensFlareVertexShader: {
  119103. name: string;
  119104. shader: string;
  119105. };
  119106. }
  119107. declare module BABYLON {
  119108. /**
  119109. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119110. * It is usually composed of several `lensFlare`.
  119111. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119112. */
  119113. export class LensFlareSystem {
  119114. /**
  119115. * Define the name of the lens flare system
  119116. */
  119117. name: string;
  119118. /**
  119119. * List of lens flares used in this system.
  119120. */
  119121. lensFlares: LensFlare[];
  119122. /**
  119123. * Define a limit from the border the lens flare can be visible.
  119124. */
  119125. borderLimit: number;
  119126. /**
  119127. * Define a viewport border we do not want to see the lens flare in.
  119128. */
  119129. viewportBorder: number;
  119130. /**
  119131. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119132. */
  119133. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119134. /**
  119135. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119136. */
  119137. layerMask: number;
  119138. /**
  119139. * Define the id of the lens flare system in the scene.
  119140. * (equal to name by default)
  119141. */
  119142. id: string;
  119143. private _scene;
  119144. private _emitter;
  119145. private _vertexBuffers;
  119146. private _indexBuffer;
  119147. private _effect;
  119148. private _positionX;
  119149. private _positionY;
  119150. private _isEnabled;
  119151. /** @hidden */
  119152. static _SceneComponentInitialization: (scene: Scene) => void;
  119153. /**
  119154. * Instantiates a lens flare system.
  119155. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119156. * It is usually composed of several `lensFlare`.
  119157. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119158. * @param name Define the name of the lens flare system in the scene
  119159. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119160. * @param scene Define the scene the lens flare system belongs to
  119161. */
  119162. constructor(
  119163. /**
  119164. * Define the name of the lens flare system
  119165. */
  119166. name: string, emitter: any, scene: Scene);
  119167. /**
  119168. * Define if the lens flare system is enabled.
  119169. */
  119170. isEnabled: boolean;
  119171. /**
  119172. * Get the scene the effects belongs to.
  119173. * @returns the scene holding the lens flare system
  119174. */
  119175. getScene(): Scene;
  119176. /**
  119177. * Get the emitter of the lens flare system.
  119178. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119179. * @returns the emitter of the lens flare system
  119180. */
  119181. getEmitter(): any;
  119182. /**
  119183. * Set the emitter of the lens flare system.
  119184. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119185. * @param newEmitter Define the new emitter of the system
  119186. */
  119187. setEmitter(newEmitter: any): void;
  119188. /**
  119189. * Get the lens flare system emitter position.
  119190. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119191. * @returns the position
  119192. */
  119193. getEmitterPosition(): Vector3;
  119194. /**
  119195. * @hidden
  119196. */
  119197. computeEffectivePosition(globalViewport: Viewport): boolean;
  119198. /** @hidden */
  119199. _isVisible(): boolean;
  119200. /**
  119201. * @hidden
  119202. */
  119203. render(): boolean;
  119204. /**
  119205. * Dispose and release the lens flare with its associated resources.
  119206. */
  119207. dispose(): void;
  119208. /**
  119209. * Parse a lens flare system from a JSON repressentation
  119210. * @param parsedLensFlareSystem Define the JSON to parse
  119211. * @param scene Define the scene the parsed system should be instantiated in
  119212. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119213. * @returns the parsed system
  119214. */
  119215. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119216. /**
  119217. * Serialize the current Lens Flare System into a JSON representation.
  119218. * @returns the serialized JSON
  119219. */
  119220. serialize(): any;
  119221. }
  119222. }
  119223. declare module BABYLON {
  119224. /**
  119225. * This represents one of the lens effect in a `lensFlareSystem`.
  119226. * It controls one of the indiviual texture used in the effect.
  119227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119228. */
  119229. export class LensFlare {
  119230. /**
  119231. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119232. */
  119233. size: number;
  119234. /**
  119235. * 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.
  119236. */
  119237. position: number;
  119238. /**
  119239. * Define the lens color.
  119240. */
  119241. color: Color3;
  119242. /**
  119243. * Define the lens texture.
  119244. */
  119245. texture: Nullable<Texture>;
  119246. /**
  119247. * Define the alpha mode to render this particular lens.
  119248. */
  119249. alphaMode: number;
  119250. private _system;
  119251. /**
  119252. * Creates a new Lens Flare.
  119253. * This represents one of the lens effect in a `lensFlareSystem`.
  119254. * It controls one of the indiviual texture used in the effect.
  119255. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119256. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119257. * @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.
  119258. * @param color Define the lens color
  119259. * @param imgUrl Define the lens texture url
  119260. * @param system Define the `lensFlareSystem` this flare is part of
  119261. * @returns The newly created Lens Flare
  119262. */
  119263. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119264. /**
  119265. * Instantiates a new Lens Flare.
  119266. * This represents one of the lens effect in a `lensFlareSystem`.
  119267. * It controls one of the indiviual texture used in the effect.
  119268. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119269. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119270. * @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.
  119271. * @param color Define the lens color
  119272. * @param imgUrl Define the lens texture url
  119273. * @param system Define the `lensFlareSystem` this flare is part of
  119274. */
  119275. constructor(
  119276. /**
  119277. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119278. */
  119279. size: number,
  119280. /**
  119281. * 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.
  119282. */
  119283. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119284. /**
  119285. * Dispose and release the lens flare with its associated resources.
  119286. */
  119287. dispose(): void;
  119288. }
  119289. }
  119290. declare module BABYLON {
  119291. interface AbstractScene {
  119292. /**
  119293. * The list of lens flare system added to the scene
  119294. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119295. */
  119296. lensFlareSystems: Array<LensFlareSystem>;
  119297. /**
  119298. * Removes the given lens flare system from this scene.
  119299. * @param toRemove The lens flare system to remove
  119300. * @returns The index of the removed lens flare system
  119301. */
  119302. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119303. /**
  119304. * Adds the given lens flare system to this scene
  119305. * @param newLensFlareSystem The lens flare system to add
  119306. */
  119307. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119308. /**
  119309. * Gets a lens flare system using its name
  119310. * @param name defines the name to look for
  119311. * @returns the lens flare system or null if not found
  119312. */
  119313. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119314. /**
  119315. * Gets a lens flare system using its id
  119316. * @param id defines the id to look for
  119317. * @returns the lens flare system or null if not found
  119318. */
  119319. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119320. }
  119321. /**
  119322. * Defines the lens flare scene component responsible to manage any lens flares
  119323. * in a given scene.
  119324. */
  119325. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119326. /**
  119327. * The component name helpfull to identify the component in the list of scene components.
  119328. */
  119329. readonly name: string;
  119330. /**
  119331. * The scene the component belongs to.
  119332. */
  119333. scene: Scene;
  119334. /**
  119335. * Creates a new instance of the component for the given scene
  119336. * @param scene Defines the scene to register the component in
  119337. */
  119338. constructor(scene: Scene);
  119339. /**
  119340. * Registers the component in a given scene
  119341. */
  119342. register(): void;
  119343. /**
  119344. * Rebuilds the elements related to this component in case of
  119345. * context lost for instance.
  119346. */
  119347. rebuild(): void;
  119348. /**
  119349. * Adds all the elements from the container to the scene
  119350. * @param container the container holding the elements
  119351. */
  119352. addFromContainer(container: AbstractScene): void;
  119353. /**
  119354. * Removes all the elements in the container from the scene
  119355. * @param container contains the elements to remove
  119356. * @param dispose if the removed element should be disposed (default: false)
  119357. */
  119358. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119359. /**
  119360. * Serializes the component data to the specified json object
  119361. * @param serializationObject The object to serialize to
  119362. */
  119363. serialize(serializationObject: any): void;
  119364. /**
  119365. * Disposes the component and the associated ressources.
  119366. */
  119367. dispose(): void;
  119368. private _draw;
  119369. }
  119370. }
  119371. declare module BABYLON {
  119372. /**
  119373. * Defines the shadow generator component responsible to manage any shadow generators
  119374. * in a given scene.
  119375. */
  119376. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119377. /**
  119378. * The component name helpfull to identify the component in the list of scene components.
  119379. */
  119380. readonly name: string;
  119381. /**
  119382. * The scene the component belongs to.
  119383. */
  119384. scene: Scene;
  119385. /**
  119386. * Creates a new instance of the component for the given scene
  119387. * @param scene Defines the scene to register the component in
  119388. */
  119389. constructor(scene: Scene);
  119390. /**
  119391. * Registers the component in a given scene
  119392. */
  119393. register(): void;
  119394. /**
  119395. * Rebuilds the elements related to this component in case of
  119396. * context lost for instance.
  119397. */
  119398. rebuild(): void;
  119399. /**
  119400. * Serializes the component data to the specified json object
  119401. * @param serializationObject The object to serialize to
  119402. */
  119403. serialize(serializationObject: any): void;
  119404. /**
  119405. * Adds all the elements from the container to the scene
  119406. * @param container the container holding the elements
  119407. */
  119408. addFromContainer(container: AbstractScene): void;
  119409. /**
  119410. * Removes all the elements in the container from the scene
  119411. * @param container contains the elements to remove
  119412. * @param dispose if the removed element should be disposed (default: false)
  119413. */
  119414. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119415. /**
  119416. * Rebuilds the elements related to this component in case of
  119417. * context lost for instance.
  119418. */
  119419. dispose(): void;
  119420. private _gatherRenderTargets;
  119421. }
  119422. }
  119423. declare module BABYLON {
  119424. /**
  119425. * A point light is a light defined by an unique point in world space.
  119426. * The light is emitted in every direction from this point.
  119427. * A good example of a point light is a standard light bulb.
  119428. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119429. */
  119430. export class PointLight extends ShadowLight {
  119431. private _shadowAngle;
  119432. /**
  119433. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119434. * This specifies what angle the shadow will use to be created.
  119435. *
  119436. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119437. */
  119438. /**
  119439. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119440. * This specifies what angle the shadow will use to be created.
  119441. *
  119442. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119443. */
  119444. shadowAngle: number;
  119445. /**
  119446. * Gets the direction if it has been set.
  119447. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119448. */
  119449. /**
  119450. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119451. */
  119452. direction: Vector3;
  119453. /**
  119454. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119455. * A PointLight emits the light in every direction.
  119456. * It can cast shadows.
  119457. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119458. * ```javascript
  119459. * var pointLight = new PointLight("pl", camera.position, scene);
  119460. * ```
  119461. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119462. * @param name The light friendly name
  119463. * @param position The position of the point light in the scene
  119464. * @param scene The scene the lights belongs to
  119465. */
  119466. constructor(name: string, position: Vector3, scene: Scene);
  119467. /**
  119468. * Returns the string "PointLight"
  119469. * @returns the class name
  119470. */
  119471. getClassName(): string;
  119472. /**
  119473. * Returns the integer 0.
  119474. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119475. */
  119476. getTypeID(): number;
  119477. /**
  119478. * Specifies wether or not the shadowmap should be a cube texture.
  119479. * @returns true if the shadowmap needs to be a cube texture.
  119480. */
  119481. needCube(): boolean;
  119482. /**
  119483. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119484. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119485. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119486. */
  119487. getShadowDirection(faceIndex?: number): Vector3;
  119488. /**
  119489. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119490. * - fov = PI / 2
  119491. * - aspect ratio : 1.0
  119492. * - z-near and far equal to the active camera minZ and maxZ.
  119493. * Returns the PointLight.
  119494. */
  119495. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119496. protected _buildUniformLayout(): void;
  119497. /**
  119498. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119499. * @param effect The effect to update
  119500. * @param lightIndex The index of the light in the effect to update
  119501. * @returns The point light
  119502. */
  119503. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119504. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119505. /**
  119506. * Prepares the list of defines specific to the light type.
  119507. * @param defines the list of defines
  119508. * @param lightIndex defines the index of the light for the effect
  119509. */
  119510. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119511. }
  119512. }
  119513. declare module BABYLON {
  119514. /**
  119515. * Header information of HDR texture files.
  119516. */
  119517. export interface HDRInfo {
  119518. /**
  119519. * The height of the texture in pixels.
  119520. */
  119521. height: number;
  119522. /**
  119523. * The width of the texture in pixels.
  119524. */
  119525. width: number;
  119526. /**
  119527. * The index of the beginning of the data in the binary file.
  119528. */
  119529. dataPosition: number;
  119530. }
  119531. /**
  119532. * This groups tools to convert HDR texture to native colors array.
  119533. */
  119534. export class HDRTools {
  119535. private static Ldexp;
  119536. private static Rgbe2float;
  119537. private static readStringLine;
  119538. /**
  119539. * Reads header information from an RGBE texture stored in a native array.
  119540. * More information on this format are available here:
  119541. * https://en.wikipedia.org/wiki/RGBE_image_format
  119542. *
  119543. * @param uint8array The binary file stored in native array.
  119544. * @return The header information.
  119545. */
  119546. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119547. /**
  119548. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119549. * This RGBE texture needs to store the information as a panorama.
  119550. *
  119551. * More information on this format are available here:
  119552. * https://en.wikipedia.org/wiki/RGBE_image_format
  119553. *
  119554. * @param buffer The binary file stored in an array buffer.
  119555. * @param size The expected size of the extracted cubemap.
  119556. * @return The Cube Map information.
  119557. */
  119558. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119559. /**
  119560. * Returns the pixels data extracted from an RGBE texture.
  119561. * This pixels will be stored left to right up to down in the R G B order in one array.
  119562. *
  119563. * More information on this format are available here:
  119564. * https://en.wikipedia.org/wiki/RGBE_image_format
  119565. *
  119566. * @param uint8array The binary file stored in an array buffer.
  119567. * @param hdrInfo The header information of the file.
  119568. * @return The pixels data in RGB right to left up to down order.
  119569. */
  119570. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119571. private static RGBE_ReadPixels_RLE;
  119572. }
  119573. }
  119574. declare module BABYLON {
  119575. /**
  119576. * This represents a texture coming from an HDR input.
  119577. *
  119578. * The only supported format is currently panorama picture stored in RGBE format.
  119579. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119580. */
  119581. export class HDRCubeTexture extends BaseTexture {
  119582. private static _facesMapping;
  119583. private _generateHarmonics;
  119584. private _noMipmap;
  119585. private _textureMatrix;
  119586. private _size;
  119587. private _onLoad;
  119588. private _onError;
  119589. /**
  119590. * The texture URL.
  119591. */
  119592. url: string;
  119593. /**
  119594. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119595. */
  119596. coordinatesMode: number;
  119597. protected _isBlocking: boolean;
  119598. /**
  119599. * Sets wether or not the texture is blocking during loading.
  119600. */
  119601. /**
  119602. * Gets wether or not the texture is blocking during loading.
  119603. */
  119604. isBlocking: boolean;
  119605. protected _rotationY: number;
  119606. /**
  119607. * Sets texture matrix rotation angle around Y axis in radians.
  119608. */
  119609. /**
  119610. * Gets texture matrix rotation angle around Y axis radians.
  119611. */
  119612. rotationY: number;
  119613. /**
  119614. * Gets or sets the center of the bounding box associated with the cube texture
  119615. * It must define where the camera used to render the texture was set
  119616. */
  119617. boundingBoxPosition: Vector3;
  119618. private _boundingBoxSize;
  119619. /**
  119620. * Gets or sets the size of the bounding box associated with the cube texture
  119621. * When defined, the cubemap will switch to local mode
  119622. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119623. * @example https://www.babylonjs-playground.com/#RNASML
  119624. */
  119625. boundingBoxSize: Vector3;
  119626. /**
  119627. * Instantiates an HDRTexture from the following parameters.
  119628. *
  119629. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119630. * @param scene The scene the texture will be used in
  119631. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119632. * @param noMipmap Forces to not generate the mipmap if true
  119633. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119634. * @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)
  119635. * @param reserved Reserved flag for internal use.
  119636. */
  119637. 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>);
  119638. /**
  119639. * Get the current class name of the texture useful for serialization or dynamic coding.
  119640. * @returns "HDRCubeTexture"
  119641. */
  119642. getClassName(): string;
  119643. /**
  119644. * Occurs when the file is raw .hdr file.
  119645. */
  119646. private loadTexture;
  119647. clone(): HDRCubeTexture;
  119648. delayLoad(): void;
  119649. /**
  119650. * Get the texture reflection matrix used to rotate/transform the reflection.
  119651. * @returns the reflection matrix
  119652. */
  119653. getReflectionTextureMatrix(): Matrix;
  119654. /**
  119655. * Set the texture reflection matrix used to rotate/transform the reflection.
  119656. * @param value Define the reflection matrix to set
  119657. */
  119658. setReflectionTextureMatrix(value: Matrix): void;
  119659. /**
  119660. * Parses a JSON representation of an HDR Texture in order to create the texture
  119661. * @param parsedTexture Define the JSON representation
  119662. * @param scene Define the scene the texture should be created in
  119663. * @param rootUrl Define the root url in case we need to load relative dependencies
  119664. * @returns the newly created texture after parsing
  119665. */
  119666. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  119667. serialize(): any;
  119668. }
  119669. }
  119670. declare module BABYLON {
  119671. /**
  119672. * Class used to control physics engine
  119673. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119674. */
  119675. export class PhysicsEngine implements IPhysicsEngine {
  119676. private _physicsPlugin;
  119677. /**
  119678. * Global value used to control the smallest number supported by the simulation
  119679. */
  119680. static Epsilon: number;
  119681. private _impostors;
  119682. private _joints;
  119683. /**
  119684. * Gets the gravity vector used by the simulation
  119685. */
  119686. gravity: Vector3;
  119687. /**
  119688. * Factory used to create the default physics plugin.
  119689. * @returns The default physics plugin
  119690. */
  119691. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  119692. /**
  119693. * Creates a new Physics Engine
  119694. * @param gravity defines the gravity vector used by the simulation
  119695. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  119696. */
  119697. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  119698. /**
  119699. * Sets the gravity vector used by the simulation
  119700. * @param gravity defines the gravity vector to use
  119701. */
  119702. setGravity(gravity: Vector3): void;
  119703. /**
  119704. * Set the time step of the physics engine.
  119705. * Default is 1/60.
  119706. * To slow it down, enter 1/600 for example.
  119707. * To speed it up, 1/30
  119708. * @param newTimeStep defines the new timestep to apply to this world.
  119709. */
  119710. setTimeStep(newTimeStep?: number): void;
  119711. /**
  119712. * Get the time step of the physics engine.
  119713. * @returns the current time step
  119714. */
  119715. getTimeStep(): number;
  119716. /**
  119717. * Release all resources
  119718. */
  119719. dispose(): void;
  119720. /**
  119721. * Gets the name of the current physics plugin
  119722. * @returns the name of the plugin
  119723. */
  119724. getPhysicsPluginName(): string;
  119725. /**
  119726. * Adding a new impostor for the impostor tracking.
  119727. * This will be done by the impostor itself.
  119728. * @param impostor the impostor to add
  119729. */
  119730. addImpostor(impostor: PhysicsImpostor): void;
  119731. /**
  119732. * Remove an impostor from the engine.
  119733. * This impostor and its mesh will not longer be updated by the physics engine.
  119734. * @param impostor the impostor to remove
  119735. */
  119736. removeImpostor(impostor: PhysicsImpostor): void;
  119737. /**
  119738. * Add a joint to the physics engine
  119739. * @param mainImpostor defines the main impostor to which the joint is added.
  119740. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  119741. * @param joint defines the joint that will connect both impostors.
  119742. */
  119743. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119744. /**
  119745. * Removes a joint from the simulation
  119746. * @param mainImpostor defines the impostor used with the joint
  119747. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  119748. * @param joint defines the joint to remove
  119749. */
  119750. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  119751. /**
  119752. * Called by the scene. No need to call it.
  119753. * @param delta defines the timespam between frames
  119754. */
  119755. _step(delta: number): void;
  119756. /**
  119757. * Gets the current plugin used to run the simulation
  119758. * @returns current plugin
  119759. */
  119760. getPhysicsPlugin(): IPhysicsEnginePlugin;
  119761. /**
  119762. * Gets the list of physic impostors
  119763. * @returns an array of PhysicsImpostor
  119764. */
  119765. getImpostors(): Array<PhysicsImpostor>;
  119766. /**
  119767. * Gets the impostor for a physics enabled object
  119768. * @param object defines the object impersonated by the impostor
  119769. * @returns the PhysicsImpostor or null if not found
  119770. */
  119771. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  119772. /**
  119773. * Gets the impostor for a physics body object
  119774. * @param body defines physics body used by the impostor
  119775. * @returns the PhysicsImpostor or null if not found
  119776. */
  119777. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  119778. /**
  119779. * Does a raycast in the physics world
  119780. * @param from when should the ray start?
  119781. * @param to when should the ray end?
  119782. * @returns PhysicsRaycastResult
  119783. */
  119784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119785. }
  119786. }
  119787. declare module BABYLON {
  119788. /** @hidden */
  119789. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  119790. private _useDeltaForWorldStep;
  119791. world: any;
  119792. name: string;
  119793. private _physicsMaterials;
  119794. private _fixedTimeStep;
  119795. private _cannonRaycastResult;
  119796. private _raycastResult;
  119797. private _physicsBodysToRemoveAfterStep;
  119798. BJSCANNON: any;
  119799. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  119800. setGravity(gravity: Vector3): void;
  119801. setTimeStep(timeStep: number): void;
  119802. getTimeStep(): number;
  119803. executeStep(delta: number): void;
  119804. private _removeMarkedPhysicsBodiesFromWorld;
  119805. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119806. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119807. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119808. private _processChildMeshes;
  119809. removePhysicsBody(impostor: PhysicsImpostor): void;
  119810. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119811. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119812. private _addMaterial;
  119813. private _checkWithEpsilon;
  119814. private _createShape;
  119815. private _createHeightmap;
  119816. private _minus90X;
  119817. private _plus90X;
  119818. private _tmpPosition;
  119819. private _tmpDeltaPosition;
  119820. private _tmpUnityRotation;
  119821. private _updatePhysicsBodyTransformation;
  119822. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119823. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119824. isSupported(): boolean;
  119825. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119826. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119827. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119828. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119829. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119830. getBodyMass(impostor: PhysicsImpostor): number;
  119831. getBodyFriction(impostor: PhysicsImpostor): number;
  119832. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119833. getBodyRestitution(impostor: PhysicsImpostor): number;
  119834. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119835. sleepBody(impostor: PhysicsImpostor): void;
  119836. wakeUpBody(impostor: PhysicsImpostor): void;
  119837. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  119838. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119839. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119840. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119841. getRadius(impostor: PhysicsImpostor): number;
  119842. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119843. dispose(): void;
  119844. private _extendNamespace;
  119845. /**
  119846. * Does a raycast in the physics world
  119847. * @param from when should the ray start?
  119848. * @param to when should the ray end?
  119849. * @returns PhysicsRaycastResult
  119850. */
  119851. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119852. }
  119853. }
  119854. declare module BABYLON {
  119855. /** @hidden */
  119856. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  119857. world: any;
  119858. name: string;
  119859. BJSOIMO: any;
  119860. private _raycastResult;
  119861. constructor(iterations?: number, oimoInjection?: any);
  119862. setGravity(gravity: Vector3): void;
  119863. setTimeStep(timeStep: number): void;
  119864. getTimeStep(): number;
  119865. private _tmpImpostorsArray;
  119866. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119867. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119868. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119869. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119870. private _tmpPositionVector;
  119871. removePhysicsBody(impostor: PhysicsImpostor): void;
  119872. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119873. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119874. isSupported(): boolean;
  119875. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119876. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119877. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119878. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119880. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119881. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119882. getBodyMass(impostor: PhysicsImpostor): number;
  119883. getBodyFriction(impostor: PhysicsImpostor): number;
  119884. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119885. getBodyRestitution(impostor: PhysicsImpostor): number;
  119886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119887. sleepBody(impostor: PhysicsImpostor): void;
  119888. wakeUpBody(impostor: PhysicsImpostor): void;
  119889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119890. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119893. getRadius(impostor: PhysicsImpostor): number;
  119894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119895. dispose(): void;
  119896. /**
  119897. * Does a raycast in the physics world
  119898. * @param from when should the ray start?
  119899. * @param to when should the ray end?
  119900. * @returns PhysicsRaycastResult
  119901. */
  119902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119903. }
  119904. }
  119905. declare module BABYLON {
  119906. /**
  119907. * Class containing static functions to help procedurally build meshes
  119908. */
  119909. export class RibbonBuilder {
  119910. /**
  119911. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119912. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119913. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119914. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119915. * * 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
  119916. * * 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
  119917. * * 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
  119918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119921. * * 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
  119922. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119923. * * 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
  119924. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119926. * @param name defines the name of the mesh
  119927. * @param options defines the options used to create the mesh
  119928. * @param scene defines the hosting scene
  119929. * @returns the ribbon mesh
  119930. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119932. */
  119933. static CreateRibbon(name: string, options: {
  119934. pathArray: Vector3[][];
  119935. closeArray?: boolean;
  119936. closePath?: boolean;
  119937. offset?: number;
  119938. updatable?: boolean;
  119939. sideOrientation?: number;
  119940. frontUVs?: Vector4;
  119941. backUVs?: Vector4;
  119942. instance?: Mesh;
  119943. invertUV?: boolean;
  119944. uvs?: Vector2[];
  119945. colors?: Color4[];
  119946. }, scene?: Nullable<Scene>): Mesh;
  119947. }
  119948. }
  119949. declare module BABYLON {
  119950. /**
  119951. * Class containing static functions to help procedurally build meshes
  119952. */
  119953. export class ShapeBuilder {
  119954. /**
  119955. * 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.
  119956. * * 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.
  119957. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119958. * * 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.
  119959. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119960. * * 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
  119961. * * 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
  119962. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119967. * @param name defines the name of the mesh
  119968. * @param options defines the options used to create the mesh
  119969. * @param scene defines the hosting scene
  119970. * @returns the extruded shape mesh
  119971. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119973. */
  119974. static ExtrudeShape(name: string, options: {
  119975. shape: Vector3[];
  119976. path: Vector3[];
  119977. scale?: number;
  119978. rotation?: number;
  119979. cap?: number;
  119980. updatable?: boolean;
  119981. sideOrientation?: number;
  119982. frontUVs?: Vector4;
  119983. backUVs?: Vector4;
  119984. instance?: Mesh;
  119985. invertUV?: boolean;
  119986. }, scene?: Nullable<Scene>): Mesh;
  119987. /**
  119988. * Creates an custom extruded shape mesh.
  119989. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119990. * * 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.
  119991. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119992. * * 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
  119993. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119994. * * 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
  119995. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119996. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119997. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119998. * * 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
  119999. * * 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
  120000. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120005. * @param name defines the name of the mesh
  120006. * @param options defines the options used to create the mesh
  120007. * @param scene defines the hosting scene
  120008. * @returns the custom extruded shape mesh
  120009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120012. */
  120013. static ExtrudeShapeCustom(name: string, options: {
  120014. shape: Vector3[];
  120015. path: Vector3[];
  120016. scaleFunction?: any;
  120017. rotationFunction?: any;
  120018. ribbonCloseArray?: boolean;
  120019. ribbonClosePath?: boolean;
  120020. cap?: number;
  120021. updatable?: boolean;
  120022. sideOrientation?: number;
  120023. frontUVs?: Vector4;
  120024. backUVs?: Vector4;
  120025. instance?: Mesh;
  120026. invertUV?: boolean;
  120027. }, scene?: Nullable<Scene>): Mesh;
  120028. private static _ExtrudeShapeGeneric;
  120029. }
  120030. }
  120031. declare module BABYLON {
  120032. /**
  120033. * AmmoJS Physics plugin
  120034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120035. * @see https://github.com/kripken/ammo.js/
  120036. */
  120037. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120038. private _useDeltaForWorldStep;
  120039. /**
  120040. * Reference to the Ammo library
  120041. */
  120042. bjsAMMO: any;
  120043. /**
  120044. * Created ammoJS world which physics bodies are added to
  120045. */
  120046. world: any;
  120047. /**
  120048. * Name of the plugin
  120049. */
  120050. name: string;
  120051. private _timeStep;
  120052. private _fixedTimeStep;
  120053. private _maxSteps;
  120054. private _tmpQuaternion;
  120055. private _tmpAmmoTransform;
  120056. private _tmpAmmoQuaternion;
  120057. private _tmpAmmoConcreteContactResultCallback;
  120058. private _collisionConfiguration;
  120059. private _dispatcher;
  120060. private _overlappingPairCache;
  120061. private _solver;
  120062. private _softBodySolver;
  120063. private _tmpAmmoVectorA;
  120064. private _tmpAmmoVectorB;
  120065. private _tmpAmmoVectorC;
  120066. private _tmpAmmoVectorD;
  120067. private _tmpContactCallbackResult;
  120068. private _tmpAmmoVectorRCA;
  120069. private _tmpAmmoVectorRCB;
  120070. private _raycastResult;
  120071. private static readonly DISABLE_COLLISION_FLAG;
  120072. private static readonly KINEMATIC_FLAG;
  120073. private static readonly DISABLE_DEACTIVATION_FLAG;
  120074. /**
  120075. * Initializes the ammoJS plugin
  120076. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120077. * @param ammoInjection can be used to inject your own ammo reference
  120078. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120079. */
  120080. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120081. /**
  120082. * Sets the gravity of the physics world (m/(s^2))
  120083. * @param gravity Gravity to set
  120084. */
  120085. setGravity(gravity: Vector3): void;
  120086. /**
  120087. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120088. * @param timeStep timestep to use in seconds
  120089. */
  120090. setTimeStep(timeStep: number): void;
  120091. /**
  120092. * 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)
  120093. * @param fixedTimeStep fixedTimeStep to use in seconds
  120094. */
  120095. setFixedTimeStep(fixedTimeStep: number): void;
  120096. /**
  120097. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120098. * @param maxSteps the maximum number of steps by the physics engine per frame
  120099. */
  120100. setMaxSteps(maxSteps: number): void;
  120101. /**
  120102. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120103. * @returns the current timestep in seconds
  120104. */
  120105. getTimeStep(): number;
  120106. private _isImpostorInContact;
  120107. private _isImpostorPairInContact;
  120108. private _stepSimulation;
  120109. /**
  120110. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120111. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120112. * After the step the babylon meshes are set to the position of the physics imposters
  120113. * @param delta amount of time to step forward
  120114. * @param impostors array of imposters to update before/after the step
  120115. */
  120116. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120117. /**
  120118. * Update babylon mesh to match physics world object
  120119. * @param impostor imposter to match
  120120. */
  120121. private _afterSoftStep;
  120122. /**
  120123. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120124. * @param impostor imposter to match
  120125. */
  120126. private _ropeStep;
  120127. /**
  120128. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120129. * @param impostor imposter to match
  120130. */
  120131. private _softbodyOrClothStep;
  120132. private _tmpVector;
  120133. private _tmpMatrix;
  120134. /**
  120135. * Applies an impulse on the imposter
  120136. * @param impostor imposter to apply impulse to
  120137. * @param force amount of force to be applied to the imposter
  120138. * @param contactPoint the location to apply the impulse on the imposter
  120139. */
  120140. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120141. /**
  120142. * Applies a force on the imposter
  120143. * @param impostor imposter to apply force
  120144. * @param force amount of force to be applied to the imposter
  120145. * @param contactPoint the location to apply the force on the imposter
  120146. */
  120147. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120148. /**
  120149. * Creates a physics body using the plugin
  120150. * @param impostor the imposter to create the physics body on
  120151. */
  120152. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120153. /**
  120154. * Removes the physics body from the imposter and disposes of the body's memory
  120155. * @param impostor imposter to remove the physics body from
  120156. */
  120157. removePhysicsBody(impostor: PhysicsImpostor): void;
  120158. /**
  120159. * Generates a joint
  120160. * @param impostorJoint the imposter joint to create the joint with
  120161. */
  120162. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120163. /**
  120164. * Removes a joint
  120165. * @param impostorJoint the imposter joint to remove the joint from
  120166. */
  120167. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120168. private _addMeshVerts;
  120169. /**
  120170. * Initialise the soft body vertices to match its object's (mesh) vertices
  120171. * Softbody vertices (nodes) are in world space and to match this
  120172. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120173. * @param impostor to create the softbody for
  120174. */
  120175. private _softVertexData;
  120176. /**
  120177. * Create an impostor's soft body
  120178. * @param impostor to create the softbody for
  120179. */
  120180. private _createSoftbody;
  120181. /**
  120182. * Create cloth for an impostor
  120183. * @param impostor to create the softbody for
  120184. */
  120185. private _createCloth;
  120186. /**
  120187. * Create rope for an impostor
  120188. * @param impostor to create the softbody for
  120189. */
  120190. private _createRope;
  120191. private _addHullVerts;
  120192. private _createShape;
  120193. /**
  120194. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120195. * @param impostor imposter containing the physics body and babylon object
  120196. */
  120197. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120198. /**
  120199. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120200. * @param impostor imposter containing the physics body and babylon object
  120201. * @param newPosition new position
  120202. * @param newRotation new rotation
  120203. */
  120204. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120205. /**
  120206. * If this plugin is supported
  120207. * @returns true if its supported
  120208. */
  120209. isSupported(): boolean;
  120210. /**
  120211. * Sets the linear velocity of the physics body
  120212. * @param impostor imposter to set the velocity on
  120213. * @param velocity velocity to set
  120214. */
  120215. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120216. /**
  120217. * Sets the angular velocity of the physics body
  120218. * @param impostor imposter to set the velocity on
  120219. * @param velocity velocity to set
  120220. */
  120221. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120222. /**
  120223. * gets the linear velocity
  120224. * @param impostor imposter to get linear velocity from
  120225. * @returns linear velocity
  120226. */
  120227. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120228. /**
  120229. * gets the angular velocity
  120230. * @param impostor imposter to get angular velocity from
  120231. * @returns angular velocity
  120232. */
  120233. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120234. /**
  120235. * Sets the mass of physics body
  120236. * @param impostor imposter to set the mass on
  120237. * @param mass mass to set
  120238. */
  120239. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120240. /**
  120241. * Gets the mass of the physics body
  120242. * @param impostor imposter to get the mass from
  120243. * @returns mass
  120244. */
  120245. getBodyMass(impostor: PhysicsImpostor): number;
  120246. /**
  120247. * Gets friction of the impostor
  120248. * @param impostor impostor to get friction from
  120249. * @returns friction value
  120250. */
  120251. getBodyFriction(impostor: PhysicsImpostor): number;
  120252. /**
  120253. * Sets friction of the impostor
  120254. * @param impostor impostor to set friction on
  120255. * @param friction friction value
  120256. */
  120257. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120258. /**
  120259. * Gets restitution of the impostor
  120260. * @param impostor impostor to get restitution from
  120261. * @returns restitution value
  120262. */
  120263. getBodyRestitution(impostor: PhysicsImpostor): number;
  120264. /**
  120265. * Sets resitution of the impostor
  120266. * @param impostor impostor to set resitution on
  120267. * @param restitution resitution value
  120268. */
  120269. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120270. /**
  120271. * Gets pressure inside the impostor
  120272. * @param impostor impostor to get pressure from
  120273. * @returns pressure value
  120274. */
  120275. getBodyPressure(impostor: PhysicsImpostor): number;
  120276. /**
  120277. * Sets pressure inside a soft body impostor
  120278. * Cloth and rope must remain 0 pressure
  120279. * @param impostor impostor to set pressure on
  120280. * @param pressure pressure value
  120281. */
  120282. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120283. /**
  120284. * Gets stiffness of the impostor
  120285. * @param impostor impostor to get stiffness from
  120286. * @returns pressure value
  120287. */
  120288. getBodyStiffness(impostor: PhysicsImpostor): number;
  120289. /**
  120290. * Sets stiffness of the impostor
  120291. * @param impostor impostor to set stiffness on
  120292. * @param stiffness stiffness value from 0 to 1
  120293. */
  120294. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120295. /**
  120296. * Gets velocityIterations of the impostor
  120297. * @param impostor impostor to get velocity iterations from
  120298. * @returns velocityIterations value
  120299. */
  120300. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120301. /**
  120302. * Sets velocityIterations of the impostor
  120303. * @param impostor impostor to set velocity iterations on
  120304. * @param velocityIterations velocityIterations value
  120305. */
  120306. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120307. /**
  120308. * Gets positionIterations of the impostor
  120309. * @param impostor impostor to get position iterations from
  120310. * @returns positionIterations value
  120311. */
  120312. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120313. /**
  120314. * Sets positionIterations of the impostor
  120315. * @param impostor impostor to set position on
  120316. * @param positionIterations positionIterations value
  120317. */
  120318. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120319. /**
  120320. * Append an anchor to a cloth object
  120321. * @param impostor is the cloth impostor to add anchor to
  120322. * @param otherImpostor is the rigid impostor to anchor to
  120323. * @param width ratio across width from 0 to 1
  120324. * @param height ratio up height from 0 to 1
  120325. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120326. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120327. */
  120328. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120329. /**
  120330. * Append an hook to a rope object
  120331. * @param impostor is the rope impostor to add hook to
  120332. * @param otherImpostor is the rigid impostor to hook to
  120333. * @param length ratio along the rope from 0 to 1
  120334. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120335. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120336. */
  120337. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120338. /**
  120339. * Sleeps the physics body and stops it from being active
  120340. * @param impostor impostor to sleep
  120341. */
  120342. sleepBody(impostor: PhysicsImpostor): void;
  120343. /**
  120344. * Activates the physics body
  120345. * @param impostor impostor to activate
  120346. */
  120347. wakeUpBody(impostor: PhysicsImpostor): void;
  120348. /**
  120349. * Updates the distance parameters of the joint
  120350. * @param joint joint to update
  120351. * @param maxDistance maximum distance of the joint
  120352. * @param minDistance minimum distance of the joint
  120353. */
  120354. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120355. /**
  120356. * Sets a motor on the joint
  120357. * @param joint joint to set motor on
  120358. * @param speed speed of the motor
  120359. * @param maxForce maximum force of the motor
  120360. * @param motorIndex index of the motor
  120361. */
  120362. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120363. /**
  120364. * Sets the motors limit
  120365. * @param joint joint to set limit on
  120366. * @param upperLimit upper limit
  120367. * @param lowerLimit lower limit
  120368. */
  120369. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120370. /**
  120371. * Syncs the position and rotation of a mesh with the impostor
  120372. * @param mesh mesh to sync
  120373. * @param impostor impostor to update the mesh with
  120374. */
  120375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120376. /**
  120377. * Gets the radius of the impostor
  120378. * @param impostor impostor to get radius from
  120379. * @returns the radius
  120380. */
  120381. getRadius(impostor: PhysicsImpostor): number;
  120382. /**
  120383. * Gets the box size of the impostor
  120384. * @param impostor impostor to get box size from
  120385. * @param result the resulting box size
  120386. */
  120387. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120388. /**
  120389. * Disposes of the impostor
  120390. */
  120391. dispose(): void;
  120392. /**
  120393. * Does a raycast in the physics world
  120394. * @param from when should the ray start?
  120395. * @param to when should the ray end?
  120396. * @returns PhysicsRaycastResult
  120397. */
  120398. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120399. }
  120400. }
  120401. declare module BABYLON {
  120402. interface AbstractScene {
  120403. /**
  120404. * The list of reflection probes added to the scene
  120405. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120406. */
  120407. reflectionProbes: Array<ReflectionProbe>;
  120408. /**
  120409. * Removes the given reflection probe from this scene.
  120410. * @param toRemove The reflection probe to remove
  120411. * @returns The index of the removed reflection probe
  120412. */
  120413. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120414. /**
  120415. * Adds the given reflection probe to this scene.
  120416. * @param newReflectionProbe The reflection probe to add
  120417. */
  120418. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120419. }
  120420. /**
  120421. * Class used to generate realtime reflection / refraction cube textures
  120422. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120423. */
  120424. export class ReflectionProbe {
  120425. /** defines the name of the probe */
  120426. name: string;
  120427. private _scene;
  120428. private _renderTargetTexture;
  120429. private _projectionMatrix;
  120430. private _viewMatrix;
  120431. private _target;
  120432. private _add;
  120433. private _attachedMesh;
  120434. private _invertYAxis;
  120435. /** Gets or sets probe position (center of the cube map) */
  120436. position: Vector3;
  120437. /**
  120438. * Creates a new reflection probe
  120439. * @param name defines the name of the probe
  120440. * @param size defines the texture resolution (for each face)
  120441. * @param scene defines the hosting scene
  120442. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120443. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120444. */
  120445. constructor(
  120446. /** defines the name of the probe */
  120447. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120448. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120449. samples: number;
  120450. /** Gets or sets the refresh rate to use (on every frame by default) */
  120451. refreshRate: number;
  120452. /**
  120453. * Gets the hosting scene
  120454. * @returns a Scene
  120455. */
  120456. getScene(): Scene;
  120457. /** Gets the internal CubeTexture used to render to */
  120458. readonly cubeTexture: RenderTargetTexture;
  120459. /** Gets the list of meshes to render */
  120460. readonly renderList: Nullable<AbstractMesh[]>;
  120461. /**
  120462. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120463. * @param mesh defines the mesh to attach to
  120464. */
  120465. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120466. /**
  120467. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120468. * @param renderingGroupId The rendering group id corresponding to its index
  120469. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120470. */
  120471. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120472. /**
  120473. * Clean all associated resources
  120474. */
  120475. dispose(): void;
  120476. /**
  120477. * Converts the reflection probe information to a readable string for debug purpose.
  120478. * @param fullDetails Supports for multiple levels of logging within scene loading
  120479. * @returns the human readable reflection probe info
  120480. */
  120481. toString(fullDetails?: boolean): string;
  120482. /**
  120483. * Get the class name of the relfection probe.
  120484. * @returns "ReflectionProbe"
  120485. */
  120486. getClassName(): string;
  120487. /**
  120488. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120489. * @returns The JSON representation of the texture
  120490. */
  120491. serialize(): any;
  120492. /**
  120493. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120494. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120495. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120496. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120497. * @returns The parsed reflection probe if successful
  120498. */
  120499. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120500. }
  120501. }
  120502. declare module BABYLON {
  120503. /** @hidden */
  120504. export var _BabylonLoaderRegistered: boolean;
  120505. /**
  120506. * Helps setting up some configuration for the babylon file loader.
  120507. */
  120508. export class BabylonFileLoaderConfiguration {
  120509. /**
  120510. * The loader does not allow injecting custom physix engine into the plugins.
  120511. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120512. * So you could set this variable to your engine import to make it work.
  120513. */
  120514. static LoaderInjectedPhysicsEngine: any;
  120515. }
  120516. }
  120517. declare module BABYLON {
  120518. /**
  120519. * The Physically based simple base material of BJS.
  120520. *
  120521. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120522. * It is used as the base class for both the specGloss and metalRough conventions.
  120523. */
  120524. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120525. /**
  120526. * Number of Simultaneous lights allowed on the material.
  120527. */
  120528. maxSimultaneousLights: number;
  120529. /**
  120530. * If sets to true, disables all the lights affecting the material.
  120531. */
  120532. disableLighting: boolean;
  120533. /**
  120534. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120535. */
  120536. environmentTexture: BaseTexture;
  120537. /**
  120538. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120539. */
  120540. invertNormalMapX: boolean;
  120541. /**
  120542. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120543. */
  120544. invertNormalMapY: boolean;
  120545. /**
  120546. * Normal map used in the model.
  120547. */
  120548. normalTexture: BaseTexture;
  120549. /**
  120550. * Emissivie color used to self-illuminate the model.
  120551. */
  120552. emissiveColor: Color3;
  120553. /**
  120554. * Emissivie texture used to self-illuminate the model.
  120555. */
  120556. emissiveTexture: BaseTexture;
  120557. /**
  120558. * Occlusion Channel Strenght.
  120559. */
  120560. occlusionStrength: number;
  120561. /**
  120562. * Occlusion Texture of the material (adding extra occlusion effects).
  120563. */
  120564. occlusionTexture: BaseTexture;
  120565. /**
  120566. * Defines the alpha limits in alpha test mode.
  120567. */
  120568. alphaCutOff: number;
  120569. /**
  120570. * Gets the current double sided mode.
  120571. */
  120572. /**
  120573. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120574. */
  120575. doubleSided: boolean;
  120576. /**
  120577. * Stores the pre-calculated light information of a mesh in a texture.
  120578. */
  120579. lightmapTexture: BaseTexture;
  120580. /**
  120581. * If true, the light map contains occlusion information instead of lighting info.
  120582. */
  120583. useLightmapAsShadowmap: boolean;
  120584. /**
  120585. * Instantiates a new PBRMaterial instance.
  120586. *
  120587. * @param name The material name
  120588. * @param scene The scene the material will be use in.
  120589. */
  120590. constructor(name: string, scene: Scene);
  120591. getClassName(): string;
  120592. }
  120593. }
  120594. declare module BABYLON {
  120595. /**
  120596. * The PBR material of BJS following the metal roughness convention.
  120597. *
  120598. * This fits to the PBR convention in the GLTF definition:
  120599. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120600. */
  120601. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120602. /**
  120603. * The base color has two different interpretations depending on the value of metalness.
  120604. * When the material is a metal, the base color is the specific measured reflectance value
  120605. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120606. * of the material.
  120607. */
  120608. baseColor: Color3;
  120609. /**
  120610. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120611. * well as opacity information in the alpha channel.
  120612. */
  120613. baseTexture: BaseTexture;
  120614. /**
  120615. * Specifies the metallic scalar value of the material.
  120616. * Can also be used to scale the metalness values of the metallic texture.
  120617. */
  120618. metallic: number;
  120619. /**
  120620. * Specifies the roughness scalar value of the material.
  120621. * Can also be used to scale the roughness values of the metallic texture.
  120622. */
  120623. roughness: number;
  120624. /**
  120625. * Texture containing both the metallic value in the B channel and the
  120626. * roughness value in the G channel to keep better precision.
  120627. */
  120628. metallicRoughnessTexture: BaseTexture;
  120629. /**
  120630. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120631. *
  120632. * @param name The material name
  120633. * @param scene The scene the material will be use in.
  120634. */
  120635. constructor(name: string, scene: Scene);
  120636. /**
  120637. * Return the currrent class name of the material.
  120638. */
  120639. getClassName(): string;
  120640. /**
  120641. * Makes a duplicate of the current material.
  120642. * @param name - name to use for the new material.
  120643. */
  120644. clone(name: string): PBRMetallicRoughnessMaterial;
  120645. /**
  120646. * Serialize the material to a parsable JSON object.
  120647. */
  120648. serialize(): any;
  120649. /**
  120650. * Parses a JSON object correponding to the serialize function.
  120651. */
  120652. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  120653. }
  120654. }
  120655. declare module BABYLON {
  120656. /**
  120657. * The PBR material of BJS following the specular glossiness convention.
  120658. *
  120659. * This fits to the PBR convention in the GLTF definition:
  120660. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  120661. */
  120662. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  120663. /**
  120664. * Specifies the diffuse color of the material.
  120665. */
  120666. diffuseColor: Color3;
  120667. /**
  120668. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  120669. * channel.
  120670. */
  120671. diffuseTexture: BaseTexture;
  120672. /**
  120673. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  120674. */
  120675. specularColor: Color3;
  120676. /**
  120677. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  120678. */
  120679. glossiness: number;
  120680. /**
  120681. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  120682. */
  120683. specularGlossinessTexture: BaseTexture;
  120684. /**
  120685. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  120686. *
  120687. * @param name The material name
  120688. * @param scene The scene the material will be use in.
  120689. */
  120690. constructor(name: string, scene: Scene);
  120691. /**
  120692. * Return the currrent class name of the material.
  120693. */
  120694. getClassName(): string;
  120695. /**
  120696. * Makes a duplicate of the current material.
  120697. * @param name - name to use for the new material.
  120698. */
  120699. clone(name: string): PBRSpecularGlossinessMaterial;
  120700. /**
  120701. * Serialize the material to a parsable JSON object.
  120702. */
  120703. serialize(): any;
  120704. /**
  120705. * Parses a JSON object correponding to the serialize function.
  120706. */
  120707. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  120708. }
  120709. }
  120710. declare module BABYLON {
  120711. /**
  120712. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  120713. * It can help converting any input color in a desired output one. This can then be used to create effects
  120714. * from sepia, black and white to sixties or futuristic rendering...
  120715. *
  120716. * The only supported format is currently 3dl.
  120717. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  120718. */
  120719. export class ColorGradingTexture extends BaseTexture {
  120720. /**
  120721. * The current texture matrix. (will always be identity in color grading texture)
  120722. */
  120723. private _textureMatrix;
  120724. /**
  120725. * The texture URL.
  120726. */
  120727. url: string;
  120728. /**
  120729. * Empty line regex stored for GC.
  120730. */
  120731. private static _noneEmptyLineRegex;
  120732. private _engine;
  120733. /**
  120734. * Instantiates a ColorGradingTexture from the following parameters.
  120735. *
  120736. * @param url The location of the color gradind data (currently only supporting 3dl)
  120737. * @param scene The scene the texture will be used in
  120738. */
  120739. constructor(url: string, scene: Scene);
  120740. /**
  120741. * Returns the texture matrix used in most of the material.
  120742. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  120743. */
  120744. getTextureMatrix(): Matrix;
  120745. /**
  120746. * Occurs when the file being loaded is a .3dl LUT file.
  120747. */
  120748. private load3dlTexture;
  120749. /**
  120750. * Starts the loading process of the texture.
  120751. */
  120752. private loadTexture;
  120753. /**
  120754. * Clones the color gradind texture.
  120755. */
  120756. clone(): ColorGradingTexture;
  120757. /**
  120758. * Called during delayed load for textures.
  120759. */
  120760. delayLoad(): void;
  120761. /**
  120762. * Parses a color grading texture serialized by Babylon.
  120763. * @param parsedTexture The texture information being parsedTexture
  120764. * @param scene The scene to load the texture in
  120765. * @param rootUrl The root url of the data assets to load
  120766. * @return A color gradind texture
  120767. */
  120768. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  120769. /**
  120770. * Serializes the LUT texture to json format.
  120771. */
  120772. serialize(): any;
  120773. }
  120774. }
  120775. declare module BABYLON {
  120776. /**
  120777. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  120778. */
  120779. export class EquiRectangularCubeTexture extends BaseTexture {
  120780. /** The six faces of the cube. */
  120781. private static _FacesMapping;
  120782. private _noMipmap;
  120783. private _onLoad;
  120784. private _onError;
  120785. /** The size of the cubemap. */
  120786. private _size;
  120787. /** The buffer of the image. */
  120788. private _buffer;
  120789. /** The width of the input image. */
  120790. private _width;
  120791. /** The height of the input image. */
  120792. private _height;
  120793. /** The URL to the image. */
  120794. url: string;
  120795. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  120796. coordinatesMode: number;
  120797. /**
  120798. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  120799. * @param url The location of the image
  120800. * @param scene The scene the texture will be used in
  120801. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120802. * @param noMipmap Forces to not generate the mipmap if true
  120803. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120804. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120805. * @param onLoad — defines a callback called when texture is loaded
  120806. * @param onError — defines a callback called if there is an error
  120807. */
  120808. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  120809. /**
  120810. * Load the image data, by putting the image on a canvas and extracting its buffer.
  120811. */
  120812. private loadImage;
  120813. /**
  120814. * Convert the image buffer into a cubemap and create a CubeTexture.
  120815. */
  120816. private loadTexture;
  120817. /**
  120818. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  120819. * @param buffer The ArrayBuffer that should be converted.
  120820. * @returns The buffer as Float32Array.
  120821. */
  120822. private getFloat32ArrayFromArrayBuffer;
  120823. /**
  120824. * Get the current class name of the texture useful for serialization or dynamic coding.
  120825. * @returns "EquiRectangularCubeTexture"
  120826. */
  120827. getClassName(): string;
  120828. /**
  120829. * Create a clone of the current EquiRectangularCubeTexture and return it.
  120830. * @returns A clone of the current EquiRectangularCubeTexture.
  120831. */
  120832. clone(): EquiRectangularCubeTexture;
  120833. }
  120834. }
  120835. declare module BABYLON {
  120836. /**
  120837. * Based on jsTGALoader - Javascript loader for TGA file
  120838. * By Vincent Thibault
  120839. * @see http://blog.robrowser.com/javascript-tga-loader.html
  120840. */
  120841. export class TGATools {
  120842. private static _TYPE_INDEXED;
  120843. private static _TYPE_RGB;
  120844. private static _TYPE_GREY;
  120845. private static _TYPE_RLE_INDEXED;
  120846. private static _TYPE_RLE_RGB;
  120847. private static _TYPE_RLE_GREY;
  120848. private static _ORIGIN_MASK;
  120849. private static _ORIGIN_SHIFT;
  120850. private static _ORIGIN_BL;
  120851. private static _ORIGIN_BR;
  120852. private static _ORIGIN_UL;
  120853. private static _ORIGIN_UR;
  120854. /**
  120855. * Gets the header of a TGA file
  120856. * @param data defines the TGA data
  120857. * @returns the header
  120858. */
  120859. static GetTGAHeader(data: Uint8Array): any;
  120860. /**
  120861. * Uploads TGA content to a Babylon Texture
  120862. * @hidden
  120863. */
  120864. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  120865. /** @hidden */
  120866. 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;
  120867. /** @hidden */
  120868. 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;
  120869. /** @hidden */
  120870. 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;
  120871. /** @hidden */
  120872. 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;
  120873. /** @hidden */
  120874. 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;
  120875. /** @hidden */
  120876. 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;
  120877. }
  120878. }
  120879. declare module BABYLON {
  120880. /**
  120881. * Implementation of the TGA Texture Loader.
  120882. * @hidden
  120883. */
  120884. export class _TGATextureLoader implements IInternalTextureLoader {
  120885. /**
  120886. * Defines wether the loader supports cascade loading the different faces.
  120887. */
  120888. readonly supportCascades: boolean;
  120889. /**
  120890. * This returns if the loader support the current file information.
  120891. * @param extension defines the file extension of the file being loaded
  120892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120893. * @param fallback defines the fallback internal texture if any
  120894. * @param isBase64 defines whether the texture is encoded as a base64
  120895. * @param isBuffer defines whether the texture data are stored as a buffer
  120896. * @returns true if the loader can load the specified file
  120897. */
  120898. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120899. /**
  120900. * Transform the url before loading if required.
  120901. * @param rootUrl the url of the texture
  120902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120903. * @returns the transformed texture
  120904. */
  120905. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120906. /**
  120907. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120908. * @param rootUrl the url of the texture
  120909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120910. * @returns the fallback texture
  120911. */
  120912. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120913. /**
  120914. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120915. * @param data contains the texture data
  120916. * @param texture defines the BabylonJS internal texture
  120917. * @param createPolynomials will be true if polynomials have been requested
  120918. * @param onLoad defines the callback to trigger once the texture is ready
  120919. * @param onError defines the callback to trigger in case of error
  120920. */
  120921. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120922. /**
  120923. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120924. * @param data contains the texture data
  120925. * @param texture defines the BabylonJS internal texture
  120926. * @param callback defines the method to call once ready to upload
  120927. */
  120928. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120929. }
  120930. }
  120931. declare module BABYLON {
  120932. /**
  120933. * Info about the .basis files
  120934. */
  120935. class BasisFileInfo {
  120936. /**
  120937. * If the file has alpha
  120938. */
  120939. hasAlpha: boolean;
  120940. /**
  120941. * Info about each image of the basis file
  120942. */
  120943. images: Array<{
  120944. levels: Array<{
  120945. width: number;
  120946. height: number;
  120947. transcodedPixels: ArrayBufferView;
  120948. }>;
  120949. }>;
  120950. }
  120951. /**
  120952. * Result of transcoding a basis file
  120953. */
  120954. class TranscodeResult {
  120955. /**
  120956. * Info about the .basis file
  120957. */
  120958. fileInfo: BasisFileInfo;
  120959. /**
  120960. * Format to use when loading the file
  120961. */
  120962. format: number;
  120963. }
  120964. /**
  120965. * Configuration options for the Basis transcoder
  120966. */
  120967. export class BasisTranscodeConfiguration {
  120968. /**
  120969. * Supported compression formats used to determine the supported output format of the transcoder
  120970. */
  120971. supportedCompressionFormats?: {
  120972. /**
  120973. * etc1 compression format
  120974. */
  120975. etc1?: boolean;
  120976. /**
  120977. * s3tc compression format
  120978. */
  120979. s3tc?: boolean;
  120980. /**
  120981. * pvrtc compression format
  120982. */
  120983. pvrtc?: boolean;
  120984. /**
  120985. * etc2 compression format
  120986. */
  120987. etc2?: boolean;
  120988. };
  120989. /**
  120990. * If mipmap levels should be loaded for transcoded images (Default: true)
  120991. */
  120992. loadMipmapLevels?: boolean;
  120993. /**
  120994. * Index of a single image to load (Default: all images)
  120995. */
  120996. loadSingleImage?: number;
  120997. }
  120998. /**
  120999. * Used to load .Basis files
  121000. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121001. */
  121002. export class BasisTools {
  121003. private static _IgnoreSupportedFormats;
  121004. /**
  121005. * URL to use when loading the basis transcoder
  121006. */
  121007. static JSModuleURL: string;
  121008. /**
  121009. * URL to use when loading the wasm module for the transcoder
  121010. */
  121011. static WasmModuleURL: string;
  121012. /**
  121013. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121014. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121015. * @returns internal format corresponding to the Basis format
  121016. */
  121017. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121018. private static _WorkerPromise;
  121019. private static _Worker;
  121020. private static _actionId;
  121021. private static _CreateWorkerAsync;
  121022. /**
  121023. * Transcodes a loaded image file to compressed pixel data
  121024. * @param imageData image data to transcode
  121025. * @param config configuration options for the transcoding
  121026. * @returns a promise resulting in the transcoded image
  121027. */
  121028. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121029. /**
  121030. * Loads a texture from the transcode result
  121031. * @param texture texture load to
  121032. * @param transcodeResult the result of transcoding the basis file to load from
  121033. */
  121034. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121035. }
  121036. }
  121037. declare module BABYLON {
  121038. /**
  121039. * Loader for .basis file format
  121040. */
  121041. export class _BasisTextureLoader implements IInternalTextureLoader {
  121042. /**
  121043. * Defines whether the loader supports cascade loading the different faces.
  121044. */
  121045. readonly supportCascades: boolean;
  121046. /**
  121047. * This returns if the loader support the current file information.
  121048. * @param extension defines the file extension of the file being loaded
  121049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121050. * @param fallback defines the fallback internal texture if any
  121051. * @param isBase64 defines whether the texture is encoded as a base64
  121052. * @param isBuffer defines whether the texture data are stored as a buffer
  121053. * @returns true if the loader can load the specified file
  121054. */
  121055. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121056. /**
  121057. * Transform the url before loading if required.
  121058. * @param rootUrl the url of the texture
  121059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121060. * @returns the transformed texture
  121061. */
  121062. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121063. /**
  121064. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121065. * @param rootUrl the url of the texture
  121066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121067. * @returns the fallback texture
  121068. */
  121069. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121070. /**
  121071. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121072. * @param data contains the texture data
  121073. * @param texture defines the BabylonJS internal texture
  121074. * @param createPolynomials will be true if polynomials have been requested
  121075. * @param onLoad defines the callback to trigger once the texture is ready
  121076. * @param onError defines the callback to trigger in case of error
  121077. */
  121078. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121079. /**
  121080. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121081. * @param data contains the texture data
  121082. * @param texture defines the BabylonJS internal texture
  121083. * @param callback defines the method to call once ready to upload
  121084. */
  121085. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121086. }
  121087. }
  121088. declare module BABYLON {
  121089. /**
  121090. * 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.
  121091. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121092. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121093. */
  121094. export class CustomProceduralTexture extends ProceduralTexture {
  121095. private _animate;
  121096. private _time;
  121097. private _config;
  121098. private _texturePath;
  121099. /**
  121100. * Instantiates a new Custom Procedural Texture.
  121101. * 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.
  121102. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121104. * @param name Define the name of the texture
  121105. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121106. * @param size Define the size of the texture to create
  121107. * @param scene Define the scene the texture belongs to
  121108. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121109. * @param generateMipMaps Define if the texture should creates mip maps or not
  121110. */
  121111. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121112. private _loadJson;
  121113. /**
  121114. * Is the texture ready to be used ? (rendered at least once)
  121115. * @returns true if ready, otherwise, false.
  121116. */
  121117. isReady(): boolean;
  121118. /**
  121119. * Render the texture to its associated render target.
  121120. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121121. */
  121122. render(useCameraPostProcess?: boolean): void;
  121123. /**
  121124. * Update the list of dependant textures samplers in the shader.
  121125. */
  121126. updateTextures(): void;
  121127. /**
  121128. * Update the uniform values of the procedural texture in the shader.
  121129. */
  121130. updateShaderUniforms(): void;
  121131. /**
  121132. * Define if the texture animates or not.
  121133. */
  121134. animate: boolean;
  121135. }
  121136. }
  121137. declare module BABYLON {
  121138. /** @hidden */
  121139. export var noisePixelShader: {
  121140. name: string;
  121141. shader: string;
  121142. };
  121143. }
  121144. declare module BABYLON {
  121145. /**
  121146. * Class used to generate noise procedural textures
  121147. */
  121148. export class NoiseProceduralTexture extends ProceduralTexture {
  121149. private _time;
  121150. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121151. brightness: number;
  121152. /** Defines the number of octaves to process */
  121153. octaves: number;
  121154. /** Defines the level of persistence (0.8 by default) */
  121155. persistence: number;
  121156. /** Gets or sets animation speed factor (default is 1) */
  121157. animationSpeedFactor: number;
  121158. /**
  121159. * Creates a new NoiseProceduralTexture
  121160. * @param name defines the name fo the texture
  121161. * @param size defines the size of the texture (default is 256)
  121162. * @param scene defines the hosting scene
  121163. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121164. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121165. */
  121166. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121167. private _updateShaderUniforms;
  121168. protected _getDefines(): string;
  121169. /** Generate the current state of the procedural texture */
  121170. render(useCameraPostProcess?: boolean): void;
  121171. /**
  121172. * Serializes this noise procedural texture
  121173. * @returns a serialized noise procedural texture object
  121174. */
  121175. serialize(): any;
  121176. /**
  121177. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121178. * @param parsedTexture defines parsed texture data
  121179. * @param scene defines the current scene
  121180. * @param rootUrl defines the root URL containing noise procedural texture information
  121181. * @returns a parsed NoiseProceduralTexture
  121182. */
  121183. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121184. }
  121185. }
  121186. declare module BABYLON {
  121187. /**
  121188. * Raw cube texture where the raw buffers are passed in
  121189. */
  121190. export class RawCubeTexture extends CubeTexture {
  121191. /**
  121192. * Creates a cube texture where the raw buffers are passed in.
  121193. * @param scene defines the scene the texture is attached to
  121194. * @param data defines the array of data to use to create each face
  121195. * @param size defines the size of the textures
  121196. * @param format defines the format of the data
  121197. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121198. * @param generateMipMaps defines if the engine should generate the mip levels
  121199. * @param invertY defines if data must be stored with Y axis inverted
  121200. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121201. * @param compression defines the compression used (null by default)
  121202. */
  121203. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121204. /**
  121205. * Updates the raw cube texture.
  121206. * @param data defines the data to store
  121207. * @param format defines the data format
  121208. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121209. * @param invertY defines if data must be stored with Y axis inverted
  121210. * @param compression defines the compression used (null by default)
  121211. * @param level defines which level of the texture to update
  121212. */
  121213. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121214. /**
  121215. * Updates a raw cube texture with RGBD encoded data.
  121216. * @param data defines the array of data [mipmap][face] to use to create each face
  121217. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121218. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121219. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121220. * @returns a promsie that resolves when the operation is complete
  121221. */
  121222. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121223. /**
  121224. * Clones the raw cube texture.
  121225. * @return a new cube texture
  121226. */
  121227. clone(): CubeTexture;
  121228. /** @hidden */
  121229. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121230. }
  121231. }
  121232. declare module BABYLON {
  121233. /**
  121234. * Class used to store 3D textures containing user data
  121235. */
  121236. export class RawTexture3D extends Texture {
  121237. /** Gets or sets the texture format to use */
  121238. format: number;
  121239. private _engine;
  121240. /**
  121241. * Create a new RawTexture3D
  121242. * @param data defines the data of the texture
  121243. * @param width defines the width of the texture
  121244. * @param height defines the height of the texture
  121245. * @param depth defines the depth of the texture
  121246. * @param format defines the texture format to use
  121247. * @param scene defines the hosting scene
  121248. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121249. * @param invertY defines if texture must be stored with Y axis inverted
  121250. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121251. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121252. */
  121253. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121254. /** Gets or sets the texture format to use */
  121255. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121256. /**
  121257. * Update the texture with new data
  121258. * @param data defines the data to store in the texture
  121259. */
  121260. update(data: ArrayBufferView): void;
  121261. }
  121262. }
  121263. declare module BABYLON {
  121264. /**
  121265. * Class used to store 2D array textures containing user data
  121266. */
  121267. export class RawTexture2DArray extends Texture {
  121268. /** Gets or sets the texture format to use */
  121269. format: number;
  121270. private _engine;
  121271. /**
  121272. * Create a new RawTexture2DArray
  121273. * @param data defines the data of the texture
  121274. * @param width defines the width of the texture
  121275. * @param height defines the height of the texture
  121276. * @param depth defines the number of layers of the texture
  121277. * @param format defines the texture format to use
  121278. * @param scene defines the hosting scene
  121279. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121280. * @param invertY defines if texture must be stored with Y axis inverted
  121281. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121282. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121283. */
  121284. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121285. /** Gets or sets the texture format to use */
  121286. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121287. /**
  121288. * Update the texture with new data
  121289. * @param data defines the data to store in the texture
  121290. */
  121291. update(data: ArrayBufferView): void;
  121292. }
  121293. }
  121294. declare module BABYLON {
  121295. /**
  121296. * Creates a refraction texture used by refraction channel of the standard material.
  121297. * It is like a mirror but to see through a material.
  121298. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121299. */
  121300. export class RefractionTexture extends RenderTargetTexture {
  121301. /**
  121302. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121303. * 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.
  121304. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121305. */
  121306. refractionPlane: Plane;
  121307. /**
  121308. * Define how deep under the surface we should see.
  121309. */
  121310. depth: number;
  121311. /**
  121312. * Creates a refraction texture used by refraction channel of the standard material.
  121313. * It is like a mirror but to see through a material.
  121314. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121315. * @param name Define the texture name
  121316. * @param size Define the size of the underlying texture
  121317. * @param scene Define the scene the refraction belongs to
  121318. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121319. */
  121320. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121321. /**
  121322. * Clone the refraction texture.
  121323. * @returns the cloned texture
  121324. */
  121325. clone(): RefractionTexture;
  121326. /**
  121327. * Serialize the texture to a JSON representation you could use in Parse later on
  121328. * @returns the serialized JSON representation
  121329. */
  121330. serialize(): any;
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Defines the options related to the creation of an HtmlElementTexture
  121336. */
  121337. export interface IHtmlElementTextureOptions {
  121338. /**
  121339. * Defines wether mip maps should be created or not.
  121340. */
  121341. generateMipMaps?: boolean;
  121342. /**
  121343. * Defines the sampling mode of the texture.
  121344. */
  121345. samplingMode?: number;
  121346. /**
  121347. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121348. */
  121349. engine: Nullable<ThinEngine>;
  121350. /**
  121351. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121352. */
  121353. scene: Nullable<Scene>;
  121354. }
  121355. /**
  121356. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121357. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121358. * is automatically managed.
  121359. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121360. * in your application.
  121361. *
  121362. * As the update is not automatic, you need to call them manually.
  121363. */
  121364. export class HtmlElementTexture extends BaseTexture {
  121365. /**
  121366. * The texture URL.
  121367. */
  121368. element: HTMLVideoElement | HTMLCanvasElement;
  121369. private static readonly DefaultOptions;
  121370. private _textureMatrix;
  121371. private _engine;
  121372. private _isVideo;
  121373. private _generateMipMaps;
  121374. private _samplingMode;
  121375. /**
  121376. * Instantiates a HtmlElementTexture from the following parameters.
  121377. *
  121378. * @param name Defines the name of the texture
  121379. * @param element Defines the video or canvas the texture is filled with
  121380. * @param options Defines the other none mandatory texture creation options
  121381. */
  121382. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121383. private _createInternalTexture;
  121384. /**
  121385. * Returns the texture matrix used in most of the material.
  121386. */
  121387. getTextureMatrix(): Matrix;
  121388. /**
  121389. * Updates the content of the texture.
  121390. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121391. */
  121392. update(invertY?: Nullable<boolean>): void;
  121393. }
  121394. }
  121395. declare module BABYLON {
  121396. /**
  121397. * Enum used to define the target of a block
  121398. */
  121399. export enum NodeMaterialBlockTargets {
  121400. /** Vertex shader */
  121401. Vertex = 1,
  121402. /** Fragment shader */
  121403. Fragment = 2,
  121404. /** Neutral */
  121405. Neutral = 4,
  121406. /** Vertex and Fragment */
  121407. VertexAndFragment = 3
  121408. }
  121409. }
  121410. declare module BABYLON {
  121411. /**
  121412. * Defines the kind of connection point for node based material
  121413. */
  121414. export enum NodeMaterialBlockConnectionPointTypes {
  121415. /** Float */
  121416. Float = 1,
  121417. /** Int */
  121418. Int = 2,
  121419. /** Vector2 */
  121420. Vector2 = 4,
  121421. /** Vector3 */
  121422. Vector3 = 8,
  121423. /** Vector4 */
  121424. Vector4 = 16,
  121425. /** Color3 */
  121426. Color3 = 32,
  121427. /** Color4 */
  121428. Color4 = 64,
  121429. /** Matrix */
  121430. Matrix = 128,
  121431. /** Detect type based on connection */
  121432. AutoDetect = 1024,
  121433. /** Output type that will be defined by input type */
  121434. BasedOnInput = 2048
  121435. }
  121436. }
  121437. declare module BABYLON {
  121438. /**
  121439. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121440. */
  121441. export enum NodeMaterialBlockConnectionPointMode {
  121442. /** Value is an uniform */
  121443. Uniform = 0,
  121444. /** Value is a mesh attribute */
  121445. Attribute = 1,
  121446. /** Value is a varying between vertex and fragment shaders */
  121447. Varying = 2,
  121448. /** Mode is undefined */
  121449. Undefined = 3
  121450. }
  121451. }
  121452. declare module BABYLON {
  121453. /**
  121454. * Enum used to define system values e.g. values automatically provided by the system
  121455. */
  121456. export enum NodeMaterialSystemValues {
  121457. /** World */
  121458. World = 1,
  121459. /** View */
  121460. View = 2,
  121461. /** Projection */
  121462. Projection = 3,
  121463. /** ViewProjection */
  121464. ViewProjection = 4,
  121465. /** WorldView */
  121466. WorldView = 5,
  121467. /** WorldViewProjection */
  121468. WorldViewProjection = 6,
  121469. /** CameraPosition */
  121470. CameraPosition = 7,
  121471. /** Fog Color */
  121472. FogColor = 8,
  121473. /** Delta time */
  121474. DeltaTime = 9
  121475. }
  121476. }
  121477. declare module BABYLON {
  121478. /**
  121479. * Root class for all node material optimizers
  121480. */
  121481. export class NodeMaterialOptimizer {
  121482. /**
  121483. * Function used to optimize a NodeMaterial graph
  121484. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121485. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121486. */
  121487. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121488. }
  121489. }
  121490. declare module BABYLON {
  121491. /**
  121492. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121493. */
  121494. export class TransformBlock extends NodeMaterialBlock {
  121495. /**
  121496. * Defines the value to use to complement W value to transform it to a Vector4
  121497. */
  121498. complementW: number;
  121499. /**
  121500. * Defines the value to use to complement z value to transform it to a Vector4
  121501. */
  121502. complementZ: number;
  121503. /**
  121504. * Creates a new TransformBlock
  121505. * @param name defines the block name
  121506. */
  121507. constructor(name: string);
  121508. /**
  121509. * Gets the current class name
  121510. * @returns the class name
  121511. */
  121512. getClassName(): string;
  121513. /**
  121514. * Gets the vector input
  121515. */
  121516. readonly vector: NodeMaterialConnectionPoint;
  121517. /**
  121518. * Gets the output component
  121519. */
  121520. readonly output: NodeMaterialConnectionPoint;
  121521. /**
  121522. * Gets the matrix transform input
  121523. */
  121524. readonly transform: NodeMaterialConnectionPoint;
  121525. protected _buildBlock(state: NodeMaterialBuildState): this;
  121526. serialize(): any;
  121527. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121528. protected _dumpPropertiesCode(): string;
  121529. }
  121530. }
  121531. declare module BABYLON {
  121532. /**
  121533. * Block used to output the vertex position
  121534. */
  121535. export class VertexOutputBlock extends NodeMaterialBlock {
  121536. /**
  121537. * Creates a new VertexOutputBlock
  121538. * @param name defines the block name
  121539. */
  121540. constructor(name: string);
  121541. /**
  121542. * Gets the current class name
  121543. * @returns the class name
  121544. */
  121545. getClassName(): string;
  121546. /**
  121547. * Gets the vector input component
  121548. */
  121549. readonly vector: NodeMaterialConnectionPoint;
  121550. protected _buildBlock(state: NodeMaterialBuildState): this;
  121551. }
  121552. }
  121553. declare module BABYLON {
  121554. /**
  121555. * Block used to output the final color
  121556. */
  121557. export class FragmentOutputBlock extends NodeMaterialBlock {
  121558. /**
  121559. * Create a new FragmentOutputBlock
  121560. * @param name defines the block name
  121561. */
  121562. constructor(name: string);
  121563. /**
  121564. * Gets the current class name
  121565. * @returns the class name
  121566. */
  121567. getClassName(): string;
  121568. /**
  121569. * Gets the rgba input component
  121570. */
  121571. readonly rgba: NodeMaterialConnectionPoint;
  121572. /**
  121573. * Gets the rgb input component
  121574. */
  121575. readonly rgb: NodeMaterialConnectionPoint;
  121576. /**
  121577. * Gets the a input component
  121578. */
  121579. readonly a: NodeMaterialConnectionPoint;
  121580. protected _buildBlock(state: NodeMaterialBuildState): this;
  121581. }
  121582. }
  121583. declare module BABYLON {
  121584. /**
  121585. * Block used to read a reflection texture from a sampler
  121586. */
  121587. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121588. private _define3DName;
  121589. private _defineCubicName;
  121590. private _defineExplicitName;
  121591. private _defineProjectionName;
  121592. private _defineLocalCubicName;
  121593. private _defineSphericalName;
  121594. private _definePlanarName;
  121595. private _defineEquirectangularName;
  121596. private _defineMirroredEquirectangularFixedName;
  121597. private _defineEquirectangularFixedName;
  121598. private _defineSkyboxName;
  121599. private _cubeSamplerName;
  121600. private _2DSamplerName;
  121601. private _positionUVWName;
  121602. private _directionWName;
  121603. private _reflectionCoordsName;
  121604. private _reflection2DCoordsName;
  121605. private _reflectionColorName;
  121606. private _reflectionMatrixName;
  121607. /**
  121608. * Gets or sets the texture associated with the node
  121609. */
  121610. texture: Nullable<BaseTexture>;
  121611. /**
  121612. * Create a new TextureBlock
  121613. * @param name defines the block name
  121614. */
  121615. constructor(name: string);
  121616. /**
  121617. * Gets the current class name
  121618. * @returns the class name
  121619. */
  121620. getClassName(): string;
  121621. /**
  121622. * Gets the world position input component
  121623. */
  121624. readonly position: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the world position input component
  121627. */
  121628. readonly worldPosition: NodeMaterialConnectionPoint;
  121629. /**
  121630. * Gets the world normal input component
  121631. */
  121632. readonly worldNormal: NodeMaterialConnectionPoint;
  121633. /**
  121634. * Gets the world input component
  121635. */
  121636. readonly world: NodeMaterialConnectionPoint;
  121637. /**
  121638. * Gets the camera (or eye) position component
  121639. */
  121640. readonly cameraPosition: NodeMaterialConnectionPoint;
  121641. /**
  121642. * Gets the view input component
  121643. */
  121644. readonly view: NodeMaterialConnectionPoint;
  121645. /**
  121646. * Gets the rgb output component
  121647. */
  121648. readonly rgb: NodeMaterialConnectionPoint;
  121649. /**
  121650. * Gets the r output component
  121651. */
  121652. readonly r: NodeMaterialConnectionPoint;
  121653. /**
  121654. * Gets the g output component
  121655. */
  121656. readonly g: NodeMaterialConnectionPoint;
  121657. /**
  121658. * Gets the b output component
  121659. */
  121660. readonly b: NodeMaterialConnectionPoint;
  121661. autoConfigure(material: NodeMaterial): void;
  121662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121663. isReady(): boolean;
  121664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121665. private _injectVertexCode;
  121666. private _writeOutput;
  121667. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121668. protected _dumpPropertiesCode(): string;
  121669. serialize(): any;
  121670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121671. }
  121672. }
  121673. declare module BABYLON {
  121674. /**
  121675. * Interface used to configure the node material editor
  121676. */
  121677. export interface INodeMaterialEditorOptions {
  121678. /** Define the URl to load node editor script */
  121679. editorURL?: string;
  121680. }
  121681. /** @hidden */
  121682. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  121683. /** BONES */
  121684. NUM_BONE_INFLUENCERS: number;
  121685. BonesPerMesh: number;
  121686. BONETEXTURE: boolean;
  121687. /** MORPH TARGETS */
  121688. MORPHTARGETS: boolean;
  121689. MORPHTARGETS_NORMAL: boolean;
  121690. MORPHTARGETS_TANGENT: boolean;
  121691. MORPHTARGETS_UV: boolean;
  121692. NUM_MORPH_INFLUENCERS: number;
  121693. /** IMAGE PROCESSING */
  121694. IMAGEPROCESSING: boolean;
  121695. VIGNETTE: boolean;
  121696. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121697. VIGNETTEBLENDMODEOPAQUE: boolean;
  121698. TONEMAPPING: boolean;
  121699. TONEMAPPING_ACES: boolean;
  121700. CONTRAST: boolean;
  121701. EXPOSURE: boolean;
  121702. COLORCURVES: boolean;
  121703. COLORGRADING: boolean;
  121704. COLORGRADING3D: boolean;
  121705. SAMPLER3DGREENDEPTH: boolean;
  121706. SAMPLER3DBGRMAP: boolean;
  121707. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121708. /** MISC. */
  121709. BUMPDIRECTUV: number;
  121710. constructor();
  121711. setValue(name: string, value: boolean): void;
  121712. }
  121713. /**
  121714. * Class used to configure NodeMaterial
  121715. */
  121716. export interface INodeMaterialOptions {
  121717. /**
  121718. * Defines if blocks should emit comments
  121719. */
  121720. emitComments: boolean;
  121721. }
  121722. /**
  121723. * Class used to create a node based material built by assembling shader blocks
  121724. */
  121725. export class NodeMaterial extends PushMaterial {
  121726. private static _BuildIdGenerator;
  121727. private _options;
  121728. private _vertexCompilationState;
  121729. private _fragmentCompilationState;
  121730. private _sharedData;
  121731. private _buildId;
  121732. private _buildWasSuccessful;
  121733. private _cachedWorldViewMatrix;
  121734. private _cachedWorldViewProjectionMatrix;
  121735. private _optimizers;
  121736. private _animationFrame;
  121737. /** Define the URl to load node editor script */
  121738. static EditorURL: string;
  121739. private BJSNODEMATERIALEDITOR;
  121740. /** Get the inspector from bundle or global */
  121741. private _getGlobalNodeMaterialEditor;
  121742. /**
  121743. * 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)
  121744. */
  121745. ignoreAlpha: boolean;
  121746. /**
  121747. * Defines the maximum number of lights that can be used in the material
  121748. */
  121749. maxSimultaneousLights: number;
  121750. /**
  121751. * Observable raised when the material is built
  121752. */
  121753. onBuildObservable: Observable<NodeMaterial>;
  121754. /**
  121755. * Gets or sets the root nodes of the material vertex shader
  121756. */
  121757. _vertexOutputNodes: NodeMaterialBlock[];
  121758. /**
  121759. * Gets or sets the root nodes of the material fragment (pixel) shader
  121760. */
  121761. _fragmentOutputNodes: NodeMaterialBlock[];
  121762. /** Gets or sets options to control the node material overall behavior */
  121763. options: INodeMaterialOptions;
  121764. /**
  121765. * Default configuration related to image processing available in the standard Material.
  121766. */
  121767. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121768. /**
  121769. * Gets the image processing configuration used either in this material.
  121770. */
  121771. /**
  121772. * Sets the Default image processing configuration used either in the this material.
  121773. *
  121774. * If sets to null, the scene one is in use.
  121775. */
  121776. imageProcessingConfiguration: ImageProcessingConfiguration;
  121777. /**
  121778. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  121779. */
  121780. attachedBlocks: NodeMaterialBlock[];
  121781. /**
  121782. * Create a new node based material
  121783. * @param name defines the material name
  121784. * @param scene defines the hosting scene
  121785. * @param options defines creation option
  121786. */
  121787. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  121788. /**
  121789. * Gets the current class name of the material e.g. "NodeMaterial"
  121790. * @returns the class name
  121791. */
  121792. getClassName(): string;
  121793. /**
  121794. * Keep track of the image processing observer to allow dispose and replace.
  121795. */
  121796. private _imageProcessingObserver;
  121797. /**
  121798. * Attaches a new image processing configuration to the Standard Material.
  121799. * @param configuration
  121800. */
  121801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121802. /**
  121803. * Get a block by its name
  121804. * @param name defines the name of the block to retrieve
  121805. * @returns the required block or null if not found
  121806. */
  121807. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  121808. /**
  121809. * Get a block by its name
  121810. * @param predicate defines the predicate used to find the good candidate
  121811. * @returns the required block or null if not found
  121812. */
  121813. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  121814. /**
  121815. * Get an input block by its name
  121816. * @param predicate defines the predicate used to find the good candidate
  121817. * @returns the required input block or null if not found
  121818. */
  121819. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  121820. /**
  121821. * Gets the list of input blocks attached to this material
  121822. * @returns an array of InputBlocks
  121823. */
  121824. getInputBlocks(): InputBlock[];
  121825. /**
  121826. * Adds a new optimizer to the list of optimizers
  121827. * @param optimizer defines the optimizers to add
  121828. * @returns the current material
  121829. */
  121830. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121831. /**
  121832. * Remove an optimizer from the list of optimizers
  121833. * @param optimizer defines the optimizers to remove
  121834. * @returns the current material
  121835. */
  121836. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  121837. /**
  121838. * Add a new block to the list of output nodes
  121839. * @param node defines the node to add
  121840. * @returns the current material
  121841. */
  121842. addOutputNode(node: NodeMaterialBlock): this;
  121843. /**
  121844. * Remove a block from the list of root nodes
  121845. * @param node defines the node to remove
  121846. * @returns the current material
  121847. */
  121848. removeOutputNode(node: NodeMaterialBlock): this;
  121849. private _addVertexOutputNode;
  121850. private _removeVertexOutputNode;
  121851. private _addFragmentOutputNode;
  121852. private _removeFragmentOutputNode;
  121853. /**
  121854. * Specifies if the material will require alpha blending
  121855. * @returns a boolean specifying if alpha blending is needed
  121856. */
  121857. needAlphaBlending(): boolean;
  121858. /**
  121859. * Specifies if this material should be rendered in alpha test mode
  121860. * @returns a boolean specifying if an alpha test is needed.
  121861. */
  121862. needAlphaTesting(): boolean;
  121863. private _initializeBlock;
  121864. private _resetDualBlocks;
  121865. /**
  121866. * Build the material and generates the inner effect
  121867. * @param verbose defines if the build should log activity
  121868. */
  121869. build(verbose?: boolean): void;
  121870. /**
  121871. * Runs an otpimization phase to try to improve the shader code
  121872. */
  121873. optimize(): void;
  121874. private _prepareDefinesForAttributes;
  121875. /**
  121876. * Get if the submesh is ready to be used and all its information available.
  121877. * Child classes can use it to update shaders
  121878. * @param mesh defines the mesh to check
  121879. * @param subMesh defines which submesh to check
  121880. * @param useInstances specifies that instances should be used
  121881. * @returns a boolean indicating that the submesh is ready or not
  121882. */
  121883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121884. /**
  121885. * Get a string representing the shaders built by the current node graph
  121886. */
  121887. readonly compiledShaders: string;
  121888. /**
  121889. * Binds the world matrix to the material
  121890. * @param world defines the world transformation matrix
  121891. */
  121892. bindOnlyWorldMatrix(world: Matrix): void;
  121893. /**
  121894. * Binds the submesh to this material by preparing the effect and shader to draw
  121895. * @param world defines the world transformation matrix
  121896. * @param mesh defines the mesh containing the submesh
  121897. * @param subMesh defines the submesh to bind the material to
  121898. */
  121899. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121900. /**
  121901. * Gets the active textures from the material
  121902. * @returns an array of textures
  121903. */
  121904. getActiveTextures(): BaseTexture[];
  121905. /**
  121906. * Gets the list of texture blocks
  121907. * @returns an array of texture blocks
  121908. */
  121909. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121910. /**
  121911. * Specifies if the material uses a texture
  121912. * @param texture defines the texture to check against the material
  121913. * @returns a boolean specifying if the material uses the texture
  121914. */
  121915. hasTexture(texture: BaseTexture): boolean;
  121916. /**
  121917. * Disposes the material
  121918. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121919. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121920. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121921. */
  121922. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121923. /** Creates the node editor window. */
  121924. private _createNodeEditor;
  121925. /**
  121926. * Launch the node material editor
  121927. * @param config Define the configuration of the editor
  121928. * @return a promise fulfilled when the node editor is visible
  121929. */
  121930. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121931. /**
  121932. * Clear the current material
  121933. */
  121934. clear(): void;
  121935. /**
  121936. * Clear the current material and set it to a default state
  121937. */
  121938. setToDefault(): void;
  121939. /**
  121940. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121941. * @param url defines the url to load from
  121942. * @returns a promise that will fullfil when the material is fully loaded
  121943. */
  121944. loadAsync(url: string): Promise<void>;
  121945. private _gatherBlocks;
  121946. /**
  121947. * Generate a string containing the code declaration required to create an equivalent of this material
  121948. * @returns a string
  121949. */
  121950. generateCode(): string;
  121951. /**
  121952. * Serializes this material in a JSON representation
  121953. * @returns the serialized material object
  121954. */
  121955. serialize(): any;
  121956. private _restoreConnections;
  121957. /**
  121958. * Clear the current graph and load a new one from a serialization object
  121959. * @param source defines the JSON representation of the material
  121960. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121961. */
  121962. loadFromSerialization(source: any, rootUrl?: string): void;
  121963. /**
  121964. * Creates a node material from parsed material data
  121965. * @param source defines the JSON representation of the material
  121966. * @param scene defines the hosting scene
  121967. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121968. * @returns a new node material
  121969. */
  121970. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121971. /**
  121972. * Creates a new node material set to default basic configuration
  121973. * @param name defines the name of the material
  121974. * @param scene defines the hosting scene
  121975. * @returns a new NodeMaterial
  121976. */
  121977. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121978. }
  121979. }
  121980. declare module BABYLON {
  121981. /**
  121982. * Block used to read a texture from a sampler
  121983. */
  121984. export class TextureBlock extends NodeMaterialBlock {
  121985. private _defineName;
  121986. private _linearDefineName;
  121987. private _samplerName;
  121988. private _transformedUVName;
  121989. private _textureTransformName;
  121990. private _textureInfoName;
  121991. private _mainUVName;
  121992. private _mainUVDefineName;
  121993. /**
  121994. * Gets or sets the texture associated with the node
  121995. */
  121996. texture: Nullable<Texture>;
  121997. /**
  121998. * Create a new TextureBlock
  121999. * @param name defines the block name
  122000. */
  122001. constructor(name: string);
  122002. /**
  122003. * Gets the current class name
  122004. * @returns the class name
  122005. */
  122006. getClassName(): string;
  122007. /**
  122008. * Gets the uv input component
  122009. */
  122010. readonly uv: NodeMaterialConnectionPoint;
  122011. /**
  122012. * Gets the rgba output component
  122013. */
  122014. readonly rgba: NodeMaterialConnectionPoint;
  122015. /**
  122016. * Gets the rgb output component
  122017. */
  122018. readonly rgb: NodeMaterialConnectionPoint;
  122019. /**
  122020. * Gets the r output component
  122021. */
  122022. readonly r: NodeMaterialConnectionPoint;
  122023. /**
  122024. * Gets the g output component
  122025. */
  122026. readonly g: NodeMaterialConnectionPoint;
  122027. /**
  122028. * Gets the b output component
  122029. */
  122030. readonly b: NodeMaterialConnectionPoint;
  122031. /**
  122032. * Gets the a output component
  122033. */
  122034. readonly a: NodeMaterialConnectionPoint;
  122035. readonly target: NodeMaterialBlockTargets;
  122036. autoConfigure(material: NodeMaterial): void;
  122037. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122039. isReady(): boolean;
  122040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122041. private readonly _isMixed;
  122042. private _injectVertexCode;
  122043. private _writeOutput;
  122044. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122045. protected _dumpPropertiesCode(): string;
  122046. serialize(): any;
  122047. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122048. }
  122049. }
  122050. declare module BABYLON {
  122051. /**
  122052. * Class used to store shared data between 2 NodeMaterialBuildState
  122053. */
  122054. export class NodeMaterialBuildStateSharedData {
  122055. /**
  122056. * Gets the list of emitted varyings
  122057. */
  122058. temps: string[];
  122059. /**
  122060. * Gets the list of emitted varyings
  122061. */
  122062. varyings: string[];
  122063. /**
  122064. * Gets the varying declaration string
  122065. */
  122066. varyingDeclaration: string;
  122067. /**
  122068. * Input blocks
  122069. */
  122070. inputBlocks: InputBlock[];
  122071. /**
  122072. * Input blocks
  122073. */
  122074. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122075. /**
  122076. * Bindable blocks (Blocks that need to set data to the effect)
  122077. */
  122078. bindableBlocks: NodeMaterialBlock[];
  122079. /**
  122080. * List of blocks that can provide a compilation fallback
  122081. */
  122082. blocksWithFallbacks: NodeMaterialBlock[];
  122083. /**
  122084. * List of blocks that can provide a define update
  122085. */
  122086. blocksWithDefines: NodeMaterialBlock[];
  122087. /**
  122088. * List of blocks that can provide a repeatable content
  122089. */
  122090. repeatableContentBlocks: NodeMaterialBlock[];
  122091. /**
  122092. * List of blocks that can provide a dynamic list of uniforms
  122093. */
  122094. dynamicUniformBlocks: NodeMaterialBlock[];
  122095. /**
  122096. * List of blocks that can block the isReady function for the material
  122097. */
  122098. blockingBlocks: NodeMaterialBlock[];
  122099. /**
  122100. * Gets the list of animated inputs
  122101. */
  122102. animatedInputs: InputBlock[];
  122103. /**
  122104. * Build Id used to avoid multiple recompilations
  122105. */
  122106. buildId: number;
  122107. /** List of emitted variables */
  122108. variableNames: {
  122109. [key: string]: number;
  122110. };
  122111. /** List of emitted defines */
  122112. defineNames: {
  122113. [key: string]: number;
  122114. };
  122115. /** Should emit comments? */
  122116. emitComments: boolean;
  122117. /** Emit build activity */
  122118. verbose: boolean;
  122119. /** Gets or sets the hosting scene */
  122120. scene: Scene;
  122121. /**
  122122. * Gets the compilation hints emitted at compilation time
  122123. */
  122124. hints: {
  122125. needWorldViewMatrix: boolean;
  122126. needWorldViewProjectionMatrix: boolean;
  122127. needAlphaBlending: boolean;
  122128. needAlphaTesting: boolean;
  122129. };
  122130. /**
  122131. * List of compilation checks
  122132. */
  122133. checks: {
  122134. emitVertex: boolean;
  122135. emitFragment: boolean;
  122136. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122137. };
  122138. /** Creates a new shared data */
  122139. constructor();
  122140. /**
  122141. * Emits console errors and exceptions if there is a failing check
  122142. */
  122143. emitErrors(): void;
  122144. }
  122145. }
  122146. declare module BABYLON {
  122147. /**
  122148. * Class used to store node based material build state
  122149. */
  122150. export class NodeMaterialBuildState {
  122151. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122152. supportUniformBuffers: boolean;
  122153. /**
  122154. * Gets the list of emitted attributes
  122155. */
  122156. attributes: string[];
  122157. /**
  122158. * Gets the list of emitted uniforms
  122159. */
  122160. uniforms: string[];
  122161. /**
  122162. * Gets the list of emitted constants
  122163. */
  122164. constants: string[];
  122165. /**
  122166. * Gets the list of emitted samplers
  122167. */
  122168. samplers: string[];
  122169. /**
  122170. * Gets the list of emitted functions
  122171. */
  122172. functions: {
  122173. [key: string]: string;
  122174. };
  122175. /**
  122176. * Gets the list of emitted extensions
  122177. */
  122178. extensions: {
  122179. [key: string]: string;
  122180. };
  122181. /**
  122182. * Gets the target of the compilation state
  122183. */
  122184. target: NodeMaterialBlockTargets;
  122185. /**
  122186. * Gets the list of emitted counters
  122187. */
  122188. counters: {
  122189. [key: string]: number;
  122190. };
  122191. /**
  122192. * Shared data between multiple NodeMaterialBuildState instances
  122193. */
  122194. sharedData: NodeMaterialBuildStateSharedData;
  122195. /** @hidden */
  122196. _vertexState: NodeMaterialBuildState;
  122197. /** @hidden */
  122198. _attributeDeclaration: string;
  122199. /** @hidden */
  122200. _uniformDeclaration: string;
  122201. /** @hidden */
  122202. _constantDeclaration: string;
  122203. /** @hidden */
  122204. _samplerDeclaration: string;
  122205. /** @hidden */
  122206. _varyingTransfer: string;
  122207. private _repeatableContentAnchorIndex;
  122208. /** @hidden */
  122209. _builtCompilationString: string;
  122210. /**
  122211. * Gets the emitted compilation strings
  122212. */
  122213. compilationString: string;
  122214. /**
  122215. * Finalize the compilation strings
  122216. * @param state defines the current compilation state
  122217. */
  122218. finalize(state: NodeMaterialBuildState): void;
  122219. /** @hidden */
  122220. readonly _repeatableContentAnchor: string;
  122221. /** @hidden */
  122222. _getFreeVariableName(prefix: string): string;
  122223. /** @hidden */
  122224. _getFreeDefineName(prefix: string): string;
  122225. /** @hidden */
  122226. _excludeVariableName(name: string): void;
  122227. /** @hidden */
  122228. _emit2DSampler(name: string): void;
  122229. /** @hidden */
  122230. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122231. /** @hidden */
  122232. _emitExtension(name: string, extension: string): void;
  122233. /** @hidden */
  122234. _emitFunction(name: string, code: string, comments: string): void;
  122235. /** @hidden */
  122236. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122237. replaceStrings?: {
  122238. search: RegExp;
  122239. replace: string;
  122240. }[];
  122241. repeatKey?: string;
  122242. }): string;
  122243. /** @hidden */
  122244. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122245. repeatKey?: string;
  122246. removeAttributes?: boolean;
  122247. removeUniforms?: boolean;
  122248. removeVaryings?: boolean;
  122249. removeIfDef?: boolean;
  122250. replaceStrings?: {
  122251. search: RegExp;
  122252. replace: string;
  122253. }[];
  122254. }, storeKey?: string): void;
  122255. /** @hidden */
  122256. _registerTempVariable(name: string): boolean;
  122257. /** @hidden */
  122258. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122259. /** @hidden */
  122260. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122261. /** @hidden */
  122262. _emitFloat(value: number): string;
  122263. }
  122264. }
  122265. declare module BABYLON {
  122266. /**
  122267. * Defines a block that can be used inside a node based material
  122268. */
  122269. export class NodeMaterialBlock {
  122270. private _buildId;
  122271. private _buildTarget;
  122272. private _target;
  122273. private _isFinalMerger;
  122274. private _isInput;
  122275. protected _isUnique: boolean;
  122276. /** @hidden */
  122277. _codeVariableName: string;
  122278. /** @hidden */
  122279. _inputs: NodeMaterialConnectionPoint[];
  122280. /** @hidden */
  122281. _outputs: NodeMaterialConnectionPoint[];
  122282. /** @hidden */
  122283. _preparationId: number;
  122284. /**
  122285. * Gets or sets the name of the block
  122286. */
  122287. name: string;
  122288. /**
  122289. * Gets or sets the unique id of the node
  122290. */
  122291. uniqueId: number;
  122292. /**
  122293. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122294. */
  122295. readonly isUnique: boolean;
  122296. /**
  122297. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122298. */
  122299. readonly isFinalMerger: boolean;
  122300. /**
  122301. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122302. */
  122303. readonly isInput: boolean;
  122304. /**
  122305. * Gets or sets the build Id
  122306. */
  122307. buildId: number;
  122308. /**
  122309. * Gets or sets the target of the block
  122310. */
  122311. target: NodeMaterialBlockTargets;
  122312. /**
  122313. * Gets the list of input points
  122314. */
  122315. readonly inputs: NodeMaterialConnectionPoint[];
  122316. /** Gets the list of output points */
  122317. readonly outputs: NodeMaterialConnectionPoint[];
  122318. /**
  122319. * Find an input by its name
  122320. * @param name defines the name of the input to look for
  122321. * @returns the input or null if not found
  122322. */
  122323. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122324. /**
  122325. * Find an output by its name
  122326. * @param name defines the name of the outputto look for
  122327. * @returns the output or null if not found
  122328. */
  122329. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122330. /**
  122331. * Creates a new NodeMaterialBlock
  122332. * @param name defines the block name
  122333. * @param target defines the target of that block (Vertex by default)
  122334. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122335. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122336. */
  122337. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122338. /**
  122339. * Initialize the block and prepare the context for build
  122340. * @param state defines the state that will be used for the build
  122341. */
  122342. initialize(state: NodeMaterialBuildState): void;
  122343. /**
  122344. * Bind data to effect. Will only be called for blocks with isBindable === true
  122345. * @param effect defines the effect to bind data to
  122346. * @param nodeMaterial defines the hosting NodeMaterial
  122347. * @param mesh defines the mesh that will be rendered
  122348. */
  122349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122350. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122351. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122352. protected _writeFloat(value: number): string;
  122353. /**
  122354. * Gets the current class name e.g. "NodeMaterialBlock"
  122355. * @returns the class name
  122356. */
  122357. getClassName(): string;
  122358. /**
  122359. * Register a new input. Must be called inside a block constructor
  122360. * @param name defines the connection point name
  122361. * @param type defines the connection point type
  122362. * @param isOptional defines a boolean indicating that this input can be omitted
  122363. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122364. * @returns the current block
  122365. */
  122366. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122367. /**
  122368. * Register a new output. Must be called inside a block constructor
  122369. * @param name defines the connection point name
  122370. * @param type defines the connection point type
  122371. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122372. * @returns the current block
  122373. */
  122374. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122375. /**
  122376. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122377. * @param forOutput defines an optional connection point to check compatibility with
  122378. * @returns the first available input or null
  122379. */
  122380. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122381. /**
  122382. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122383. * @param forBlock defines an optional block to check compatibility with
  122384. * @returns the first available input or null
  122385. */
  122386. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122387. /**
  122388. * Gets the sibling of the given output
  122389. * @param current defines the current output
  122390. * @returns the next output in the list or null
  122391. */
  122392. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122393. /**
  122394. * Connect current block with another block
  122395. * @param other defines the block to connect with
  122396. * @param options define the various options to help pick the right connections
  122397. * @returns the current block
  122398. */
  122399. connectTo(other: NodeMaterialBlock, options?: {
  122400. input?: string;
  122401. output?: string;
  122402. outputSwizzle?: string;
  122403. }): this | undefined;
  122404. protected _buildBlock(state: NodeMaterialBuildState): void;
  122405. /**
  122406. * Add uniforms, samplers and uniform buffers at compilation time
  122407. * @param state defines the state to update
  122408. * @param nodeMaterial defines the node material requesting the update
  122409. * @param defines defines the material defines to update
  122410. * @param uniformBuffers defines the list of uniform buffer names
  122411. */
  122412. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122413. /**
  122414. * Add potential fallbacks if shader compilation fails
  122415. * @param mesh defines the mesh to be rendered
  122416. * @param fallbacks defines the current prioritized list of fallbacks
  122417. */
  122418. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122419. /**
  122420. * Initialize defines for shader compilation
  122421. * @param mesh defines the mesh to be rendered
  122422. * @param nodeMaterial defines the node material requesting the update
  122423. * @param defines defines the material defines to update
  122424. * @param useInstances specifies that instances should be used
  122425. */
  122426. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122427. /**
  122428. * Update defines for shader compilation
  122429. * @param mesh defines the mesh to be rendered
  122430. * @param nodeMaterial defines the node material requesting the update
  122431. * @param defines defines the material defines to update
  122432. * @param useInstances specifies that instances should be used
  122433. */
  122434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122435. /**
  122436. * Lets the block try to connect some inputs automatically
  122437. * @param material defines the hosting NodeMaterial
  122438. */
  122439. autoConfigure(material: NodeMaterial): void;
  122440. /**
  122441. * Function called when a block is declared as repeatable content generator
  122442. * @param vertexShaderState defines the current compilation state for the vertex shader
  122443. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122444. * @param mesh defines the mesh to be rendered
  122445. * @param defines defines the material defines to update
  122446. */
  122447. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122448. /**
  122449. * Checks if the block is ready
  122450. * @param mesh defines the mesh to be rendered
  122451. * @param nodeMaterial defines the node material requesting the update
  122452. * @param defines defines the material defines to update
  122453. * @param useInstances specifies that instances should be used
  122454. * @returns true if the block is ready
  122455. */
  122456. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122457. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122458. private _processBuild;
  122459. /**
  122460. * Compile the current node and generate the shader code
  122461. * @param state defines the current compilation state (uniforms, samplers, current string)
  122462. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122463. * @returns true if already built
  122464. */
  122465. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122466. protected _inputRename(name: string): string;
  122467. protected _outputRename(name: string): string;
  122468. protected _dumpPropertiesCode(): string;
  122469. /** @hidden */
  122470. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122471. /** @hidden */
  122472. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122473. /**
  122474. * Clone the current block to a new identical block
  122475. * @param scene defines the hosting scene
  122476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122477. * @returns a copy of the current block
  122478. */
  122479. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122480. /**
  122481. * Serializes this block in a JSON representation
  122482. * @returns the serialized block object
  122483. */
  122484. serialize(): any;
  122485. /** @hidden */
  122486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122487. /**
  122488. * Release resources
  122489. */
  122490. dispose(): void;
  122491. }
  122492. }
  122493. declare module BABYLON {
  122494. /**
  122495. * Enum defining the type of animations supported by InputBlock
  122496. */
  122497. export enum AnimatedInputBlockTypes {
  122498. /** No animation */
  122499. None = 0,
  122500. /** Time based animation. Will only work for floats */
  122501. Time = 1
  122502. }
  122503. }
  122504. declare module BABYLON {
  122505. /**
  122506. * Block used to expose an input value
  122507. */
  122508. export class InputBlock extends NodeMaterialBlock {
  122509. private _mode;
  122510. private _associatedVariableName;
  122511. private _storedValue;
  122512. private _valueCallback;
  122513. private _type;
  122514. private _animationType;
  122515. /** Gets or set a value used to limit the range of float values */
  122516. min: number;
  122517. /** Gets or set a value used to limit the range of float values */
  122518. max: number;
  122519. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122520. matrixMode: number;
  122521. /** @hidden */
  122522. _systemValue: Nullable<NodeMaterialSystemValues>;
  122523. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122524. visibleInInspector: boolean;
  122525. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122526. isConstant: boolean;
  122527. /**
  122528. * Gets or sets the connection point type (default is float)
  122529. */
  122530. readonly type: NodeMaterialBlockConnectionPointTypes;
  122531. /**
  122532. * Creates a new InputBlock
  122533. * @param name defines the block name
  122534. * @param target defines the target of that block (Vertex by default)
  122535. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122536. */
  122537. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122538. /**
  122539. * Gets the output component
  122540. */
  122541. readonly output: NodeMaterialConnectionPoint;
  122542. /**
  122543. * Set the source of this connection point to a vertex attribute
  122544. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122545. * @returns the current connection point
  122546. */
  122547. setAsAttribute(attributeName?: string): InputBlock;
  122548. /**
  122549. * Set the source of this connection point to a system value
  122550. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122551. * @returns the current connection point
  122552. */
  122553. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122554. /**
  122555. * Gets or sets the value of that point.
  122556. * Please note that this value will be ignored if valueCallback is defined
  122557. */
  122558. value: any;
  122559. /**
  122560. * Gets or sets a callback used to get the value of that point.
  122561. * Please note that setting this value will force the connection point to ignore the value property
  122562. */
  122563. valueCallback: () => any;
  122564. /**
  122565. * Gets or sets the associated variable name in the shader
  122566. */
  122567. associatedVariableName: string;
  122568. /** Gets or sets the type of animation applied to the input */
  122569. animationType: AnimatedInputBlockTypes;
  122570. /**
  122571. * Gets a boolean indicating that this connection point not defined yet
  122572. */
  122573. readonly isUndefined: boolean;
  122574. /**
  122575. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122576. * In this case the connection point name must be the name of the uniform to use.
  122577. * Can only be set on inputs
  122578. */
  122579. isUniform: boolean;
  122580. /**
  122581. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122582. * In this case the connection point name must be the name of the attribute to use
  122583. * Can only be set on inputs
  122584. */
  122585. isAttribute: boolean;
  122586. /**
  122587. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122588. * Can only be set on exit points
  122589. */
  122590. isVarying: boolean;
  122591. /**
  122592. * Gets a boolean indicating that the current connection point is a system value
  122593. */
  122594. readonly isSystemValue: boolean;
  122595. /**
  122596. * Gets or sets the current well known value or null if not defined as a system value
  122597. */
  122598. systemValue: Nullable<NodeMaterialSystemValues>;
  122599. /**
  122600. * Gets the current class name
  122601. * @returns the class name
  122602. */
  122603. getClassName(): string;
  122604. /**
  122605. * Animate the input if animationType !== None
  122606. * @param scene defines the rendering scene
  122607. */
  122608. animate(scene: Scene): void;
  122609. private _emitDefine;
  122610. initialize(state: NodeMaterialBuildState): void;
  122611. /**
  122612. * Set the input block to its default value (based on its type)
  122613. */
  122614. setDefaultValue(): void;
  122615. private _emitConstant;
  122616. private _emit;
  122617. /** @hidden */
  122618. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122619. /** @hidden */
  122620. _transmit(effect: Effect, scene: Scene): void;
  122621. protected _buildBlock(state: NodeMaterialBuildState): void;
  122622. protected _dumpPropertiesCode(): string;
  122623. serialize(): any;
  122624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122625. }
  122626. }
  122627. declare module BABYLON {
  122628. /**
  122629. * Enum used to define the compatibility state between two connection points
  122630. */
  122631. export enum NodeMaterialConnectionPointCompatibilityStates {
  122632. /** Points are compatibles */
  122633. Compatible = 0,
  122634. /** Points are incompatible because of their types */
  122635. TypeIncompatible = 1,
  122636. /** Points are incompatible because of their targets (vertex vs fragment) */
  122637. TargetIncompatible = 2
  122638. }
  122639. /**
  122640. * Defines a connection point for a block
  122641. */
  122642. export class NodeMaterialConnectionPoint {
  122643. /** @hidden */
  122644. _ownerBlock: NodeMaterialBlock;
  122645. /** @hidden */
  122646. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122647. private _endpoints;
  122648. private _associatedVariableName;
  122649. /** @hidden */
  122650. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122651. /** @hidden */
  122652. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  122653. private _type;
  122654. /** @hidden */
  122655. _enforceAssociatedVariableName: boolean;
  122656. /**
  122657. * Gets or sets the additional types supported by this connection point
  122658. */
  122659. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122660. /**
  122661. * Gets or sets the additional types excluded by this connection point
  122662. */
  122663. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  122664. /**
  122665. * Observable triggered when this point is connected
  122666. */
  122667. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  122668. /**
  122669. * Gets or sets the associated variable name in the shader
  122670. */
  122671. associatedVariableName: string;
  122672. /**
  122673. * Gets or sets the connection point type (default is float)
  122674. */
  122675. type: NodeMaterialBlockConnectionPointTypes;
  122676. /**
  122677. * Gets or sets the connection point name
  122678. */
  122679. name: string;
  122680. /**
  122681. * Gets or sets a boolean indicating that this connection point can be omitted
  122682. */
  122683. isOptional: boolean;
  122684. /**
  122685. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  122686. */
  122687. define: string;
  122688. /** @hidden */
  122689. _prioritizeVertex: boolean;
  122690. private _target;
  122691. /** Gets or sets the target of that connection point */
  122692. target: NodeMaterialBlockTargets;
  122693. /**
  122694. * Gets a boolean indicating that the current point is connected
  122695. */
  122696. readonly isConnected: boolean;
  122697. /**
  122698. * Gets a boolean indicating that the current point is connected to an input block
  122699. */
  122700. readonly isConnectedToInputBlock: boolean;
  122701. /**
  122702. * Gets a the connected input block (if any)
  122703. */
  122704. readonly connectInputBlock: Nullable<InputBlock>;
  122705. /** Get the other side of the connection (if any) */
  122706. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  122707. /** Get the block that owns this connection point */
  122708. readonly ownerBlock: NodeMaterialBlock;
  122709. /** Get the block connected on the other side of this connection (if any) */
  122710. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  122711. /** Get the block connected on the endpoints of this connection (if any) */
  122712. readonly connectedBlocks: Array<NodeMaterialBlock>;
  122713. /** Gets the list of connected endpoints */
  122714. readonly endpoints: NodeMaterialConnectionPoint[];
  122715. /** Gets a boolean indicating if that output point is connected to at least one input */
  122716. readonly hasEndpoints: boolean;
  122717. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  122718. readonly isConnectedInVertexShader: boolean;
  122719. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  122720. readonly isConnectedInFragmentShader: boolean;
  122721. /**
  122722. * Creates a new connection point
  122723. * @param name defines the connection point name
  122724. * @param ownerBlock defines the block hosting this connection point
  122725. */
  122726. constructor(name: string, ownerBlock: NodeMaterialBlock);
  122727. /**
  122728. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  122729. * @returns the class name
  122730. */
  122731. getClassName(): string;
  122732. /**
  122733. * Gets a boolean indicating if the current point can be connected to another point
  122734. * @param connectionPoint defines the other connection point
  122735. * @returns a boolean
  122736. */
  122737. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  122738. /**
  122739. * Gets a number indicating if the current point can be connected to another point
  122740. * @param connectionPoint defines the other connection point
  122741. * @returns a number defining the compatibility state
  122742. */
  122743. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  122744. /**
  122745. * Connect this point to another connection point
  122746. * @param connectionPoint defines the other connection point
  122747. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  122748. * @returns the current connection point
  122749. */
  122750. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  122751. /**
  122752. * Disconnect this point from one of his endpoint
  122753. * @param endpoint defines the other connection point
  122754. * @returns the current connection point
  122755. */
  122756. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  122757. /**
  122758. * Serializes this point in a JSON representation
  122759. * @returns the serialized point object
  122760. */
  122761. serialize(): any;
  122762. /**
  122763. * Release resources
  122764. */
  122765. dispose(): void;
  122766. }
  122767. }
  122768. declare module BABYLON {
  122769. /**
  122770. * Block used to add support for vertex skinning (bones)
  122771. */
  122772. export class BonesBlock extends NodeMaterialBlock {
  122773. /**
  122774. * Creates a new BonesBlock
  122775. * @param name defines the block name
  122776. */
  122777. constructor(name: string);
  122778. /**
  122779. * Initialize the block and prepare the context for build
  122780. * @param state defines the state that will be used for the build
  122781. */
  122782. initialize(state: NodeMaterialBuildState): void;
  122783. /**
  122784. * Gets the current class name
  122785. * @returns the class name
  122786. */
  122787. getClassName(): string;
  122788. /**
  122789. * Gets the matrix indices input component
  122790. */
  122791. readonly matricesIndices: NodeMaterialConnectionPoint;
  122792. /**
  122793. * Gets the matrix weights input component
  122794. */
  122795. readonly matricesWeights: NodeMaterialConnectionPoint;
  122796. /**
  122797. * Gets the extra matrix indices input component
  122798. */
  122799. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  122800. /**
  122801. * Gets the extra matrix weights input component
  122802. */
  122803. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  122804. /**
  122805. * Gets the world input component
  122806. */
  122807. readonly world: NodeMaterialConnectionPoint;
  122808. /**
  122809. * Gets the output component
  122810. */
  122811. readonly output: NodeMaterialConnectionPoint;
  122812. autoConfigure(material: NodeMaterial): void;
  122813. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122814. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122816. protected _buildBlock(state: NodeMaterialBuildState): this;
  122817. }
  122818. }
  122819. declare module BABYLON {
  122820. /**
  122821. * Block used to add support for instances
  122822. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  122823. */
  122824. export class InstancesBlock extends NodeMaterialBlock {
  122825. /**
  122826. * Creates a new InstancesBlock
  122827. * @param name defines the block name
  122828. */
  122829. constructor(name: string);
  122830. /**
  122831. * Gets the current class name
  122832. * @returns the class name
  122833. */
  122834. getClassName(): string;
  122835. /**
  122836. * Gets the first world row input component
  122837. */
  122838. readonly world0: NodeMaterialConnectionPoint;
  122839. /**
  122840. * Gets the second world row input component
  122841. */
  122842. readonly world1: NodeMaterialConnectionPoint;
  122843. /**
  122844. * Gets the third world row input component
  122845. */
  122846. readonly world2: NodeMaterialConnectionPoint;
  122847. /**
  122848. * Gets the forth world row input component
  122849. */
  122850. readonly world3: NodeMaterialConnectionPoint;
  122851. /**
  122852. * Gets the world input component
  122853. */
  122854. readonly world: NodeMaterialConnectionPoint;
  122855. /**
  122856. * Gets the output component
  122857. */
  122858. readonly output: NodeMaterialConnectionPoint;
  122859. autoConfigure(material: NodeMaterial): void;
  122860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122861. protected _buildBlock(state: NodeMaterialBuildState): this;
  122862. }
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * Block used to add morph targets support to vertex shader
  122867. */
  122868. export class MorphTargetsBlock extends NodeMaterialBlock {
  122869. private _repeatableContentAnchor;
  122870. private _repeatebleContentGenerated;
  122871. /**
  122872. * Create a new MorphTargetsBlock
  122873. * @param name defines the block name
  122874. */
  122875. constructor(name: string);
  122876. /**
  122877. * Gets the current class name
  122878. * @returns the class name
  122879. */
  122880. getClassName(): string;
  122881. /**
  122882. * Gets the position input component
  122883. */
  122884. readonly position: NodeMaterialConnectionPoint;
  122885. /**
  122886. * Gets the normal input component
  122887. */
  122888. readonly normal: NodeMaterialConnectionPoint;
  122889. /**
  122890. * Gets the tangent input component
  122891. */
  122892. readonly tangent: NodeMaterialConnectionPoint;
  122893. /**
  122894. * Gets the tangent input component
  122895. */
  122896. readonly uv: NodeMaterialConnectionPoint;
  122897. /**
  122898. * Gets the position output component
  122899. */
  122900. readonly positionOutput: NodeMaterialConnectionPoint;
  122901. /**
  122902. * Gets the normal output component
  122903. */
  122904. readonly normalOutput: NodeMaterialConnectionPoint;
  122905. /**
  122906. * Gets the tangent output component
  122907. */
  122908. readonly tangentOutput: NodeMaterialConnectionPoint;
  122909. /**
  122910. * Gets the tangent output component
  122911. */
  122912. readonly uvOutput: NodeMaterialConnectionPoint;
  122913. initialize(state: NodeMaterialBuildState): void;
  122914. autoConfigure(material: NodeMaterial): void;
  122915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122917. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122918. protected _buildBlock(state: NodeMaterialBuildState): this;
  122919. }
  122920. }
  122921. declare module BABYLON {
  122922. /**
  122923. * Block used to get data information from a light
  122924. */
  122925. export class LightInformationBlock extends NodeMaterialBlock {
  122926. private _lightDataUniformName;
  122927. private _lightColorUniformName;
  122928. private _lightTypeDefineName;
  122929. /**
  122930. * Gets or sets the light associated with this block
  122931. */
  122932. light: Nullable<Light>;
  122933. /**
  122934. * Creates a new LightInformationBlock
  122935. * @param name defines the block name
  122936. */
  122937. constructor(name: string);
  122938. /**
  122939. * Gets the current class name
  122940. * @returns the class name
  122941. */
  122942. getClassName(): string;
  122943. /**
  122944. * Gets the world position input component
  122945. */
  122946. readonly worldPosition: NodeMaterialConnectionPoint;
  122947. /**
  122948. * Gets the direction output component
  122949. */
  122950. readonly direction: NodeMaterialConnectionPoint;
  122951. /**
  122952. * Gets the direction output component
  122953. */
  122954. readonly color: NodeMaterialConnectionPoint;
  122955. /**
  122956. * Gets the direction output component
  122957. */
  122958. readonly intensity: NodeMaterialConnectionPoint;
  122959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122961. protected _buildBlock(state: NodeMaterialBuildState): this;
  122962. serialize(): any;
  122963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122964. }
  122965. }
  122966. declare module BABYLON {
  122967. /**
  122968. * Block used to add image processing support to fragment shader
  122969. */
  122970. export class ImageProcessingBlock extends NodeMaterialBlock {
  122971. /**
  122972. * Create a new ImageProcessingBlock
  122973. * @param name defines the block name
  122974. */
  122975. constructor(name: string);
  122976. /**
  122977. * Gets the current class name
  122978. * @returns the class name
  122979. */
  122980. getClassName(): string;
  122981. /**
  122982. * Gets the color input component
  122983. */
  122984. readonly color: NodeMaterialConnectionPoint;
  122985. /**
  122986. * Gets the output component
  122987. */
  122988. readonly output: NodeMaterialConnectionPoint;
  122989. /**
  122990. * Initialize the block and prepare the context for build
  122991. * @param state defines the state that will be used for the build
  122992. */
  122993. initialize(state: NodeMaterialBuildState): void;
  122994. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122997. protected _buildBlock(state: NodeMaterialBuildState): this;
  122998. }
  122999. }
  123000. declare module BABYLON {
  123001. /**
  123002. * Block used to pertub normals based on a normal map
  123003. */
  123004. export class PerturbNormalBlock extends NodeMaterialBlock {
  123005. private _tangentSpaceParameterName;
  123006. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123007. invertX: boolean;
  123008. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123009. invertY: boolean;
  123010. /**
  123011. * Create a new PerturbNormalBlock
  123012. * @param name defines the block name
  123013. */
  123014. constructor(name: string);
  123015. /**
  123016. * Gets the current class name
  123017. * @returns the class name
  123018. */
  123019. getClassName(): string;
  123020. /**
  123021. * Gets the world position input component
  123022. */
  123023. readonly worldPosition: NodeMaterialConnectionPoint;
  123024. /**
  123025. * Gets the world normal input component
  123026. */
  123027. readonly worldNormal: NodeMaterialConnectionPoint;
  123028. /**
  123029. * Gets the uv input component
  123030. */
  123031. readonly uv: NodeMaterialConnectionPoint;
  123032. /**
  123033. * Gets the normal map color input component
  123034. */
  123035. readonly normalMapColor: NodeMaterialConnectionPoint;
  123036. /**
  123037. * Gets the strength input component
  123038. */
  123039. readonly strength: NodeMaterialConnectionPoint;
  123040. /**
  123041. * Gets the output component
  123042. */
  123043. readonly output: NodeMaterialConnectionPoint;
  123044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123046. autoConfigure(material: NodeMaterial): void;
  123047. protected _buildBlock(state: NodeMaterialBuildState): this;
  123048. protected _dumpPropertiesCode(): string;
  123049. serialize(): any;
  123050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123051. }
  123052. }
  123053. declare module BABYLON {
  123054. /**
  123055. * Block used to discard a pixel if a value is smaller than a cutoff
  123056. */
  123057. export class DiscardBlock extends NodeMaterialBlock {
  123058. /**
  123059. * Create a new DiscardBlock
  123060. * @param name defines the block name
  123061. */
  123062. constructor(name: string);
  123063. /**
  123064. * Gets the current class name
  123065. * @returns the class name
  123066. */
  123067. getClassName(): string;
  123068. /**
  123069. * Gets the color input component
  123070. */
  123071. readonly value: NodeMaterialConnectionPoint;
  123072. /**
  123073. * Gets the cutoff input component
  123074. */
  123075. readonly cutoff: NodeMaterialConnectionPoint;
  123076. protected _buildBlock(state: NodeMaterialBuildState): this;
  123077. }
  123078. }
  123079. declare module BABYLON {
  123080. /**
  123081. * Block used to test if the fragment shader is front facing
  123082. */
  123083. export class FrontFacingBlock extends NodeMaterialBlock {
  123084. /**
  123085. * Creates a new FrontFacingBlock
  123086. * @param name defines the block name
  123087. */
  123088. constructor(name: string);
  123089. /**
  123090. * Gets the current class name
  123091. * @returns the class name
  123092. */
  123093. getClassName(): string;
  123094. /**
  123095. * Gets the output component
  123096. */
  123097. readonly output: NodeMaterialConnectionPoint;
  123098. protected _buildBlock(state: NodeMaterialBuildState): this;
  123099. }
  123100. }
  123101. declare module BABYLON {
  123102. /**
  123103. * Block used to add support for scene fog
  123104. */
  123105. export class FogBlock extends NodeMaterialBlock {
  123106. private _fogDistanceName;
  123107. private _fogParameters;
  123108. /**
  123109. * Create a new FogBlock
  123110. * @param name defines the block name
  123111. */
  123112. constructor(name: string);
  123113. /**
  123114. * Gets the current class name
  123115. * @returns the class name
  123116. */
  123117. getClassName(): string;
  123118. /**
  123119. * Gets the world position input component
  123120. */
  123121. readonly worldPosition: NodeMaterialConnectionPoint;
  123122. /**
  123123. * Gets the view input component
  123124. */
  123125. readonly view: NodeMaterialConnectionPoint;
  123126. /**
  123127. * Gets the color input component
  123128. */
  123129. readonly input: NodeMaterialConnectionPoint;
  123130. /**
  123131. * Gets the fog color input component
  123132. */
  123133. readonly fogColor: NodeMaterialConnectionPoint;
  123134. /**
  123135. * Gets the output component
  123136. */
  123137. readonly output: NodeMaterialConnectionPoint;
  123138. autoConfigure(material: NodeMaterial): void;
  123139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123141. protected _buildBlock(state: NodeMaterialBuildState): this;
  123142. }
  123143. }
  123144. declare module BABYLON {
  123145. /**
  123146. * Block used to add light in the fragment shader
  123147. */
  123148. export class LightBlock extends NodeMaterialBlock {
  123149. private _lightId;
  123150. /**
  123151. * Gets or sets the light associated with this block
  123152. */
  123153. light: Nullable<Light>;
  123154. /**
  123155. * Create a new LightBlock
  123156. * @param name defines the block name
  123157. */
  123158. constructor(name: string);
  123159. /**
  123160. * Gets the current class name
  123161. * @returns the class name
  123162. */
  123163. getClassName(): string;
  123164. /**
  123165. * Gets the world position input component
  123166. */
  123167. readonly worldPosition: NodeMaterialConnectionPoint;
  123168. /**
  123169. * Gets the world normal input component
  123170. */
  123171. readonly worldNormal: NodeMaterialConnectionPoint;
  123172. /**
  123173. * Gets the camera (or eye) position component
  123174. */
  123175. readonly cameraPosition: NodeMaterialConnectionPoint;
  123176. /**
  123177. * Gets the glossiness component
  123178. */
  123179. readonly glossiness: NodeMaterialConnectionPoint;
  123180. /**
  123181. * Gets the glossinness power component
  123182. */
  123183. readonly glossPower: NodeMaterialConnectionPoint;
  123184. /**
  123185. * Gets the diffuse color component
  123186. */
  123187. readonly diffuseColor: NodeMaterialConnectionPoint;
  123188. /**
  123189. * Gets the specular color component
  123190. */
  123191. readonly specularColor: NodeMaterialConnectionPoint;
  123192. /**
  123193. * Gets the diffuse output component
  123194. */
  123195. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123196. /**
  123197. * Gets the specular output component
  123198. */
  123199. readonly specularOutput: NodeMaterialConnectionPoint;
  123200. autoConfigure(material: NodeMaterial): void;
  123201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123202. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123204. private _injectVertexCode;
  123205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123206. serialize(): any;
  123207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123208. }
  123209. }
  123210. declare module BABYLON {
  123211. /**
  123212. * Block used to multiply 2 values
  123213. */
  123214. export class MultiplyBlock extends NodeMaterialBlock {
  123215. /**
  123216. * Creates a new MultiplyBlock
  123217. * @param name defines the block name
  123218. */
  123219. constructor(name: string);
  123220. /**
  123221. * Gets the current class name
  123222. * @returns the class name
  123223. */
  123224. getClassName(): string;
  123225. /**
  123226. * Gets the left operand input component
  123227. */
  123228. readonly left: NodeMaterialConnectionPoint;
  123229. /**
  123230. * Gets the right operand input component
  123231. */
  123232. readonly right: NodeMaterialConnectionPoint;
  123233. /**
  123234. * Gets the output component
  123235. */
  123236. readonly output: NodeMaterialConnectionPoint;
  123237. protected _buildBlock(state: NodeMaterialBuildState): this;
  123238. }
  123239. }
  123240. declare module BABYLON {
  123241. /**
  123242. * Block used to add 2 vectors
  123243. */
  123244. export class AddBlock extends NodeMaterialBlock {
  123245. /**
  123246. * Creates a new AddBlock
  123247. * @param name defines the block name
  123248. */
  123249. constructor(name: string);
  123250. /**
  123251. * Gets the current class name
  123252. * @returns the class name
  123253. */
  123254. getClassName(): string;
  123255. /**
  123256. * Gets the left operand input component
  123257. */
  123258. readonly left: NodeMaterialConnectionPoint;
  123259. /**
  123260. * Gets the right operand input component
  123261. */
  123262. readonly right: NodeMaterialConnectionPoint;
  123263. /**
  123264. * Gets the output component
  123265. */
  123266. readonly output: NodeMaterialConnectionPoint;
  123267. protected _buildBlock(state: NodeMaterialBuildState): this;
  123268. }
  123269. }
  123270. declare module BABYLON {
  123271. /**
  123272. * Block used to scale a vector by a float
  123273. */
  123274. export class ScaleBlock extends NodeMaterialBlock {
  123275. /**
  123276. * Creates a new ScaleBlock
  123277. * @param name defines the block name
  123278. */
  123279. constructor(name: string);
  123280. /**
  123281. * Gets the current class name
  123282. * @returns the class name
  123283. */
  123284. getClassName(): string;
  123285. /**
  123286. * Gets the input component
  123287. */
  123288. readonly input: NodeMaterialConnectionPoint;
  123289. /**
  123290. * Gets the factor input component
  123291. */
  123292. readonly factor: NodeMaterialConnectionPoint;
  123293. /**
  123294. * Gets the output component
  123295. */
  123296. readonly output: NodeMaterialConnectionPoint;
  123297. protected _buildBlock(state: NodeMaterialBuildState): this;
  123298. }
  123299. }
  123300. declare module BABYLON {
  123301. /**
  123302. * Block used to clamp a float
  123303. */
  123304. export class ClampBlock extends NodeMaterialBlock {
  123305. /** Gets or sets the minimum range */
  123306. minimum: number;
  123307. /** Gets or sets the maximum range */
  123308. maximum: number;
  123309. /**
  123310. * Creates a new ClampBlock
  123311. * @param name defines the block name
  123312. */
  123313. constructor(name: string);
  123314. /**
  123315. * Gets the current class name
  123316. * @returns the class name
  123317. */
  123318. getClassName(): string;
  123319. /**
  123320. * Gets the value input component
  123321. */
  123322. readonly value: NodeMaterialConnectionPoint;
  123323. /**
  123324. * Gets the output component
  123325. */
  123326. readonly output: NodeMaterialConnectionPoint;
  123327. protected _buildBlock(state: NodeMaterialBuildState): this;
  123328. protected _dumpPropertiesCode(): string;
  123329. serialize(): any;
  123330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123331. }
  123332. }
  123333. declare module BABYLON {
  123334. /**
  123335. * Block used to apply a cross product between 2 vectors
  123336. */
  123337. export class CrossBlock extends NodeMaterialBlock {
  123338. /**
  123339. * Creates a new CrossBlock
  123340. * @param name defines the block name
  123341. */
  123342. constructor(name: string);
  123343. /**
  123344. * Gets the current class name
  123345. * @returns the class name
  123346. */
  123347. getClassName(): string;
  123348. /**
  123349. * Gets the left operand input component
  123350. */
  123351. readonly left: NodeMaterialConnectionPoint;
  123352. /**
  123353. * Gets the right operand input component
  123354. */
  123355. readonly right: NodeMaterialConnectionPoint;
  123356. /**
  123357. * Gets the output component
  123358. */
  123359. readonly output: NodeMaterialConnectionPoint;
  123360. protected _buildBlock(state: NodeMaterialBuildState): this;
  123361. }
  123362. }
  123363. declare module BABYLON {
  123364. /**
  123365. * Block used to apply a dot product between 2 vectors
  123366. */
  123367. export class DotBlock extends NodeMaterialBlock {
  123368. /**
  123369. * Creates a new DotBlock
  123370. * @param name defines the block name
  123371. */
  123372. constructor(name: string);
  123373. /**
  123374. * Gets the current class name
  123375. * @returns the class name
  123376. */
  123377. getClassName(): string;
  123378. /**
  123379. * Gets the left operand input component
  123380. */
  123381. readonly left: NodeMaterialConnectionPoint;
  123382. /**
  123383. * Gets the right operand input component
  123384. */
  123385. readonly right: NodeMaterialConnectionPoint;
  123386. /**
  123387. * Gets the output component
  123388. */
  123389. readonly output: NodeMaterialConnectionPoint;
  123390. protected _buildBlock(state: NodeMaterialBuildState): this;
  123391. }
  123392. }
  123393. declare module BABYLON {
  123394. /**
  123395. * Block used to remap a float from a range to a new one
  123396. */
  123397. export class RemapBlock extends NodeMaterialBlock {
  123398. /**
  123399. * Gets or sets the source range
  123400. */
  123401. sourceRange: Vector2;
  123402. /**
  123403. * Gets or sets the target range
  123404. */
  123405. targetRange: Vector2;
  123406. /**
  123407. * Creates a new RemapBlock
  123408. * @param name defines the block name
  123409. */
  123410. constructor(name: string);
  123411. /**
  123412. * Gets the current class name
  123413. * @returns the class name
  123414. */
  123415. getClassName(): string;
  123416. /**
  123417. * Gets the input component
  123418. */
  123419. readonly input: NodeMaterialConnectionPoint;
  123420. /**
  123421. * Gets the source min input component
  123422. */
  123423. readonly sourceMin: NodeMaterialConnectionPoint;
  123424. /**
  123425. * Gets the source max input component
  123426. */
  123427. readonly sourceMax: NodeMaterialConnectionPoint;
  123428. /**
  123429. * Gets the target min input component
  123430. */
  123431. readonly targetMin: NodeMaterialConnectionPoint;
  123432. /**
  123433. * Gets the target max input component
  123434. */
  123435. readonly targetMax: NodeMaterialConnectionPoint;
  123436. /**
  123437. * Gets the output component
  123438. */
  123439. readonly output: NodeMaterialConnectionPoint;
  123440. protected _buildBlock(state: NodeMaterialBuildState): this;
  123441. protected _dumpPropertiesCode(): string;
  123442. serialize(): any;
  123443. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123444. }
  123445. }
  123446. declare module BABYLON {
  123447. /**
  123448. * Block used to normalize a vector
  123449. */
  123450. export class NormalizeBlock extends NodeMaterialBlock {
  123451. /**
  123452. * Creates a new NormalizeBlock
  123453. * @param name defines the block name
  123454. */
  123455. constructor(name: string);
  123456. /**
  123457. * Gets the current class name
  123458. * @returns the class name
  123459. */
  123460. getClassName(): string;
  123461. /**
  123462. * Gets the input component
  123463. */
  123464. readonly input: NodeMaterialConnectionPoint;
  123465. /**
  123466. * Gets the output component
  123467. */
  123468. readonly output: NodeMaterialConnectionPoint;
  123469. protected _buildBlock(state: NodeMaterialBuildState): this;
  123470. }
  123471. }
  123472. declare module BABYLON {
  123473. /**
  123474. * Operations supported by the Trigonometry block
  123475. */
  123476. export enum TrigonometryBlockOperations {
  123477. /** Cos */
  123478. Cos = 0,
  123479. /** Sin */
  123480. Sin = 1,
  123481. /** Abs */
  123482. Abs = 2,
  123483. /** Exp */
  123484. Exp = 3,
  123485. /** Exp2 */
  123486. Exp2 = 4,
  123487. /** Round */
  123488. Round = 5,
  123489. /** Floor */
  123490. Floor = 6,
  123491. /** Ceiling */
  123492. Ceiling = 7,
  123493. /** Square root */
  123494. Sqrt = 8,
  123495. /** Log */
  123496. Log = 9,
  123497. /** Tangent */
  123498. Tan = 10,
  123499. /** Arc tangent */
  123500. ArcTan = 11,
  123501. /** Arc cosinus */
  123502. ArcCos = 12,
  123503. /** Arc sinus */
  123504. ArcSin = 13,
  123505. /** Fraction */
  123506. Fract = 14,
  123507. /** Sign */
  123508. Sign = 15,
  123509. /** To radians (from degrees) */
  123510. Radians = 16,
  123511. /** To degrees (from radians) */
  123512. Degrees = 17
  123513. }
  123514. /**
  123515. * Block used to apply trigonometry operation to floats
  123516. */
  123517. export class TrigonometryBlock extends NodeMaterialBlock {
  123518. /**
  123519. * Gets or sets the operation applied by the block
  123520. */
  123521. operation: TrigonometryBlockOperations;
  123522. /**
  123523. * Creates a new TrigonometryBlock
  123524. * @param name defines the block name
  123525. */
  123526. constructor(name: string);
  123527. /**
  123528. * Gets the current class name
  123529. * @returns the class name
  123530. */
  123531. getClassName(): string;
  123532. /**
  123533. * Gets the input component
  123534. */
  123535. readonly input: NodeMaterialConnectionPoint;
  123536. /**
  123537. * Gets the output component
  123538. */
  123539. readonly output: NodeMaterialConnectionPoint;
  123540. protected _buildBlock(state: NodeMaterialBuildState): this;
  123541. serialize(): any;
  123542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123543. }
  123544. }
  123545. declare module BABYLON {
  123546. /**
  123547. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123548. */
  123549. export class ColorMergerBlock extends NodeMaterialBlock {
  123550. /**
  123551. * Create a new ColorMergerBlock
  123552. * @param name defines the block name
  123553. */
  123554. constructor(name: string);
  123555. /**
  123556. * Gets the current class name
  123557. * @returns the class name
  123558. */
  123559. getClassName(): string;
  123560. /**
  123561. * Gets the r component (input)
  123562. */
  123563. readonly r: NodeMaterialConnectionPoint;
  123564. /**
  123565. * Gets the g component (input)
  123566. */
  123567. readonly g: NodeMaterialConnectionPoint;
  123568. /**
  123569. * Gets the b component (input)
  123570. */
  123571. readonly b: NodeMaterialConnectionPoint;
  123572. /**
  123573. * Gets the a component (input)
  123574. */
  123575. readonly a: NodeMaterialConnectionPoint;
  123576. /**
  123577. * Gets the rgba component (output)
  123578. */
  123579. readonly rgba: NodeMaterialConnectionPoint;
  123580. /**
  123581. * Gets the rgb component (output)
  123582. */
  123583. readonly rgb: NodeMaterialConnectionPoint;
  123584. protected _buildBlock(state: NodeMaterialBuildState): this;
  123585. }
  123586. }
  123587. declare module BABYLON {
  123588. /**
  123589. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123590. */
  123591. export class VectorMergerBlock extends NodeMaterialBlock {
  123592. /**
  123593. * Create a new VectorMergerBlock
  123594. * @param name defines the block name
  123595. */
  123596. constructor(name: string);
  123597. /**
  123598. * Gets the current class name
  123599. * @returns the class name
  123600. */
  123601. getClassName(): string;
  123602. /**
  123603. * Gets the x component (input)
  123604. */
  123605. readonly x: NodeMaterialConnectionPoint;
  123606. /**
  123607. * Gets the y component (input)
  123608. */
  123609. readonly y: NodeMaterialConnectionPoint;
  123610. /**
  123611. * Gets the z component (input)
  123612. */
  123613. readonly z: NodeMaterialConnectionPoint;
  123614. /**
  123615. * Gets the w component (input)
  123616. */
  123617. readonly w: NodeMaterialConnectionPoint;
  123618. /**
  123619. * Gets the xyzw component (output)
  123620. */
  123621. readonly xyzw: NodeMaterialConnectionPoint;
  123622. /**
  123623. * Gets the xyz component (output)
  123624. */
  123625. readonly xyz: NodeMaterialConnectionPoint;
  123626. /**
  123627. * Gets the xy component (output)
  123628. */
  123629. readonly xy: NodeMaterialConnectionPoint;
  123630. protected _buildBlock(state: NodeMaterialBuildState): this;
  123631. }
  123632. }
  123633. declare module BABYLON {
  123634. /**
  123635. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123636. */
  123637. export class ColorSplitterBlock extends NodeMaterialBlock {
  123638. /**
  123639. * Create a new ColorSplitterBlock
  123640. * @param name defines the block name
  123641. */
  123642. constructor(name: string);
  123643. /**
  123644. * Gets the current class name
  123645. * @returns the class name
  123646. */
  123647. getClassName(): string;
  123648. /**
  123649. * Gets the rgba component (input)
  123650. */
  123651. readonly rgba: NodeMaterialConnectionPoint;
  123652. /**
  123653. * Gets the rgb component (input)
  123654. */
  123655. readonly rgbIn: NodeMaterialConnectionPoint;
  123656. /**
  123657. * Gets the rgb component (output)
  123658. */
  123659. readonly rgbOut: NodeMaterialConnectionPoint;
  123660. /**
  123661. * Gets the r component (output)
  123662. */
  123663. readonly r: NodeMaterialConnectionPoint;
  123664. /**
  123665. * Gets the g component (output)
  123666. */
  123667. readonly g: NodeMaterialConnectionPoint;
  123668. /**
  123669. * Gets the b component (output)
  123670. */
  123671. readonly b: NodeMaterialConnectionPoint;
  123672. /**
  123673. * Gets the a component (output)
  123674. */
  123675. readonly a: NodeMaterialConnectionPoint;
  123676. protected _inputRename(name: string): string;
  123677. protected _outputRename(name: string): string;
  123678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123679. }
  123680. }
  123681. declare module BABYLON {
  123682. /**
  123683. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  123684. */
  123685. export class VectorSplitterBlock extends NodeMaterialBlock {
  123686. /**
  123687. * Create a new VectorSplitterBlock
  123688. * @param name defines the block name
  123689. */
  123690. constructor(name: string);
  123691. /**
  123692. * Gets the current class name
  123693. * @returns the class name
  123694. */
  123695. getClassName(): string;
  123696. /**
  123697. * Gets the xyzw component (input)
  123698. */
  123699. readonly xyzw: NodeMaterialConnectionPoint;
  123700. /**
  123701. * Gets the xyz component (input)
  123702. */
  123703. readonly xyzIn: NodeMaterialConnectionPoint;
  123704. /**
  123705. * Gets the xy component (input)
  123706. */
  123707. readonly xyIn: NodeMaterialConnectionPoint;
  123708. /**
  123709. * Gets the xyz component (output)
  123710. */
  123711. readonly xyzOut: NodeMaterialConnectionPoint;
  123712. /**
  123713. * Gets the xy component (output)
  123714. */
  123715. readonly xyOut: NodeMaterialConnectionPoint;
  123716. /**
  123717. * Gets the x component (output)
  123718. */
  123719. readonly x: NodeMaterialConnectionPoint;
  123720. /**
  123721. * Gets the y component (output)
  123722. */
  123723. readonly y: NodeMaterialConnectionPoint;
  123724. /**
  123725. * Gets the z component (output)
  123726. */
  123727. readonly z: NodeMaterialConnectionPoint;
  123728. /**
  123729. * Gets the w component (output)
  123730. */
  123731. readonly w: NodeMaterialConnectionPoint;
  123732. protected _inputRename(name: string): string;
  123733. protected _outputRename(name: string): string;
  123734. protected _buildBlock(state: NodeMaterialBuildState): this;
  123735. }
  123736. }
  123737. declare module BABYLON {
  123738. /**
  123739. * Block used to lerp between 2 values
  123740. */
  123741. export class LerpBlock extends NodeMaterialBlock {
  123742. /**
  123743. * Creates a new LerpBlock
  123744. * @param name defines the block name
  123745. */
  123746. constructor(name: string);
  123747. /**
  123748. * Gets the current class name
  123749. * @returns the class name
  123750. */
  123751. getClassName(): string;
  123752. /**
  123753. * Gets the left operand input component
  123754. */
  123755. readonly left: NodeMaterialConnectionPoint;
  123756. /**
  123757. * Gets the right operand input component
  123758. */
  123759. readonly right: NodeMaterialConnectionPoint;
  123760. /**
  123761. * Gets the gradient operand input component
  123762. */
  123763. readonly gradient: NodeMaterialConnectionPoint;
  123764. /**
  123765. * Gets the output component
  123766. */
  123767. readonly output: NodeMaterialConnectionPoint;
  123768. protected _buildBlock(state: NodeMaterialBuildState): this;
  123769. }
  123770. }
  123771. declare module BABYLON {
  123772. /**
  123773. * Block used to divide 2 vectors
  123774. */
  123775. export class DivideBlock extends NodeMaterialBlock {
  123776. /**
  123777. * Creates a new DivideBlock
  123778. * @param name defines the block name
  123779. */
  123780. constructor(name: string);
  123781. /**
  123782. * Gets the current class name
  123783. * @returns the class name
  123784. */
  123785. getClassName(): string;
  123786. /**
  123787. * Gets the left operand input component
  123788. */
  123789. readonly left: NodeMaterialConnectionPoint;
  123790. /**
  123791. * Gets the right operand input component
  123792. */
  123793. readonly right: NodeMaterialConnectionPoint;
  123794. /**
  123795. * Gets the output component
  123796. */
  123797. readonly output: NodeMaterialConnectionPoint;
  123798. protected _buildBlock(state: NodeMaterialBuildState): this;
  123799. }
  123800. }
  123801. declare module BABYLON {
  123802. /**
  123803. * Block used to subtract 2 vectors
  123804. */
  123805. export class SubtractBlock extends NodeMaterialBlock {
  123806. /**
  123807. * Creates a new SubtractBlock
  123808. * @param name defines the block name
  123809. */
  123810. constructor(name: string);
  123811. /**
  123812. * Gets the current class name
  123813. * @returns the class name
  123814. */
  123815. getClassName(): string;
  123816. /**
  123817. * Gets the left operand input component
  123818. */
  123819. readonly left: NodeMaterialConnectionPoint;
  123820. /**
  123821. * Gets the right operand input component
  123822. */
  123823. readonly right: NodeMaterialConnectionPoint;
  123824. /**
  123825. * Gets the output component
  123826. */
  123827. readonly output: NodeMaterialConnectionPoint;
  123828. protected _buildBlock(state: NodeMaterialBuildState): this;
  123829. }
  123830. }
  123831. declare module BABYLON {
  123832. /**
  123833. * Block used to step a value
  123834. */
  123835. export class StepBlock extends NodeMaterialBlock {
  123836. /**
  123837. * Creates a new StepBlock
  123838. * @param name defines the block name
  123839. */
  123840. constructor(name: string);
  123841. /**
  123842. * Gets the current class name
  123843. * @returns the class name
  123844. */
  123845. getClassName(): string;
  123846. /**
  123847. * Gets the value operand input component
  123848. */
  123849. readonly value: NodeMaterialConnectionPoint;
  123850. /**
  123851. * Gets the edge operand input component
  123852. */
  123853. readonly edge: NodeMaterialConnectionPoint;
  123854. /**
  123855. * Gets the output component
  123856. */
  123857. readonly output: NodeMaterialConnectionPoint;
  123858. protected _buildBlock(state: NodeMaterialBuildState): this;
  123859. }
  123860. }
  123861. declare module BABYLON {
  123862. /**
  123863. * Block used to get the opposite (1 - x) of a value
  123864. */
  123865. export class OneMinusBlock extends NodeMaterialBlock {
  123866. /**
  123867. * Creates a new OneMinusBlock
  123868. * @param name defines the block name
  123869. */
  123870. constructor(name: string);
  123871. /**
  123872. * Gets the current class name
  123873. * @returns the class name
  123874. */
  123875. getClassName(): string;
  123876. /**
  123877. * Gets the input component
  123878. */
  123879. readonly input: NodeMaterialConnectionPoint;
  123880. /**
  123881. * Gets the output component
  123882. */
  123883. readonly output: NodeMaterialConnectionPoint;
  123884. protected _buildBlock(state: NodeMaterialBuildState): this;
  123885. }
  123886. }
  123887. declare module BABYLON {
  123888. /**
  123889. * Block used to get the view direction
  123890. */
  123891. export class ViewDirectionBlock extends NodeMaterialBlock {
  123892. /**
  123893. * Creates a new ViewDirectionBlock
  123894. * @param name defines the block name
  123895. */
  123896. constructor(name: string);
  123897. /**
  123898. * Gets the current class name
  123899. * @returns the class name
  123900. */
  123901. getClassName(): string;
  123902. /**
  123903. * Gets the world position component
  123904. */
  123905. readonly worldPosition: NodeMaterialConnectionPoint;
  123906. /**
  123907. * Gets the camera position component
  123908. */
  123909. readonly cameraPosition: NodeMaterialConnectionPoint;
  123910. /**
  123911. * Gets the output component
  123912. */
  123913. readonly output: NodeMaterialConnectionPoint;
  123914. autoConfigure(material: NodeMaterial): void;
  123915. protected _buildBlock(state: NodeMaterialBuildState): this;
  123916. }
  123917. }
  123918. declare module BABYLON {
  123919. /**
  123920. * Block used to compute fresnel value
  123921. */
  123922. export class FresnelBlock extends NodeMaterialBlock {
  123923. /**
  123924. * Create a new FresnelBlock
  123925. * @param name defines the block name
  123926. */
  123927. constructor(name: string);
  123928. /**
  123929. * Gets the current class name
  123930. * @returns the class name
  123931. */
  123932. getClassName(): string;
  123933. /**
  123934. * Gets the world normal input component
  123935. */
  123936. readonly worldNormal: NodeMaterialConnectionPoint;
  123937. /**
  123938. * Gets the view direction input component
  123939. */
  123940. readonly viewDirection: NodeMaterialConnectionPoint;
  123941. /**
  123942. * Gets the bias input component
  123943. */
  123944. readonly bias: NodeMaterialConnectionPoint;
  123945. /**
  123946. * Gets the camera (or eye) position component
  123947. */
  123948. readonly power: NodeMaterialConnectionPoint;
  123949. /**
  123950. * Gets the fresnel output component
  123951. */
  123952. readonly fresnel: NodeMaterialConnectionPoint;
  123953. autoConfigure(material: NodeMaterial): void;
  123954. protected _buildBlock(state: NodeMaterialBuildState): this;
  123955. }
  123956. }
  123957. declare module BABYLON {
  123958. /**
  123959. * Block used to get the max of 2 values
  123960. */
  123961. export class MaxBlock extends NodeMaterialBlock {
  123962. /**
  123963. * Creates a new MaxBlock
  123964. * @param name defines the block name
  123965. */
  123966. constructor(name: string);
  123967. /**
  123968. * Gets the current class name
  123969. * @returns the class name
  123970. */
  123971. getClassName(): string;
  123972. /**
  123973. * Gets the left operand input component
  123974. */
  123975. readonly left: NodeMaterialConnectionPoint;
  123976. /**
  123977. * Gets the right operand input component
  123978. */
  123979. readonly right: NodeMaterialConnectionPoint;
  123980. /**
  123981. * Gets the output component
  123982. */
  123983. readonly output: NodeMaterialConnectionPoint;
  123984. protected _buildBlock(state: NodeMaterialBuildState): this;
  123985. }
  123986. }
  123987. declare module BABYLON {
  123988. /**
  123989. * Block used to get the min of 2 values
  123990. */
  123991. export class MinBlock extends NodeMaterialBlock {
  123992. /**
  123993. * Creates a new MinBlock
  123994. * @param name defines the block name
  123995. */
  123996. constructor(name: string);
  123997. /**
  123998. * Gets the current class name
  123999. * @returns the class name
  124000. */
  124001. getClassName(): string;
  124002. /**
  124003. * Gets the left operand input component
  124004. */
  124005. readonly left: NodeMaterialConnectionPoint;
  124006. /**
  124007. * Gets the right operand input component
  124008. */
  124009. readonly right: NodeMaterialConnectionPoint;
  124010. /**
  124011. * Gets the output component
  124012. */
  124013. readonly output: NodeMaterialConnectionPoint;
  124014. protected _buildBlock(state: NodeMaterialBuildState): this;
  124015. }
  124016. }
  124017. declare module BABYLON {
  124018. /**
  124019. * Block used to get the distance between 2 values
  124020. */
  124021. export class DistanceBlock extends NodeMaterialBlock {
  124022. /**
  124023. * Creates a new DistanceBlock
  124024. * @param name defines the block name
  124025. */
  124026. constructor(name: string);
  124027. /**
  124028. * Gets the current class name
  124029. * @returns the class name
  124030. */
  124031. getClassName(): string;
  124032. /**
  124033. * Gets the left operand input component
  124034. */
  124035. readonly left: NodeMaterialConnectionPoint;
  124036. /**
  124037. * Gets the right operand input component
  124038. */
  124039. readonly right: NodeMaterialConnectionPoint;
  124040. /**
  124041. * Gets the output component
  124042. */
  124043. readonly output: NodeMaterialConnectionPoint;
  124044. protected _buildBlock(state: NodeMaterialBuildState): this;
  124045. }
  124046. }
  124047. declare module BABYLON {
  124048. /**
  124049. * Block used to get the length of a vector
  124050. */
  124051. export class LengthBlock extends NodeMaterialBlock {
  124052. /**
  124053. * Creates a new LengthBlock
  124054. * @param name defines the block name
  124055. */
  124056. constructor(name: string);
  124057. /**
  124058. * Gets the current class name
  124059. * @returns the class name
  124060. */
  124061. getClassName(): string;
  124062. /**
  124063. * Gets the value input component
  124064. */
  124065. readonly value: NodeMaterialConnectionPoint;
  124066. /**
  124067. * Gets the output component
  124068. */
  124069. readonly output: NodeMaterialConnectionPoint;
  124070. protected _buildBlock(state: NodeMaterialBuildState): this;
  124071. }
  124072. }
  124073. declare module BABYLON {
  124074. /**
  124075. * Block used to get negative version of a value (i.e. x * -1)
  124076. */
  124077. export class NegateBlock extends NodeMaterialBlock {
  124078. /**
  124079. * Creates a new NegateBlock
  124080. * @param name defines the block name
  124081. */
  124082. constructor(name: string);
  124083. /**
  124084. * Gets the current class name
  124085. * @returns the class name
  124086. */
  124087. getClassName(): string;
  124088. /**
  124089. * Gets the value input component
  124090. */
  124091. readonly value: NodeMaterialConnectionPoint;
  124092. /**
  124093. * Gets the output component
  124094. */
  124095. readonly output: NodeMaterialConnectionPoint;
  124096. protected _buildBlock(state: NodeMaterialBuildState): this;
  124097. }
  124098. }
  124099. declare module BABYLON {
  124100. /**
  124101. * Block used to get the value of the first parameter raised to the power of the second
  124102. */
  124103. export class PowBlock extends NodeMaterialBlock {
  124104. /**
  124105. * Creates a new PowBlock
  124106. * @param name defines the block name
  124107. */
  124108. constructor(name: string);
  124109. /**
  124110. * Gets the current class name
  124111. * @returns the class name
  124112. */
  124113. getClassName(): string;
  124114. /**
  124115. * Gets the value operand input component
  124116. */
  124117. readonly value: NodeMaterialConnectionPoint;
  124118. /**
  124119. * Gets the power operand input component
  124120. */
  124121. readonly power: NodeMaterialConnectionPoint;
  124122. /**
  124123. * Gets the output component
  124124. */
  124125. readonly output: NodeMaterialConnectionPoint;
  124126. protected _buildBlock(state: NodeMaterialBuildState): this;
  124127. }
  124128. }
  124129. declare module BABYLON {
  124130. /**
  124131. * Block used to get a random number
  124132. */
  124133. export class RandomNumberBlock extends NodeMaterialBlock {
  124134. /**
  124135. * Creates a new RandomNumberBlock
  124136. * @param name defines the block name
  124137. */
  124138. constructor(name: string);
  124139. /**
  124140. * Gets the current class name
  124141. * @returns the class name
  124142. */
  124143. getClassName(): string;
  124144. /**
  124145. * Gets the seed input component
  124146. */
  124147. readonly seed: NodeMaterialConnectionPoint;
  124148. /**
  124149. * Gets the output component
  124150. */
  124151. readonly output: NodeMaterialConnectionPoint;
  124152. protected _buildBlock(state: NodeMaterialBuildState): this;
  124153. }
  124154. }
  124155. declare module BABYLON {
  124156. /**
  124157. * Block used to compute arc tangent of 2 values
  124158. */
  124159. export class ArcTan2Block extends NodeMaterialBlock {
  124160. /**
  124161. * Creates a new ArcTan2Block
  124162. * @param name defines the block name
  124163. */
  124164. constructor(name: string);
  124165. /**
  124166. * Gets the current class name
  124167. * @returns the class name
  124168. */
  124169. getClassName(): string;
  124170. /**
  124171. * Gets the x operand input component
  124172. */
  124173. readonly x: NodeMaterialConnectionPoint;
  124174. /**
  124175. * Gets the y operand input component
  124176. */
  124177. readonly y: NodeMaterialConnectionPoint;
  124178. /**
  124179. * Gets the output component
  124180. */
  124181. readonly output: NodeMaterialConnectionPoint;
  124182. protected _buildBlock(state: NodeMaterialBuildState): this;
  124183. }
  124184. }
  124185. declare module BABYLON {
  124186. /**
  124187. * Block used to smooth step a value
  124188. */
  124189. export class SmoothStepBlock extends NodeMaterialBlock {
  124190. /**
  124191. * Creates a new SmoothStepBlock
  124192. * @param name defines the block name
  124193. */
  124194. constructor(name: string);
  124195. /**
  124196. * Gets the current class name
  124197. * @returns the class name
  124198. */
  124199. getClassName(): string;
  124200. /**
  124201. * Gets the value operand input component
  124202. */
  124203. readonly value: NodeMaterialConnectionPoint;
  124204. /**
  124205. * Gets the first edge operand input component
  124206. */
  124207. readonly edge0: NodeMaterialConnectionPoint;
  124208. /**
  124209. * Gets the second edge operand input component
  124210. */
  124211. readonly edge1: NodeMaterialConnectionPoint;
  124212. /**
  124213. * Gets the output component
  124214. */
  124215. readonly output: NodeMaterialConnectionPoint;
  124216. protected _buildBlock(state: NodeMaterialBuildState): this;
  124217. }
  124218. }
  124219. declare module BABYLON {
  124220. /**
  124221. * Block used to get the reciprocal (1 / x) of a value
  124222. */
  124223. export class ReciprocalBlock extends NodeMaterialBlock {
  124224. /**
  124225. * Creates a new ReciprocalBlock
  124226. * @param name defines the block name
  124227. */
  124228. constructor(name: string);
  124229. /**
  124230. * Gets the current class name
  124231. * @returns the class name
  124232. */
  124233. getClassName(): string;
  124234. /**
  124235. * Gets the input component
  124236. */
  124237. readonly input: NodeMaterialConnectionPoint;
  124238. /**
  124239. * Gets the output component
  124240. */
  124241. readonly output: NodeMaterialConnectionPoint;
  124242. protected _buildBlock(state: NodeMaterialBuildState): this;
  124243. }
  124244. }
  124245. declare module BABYLON {
  124246. /**
  124247. * Block used to replace a color by another one
  124248. */
  124249. export class ReplaceColorBlock extends NodeMaterialBlock {
  124250. /**
  124251. * Creates a new ReplaceColorBlock
  124252. * @param name defines the block name
  124253. */
  124254. constructor(name: string);
  124255. /**
  124256. * Gets the current class name
  124257. * @returns the class name
  124258. */
  124259. getClassName(): string;
  124260. /**
  124261. * Gets the value input component
  124262. */
  124263. readonly value: NodeMaterialConnectionPoint;
  124264. /**
  124265. * Gets the reference input component
  124266. */
  124267. readonly reference: NodeMaterialConnectionPoint;
  124268. /**
  124269. * Gets the distance input component
  124270. */
  124271. readonly distance: NodeMaterialConnectionPoint;
  124272. /**
  124273. * Gets the replacement input component
  124274. */
  124275. readonly replacement: NodeMaterialConnectionPoint;
  124276. /**
  124277. * Gets the output component
  124278. */
  124279. readonly output: NodeMaterialConnectionPoint;
  124280. protected _buildBlock(state: NodeMaterialBuildState): this;
  124281. }
  124282. }
  124283. declare module BABYLON {
  124284. /**
  124285. * Block used to posterize a value
  124286. * @see https://en.wikipedia.org/wiki/Posterization
  124287. */
  124288. export class PosterizeBlock extends NodeMaterialBlock {
  124289. /**
  124290. * Creates a new PosterizeBlock
  124291. * @param name defines the block name
  124292. */
  124293. constructor(name: string);
  124294. /**
  124295. * Gets the current class name
  124296. * @returns the class name
  124297. */
  124298. getClassName(): string;
  124299. /**
  124300. * Gets the value input component
  124301. */
  124302. readonly value: NodeMaterialConnectionPoint;
  124303. /**
  124304. * Gets the steps input component
  124305. */
  124306. readonly steps: NodeMaterialConnectionPoint;
  124307. /**
  124308. * Gets the output component
  124309. */
  124310. readonly output: NodeMaterialConnectionPoint;
  124311. protected _buildBlock(state: NodeMaterialBuildState): this;
  124312. }
  124313. }
  124314. declare module BABYLON {
  124315. /**
  124316. * Operations supported by the Wave block
  124317. */
  124318. export enum WaveBlockKind {
  124319. /** SawTooth */
  124320. SawTooth = 0,
  124321. /** Square */
  124322. Square = 1,
  124323. /** Triangle */
  124324. Triangle = 2
  124325. }
  124326. /**
  124327. * Block used to apply wave operation to floats
  124328. */
  124329. export class WaveBlock extends NodeMaterialBlock {
  124330. /**
  124331. * Gets or sets the kibnd of wave to be applied by the block
  124332. */
  124333. kind: WaveBlockKind;
  124334. /**
  124335. * Creates a new WaveBlock
  124336. * @param name defines the block name
  124337. */
  124338. constructor(name: string);
  124339. /**
  124340. * Gets the current class name
  124341. * @returns the class name
  124342. */
  124343. getClassName(): string;
  124344. /**
  124345. * Gets the input component
  124346. */
  124347. readonly input: NodeMaterialConnectionPoint;
  124348. /**
  124349. * Gets the output component
  124350. */
  124351. readonly output: NodeMaterialConnectionPoint;
  124352. protected _buildBlock(state: NodeMaterialBuildState): this;
  124353. serialize(): any;
  124354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124355. }
  124356. }
  124357. declare module BABYLON {
  124358. /**
  124359. * Class used to store a color step for the GradientBlock
  124360. */
  124361. export class GradientBlockColorStep {
  124362. /**
  124363. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124364. */
  124365. step: number;
  124366. /**
  124367. * Gets or sets the color associated with this step
  124368. */
  124369. color: Color3;
  124370. /**
  124371. * Creates a new GradientBlockColorStep
  124372. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124373. * @param color defines the color associated with this step
  124374. */
  124375. constructor(
  124376. /**
  124377. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124378. */
  124379. step: number,
  124380. /**
  124381. * Gets or sets the color associated with this step
  124382. */
  124383. color: Color3);
  124384. }
  124385. /**
  124386. * Block used to return a color from a gradient based on an input value between 0 and 1
  124387. */
  124388. export class GradientBlock extends NodeMaterialBlock {
  124389. /**
  124390. * Gets or sets the list of color steps
  124391. */
  124392. colorSteps: GradientBlockColorStep[];
  124393. /**
  124394. * Creates a new GradientBlock
  124395. * @param name defines the block name
  124396. */
  124397. constructor(name: string);
  124398. /**
  124399. * Gets the current class name
  124400. * @returns the class name
  124401. */
  124402. getClassName(): string;
  124403. /**
  124404. * Gets the gradient input component
  124405. */
  124406. readonly gradient: NodeMaterialConnectionPoint;
  124407. /**
  124408. * Gets the output component
  124409. */
  124410. readonly output: NodeMaterialConnectionPoint;
  124411. private _writeColorConstant;
  124412. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124413. serialize(): any;
  124414. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124415. protected _dumpPropertiesCode(): string;
  124416. }
  124417. }
  124418. declare module BABYLON {
  124419. /**
  124420. * Block used to normalize lerp between 2 values
  124421. */
  124422. export class NLerpBlock extends NodeMaterialBlock {
  124423. /**
  124424. * Creates a new NLerpBlock
  124425. * @param name defines the block name
  124426. */
  124427. constructor(name: string);
  124428. /**
  124429. * Gets the current class name
  124430. * @returns the class name
  124431. */
  124432. getClassName(): string;
  124433. /**
  124434. * Gets the left operand input component
  124435. */
  124436. readonly left: NodeMaterialConnectionPoint;
  124437. /**
  124438. * Gets the right operand input component
  124439. */
  124440. readonly right: NodeMaterialConnectionPoint;
  124441. /**
  124442. * Gets the gradient operand input component
  124443. */
  124444. readonly gradient: NodeMaterialConnectionPoint;
  124445. /**
  124446. * Gets the output component
  124447. */
  124448. readonly output: NodeMaterialConnectionPoint;
  124449. protected _buildBlock(state: NodeMaterialBuildState): this;
  124450. }
  124451. }
  124452. declare module BABYLON {
  124453. /**
  124454. * Effect Render Options
  124455. */
  124456. export interface IEffectRendererOptions {
  124457. /**
  124458. * Defines the vertices positions.
  124459. */
  124460. positions?: number[];
  124461. /**
  124462. * Defines the indices.
  124463. */
  124464. indices?: number[];
  124465. }
  124466. /**
  124467. * Helper class to render one or more effects
  124468. */
  124469. export class EffectRenderer {
  124470. private engine;
  124471. private static _DefaultOptions;
  124472. private _vertexBuffers;
  124473. private _indexBuffer;
  124474. private _ringBufferIndex;
  124475. private _ringScreenBuffer;
  124476. private _fullscreenViewport;
  124477. private _getNextFrameBuffer;
  124478. /**
  124479. * Creates an effect renderer
  124480. * @param engine the engine to use for rendering
  124481. * @param options defines the options of the effect renderer
  124482. */
  124483. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124484. /**
  124485. * Sets the current viewport in normalized coordinates 0-1
  124486. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124487. */
  124488. setViewport(viewport?: Viewport): void;
  124489. /**
  124490. * Binds the embedded attributes buffer to the effect.
  124491. * @param effect Defines the effect to bind the attributes for
  124492. */
  124493. bindBuffers(effect: Effect): void;
  124494. /**
  124495. * Sets the current effect wrapper to use during draw.
  124496. * The effect needs to be ready before calling this api.
  124497. * This also sets the default full screen position attribute.
  124498. * @param effectWrapper Defines the effect to draw with
  124499. */
  124500. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124501. /**
  124502. * Draws a full screen quad.
  124503. */
  124504. draw(): void;
  124505. /**
  124506. * renders one or more effects to a specified texture
  124507. * @param effectWrappers list of effects to renderer
  124508. * @param outputTexture texture to draw to, if null it will render to the screen
  124509. */
  124510. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124511. /**
  124512. * Disposes of the effect renderer
  124513. */
  124514. dispose(): void;
  124515. }
  124516. /**
  124517. * Options to create an EffectWrapper
  124518. */
  124519. interface EffectWrapperCreationOptions {
  124520. /**
  124521. * Engine to use to create the effect
  124522. */
  124523. engine: ThinEngine;
  124524. /**
  124525. * Fragment shader for the effect
  124526. */
  124527. fragmentShader: string;
  124528. /**
  124529. * Vertex shader for the effect
  124530. */
  124531. vertexShader?: string;
  124532. /**
  124533. * Attributes to use in the shader
  124534. */
  124535. attributeNames?: Array<string>;
  124536. /**
  124537. * Uniforms to use in the shader
  124538. */
  124539. uniformNames?: Array<string>;
  124540. /**
  124541. * Texture sampler names to use in the shader
  124542. */
  124543. samplerNames?: Array<string>;
  124544. /**
  124545. * The friendly name of the effect displayed in Spector.
  124546. */
  124547. name?: string;
  124548. }
  124549. /**
  124550. * Wraps an effect to be used for rendering
  124551. */
  124552. export class EffectWrapper {
  124553. /**
  124554. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  124555. */
  124556. onApplyObservable: Observable<{}>;
  124557. /**
  124558. * The underlying effect
  124559. */
  124560. effect: Effect;
  124561. /**
  124562. * Creates an effect to be renderer
  124563. * @param creationOptions options to create the effect
  124564. */
  124565. constructor(creationOptions: EffectWrapperCreationOptions);
  124566. /**
  124567. * Disposes of the effect wrapper
  124568. */
  124569. dispose(): void;
  124570. }
  124571. }
  124572. declare module BABYLON {
  124573. /**
  124574. * Helper class to push actions to a pool of workers.
  124575. */
  124576. export class WorkerPool implements IDisposable {
  124577. private _workerInfos;
  124578. private _pendingActions;
  124579. /**
  124580. * Constructor
  124581. * @param workers Array of workers to use for actions
  124582. */
  124583. constructor(workers: Array<Worker>);
  124584. /**
  124585. * Terminates all workers and clears any pending actions.
  124586. */
  124587. dispose(): void;
  124588. /**
  124589. * Pushes an action to the worker pool. If all the workers are active, the action will be
  124590. * pended until a worker has completed its action.
  124591. * @param action The action to perform. Call onComplete when the action is complete.
  124592. */
  124593. push(action: (worker: Worker, onComplete: () => void) => void): void;
  124594. private _execute;
  124595. }
  124596. }
  124597. declare module BABYLON {
  124598. /**
  124599. * Configuration for Draco compression
  124600. */
  124601. export interface IDracoCompressionConfiguration {
  124602. /**
  124603. * Configuration for the decoder.
  124604. */
  124605. decoder: {
  124606. /**
  124607. * The url to the WebAssembly module.
  124608. */
  124609. wasmUrl?: string;
  124610. /**
  124611. * The url to the WebAssembly binary.
  124612. */
  124613. wasmBinaryUrl?: string;
  124614. /**
  124615. * The url to the fallback JavaScript module.
  124616. */
  124617. fallbackUrl?: string;
  124618. };
  124619. }
  124620. /**
  124621. * Draco compression (https://google.github.io/draco/)
  124622. *
  124623. * This class wraps the Draco module.
  124624. *
  124625. * **Encoder**
  124626. *
  124627. * The encoder is not currently implemented.
  124628. *
  124629. * **Decoder**
  124630. *
  124631. * 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.
  124632. *
  124633. * To update the configuration, use the following code:
  124634. * ```javascript
  124635. * DracoCompression.Configuration = {
  124636. * decoder: {
  124637. * wasmUrl: "<url to the WebAssembly library>",
  124638. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  124639. * fallbackUrl: "<url to the fallback JavaScript library>",
  124640. * }
  124641. * };
  124642. * ```
  124643. *
  124644. * 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.
  124645. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  124646. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  124647. *
  124648. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  124649. * ```javascript
  124650. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  124651. * ```
  124652. *
  124653. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  124654. */
  124655. export class DracoCompression implements IDisposable {
  124656. private _workerPoolPromise?;
  124657. private _decoderModulePromise?;
  124658. /**
  124659. * The configuration. Defaults to the following urls:
  124660. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  124661. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  124662. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  124663. */
  124664. static Configuration: IDracoCompressionConfiguration;
  124665. /**
  124666. * Returns true if the decoder configuration is available.
  124667. */
  124668. static readonly DecoderAvailable: boolean;
  124669. /**
  124670. * Default number of workers to create when creating the draco compression object.
  124671. */
  124672. static DefaultNumWorkers: number;
  124673. private static GetDefaultNumWorkers;
  124674. private static _Default;
  124675. /**
  124676. * Default instance for the draco compression object.
  124677. */
  124678. static readonly Default: DracoCompression;
  124679. /**
  124680. * Constructor
  124681. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  124682. */
  124683. constructor(numWorkers?: number);
  124684. /**
  124685. * Stop all async operations and release resources.
  124686. */
  124687. dispose(): void;
  124688. /**
  124689. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  124690. * @returns a promise that resolves when ready
  124691. */
  124692. whenReadyAsync(): Promise<void>;
  124693. /**
  124694. * Decode Draco compressed mesh data to vertex data.
  124695. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  124696. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  124697. * @returns A promise that resolves with the decoded vertex data
  124698. */
  124699. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  124700. [kind: string]: number;
  124701. }): Promise<VertexData>;
  124702. }
  124703. }
  124704. declare module BABYLON {
  124705. /**
  124706. * Class for building Constructive Solid Geometry
  124707. */
  124708. export class CSG {
  124709. private polygons;
  124710. /**
  124711. * The world matrix
  124712. */
  124713. matrix: Matrix;
  124714. /**
  124715. * Stores the position
  124716. */
  124717. position: Vector3;
  124718. /**
  124719. * Stores the rotation
  124720. */
  124721. rotation: Vector3;
  124722. /**
  124723. * Stores the rotation quaternion
  124724. */
  124725. rotationQuaternion: Nullable<Quaternion>;
  124726. /**
  124727. * Stores the scaling vector
  124728. */
  124729. scaling: Vector3;
  124730. /**
  124731. * Convert the Mesh to CSG
  124732. * @param mesh The Mesh to convert to CSG
  124733. * @returns A new CSG from the Mesh
  124734. */
  124735. static FromMesh(mesh: Mesh): CSG;
  124736. /**
  124737. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  124738. * @param polygons Polygons used to construct a CSG solid
  124739. */
  124740. private static FromPolygons;
  124741. /**
  124742. * Clones, or makes a deep copy, of the CSG
  124743. * @returns A new CSG
  124744. */
  124745. clone(): CSG;
  124746. /**
  124747. * Unions this CSG with another CSG
  124748. * @param csg The CSG to union against this CSG
  124749. * @returns The unioned CSG
  124750. */
  124751. union(csg: CSG): CSG;
  124752. /**
  124753. * Unions this CSG with another CSG in place
  124754. * @param csg The CSG to union against this CSG
  124755. */
  124756. unionInPlace(csg: CSG): void;
  124757. /**
  124758. * Subtracts this CSG with another CSG
  124759. * @param csg The CSG to subtract against this CSG
  124760. * @returns A new CSG
  124761. */
  124762. subtract(csg: CSG): CSG;
  124763. /**
  124764. * Subtracts this CSG with another CSG in place
  124765. * @param csg The CSG to subtact against this CSG
  124766. */
  124767. subtractInPlace(csg: CSG): void;
  124768. /**
  124769. * Intersect this CSG with another CSG
  124770. * @param csg The CSG to intersect against this CSG
  124771. * @returns A new CSG
  124772. */
  124773. intersect(csg: CSG): CSG;
  124774. /**
  124775. * Intersects this CSG with another CSG in place
  124776. * @param csg The CSG to intersect against this CSG
  124777. */
  124778. intersectInPlace(csg: CSG): void;
  124779. /**
  124780. * Return a new CSG solid with solid and empty space switched. This solid is
  124781. * not modified.
  124782. * @returns A new CSG solid with solid and empty space switched
  124783. */
  124784. inverse(): CSG;
  124785. /**
  124786. * Inverses the CSG in place
  124787. */
  124788. inverseInPlace(): void;
  124789. /**
  124790. * This is used to keep meshes transformations so they can be restored
  124791. * when we build back a Babylon Mesh
  124792. * NB : All CSG operations are performed in world coordinates
  124793. * @param csg The CSG to copy the transform attributes from
  124794. * @returns This CSG
  124795. */
  124796. copyTransformAttributes(csg: CSG): CSG;
  124797. /**
  124798. * Build Raw mesh from CSG
  124799. * Coordinates here are in world space
  124800. * @param name The name of the mesh geometry
  124801. * @param scene The Scene
  124802. * @param keepSubMeshes Specifies if the submeshes should be kept
  124803. * @returns A new Mesh
  124804. */
  124805. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124806. /**
  124807. * Build Mesh from CSG taking material and transforms into account
  124808. * @param name The name of the Mesh
  124809. * @param material The material of the Mesh
  124810. * @param scene The Scene
  124811. * @param keepSubMeshes Specifies if submeshes should be kept
  124812. * @returns The new Mesh
  124813. */
  124814. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  124815. }
  124816. }
  124817. declare module BABYLON {
  124818. /**
  124819. * Class used to create a trail following a mesh
  124820. */
  124821. export class TrailMesh extends Mesh {
  124822. private _generator;
  124823. private _autoStart;
  124824. private _running;
  124825. private _diameter;
  124826. private _length;
  124827. private _sectionPolygonPointsCount;
  124828. private _sectionVectors;
  124829. private _sectionNormalVectors;
  124830. private _beforeRenderObserver;
  124831. /**
  124832. * @constructor
  124833. * @param name The value used by scene.getMeshByName() to do a lookup.
  124834. * @param generator The mesh to generate a trail.
  124835. * @param scene The scene to add this mesh to.
  124836. * @param diameter Diameter of trailing mesh. Default is 1.
  124837. * @param length Length of trailing mesh. Default is 60.
  124838. * @param autoStart Automatically start trailing mesh. Default true.
  124839. */
  124840. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  124841. /**
  124842. * "TrailMesh"
  124843. * @returns "TrailMesh"
  124844. */
  124845. getClassName(): string;
  124846. private _createMesh;
  124847. /**
  124848. * Start trailing mesh.
  124849. */
  124850. start(): void;
  124851. /**
  124852. * Stop trailing mesh.
  124853. */
  124854. stop(): void;
  124855. /**
  124856. * Update trailing mesh geometry.
  124857. */
  124858. update(): void;
  124859. /**
  124860. * Returns a new TrailMesh object.
  124861. * @param name is a string, the name given to the new mesh
  124862. * @param newGenerator use new generator object for cloned trail mesh
  124863. * @returns a new mesh
  124864. */
  124865. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  124866. /**
  124867. * Serializes this trail mesh
  124868. * @param serializationObject object to write serialization to
  124869. */
  124870. serialize(serializationObject: any): void;
  124871. /**
  124872. * Parses a serialized trail mesh
  124873. * @param parsedMesh the serialized mesh
  124874. * @param scene the scene to create the trail mesh in
  124875. * @returns the created trail mesh
  124876. */
  124877. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  124878. }
  124879. }
  124880. declare module BABYLON {
  124881. /**
  124882. * Class containing static functions to help procedurally build meshes
  124883. */
  124884. export class TiledBoxBuilder {
  124885. /**
  124886. * Creates a box mesh
  124887. * 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)
  124888. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124892. * @param name defines the name of the mesh
  124893. * @param options defines the options used to create the mesh
  124894. * @param scene defines the hosting scene
  124895. * @returns the box mesh
  124896. */
  124897. static CreateTiledBox(name: string, options: {
  124898. pattern?: number;
  124899. width?: number;
  124900. height?: number;
  124901. depth?: number;
  124902. tileSize?: number;
  124903. tileWidth?: number;
  124904. tileHeight?: number;
  124905. alignHorizontal?: number;
  124906. alignVertical?: number;
  124907. faceUV?: Vector4[];
  124908. faceColors?: Color4[];
  124909. sideOrientation?: number;
  124910. updatable?: boolean;
  124911. }, scene?: Nullable<Scene>): Mesh;
  124912. }
  124913. }
  124914. declare module BABYLON {
  124915. /**
  124916. * Class containing static functions to help procedurally build meshes
  124917. */
  124918. export class TorusKnotBuilder {
  124919. /**
  124920. * Creates a torus knot mesh
  124921. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124922. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124923. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124924. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124928. * @param name defines the name of the mesh
  124929. * @param options defines the options used to create the mesh
  124930. * @param scene defines the hosting scene
  124931. * @returns the torus knot mesh
  124932. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124933. */
  124934. static CreateTorusKnot(name: string, options: {
  124935. radius?: number;
  124936. tube?: number;
  124937. radialSegments?: number;
  124938. tubularSegments?: number;
  124939. p?: number;
  124940. q?: number;
  124941. updatable?: boolean;
  124942. sideOrientation?: number;
  124943. frontUVs?: Vector4;
  124944. backUVs?: Vector4;
  124945. }, scene: any): Mesh;
  124946. }
  124947. }
  124948. declare module BABYLON {
  124949. /**
  124950. * Polygon
  124951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124952. */
  124953. export class Polygon {
  124954. /**
  124955. * Creates a rectangle
  124956. * @param xmin bottom X coord
  124957. * @param ymin bottom Y coord
  124958. * @param xmax top X coord
  124959. * @param ymax top Y coord
  124960. * @returns points that make the resulting rectation
  124961. */
  124962. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124963. /**
  124964. * Creates a circle
  124965. * @param radius radius of circle
  124966. * @param cx scale in x
  124967. * @param cy scale in y
  124968. * @param numberOfSides number of sides that make up the circle
  124969. * @returns points that make the resulting circle
  124970. */
  124971. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124972. /**
  124973. * Creates a polygon from input string
  124974. * @param input Input polygon data
  124975. * @returns the parsed points
  124976. */
  124977. static Parse(input: string): Vector2[];
  124978. /**
  124979. * Starts building a polygon from x and y coordinates
  124980. * @param x x coordinate
  124981. * @param y y coordinate
  124982. * @returns the started path2
  124983. */
  124984. static StartingAt(x: number, y: number): Path2;
  124985. }
  124986. /**
  124987. * Builds a polygon
  124988. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124989. */
  124990. export class PolygonMeshBuilder {
  124991. private _points;
  124992. private _outlinepoints;
  124993. private _holes;
  124994. private _name;
  124995. private _scene;
  124996. private _epoints;
  124997. private _eholes;
  124998. private _addToepoint;
  124999. /**
  125000. * Babylon reference to the earcut plugin.
  125001. */
  125002. bjsEarcut: any;
  125003. /**
  125004. * Creates a PolygonMeshBuilder
  125005. * @param name name of the builder
  125006. * @param contours Path of the polygon
  125007. * @param scene scene to add to when creating the mesh
  125008. * @param earcutInjection can be used to inject your own earcut reference
  125009. */
  125010. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125011. /**
  125012. * Adds a whole within the polygon
  125013. * @param hole Array of points defining the hole
  125014. * @returns this
  125015. */
  125016. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125017. /**
  125018. * Creates the polygon
  125019. * @param updatable If the mesh should be updatable
  125020. * @param depth The depth of the mesh created
  125021. * @returns the created mesh
  125022. */
  125023. build(updatable?: boolean, depth?: number): Mesh;
  125024. /**
  125025. * Creates the polygon
  125026. * @param depth The depth of the mesh created
  125027. * @returns the created VertexData
  125028. */
  125029. buildVertexData(depth?: number): VertexData;
  125030. /**
  125031. * Adds a side to the polygon
  125032. * @param positions points that make the polygon
  125033. * @param normals normals of the polygon
  125034. * @param uvs uvs of the polygon
  125035. * @param indices indices of the polygon
  125036. * @param bounds bounds of the polygon
  125037. * @param points points of the polygon
  125038. * @param depth depth of the polygon
  125039. * @param flip flip of the polygon
  125040. */
  125041. private addSide;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * Class containing static functions to help procedurally build meshes
  125047. */
  125048. export class PolygonBuilder {
  125049. /**
  125050. * Creates a polygon mesh
  125051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125052. * * 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
  125053. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125056. * * Remember you can only change the shape positions, not their number when updating a polygon
  125057. * @param name defines the name of the mesh
  125058. * @param options defines the options used to create the mesh
  125059. * @param scene defines the hosting scene
  125060. * @param earcutInjection can be used to inject your own earcut reference
  125061. * @returns the polygon mesh
  125062. */
  125063. static CreatePolygon(name: string, options: {
  125064. shape: Vector3[];
  125065. holes?: Vector3[][];
  125066. depth?: number;
  125067. faceUV?: Vector4[];
  125068. faceColors?: Color4[];
  125069. updatable?: boolean;
  125070. sideOrientation?: number;
  125071. frontUVs?: Vector4;
  125072. backUVs?: Vector4;
  125073. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125074. /**
  125075. * Creates an extruded polygon mesh, with depth in the Y direction.
  125076. * * 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)
  125077. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125078. * @param name defines the name of the mesh
  125079. * @param options defines the options used to create the mesh
  125080. * @param scene defines the hosting scene
  125081. * @param earcutInjection can be used to inject your own earcut reference
  125082. * @returns the polygon mesh
  125083. */
  125084. static ExtrudePolygon(name: string, options: {
  125085. shape: Vector3[];
  125086. holes?: Vector3[][];
  125087. depth?: number;
  125088. faceUV?: Vector4[];
  125089. faceColors?: Color4[];
  125090. updatable?: boolean;
  125091. sideOrientation?: number;
  125092. frontUVs?: Vector4;
  125093. backUVs?: Vector4;
  125094. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125095. }
  125096. }
  125097. declare module BABYLON {
  125098. /**
  125099. * Class containing static functions to help procedurally build meshes
  125100. */
  125101. export class LatheBuilder {
  125102. /**
  125103. * Creates lathe mesh.
  125104. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125105. * * 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
  125106. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125107. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125108. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125109. * * 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
  125110. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125111. * * 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
  125112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125116. * @param name defines the name of the mesh
  125117. * @param options defines the options used to create the mesh
  125118. * @param scene defines the hosting scene
  125119. * @returns the lathe mesh
  125120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125121. */
  125122. static CreateLathe(name: string, options: {
  125123. shape: Vector3[];
  125124. radius?: number;
  125125. tessellation?: number;
  125126. clip?: number;
  125127. arc?: number;
  125128. closed?: boolean;
  125129. updatable?: boolean;
  125130. sideOrientation?: number;
  125131. frontUVs?: Vector4;
  125132. backUVs?: Vector4;
  125133. cap?: number;
  125134. invertUV?: boolean;
  125135. }, scene?: Nullable<Scene>): Mesh;
  125136. }
  125137. }
  125138. declare module BABYLON {
  125139. /**
  125140. * Class containing static functions to help procedurally build meshes
  125141. */
  125142. export class TiledPlaneBuilder {
  125143. /**
  125144. * Creates a tiled plane mesh
  125145. * * The parameter `pattern` will, depending on value, do nothing or
  125146. * * * flip (reflect about central vertical) alternate tiles across and up
  125147. * * * flip every tile on alternate rows
  125148. * * * rotate (180 degs) alternate tiles across and up
  125149. * * * rotate every tile on alternate rows
  125150. * * * flip and rotate alternate tiles across and up
  125151. * * * flip and rotate every tile on alternate rows
  125152. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125153. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125156. * * 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)
  125157. * * 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)
  125158. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125159. * @param name defines the name of the mesh
  125160. * @param options defines the options used to create the mesh
  125161. * @param scene defines the hosting scene
  125162. * @returns the box mesh
  125163. */
  125164. static CreateTiledPlane(name: string, options: {
  125165. pattern?: number;
  125166. tileSize?: number;
  125167. tileWidth?: number;
  125168. tileHeight?: number;
  125169. size?: number;
  125170. width?: number;
  125171. height?: number;
  125172. alignHorizontal?: number;
  125173. alignVertical?: number;
  125174. sideOrientation?: number;
  125175. frontUVs?: Vector4;
  125176. backUVs?: Vector4;
  125177. updatable?: boolean;
  125178. }, scene?: Nullable<Scene>): Mesh;
  125179. }
  125180. }
  125181. declare module BABYLON {
  125182. /**
  125183. * Class containing static functions to help procedurally build meshes
  125184. */
  125185. export class TubeBuilder {
  125186. /**
  125187. * Creates a tube mesh.
  125188. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125189. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125190. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125191. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125192. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125193. * * 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)
  125194. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125195. * * 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
  125196. * * 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
  125197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125201. * @param name defines the name of the mesh
  125202. * @param options defines the options used to create the mesh
  125203. * @param scene defines the hosting scene
  125204. * @returns the tube mesh
  125205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125206. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125207. */
  125208. static CreateTube(name: string, options: {
  125209. path: Vector3[];
  125210. radius?: number;
  125211. tessellation?: number;
  125212. radiusFunction?: {
  125213. (i: number, distance: number): number;
  125214. };
  125215. cap?: number;
  125216. arc?: number;
  125217. updatable?: boolean;
  125218. sideOrientation?: number;
  125219. frontUVs?: Vector4;
  125220. backUVs?: Vector4;
  125221. instance?: Mesh;
  125222. invertUV?: boolean;
  125223. }, scene?: Nullable<Scene>): Mesh;
  125224. }
  125225. }
  125226. declare module BABYLON {
  125227. /**
  125228. * Class containing static functions to help procedurally build meshes
  125229. */
  125230. export class IcoSphereBuilder {
  125231. /**
  125232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125234. * * 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`)
  125235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125236. * * 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
  125237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125240. * @param name defines the name of the mesh
  125241. * @param options defines the options used to create the mesh
  125242. * @param scene defines the hosting scene
  125243. * @returns the icosahedron mesh
  125244. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125245. */
  125246. static CreateIcoSphere(name: string, options: {
  125247. radius?: number;
  125248. radiusX?: number;
  125249. radiusY?: number;
  125250. radiusZ?: number;
  125251. flat?: boolean;
  125252. subdivisions?: number;
  125253. sideOrientation?: number;
  125254. frontUVs?: Vector4;
  125255. backUVs?: Vector4;
  125256. updatable?: boolean;
  125257. }, scene?: Nullable<Scene>): Mesh;
  125258. }
  125259. }
  125260. declare module BABYLON {
  125261. /**
  125262. * Class containing static functions to help procedurally build meshes
  125263. */
  125264. export class DecalBuilder {
  125265. /**
  125266. * Creates a decal mesh.
  125267. * 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
  125268. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125269. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125270. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125271. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125272. * @param name defines the name of the mesh
  125273. * @param sourceMesh defines the mesh where the decal must be applied
  125274. * @param options defines the options used to create the mesh
  125275. * @param scene defines the hosting scene
  125276. * @returns the decal mesh
  125277. * @see https://doc.babylonjs.com/how_to/decals
  125278. */
  125279. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125280. position?: Vector3;
  125281. normal?: Vector3;
  125282. size?: Vector3;
  125283. angle?: number;
  125284. }): Mesh;
  125285. }
  125286. }
  125287. declare module BABYLON {
  125288. /**
  125289. * Class containing static functions to help procedurally build meshes
  125290. */
  125291. export class MeshBuilder {
  125292. /**
  125293. * Creates a box mesh
  125294. * * The parameter `size` sets the size (float) of each box side (default 1)
  125295. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125296. * * 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)
  125297. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125301. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125302. * @param name defines the name of the mesh
  125303. * @param options defines the options used to create the mesh
  125304. * @param scene defines the hosting scene
  125305. * @returns the box mesh
  125306. */
  125307. static CreateBox(name: string, options: {
  125308. size?: number;
  125309. width?: number;
  125310. height?: number;
  125311. depth?: number;
  125312. faceUV?: Vector4[];
  125313. faceColors?: Color4[];
  125314. sideOrientation?: number;
  125315. frontUVs?: Vector4;
  125316. backUVs?: Vector4;
  125317. updatable?: boolean;
  125318. }, scene?: Nullable<Scene>): Mesh;
  125319. /**
  125320. * Creates a tiled box mesh
  125321. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125323. * @param name defines the name of the mesh
  125324. * @param options defines the options used to create the mesh
  125325. * @param scene defines the hosting scene
  125326. * @returns the tiled box mesh
  125327. */
  125328. static CreateTiledBox(name: string, options: {
  125329. pattern?: number;
  125330. size?: number;
  125331. width?: number;
  125332. height?: number;
  125333. depth: number;
  125334. tileSize?: number;
  125335. tileWidth?: number;
  125336. tileHeight?: number;
  125337. faceUV?: Vector4[];
  125338. faceColors?: Color4[];
  125339. alignHorizontal?: number;
  125340. alignVertical?: number;
  125341. sideOrientation?: number;
  125342. updatable?: boolean;
  125343. }, scene?: Nullable<Scene>): Mesh;
  125344. /**
  125345. * Creates a sphere mesh
  125346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125347. * * 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`)
  125348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125349. * * 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
  125350. * * 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)
  125351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125354. * @param name defines the name of the mesh
  125355. * @param options defines the options used to create the mesh
  125356. * @param scene defines the hosting scene
  125357. * @returns the sphere mesh
  125358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125359. */
  125360. static CreateSphere(name: string, options: {
  125361. segments?: number;
  125362. diameter?: number;
  125363. diameterX?: number;
  125364. diameterY?: number;
  125365. diameterZ?: number;
  125366. arc?: number;
  125367. slice?: number;
  125368. sideOrientation?: number;
  125369. frontUVs?: Vector4;
  125370. backUVs?: Vector4;
  125371. updatable?: boolean;
  125372. }, scene?: Nullable<Scene>): Mesh;
  125373. /**
  125374. * Creates a plane polygonal mesh. By default, this is a disc
  125375. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125376. * * 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
  125377. * * 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
  125378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125381. * @param name defines the name of the mesh
  125382. * @param options defines the options used to create the mesh
  125383. * @param scene defines the hosting scene
  125384. * @returns the plane polygonal mesh
  125385. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125386. */
  125387. static CreateDisc(name: string, options: {
  125388. radius?: number;
  125389. tessellation?: number;
  125390. arc?: number;
  125391. updatable?: boolean;
  125392. sideOrientation?: number;
  125393. frontUVs?: Vector4;
  125394. backUVs?: Vector4;
  125395. }, scene?: Nullable<Scene>): Mesh;
  125396. /**
  125397. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125398. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125399. * * 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`)
  125400. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125401. * * 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
  125402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125405. * @param name defines the name of the mesh
  125406. * @param options defines the options used to create the mesh
  125407. * @param scene defines the hosting scene
  125408. * @returns the icosahedron mesh
  125409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125410. */
  125411. static CreateIcoSphere(name: string, options: {
  125412. radius?: number;
  125413. radiusX?: number;
  125414. radiusY?: number;
  125415. radiusZ?: number;
  125416. flat?: boolean;
  125417. subdivisions?: number;
  125418. sideOrientation?: number;
  125419. frontUVs?: Vector4;
  125420. backUVs?: Vector4;
  125421. updatable?: boolean;
  125422. }, scene?: Nullable<Scene>): Mesh;
  125423. /**
  125424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125428. * * 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
  125429. * * 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
  125430. * * 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
  125431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125434. * * The 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
  125435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125436. * * 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
  125437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125439. * @param name defines the name of the mesh
  125440. * @param options defines the options used to create the mesh
  125441. * @param scene defines the hosting scene
  125442. * @returns the ribbon mesh
  125443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125445. */
  125446. static CreateRibbon(name: string, options: {
  125447. pathArray: Vector3[][];
  125448. closeArray?: boolean;
  125449. closePath?: boolean;
  125450. offset?: number;
  125451. updatable?: boolean;
  125452. sideOrientation?: number;
  125453. frontUVs?: Vector4;
  125454. backUVs?: Vector4;
  125455. instance?: Mesh;
  125456. invertUV?: boolean;
  125457. uvs?: Vector2[];
  125458. colors?: Color4[];
  125459. }, scene?: Nullable<Scene>): Mesh;
  125460. /**
  125461. * Creates a cylinder or a cone mesh
  125462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125464. * * 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.
  125465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125469. * * 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).
  125470. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125471. * * 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).
  125472. * * 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
  125473. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125474. * * 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
  125475. * * 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.
  125476. * * If `enclose` is false, a ring surface is one element.
  125477. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125478. * * 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
  125479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125482. * @param name defines the name of the mesh
  125483. * @param options defines the options used to create the mesh
  125484. * @param scene defines the hosting scene
  125485. * @returns the cylinder mesh
  125486. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125487. */
  125488. static CreateCylinder(name: string, options: {
  125489. height?: number;
  125490. diameterTop?: number;
  125491. diameterBottom?: number;
  125492. diameter?: number;
  125493. tessellation?: number;
  125494. subdivisions?: number;
  125495. arc?: number;
  125496. faceColors?: Color4[];
  125497. faceUV?: Vector4[];
  125498. updatable?: boolean;
  125499. hasRings?: boolean;
  125500. enclose?: boolean;
  125501. cap?: number;
  125502. sideOrientation?: number;
  125503. frontUVs?: Vector4;
  125504. backUVs?: Vector4;
  125505. }, scene?: Nullable<Scene>): Mesh;
  125506. /**
  125507. * Creates a torus mesh
  125508. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125509. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125510. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125514. * @param name defines the name of the mesh
  125515. * @param options defines the options used to create the mesh
  125516. * @param scene defines the hosting scene
  125517. * @returns the torus mesh
  125518. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125519. */
  125520. static CreateTorus(name: string, options: {
  125521. diameter?: number;
  125522. thickness?: number;
  125523. tessellation?: number;
  125524. updatable?: boolean;
  125525. sideOrientation?: number;
  125526. frontUVs?: Vector4;
  125527. backUVs?: Vector4;
  125528. }, scene?: Nullable<Scene>): Mesh;
  125529. /**
  125530. * Creates a torus knot mesh
  125531. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125532. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125533. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125534. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125538. * @param name defines the name of the mesh
  125539. * @param options defines the options used to create the mesh
  125540. * @param scene defines the hosting scene
  125541. * @returns the torus knot mesh
  125542. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125543. */
  125544. static CreateTorusKnot(name: string, options: {
  125545. radius?: number;
  125546. tube?: number;
  125547. radialSegments?: number;
  125548. tubularSegments?: number;
  125549. p?: number;
  125550. q?: number;
  125551. updatable?: boolean;
  125552. sideOrientation?: number;
  125553. frontUVs?: Vector4;
  125554. backUVs?: Vector4;
  125555. }, scene?: Nullable<Scene>): Mesh;
  125556. /**
  125557. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125558. * * 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
  125559. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125560. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125561. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125562. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125563. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125564. * * 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
  125565. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125568. * @param name defines the name of the new line system
  125569. * @param options defines the options used to create the line system
  125570. * @param scene defines the hosting scene
  125571. * @returns a new line system mesh
  125572. */
  125573. static CreateLineSystem(name: string, options: {
  125574. lines: Vector3[][];
  125575. updatable?: boolean;
  125576. instance?: Nullable<LinesMesh>;
  125577. colors?: Nullable<Color4[][]>;
  125578. useVertexAlpha?: boolean;
  125579. }, scene: Nullable<Scene>): LinesMesh;
  125580. /**
  125581. * Creates a line mesh
  125582. * 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
  125583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125584. * * The parameter `points` is an array successive Vector3
  125585. * * 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
  125586. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125587. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125588. * * When updating an instance, remember that only point positions can change, not the number of points
  125589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125591. * @param name defines the name of the new line system
  125592. * @param options defines the options used to create the line system
  125593. * @param scene defines the hosting scene
  125594. * @returns a new line mesh
  125595. */
  125596. static CreateLines(name: string, options: {
  125597. points: Vector3[];
  125598. updatable?: boolean;
  125599. instance?: Nullable<LinesMesh>;
  125600. colors?: Color4[];
  125601. useVertexAlpha?: boolean;
  125602. }, scene?: Nullable<Scene>): LinesMesh;
  125603. /**
  125604. * Creates a dashed line mesh
  125605. * * 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
  125606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125607. * * The parameter `points` is an array successive Vector3
  125608. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125609. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125610. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125611. * * 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
  125612. * * When updating an instance, remember that only point positions can change, not the number of points
  125613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125614. * @param name defines the name of the mesh
  125615. * @param options defines the options used to create the mesh
  125616. * @param scene defines the hosting scene
  125617. * @returns the dashed line mesh
  125618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125619. */
  125620. static CreateDashedLines(name: string, options: {
  125621. points: Vector3[];
  125622. dashSize?: number;
  125623. gapSize?: number;
  125624. dashNb?: number;
  125625. updatable?: boolean;
  125626. instance?: LinesMesh;
  125627. }, scene?: Nullable<Scene>): LinesMesh;
  125628. /**
  125629. * 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.
  125630. * * 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.
  125631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125632. * * 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.
  125633. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125634. * * 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
  125635. * * 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
  125636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125641. * @param name defines the name of the mesh
  125642. * @param options defines the options used to create the mesh
  125643. * @param scene defines the hosting scene
  125644. * @returns the extruded shape mesh
  125645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125647. */
  125648. static ExtrudeShape(name: string, options: {
  125649. shape: Vector3[];
  125650. path: Vector3[];
  125651. scale?: number;
  125652. rotation?: number;
  125653. cap?: number;
  125654. updatable?: boolean;
  125655. sideOrientation?: number;
  125656. frontUVs?: Vector4;
  125657. backUVs?: Vector4;
  125658. instance?: Mesh;
  125659. invertUV?: boolean;
  125660. }, scene?: Nullable<Scene>): Mesh;
  125661. /**
  125662. * Creates an custom extruded shape mesh.
  125663. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125664. * * 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.
  125665. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125666. * * 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
  125667. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125668. * * 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
  125669. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125670. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125671. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125672. * * 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
  125673. * * 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
  125674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125679. * @param name defines the name of the mesh
  125680. * @param options defines the options used to create the mesh
  125681. * @param scene defines the hosting scene
  125682. * @returns the custom extruded shape mesh
  125683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125686. */
  125687. static ExtrudeShapeCustom(name: string, options: {
  125688. shape: Vector3[];
  125689. path: Vector3[];
  125690. scaleFunction?: any;
  125691. rotationFunction?: any;
  125692. ribbonCloseArray?: boolean;
  125693. ribbonClosePath?: boolean;
  125694. cap?: number;
  125695. updatable?: boolean;
  125696. sideOrientation?: number;
  125697. frontUVs?: Vector4;
  125698. backUVs?: Vector4;
  125699. instance?: Mesh;
  125700. invertUV?: boolean;
  125701. }, scene?: Nullable<Scene>): Mesh;
  125702. /**
  125703. * Creates lathe mesh.
  125704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125705. * * 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
  125706. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125707. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125708. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125709. * * 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
  125710. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125711. * * 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
  125712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125716. * @param name defines the name of the mesh
  125717. * @param options defines the options used to create the mesh
  125718. * @param scene defines the hosting scene
  125719. * @returns the lathe mesh
  125720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125721. */
  125722. static CreateLathe(name: string, options: {
  125723. shape: Vector3[];
  125724. radius?: number;
  125725. tessellation?: number;
  125726. clip?: number;
  125727. arc?: number;
  125728. closed?: boolean;
  125729. updatable?: boolean;
  125730. sideOrientation?: number;
  125731. frontUVs?: Vector4;
  125732. backUVs?: Vector4;
  125733. cap?: number;
  125734. invertUV?: boolean;
  125735. }, scene?: Nullable<Scene>): Mesh;
  125736. /**
  125737. * Creates a tiled plane mesh
  125738. * * You can set a limited pattern arrangement with the tiles
  125739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125742. * @param name defines the name of the mesh
  125743. * @param options defines the options used to create the mesh
  125744. * @param scene defines the hosting scene
  125745. * @returns the plane mesh
  125746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125747. */
  125748. static CreateTiledPlane(name: string, options: {
  125749. pattern?: number;
  125750. tileSize?: number;
  125751. tileWidth?: number;
  125752. tileHeight?: number;
  125753. size?: number;
  125754. width?: number;
  125755. height?: number;
  125756. alignHorizontal?: number;
  125757. alignVertical?: number;
  125758. sideOrientation?: number;
  125759. frontUVs?: Vector4;
  125760. backUVs?: Vector4;
  125761. updatable?: boolean;
  125762. }, scene?: Nullable<Scene>): Mesh;
  125763. /**
  125764. * Creates a plane mesh
  125765. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  125766. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  125767. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  125768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125771. * @param name defines the name of the mesh
  125772. * @param options defines the options used to create the mesh
  125773. * @param scene defines the hosting scene
  125774. * @returns the plane mesh
  125775. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  125776. */
  125777. static CreatePlane(name: string, options: {
  125778. size?: number;
  125779. width?: number;
  125780. height?: number;
  125781. sideOrientation?: number;
  125782. frontUVs?: Vector4;
  125783. backUVs?: Vector4;
  125784. updatable?: boolean;
  125785. sourcePlane?: Plane;
  125786. }, scene?: Nullable<Scene>): Mesh;
  125787. /**
  125788. * Creates a ground mesh
  125789. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125790. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125792. * @param name defines the name of the mesh
  125793. * @param options defines the options used to create the mesh
  125794. * @param scene defines the hosting scene
  125795. * @returns the ground mesh
  125796. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125797. */
  125798. static CreateGround(name: string, options: {
  125799. width?: number;
  125800. height?: number;
  125801. subdivisions?: number;
  125802. subdivisionsX?: number;
  125803. subdivisionsY?: number;
  125804. updatable?: boolean;
  125805. }, scene?: Nullable<Scene>): Mesh;
  125806. /**
  125807. * Creates a tiled ground mesh
  125808. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125809. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125810. * * 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
  125811. * * 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
  125812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125813. * @param name defines the name of the mesh
  125814. * @param options defines the options used to create the mesh
  125815. * @param scene defines the hosting scene
  125816. * @returns the tiled ground mesh
  125817. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125818. */
  125819. static CreateTiledGround(name: string, options: {
  125820. xmin: number;
  125821. zmin: number;
  125822. xmax: number;
  125823. zmax: number;
  125824. subdivisions?: {
  125825. w: number;
  125826. h: number;
  125827. };
  125828. precision?: {
  125829. w: number;
  125830. h: number;
  125831. };
  125832. updatable?: boolean;
  125833. }, scene?: Nullable<Scene>): Mesh;
  125834. /**
  125835. * Creates a ground mesh from a height map
  125836. * * The parameter `url` sets the URL of the height map image resource.
  125837. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125838. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125839. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125840. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125841. * * 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.
  125842. * * 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).
  125843. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125845. * @param name defines the name of the mesh
  125846. * @param url defines the url to the height map
  125847. * @param options defines the options used to create the mesh
  125848. * @param scene defines the hosting scene
  125849. * @returns the ground mesh
  125850. * @see https://doc.babylonjs.com/babylon101/height_map
  125851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125852. */
  125853. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125854. width?: number;
  125855. height?: number;
  125856. subdivisions?: number;
  125857. minHeight?: number;
  125858. maxHeight?: number;
  125859. colorFilter?: Color3;
  125860. alphaFilter?: number;
  125861. updatable?: boolean;
  125862. onReady?: (mesh: GroundMesh) => void;
  125863. }, scene?: Nullable<Scene>): GroundMesh;
  125864. /**
  125865. * Creates a polygon mesh
  125866. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125867. * * 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
  125868. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125871. * * Remember you can only change the shape positions, not their number when updating a polygon
  125872. * @param name defines the name of the mesh
  125873. * @param options defines the options used to create the mesh
  125874. * @param scene defines the hosting scene
  125875. * @param earcutInjection can be used to inject your own earcut reference
  125876. * @returns the polygon mesh
  125877. */
  125878. static CreatePolygon(name: string, options: {
  125879. shape: Vector3[];
  125880. holes?: Vector3[][];
  125881. depth?: number;
  125882. faceUV?: Vector4[];
  125883. faceColors?: Color4[];
  125884. updatable?: boolean;
  125885. sideOrientation?: number;
  125886. frontUVs?: Vector4;
  125887. backUVs?: Vector4;
  125888. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125889. /**
  125890. * Creates an extruded polygon mesh, with depth in the Y direction.
  125891. * * 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)
  125892. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125893. * @param name defines the name of the mesh
  125894. * @param options defines the options used to create the mesh
  125895. * @param scene defines the hosting scene
  125896. * @param earcutInjection can be used to inject your own earcut reference
  125897. * @returns the polygon mesh
  125898. */
  125899. static ExtrudePolygon(name: string, options: {
  125900. shape: Vector3[];
  125901. holes?: Vector3[][];
  125902. depth?: number;
  125903. faceUV?: Vector4[];
  125904. faceColors?: Color4[];
  125905. updatable?: boolean;
  125906. sideOrientation?: number;
  125907. frontUVs?: Vector4;
  125908. backUVs?: Vector4;
  125909. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125910. /**
  125911. * Creates a tube mesh.
  125912. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125913. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125914. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125915. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125916. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125917. * * 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)
  125918. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125919. * * 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
  125920. * * 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
  125921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125925. * @param name defines the name of the mesh
  125926. * @param options defines the options used to create the mesh
  125927. * @param scene defines the hosting scene
  125928. * @returns the tube mesh
  125929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125930. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125931. */
  125932. static CreateTube(name: string, options: {
  125933. path: Vector3[];
  125934. radius?: number;
  125935. tessellation?: number;
  125936. radiusFunction?: {
  125937. (i: number, distance: number): number;
  125938. };
  125939. cap?: number;
  125940. arc?: number;
  125941. updatable?: boolean;
  125942. sideOrientation?: number;
  125943. frontUVs?: Vector4;
  125944. backUVs?: Vector4;
  125945. instance?: Mesh;
  125946. invertUV?: boolean;
  125947. }, scene?: Nullable<Scene>): Mesh;
  125948. /**
  125949. * Creates a polyhedron mesh
  125950. * * 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
  125951. * * The parameter `size` (positive float, default 1) sets the polygon size
  125952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125953. * * 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`
  125954. * * 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
  125955. * * 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)`)
  125956. * * 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
  125957. * * 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
  125958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125961. * @param name defines the name of the mesh
  125962. * @param options defines the options used to create the mesh
  125963. * @param scene defines the hosting scene
  125964. * @returns the polyhedron mesh
  125965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125966. */
  125967. static CreatePolyhedron(name: string, options: {
  125968. type?: number;
  125969. size?: number;
  125970. sizeX?: number;
  125971. sizeY?: number;
  125972. sizeZ?: number;
  125973. custom?: any;
  125974. faceUV?: Vector4[];
  125975. faceColors?: Color4[];
  125976. flat?: boolean;
  125977. updatable?: boolean;
  125978. sideOrientation?: number;
  125979. frontUVs?: Vector4;
  125980. backUVs?: Vector4;
  125981. }, scene?: Nullable<Scene>): Mesh;
  125982. /**
  125983. * Creates a decal mesh.
  125984. * 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
  125985. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125986. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125987. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125988. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125989. * @param name defines the name of the mesh
  125990. * @param sourceMesh defines the mesh where the decal must be applied
  125991. * @param options defines the options used to create the mesh
  125992. * @param scene defines the hosting scene
  125993. * @returns the decal mesh
  125994. * @see https://doc.babylonjs.com/how_to/decals
  125995. */
  125996. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125997. position?: Vector3;
  125998. normal?: Vector3;
  125999. size?: Vector3;
  126000. angle?: number;
  126001. }): Mesh;
  126002. }
  126003. }
  126004. declare module BABYLON {
  126005. /**
  126006. * A simplifier interface for future simplification implementations
  126007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126008. */
  126009. export interface ISimplifier {
  126010. /**
  126011. * Simplification of a given mesh according to the given settings.
  126012. * Since this requires computation, it is assumed that the function runs async.
  126013. * @param settings The settings of the simplification, including quality and distance
  126014. * @param successCallback A callback that will be called after the mesh was simplified.
  126015. * @param errorCallback in case of an error, this callback will be called. optional.
  126016. */
  126017. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126018. }
  126019. /**
  126020. * Expected simplification settings.
  126021. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126022. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126023. */
  126024. export interface ISimplificationSettings {
  126025. /**
  126026. * Gets or sets the expected quality
  126027. */
  126028. quality: number;
  126029. /**
  126030. * Gets or sets the distance when this optimized version should be used
  126031. */
  126032. distance: number;
  126033. /**
  126034. * Gets an already optimized mesh
  126035. */
  126036. optimizeMesh?: boolean;
  126037. }
  126038. /**
  126039. * Class used to specify simplification options
  126040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126041. */
  126042. export class SimplificationSettings implements ISimplificationSettings {
  126043. /** expected quality */
  126044. quality: number;
  126045. /** distance when this optimized version should be used */
  126046. distance: number;
  126047. /** already optimized mesh */
  126048. optimizeMesh?: boolean | undefined;
  126049. /**
  126050. * Creates a SimplificationSettings
  126051. * @param quality expected quality
  126052. * @param distance distance when this optimized version should be used
  126053. * @param optimizeMesh already optimized mesh
  126054. */
  126055. constructor(
  126056. /** expected quality */
  126057. quality: number,
  126058. /** distance when this optimized version should be used */
  126059. distance: number,
  126060. /** already optimized mesh */
  126061. optimizeMesh?: boolean | undefined);
  126062. }
  126063. /**
  126064. * Interface used to define a simplification task
  126065. */
  126066. export interface ISimplificationTask {
  126067. /**
  126068. * Array of settings
  126069. */
  126070. settings: Array<ISimplificationSettings>;
  126071. /**
  126072. * Simplification type
  126073. */
  126074. simplificationType: SimplificationType;
  126075. /**
  126076. * Mesh to simplify
  126077. */
  126078. mesh: Mesh;
  126079. /**
  126080. * Callback called on success
  126081. */
  126082. successCallback?: () => void;
  126083. /**
  126084. * Defines if parallel processing can be used
  126085. */
  126086. parallelProcessing: boolean;
  126087. }
  126088. /**
  126089. * Queue used to order the simplification tasks
  126090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126091. */
  126092. export class SimplificationQueue {
  126093. private _simplificationArray;
  126094. /**
  126095. * Gets a boolean indicating that the process is still running
  126096. */
  126097. running: boolean;
  126098. /**
  126099. * Creates a new queue
  126100. */
  126101. constructor();
  126102. /**
  126103. * Adds a new simplification task
  126104. * @param task defines a task to add
  126105. */
  126106. addTask(task: ISimplificationTask): void;
  126107. /**
  126108. * Execute next task
  126109. */
  126110. executeNext(): void;
  126111. /**
  126112. * Execute a simplification task
  126113. * @param task defines the task to run
  126114. */
  126115. runSimplification(task: ISimplificationTask): void;
  126116. private getSimplifier;
  126117. }
  126118. /**
  126119. * The implemented types of simplification
  126120. * At the moment only Quadratic Error Decimation is implemented
  126121. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126122. */
  126123. export enum SimplificationType {
  126124. /** Quadratic error decimation */
  126125. QUADRATIC = 0
  126126. }
  126127. }
  126128. declare module BABYLON {
  126129. interface Scene {
  126130. /** @hidden (Backing field) */
  126131. _simplificationQueue: SimplificationQueue;
  126132. /**
  126133. * Gets or sets the simplification queue attached to the scene
  126134. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126135. */
  126136. simplificationQueue: SimplificationQueue;
  126137. }
  126138. interface Mesh {
  126139. /**
  126140. * Simplify the mesh according to the given array of settings.
  126141. * Function will return immediately and will simplify async
  126142. * @param settings a collection of simplification settings
  126143. * @param parallelProcessing should all levels calculate parallel or one after the other
  126144. * @param simplificationType the type of simplification to run
  126145. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126146. * @returns the current mesh
  126147. */
  126148. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126149. }
  126150. /**
  126151. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126152. * created in a scene
  126153. */
  126154. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126155. /**
  126156. * The component name helpfull to identify the component in the list of scene components.
  126157. */
  126158. readonly name: string;
  126159. /**
  126160. * The scene the component belongs to.
  126161. */
  126162. scene: Scene;
  126163. /**
  126164. * Creates a new instance of the component for the given scene
  126165. * @param scene Defines the scene to register the component in
  126166. */
  126167. constructor(scene: Scene);
  126168. /**
  126169. * Registers the component in a given scene
  126170. */
  126171. register(): void;
  126172. /**
  126173. * Rebuilds the elements related to this component in case of
  126174. * context lost for instance.
  126175. */
  126176. rebuild(): void;
  126177. /**
  126178. * Disposes the component and the associated ressources
  126179. */
  126180. dispose(): void;
  126181. private _beforeCameraUpdate;
  126182. }
  126183. }
  126184. declare module BABYLON {
  126185. /**
  126186. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126187. */
  126188. export interface INavigationEnginePlugin {
  126189. /**
  126190. * plugin name
  126191. */
  126192. name: string;
  126193. /**
  126194. * Creates a navigation mesh
  126195. * @param meshes array of all the geometry used to compute the navigatio mesh
  126196. * @param parameters bunch of parameters used to filter geometry
  126197. */
  126198. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126199. /**
  126200. * Create a navigation mesh debug mesh
  126201. * @param scene is where the mesh will be added
  126202. * @returns debug display mesh
  126203. */
  126204. createDebugNavMesh(scene: Scene): Mesh;
  126205. /**
  126206. * Get a navigation mesh constrained position, closest to the parameter position
  126207. * @param position world position
  126208. * @returns the closest point to position constrained by the navigation mesh
  126209. */
  126210. getClosestPoint(position: Vector3): Vector3;
  126211. /**
  126212. * Get a navigation mesh constrained position, within a particular radius
  126213. * @param position world position
  126214. * @param maxRadius the maximum distance to the constrained world position
  126215. * @returns the closest point to position constrained by the navigation mesh
  126216. */
  126217. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126218. /**
  126219. * Compute the final position from a segment made of destination-position
  126220. * @param position world position
  126221. * @param destination world position
  126222. * @returns the resulting point along the navmesh
  126223. */
  126224. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126225. /**
  126226. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126227. * @param start world position
  126228. * @param end world position
  126229. * @returns array containing world position composing the path
  126230. */
  126231. computePath(start: Vector3, end: Vector3): Vector3[];
  126232. /**
  126233. * If this plugin is supported
  126234. * @returns true if plugin is supported
  126235. */
  126236. isSupported(): boolean;
  126237. /**
  126238. * Create a new Crowd so you can add agents
  126239. * @param maxAgents the maximum agent count in the crowd
  126240. * @param maxAgentRadius the maximum radius an agent can have
  126241. * @param scene to attach the crowd to
  126242. * @returns the crowd you can add agents to
  126243. */
  126244. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126245. /**
  126246. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126247. * The queries will try to find a solution within those bounds
  126248. * default is (1,1,1)
  126249. * @param extent x,y,z value that define the extent around the queries point of reference
  126250. */
  126251. setDefaultQueryExtent(extent: Vector3): void;
  126252. /**
  126253. * Get the Bounding box extent specified by setDefaultQueryExtent
  126254. * @returns the box extent values
  126255. */
  126256. getDefaultQueryExtent(): Vector3;
  126257. /**
  126258. * Release all resources
  126259. */
  126260. dispose(): void;
  126261. }
  126262. /**
  126263. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126264. */
  126265. export interface ICrowd {
  126266. /**
  126267. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126268. * You can attach anything to that node. The node position is updated in the scene update tick.
  126269. * @param pos world position that will be constrained by the navigation mesh
  126270. * @param parameters agent parameters
  126271. * @param transform hooked to the agent that will be update by the scene
  126272. * @returns agent index
  126273. */
  126274. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126275. /**
  126276. * Returns the agent position in world space
  126277. * @param index agent index returned by addAgent
  126278. * @returns world space position
  126279. */
  126280. getAgentPosition(index: number): Vector3;
  126281. /**
  126282. * Gets the agent velocity in world space
  126283. * @param index agent index returned by addAgent
  126284. * @returns world space velocity
  126285. */
  126286. getAgentVelocity(index: number): Vector3;
  126287. /**
  126288. * remove a particular agent previously created
  126289. * @param index agent index returned by addAgent
  126290. */
  126291. removeAgent(index: number): void;
  126292. /**
  126293. * get the list of all agents attached to this crowd
  126294. * @returns list of agent indices
  126295. */
  126296. getAgents(): number[];
  126297. /**
  126298. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126299. * @param deltaTime in seconds
  126300. */
  126301. update(deltaTime: number): void;
  126302. /**
  126303. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126304. * @param index agent index returned by addAgent
  126305. * @param destination targeted world position
  126306. */
  126307. agentGoto(index: number, destination: Vector3): void;
  126308. /**
  126309. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126310. * The queries will try to find a solution within those bounds
  126311. * default is (1,1,1)
  126312. * @param extent x,y,z value that define the extent around the queries point of reference
  126313. */
  126314. setDefaultQueryExtent(extent: Vector3): void;
  126315. /**
  126316. * Get the Bounding box extent specified by setDefaultQueryExtent
  126317. * @returns the box extent values
  126318. */
  126319. getDefaultQueryExtent(): Vector3;
  126320. /**
  126321. * Release all resources
  126322. */
  126323. dispose(): void;
  126324. }
  126325. /**
  126326. * Configures an agent
  126327. */
  126328. export interface IAgentParameters {
  126329. /**
  126330. * Agent radius. [Limit: >= 0]
  126331. */
  126332. radius: number;
  126333. /**
  126334. * Agent height. [Limit: > 0]
  126335. */
  126336. height: number;
  126337. /**
  126338. * Maximum allowed acceleration. [Limit: >= 0]
  126339. */
  126340. maxAcceleration: number;
  126341. /**
  126342. * Maximum allowed speed. [Limit: >= 0]
  126343. */
  126344. maxSpeed: number;
  126345. /**
  126346. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126347. */
  126348. collisionQueryRange: number;
  126349. /**
  126350. * The path visibility optimization range. [Limit: > 0]
  126351. */
  126352. pathOptimizationRange: number;
  126353. /**
  126354. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126355. */
  126356. separationWeight: number;
  126357. }
  126358. /**
  126359. * Configures the navigation mesh creation
  126360. */
  126361. export interface INavMeshParameters {
  126362. /**
  126363. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126364. */
  126365. cs: number;
  126366. /**
  126367. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126368. */
  126369. ch: number;
  126370. /**
  126371. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126372. */
  126373. walkableSlopeAngle: number;
  126374. /**
  126375. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126376. * be considered walkable. [Limit: >= 3] [Units: vx]
  126377. */
  126378. walkableHeight: number;
  126379. /**
  126380. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126381. */
  126382. walkableClimb: number;
  126383. /**
  126384. * The distance to erode/shrink the walkable area of the heightfield away from
  126385. * obstructions. [Limit: >=0] [Units: vx]
  126386. */
  126387. walkableRadius: number;
  126388. /**
  126389. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126390. */
  126391. maxEdgeLen: number;
  126392. /**
  126393. * The maximum distance a simplfied contour's border edges should deviate
  126394. * the original raw contour. [Limit: >=0] [Units: vx]
  126395. */
  126396. maxSimplificationError: number;
  126397. /**
  126398. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126399. */
  126400. minRegionArea: number;
  126401. /**
  126402. * Any regions with a span count smaller than this value will, if possible,
  126403. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126404. */
  126405. mergeRegionArea: number;
  126406. /**
  126407. * The maximum number of vertices allowed for polygons generated during the
  126408. * contour to polygon conversion process. [Limit: >= 3]
  126409. */
  126410. maxVertsPerPoly: number;
  126411. /**
  126412. * Sets the sampling distance to use when generating the detail mesh.
  126413. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126414. */
  126415. detailSampleDist: number;
  126416. /**
  126417. * The maximum distance the detail mesh surface should deviate from heightfield
  126418. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126419. */
  126420. detailSampleMaxError: number;
  126421. }
  126422. }
  126423. declare module BABYLON {
  126424. /**
  126425. * RecastJS navigation plugin
  126426. */
  126427. export class RecastJSPlugin implements INavigationEnginePlugin {
  126428. /**
  126429. * Reference to the Recast library
  126430. */
  126431. bjsRECAST: any;
  126432. /**
  126433. * plugin name
  126434. */
  126435. name: string;
  126436. /**
  126437. * the first navmesh created. We might extend this to support multiple navmeshes
  126438. */
  126439. navMesh: any;
  126440. /**
  126441. * Initializes the recastJS plugin
  126442. * @param recastInjection can be used to inject your own recast reference
  126443. */
  126444. constructor(recastInjection?: any);
  126445. /**
  126446. * Creates a navigation mesh
  126447. * @param meshes array of all the geometry used to compute the navigatio mesh
  126448. * @param parameters bunch of parameters used to filter geometry
  126449. */
  126450. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126451. /**
  126452. * Create a navigation mesh debug mesh
  126453. * @param scene is where the mesh will be added
  126454. * @returns debug display mesh
  126455. */
  126456. createDebugNavMesh(scene: Scene): Mesh;
  126457. /**
  126458. * Get a navigation mesh constrained position, closest to the parameter position
  126459. * @param position world position
  126460. * @returns the closest point to position constrained by the navigation mesh
  126461. */
  126462. getClosestPoint(position: Vector3): Vector3;
  126463. /**
  126464. * Get a navigation mesh constrained position, within a particular radius
  126465. * @param position world position
  126466. * @param maxRadius the maximum distance to the constrained world position
  126467. * @returns the closest point to position constrained by the navigation mesh
  126468. */
  126469. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126470. /**
  126471. * Compute the final position from a segment made of destination-position
  126472. * @param position world position
  126473. * @param destination world position
  126474. * @returns the resulting point along the navmesh
  126475. */
  126476. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126477. /**
  126478. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126479. * @param start world position
  126480. * @param end world position
  126481. * @returns array containing world position composing the path
  126482. */
  126483. computePath(start: Vector3, end: Vector3): Vector3[];
  126484. /**
  126485. * Create a new Crowd so you can add agents
  126486. * @param maxAgents the maximum agent count in the crowd
  126487. * @param maxAgentRadius the maximum radius an agent can have
  126488. * @param scene to attach the crowd to
  126489. * @returns the crowd you can add agents to
  126490. */
  126491. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126492. /**
  126493. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126494. * The queries will try to find a solution within those bounds
  126495. * default is (1,1,1)
  126496. * @param extent x,y,z value that define the extent around the queries point of reference
  126497. */
  126498. setDefaultQueryExtent(extent: Vector3): void;
  126499. /**
  126500. * Get the Bounding box extent specified by setDefaultQueryExtent
  126501. * @returns the box extent values
  126502. */
  126503. getDefaultQueryExtent(): Vector3;
  126504. /**
  126505. * Disposes
  126506. */
  126507. dispose(): void;
  126508. /**
  126509. * If this plugin is supported
  126510. * @returns true if plugin is supported
  126511. */
  126512. isSupported(): boolean;
  126513. }
  126514. /**
  126515. * Recast detour crowd implementation
  126516. */
  126517. export class RecastJSCrowd implements ICrowd {
  126518. /**
  126519. * Recast/detour plugin
  126520. */
  126521. bjsRECASTPlugin: RecastJSPlugin;
  126522. /**
  126523. * Link to the detour crowd
  126524. */
  126525. recastCrowd: any;
  126526. /**
  126527. * One transform per agent
  126528. */
  126529. transforms: TransformNode[];
  126530. /**
  126531. * All agents created
  126532. */
  126533. agents: number[];
  126534. /**
  126535. * Link to the scene is kept to unregister the crowd from the scene
  126536. */
  126537. private _scene;
  126538. /**
  126539. * Observer for crowd updates
  126540. */
  126541. private _onBeforeAnimationsObserver;
  126542. /**
  126543. * Constructor
  126544. * @param plugin recastJS plugin
  126545. * @param maxAgents the maximum agent count in the crowd
  126546. * @param maxAgentRadius the maximum radius an agent can have
  126547. * @param scene to attach the crowd to
  126548. * @returns the crowd you can add agents to
  126549. */
  126550. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  126551. /**
  126552. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126553. * You can attach anything to that node. The node position is updated in the scene update tick.
  126554. * @param pos world position that will be constrained by the navigation mesh
  126555. * @param parameters agent parameters
  126556. * @param transform hooked to the agent that will be update by the scene
  126557. * @returns agent index
  126558. */
  126559. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126560. /**
  126561. * Returns the agent position in world space
  126562. * @param index agent index returned by addAgent
  126563. * @returns world space position
  126564. */
  126565. getAgentPosition(index: number): Vector3;
  126566. /**
  126567. * Returns the agent velocity in world space
  126568. * @param index agent index returned by addAgent
  126569. * @returns world space velocity
  126570. */
  126571. getAgentVelocity(index: number): Vector3;
  126572. /**
  126573. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126574. * @param index agent index returned by addAgent
  126575. * @param destination targeted world position
  126576. */
  126577. agentGoto(index: number, destination: Vector3): void;
  126578. /**
  126579. * remove a particular agent previously created
  126580. * @param index agent index returned by addAgent
  126581. */
  126582. removeAgent(index: number): void;
  126583. /**
  126584. * get the list of all agents attached to this crowd
  126585. * @returns list of agent indices
  126586. */
  126587. getAgents(): number[];
  126588. /**
  126589. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126590. * @param deltaTime in seconds
  126591. */
  126592. update(deltaTime: number): void;
  126593. /**
  126594. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126595. * The queries will try to find a solution within those bounds
  126596. * default is (1,1,1)
  126597. * @param extent x,y,z value that define the extent around the queries point of reference
  126598. */
  126599. setDefaultQueryExtent(extent: Vector3): void;
  126600. /**
  126601. * Get the Bounding box extent specified by setDefaultQueryExtent
  126602. * @returns the box extent values
  126603. */
  126604. getDefaultQueryExtent(): Vector3;
  126605. /**
  126606. * Release all resources
  126607. */
  126608. dispose(): void;
  126609. }
  126610. }
  126611. declare module BABYLON {
  126612. /**
  126613. * Class used to enable access to IndexedDB
  126614. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  126615. */
  126616. export class Database implements IOfflineProvider {
  126617. private _callbackManifestChecked;
  126618. private _currentSceneUrl;
  126619. private _db;
  126620. private _enableSceneOffline;
  126621. private _enableTexturesOffline;
  126622. private _manifestVersionFound;
  126623. private _mustUpdateRessources;
  126624. private _hasReachedQuota;
  126625. private _isSupported;
  126626. private _idbFactory;
  126627. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  126628. private static IsUASupportingBlobStorage;
  126629. /**
  126630. * Gets a boolean indicating if Database storate is enabled (off by default)
  126631. */
  126632. static IDBStorageEnabled: boolean;
  126633. /**
  126634. * Gets a boolean indicating if scene must be saved in the database
  126635. */
  126636. readonly enableSceneOffline: boolean;
  126637. /**
  126638. * Gets a boolean indicating if textures must be saved in the database
  126639. */
  126640. readonly enableTexturesOffline: boolean;
  126641. /**
  126642. * Creates a new Database
  126643. * @param urlToScene defines the url to load the scene
  126644. * @param callbackManifestChecked defines the callback to use when manifest is checked
  126645. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  126646. */
  126647. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  126648. private static _ParseURL;
  126649. private static _ReturnFullUrlLocation;
  126650. private _checkManifestFile;
  126651. /**
  126652. * Open the database and make it available
  126653. * @param successCallback defines the callback to call on success
  126654. * @param errorCallback defines the callback to call on error
  126655. */
  126656. open(successCallback: () => void, errorCallback: () => void): void;
  126657. /**
  126658. * Loads an image from the database
  126659. * @param url defines the url to load from
  126660. * @param image defines the target DOM image
  126661. */
  126662. loadImage(url: string, image: HTMLImageElement): void;
  126663. private _loadImageFromDBAsync;
  126664. private _saveImageIntoDBAsync;
  126665. private _checkVersionFromDB;
  126666. private _loadVersionFromDBAsync;
  126667. private _saveVersionIntoDBAsync;
  126668. /**
  126669. * Loads a file from database
  126670. * @param url defines the URL to load from
  126671. * @param sceneLoaded defines a callback to call on success
  126672. * @param progressCallBack defines a callback to call when progress changed
  126673. * @param errorCallback defines a callback to call on error
  126674. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  126675. */
  126676. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  126677. private _loadFileAsync;
  126678. private _saveFileAsync;
  126679. /**
  126680. * Validates if xhr data is correct
  126681. * @param xhr defines the request to validate
  126682. * @param dataType defines the expected data type
  126683. * @returns true if data is correct
  126684. */
  126685. private static _ValidateXHRData;
  126686. }
  126687. }
  126688. declare module BABYLON {
  126689. /** @hidden */
  126690. export var gpuUpdateParticlesPixelShader: {
  126691. name: string;
  126692. shader: string;
  126693. };
  126694. }
  126695. declare module BABYLON {
  126696. /** @hidden */
  126697. export var gpuUpdateParticlesVertexShader: {
  126698. name: string;
  126699. shader: string;
  126700. };
  126701. }
  126702. declare module BABYLON {
  126703. /** @hidden */
  126704. export var clipPlaneFragmentDeclaration2: {
  126705. name: string;
  126706. shader: string;
  126707. };
  126708. }
  126709. declare module BABYLON {
  126710. /** @hidden */
  126711. export var gpuRenderParticlesPixelShader: {
  126712. name: string;
  126713. shader: string;
  126714. };
  126715. }
  126716. declare module BABYLON {
  126717. /** @hidden */
  126718. export var clipPlaneVertexDeclaration2: {
  126719. name: string;
  126720. shader: string;
  126721. };
  126722. }
  126723. declare module BABYLON {
  126724. /** @hidden */
  126725. export var gpuRenderParticlesVertexShader: {
  126726. name: string;
  126727. shader: string;
  126728. };
  126729. }
  126730. declare module BABYLON {
  126731. /**
  126732. * This represents a GPU particle system in Babylon
  126733. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  126734. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  126735. */
  126736. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  126737. /**
  126738. * The layer mask we are rendering the particles through.
  126739. */
  126740. layerMask: number;
  126741. private _capacity;
  126742. private _activeCount;
  126743. private _currentActiveCount;
  126744. private _accumulatedCount;
  126745. private _renderEffect;
  126746. private _updateEffect;
  126747. private _buffer0;
  126748. private _buffer1;
  126749. private _spriteBuffer;
  126750. private _updateVAO;
  126751. private _renderVAO;
  126752. private _targetIndex;
  126753. private _sourceBuffer;
  126754. private _targetBuffer;
  126755. private _engine;
  126756. private _currentRenderId;
  126757. private _started;
  126758. private _stopped;
  126759. private _timeDelta;
  126760. private _randomTexture;
  126761. private _randomTexture2;
  126762. private _attributesStrideSize;
  126763. private _updateEffectOptions;
  126764. private _randomTextureSize;
  126765. private _actualFrame;
  126766. private readonly _rawTextureWidth;
  126767. /**
  126768. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  126769. */
  126770. static readonly IsSupported: boolean;
  126771. /**
  126772. * An event triggered when the system is disposed.
  126773. */
  126774. onDisposeObservable: Observable<GPUParticleSystem>;
  126775. /**
  126776. * Gets the maximum number of particles active at the same time.
  126777. * @returns The max number of active particles.
  126778. */
  126779. getCapacity(): number;
  126780. /**
  126781. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  126782. * to override the particles.
  126783. */
  126784. forceDepthWrite: boolean;
  126785. /**
  126786. * Gets or set the number of active particles
  126787. */
  126788. activeParticleCount: number;
  126789. private _preWarmDone;
  126790. /**
  126791. * Is this system ready to be used/rendered
  126792. * @return true if the system is ready
  126793. */
  126794. isReady(): boolean;
  126795. /**
  126796. * Gets if the system has been started. (Note: this will still be true after stop is called)
  126797. * @returns True if it has been started, otherwise false.
  126798. */
  126799. isStarted(): boolean;
  126800. /**
  126801. * Starts the particle system and begins to emit
  126802. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  126803. */
  126804. start(delay?: number): void;
  126805. /**
  126806. * Stops the particle system.
  126807. */
  126808. stop(): void;
  126809. /**
  126810. * Remove all active particles
  126811. */
  126812. reset(): void;
  126813. /**
  126814. * Returns the string "GPUParticleSystem"
  126815. * @returns a string containing the class name
  126816. */
  126817. getClassName(): string;
  126818. private _colorGradientsTexture;
  126819. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  126820. /**
  126821. * Adds a new color gradient
  126822. * @param gradient defines the gradient to use (between 0 and 1)
  126823. * @param color1 defines the color to affect to the specified gradient
  126824. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  126825. * @returns the current particle system
  126826. */
  126827. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  126828. /**
  126829. * Remove a specific color gradient
  126830. * @param gradient defines the gradient to remove
  126831. * @returns the current particle system
  126832. */
  126833. removeColorGradient(gradient: number): GPUParticleSystem;
  126834. private _angularSpeedGradientsTexture;
  126835. private _sizeGradientsTexture;
  126836. private _velocityGradientsTexture;
  126837. private _limitVelocityGradientsTexture;
  126838. private _dragGradientsTexture;
  126839. private _addFactorGradient;
  126840. /**
  126841. * Adds a new size gradient
  126842. * @param gradient defines the gradient to use (between 0 and 1)
  126843. * @param factor defines the size factor to affect to the specified gradient
  126844. * @returns the current particle system
  126845. */
  126846. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  126847. /**
  126848. * Remove a specific size gradient
  126849. * @param gradient defines the gradient to remove
  126850. * @returns the current particle system
  126851. */
  126852. removeSizeGradient(gradient: number): GPUParticleSystem;
  126853. /**
  126854. * Adds a new angular speed gradient
  126855. * @param gradient defines the gradient to use (between 0 and 1)
  126856. * @param factor defines the angular speed to affect to the specified gradient
  126857. * @returns the current particle system
  126858. */
  126859. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  126860. /**
  126861. * Remove a specific angular speed gradient
  126862. * @param gradient defines the gradient to remove
  126863. * @returns the current particle system
  126864. */
  126865. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  126866. /**
  126867. * Adds a new velocity gradient
  126868. * @param gradient defines the gradient to use (between 0 and 1)
  126869. * @param factor defines the velocity to affect to the specified gradient
  126870. * @returns the current particle system
  126871. */
  126872. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126873. /**
  126874. * Remove a specific velocity gradient
  126875. * @param gradient defines the gradient to remove
  126876. * @returns the current particle system
  126877. */
  126878. removeVelocityGradient(gradient: number): GPUParticleSystem;
  126879. /**
  126880. * Adds a new limit velocity gradient
  126881. * @param gradient defines the gradient to use (between 0 and 1)
  126882. * @param factor defines the limit velocity value to affect to the specified gradient
  126883. * @returns the current particle system
  126884. */
  126885. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  126886. /**
  126887. * Remove a specific limit velocity gradient
  126888. * @param gradient defines the gradient to remove
  126889. * @returns the current particle system
  126890. */
  126891. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  126892. /**
  126893. * Adds a new drag gradient
  126894. * @param gradient defines the gradient to use (between 0 and 1)
  126895. * @param factor defines the drag value to affect to the specified gradient
  126896. * @returns the current particle system
  126897. */
  126898. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  126899. /**
  126900. * Remove a specific drag gradient
  126901. * @param gradient defines the gradient to remove
  126902. * @returns the current particle system
  126903. */
  126904. removeDragGradient(gradient: number): GPUParticleSystem;
  126905. /**
  126906. * Not supported by GPUParticleSystem
  126907. * @param gradient defines the gradient to use (between 0 and 1)
  126908. * @param factor defines the emit rate value to affect to the specified gradient
  126909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126910. * @returns the current particle system
  126911. */
  126912. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126913. /**
  126914. * Not supported by GPUParticleSystem
  126915. * @param gradient defines the gradient to remove
  126916. * @returns the current particle system
  126917. */
  126918. removeEmitRateGradient(gradient: number): IParticleSystem;
  126919. /**
  126920. * Not supported by GPUParticleSystem
  126921. * @param gradient defines the gradient to use (between 0 and 1)
  126922. * @param factor defines the start size value to affect to the specified gradient
  126923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126924. * @returns the current particle system
  126925. */
  126926. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126927. /**
  126928. * Not supported by GPUParticleSystem
  126929. * @param gradient defines the gradient to remove
  126930. * @returns the current particle system
  126931. */
  126932. removeStartSizeGradient(gradient: number): IParticleSystem;
  126933. /**
  126934. * Not supported by GPUParticleSystem
  126935. * @param gradient defines the gradient to use (between 0 and 1)
  126936. * @param min defines the color remap minimal range
  126937. * @param max defines the color remap maximal range
  126938. * @returns the current particle system
  126939. */
  126940. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126941. /**
  126942. * Not supported by GPUParticleSystem
  126943. * @param gradient defines the gradient to remove
  126944. * @returns the current particle system
  126945. */
  126946. removeColorRemapGradient(): IParticleSystem;
  126947. /**
  126948. * Not supported by GPUParticleSystem
  126949. * @param gradient defines the gradient to use (between 0 and 1)
  126950. * @param min defines the alpha remap minimal range
  126951. * @param max defines the alpha remap maximal range
  126952. * @returns the current particle system
  126953. */
  126954. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126955. /**
  126956. * Not supported by GPUParticleSystem
  126957. * @param gradient defines the gradient to remove
  126958. * @returns the current particle system
  126959. */
  126960. removeAlphaRemapGradient(): IParticleSystem;
  126961. /**
  126962. * Not supported by GPUParticleSystem
  126963. * @param gradient defines the gradient to use (between 0 and 1)
  126964. * @param color defines the color to affect to the specified gradient
  126965. * @returns the current particle system
  126966. */
  126967. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126968. /**
  126969. * Not supported by GPUParticleSystem
  126970. * @param gradient defines the gradient to remove
  126971. * @returns the current particle system
  126972. */
  126973. removeRampGradient(): IParticleSystem;
  126974. /**
  126975. * Not supported by GPUParticleSystem
  126976. * @returns the list of ramp gradients
  126977. */
  126978. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126979. /**
  126980. * Not supported by GPUParticleSystem
  126981. * Gets or sets a boolean indicating that ramp gradients must be used
  126982. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126983. */
  126984. useRampGradients: boolean;
  126985. /**
  126986. * Not supported by GPUParticleSystem
  126987. * @param gradient defines the gradient to use (between 0 and 1)
  126988. * @param factor defines the life time factor to affect to the specified gradient
  126989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126990. * @returns the current particle system
  126991. */
  126992. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126993. /**
  126994. * Not supported by GPUParticleSystem
  126995. * @param gradient defines the gradient to remove
  126996. * @returns the current particle system
  126997. */
  126998. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126999. /**
  127000. * Instantiates a GPU particle system.
  127001. * 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.
  127002. * @param name The name of the particle system
  127003. * @param options The options used to create the system
  127004. * @param scene The scene the particle system belongs to
  127005. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127006. */
  127007. constructor(name: string, options: Partial<{
  127008. capacity: number;
  127009. randomTextureSize: number;
  127010. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127011. protected _reset(): void;
  127012. private _createUpdateVAO;
  127013. private _createRenderVAO;
  127014. private _initialize;
  127015. /** @hidden */
  127016. _recreateUpdateEffect(): void;
  127017. /** @hidden */
  127018. _recreateRenderEffect(): void;
  127019. /**
  127020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127021. * @param preWarm defines if we are in the pre-warmimg phase
  127022. */
  127023. animate(preWarm?: boolean): void;
  127024. private _createFactorGradientTexture;
  127025. private _createSizeGradientTexture;
  127026. private _createAngularSpeedGradientTexture;
  127027. private _createVelocityGradientTexture;
  127028. private _createLimitVelocityGradientTexture;
  127029. private _createDragGradientTexture;
  127030. private _createColorGradientTexture;
  127031. /**
  127032. * Renders the particle system in its current state
  127033. * @param preWarm defines if the system should only update the particles but not render them
  127034. * @returns the current number of particles
  127035. */
  127036. render(preWarm?: boolean): number;
  127037. /**
  127038. * Rebuilds the particle system
  127039. */
  127040. rebuild(): void;
  127041. private _releaseBuffers;
  127042. private _releaseVAOs;
  127043. /**
  127044. * Disposes the particle system and free the associated resources
  127045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127046. */
  127047. dispose(disposeTexture?: boolean): void;
  127048. /**
  127049. * Clones the particle system.
  127050. * @param name The name of the cloned object
  127051. * @param newEmitter The new emitter to use
  127052. * @returns the cloned particle system
  127053. */
  127054. clone(name: string, newEmitter: any): GPUParticleSystem;
  127055. /**
  127056. * Serializes the particle system to a JSON object.
  127057. * @returns the JSON object
  127058. */
  127059. serialize(): any;
  127060. /**
  127061. * Parses a JSON object to create a GPU particle system.
  127062. * @param parsedParticleSystem The JSON object to parse
  127063. * @param scene The scene to create the particle system in
  127064. * @param rootUrl The root url to use to load external dependencies like texture
  127065. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127066. * @returns the parsed GPU particle system
  127067. */
  127068. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127069. }
  127070. }
  127071. declare module BABYLON {
  127072. /**
  127073. * Represents a set of particle systems working together to create a specific effect
  127074. */
  127075. export class ParticleSystemSet implements IDisposable {
  127076. /**
  127077. * Gets or sets base Assets URL
  127078. */
  127079. static BaseAssetsUrl: string;
  127080. private _emitterCreationOptions;
  127081. private _emitterNode;
  127082. /**
  127083. * Gets the particle system list
  127084. */
  127085. systems: IParticleSystem[];
  127086. /**
  127087. * Gets the emitter node used with this set
  127088. */
  127089. readonly emitterNode: Nullable<TransformNode>;
  127090. /**
  127091. * Creates a new emitter mesh as a sphere
  127092. * @param options defines the options used to create the sphere
  127093. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127094. * @param scene defines the hosting scene
  127095. */
  127096. setEmitterAsSphere(options: {
  127097. diameter: number;
  127098. segments: number;
  127099. color: Color3;
  127100. }, renderingGroupId: number, scene: Scene): void;
  127101. /**
  127102. * Starts all particle systems of the set
  127103. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127104. */
  127105. start(emitter?: AbstractMesh): void;
  127106. /**
  127107. * Release all associated resources
  127108. */
  127109. dispose(): void;
  127110. /**
  127111. * Serialize the set into a JSON compatible object
  127112. * @returns a JSON compatible representation of the set
  127113. */
  127114. serialize(): any;
  127115. /**
  127116. * Parse a new ParticleSystemSet from a serialized source
  127117. * @param data defines a JSON compatible representation of the set
  127118. * @param scene defines the hosting scene
  127119. * @param gpu defines if we want GPU particles or CPU particles
  127120. * @returns a new ParticleSystemSet
  127121. */
  127122. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127123. }
  127124. }
  127125. declare module BABYLON {
  127126. /**
  127127. * This class is made for on one-liner static method to help creating particle system set.
  127128. */
  127129. export class ParticleHelper {
  127130. /**
  127131. * Gets or sets base Assets URL
  127132. */
  127133. static BaseAssetsUrl: string;
  127134. /**
  127135. * Create a default particle system that you can tweak
  127136. * @param emitter defines the emitter to use
  127137. * @param capacity defines the system capacity (default is 500 particles)
  127138. * @param scene defines the hosting scene
  127139. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127140. * @returns the new Particle system
  127141. */
  127142. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127143. /**
  127144. * This is the main static method (one-liner) of this helper to create different particle systems
  127145. * @param type This string represents the type to the particle system to create
  127146. * @param scene The scene where the particle system should live
  127147. * @param gpu If the system will use gpu
  127148. * @returns the ParticleSystemSet created
  127149. */
  127150. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127151. /**
  127152. * Static function used to export a particle system to a ParticleSystemSet variable.
  127153. * Please note that the emitter shape is not exported
  127154. * @param systems defines the particle systems to export
  127155. * @returns the created particle system set
  127156. */
  127157. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127158. }
  127159. }
  127160. declare module BABYLON {
  127161. interface Engine {
  127162. /**
  127163. * Create an effect to use with particle systems.
  127164. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127165. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127166. * @param uniformsNames defines a list of attribute names
  127167. * @param samplers defines an array of string used to represent textures
  127168. * @param defines defines the string containing the defines to use to compile the shaders
  127169. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127170. * @param onCompiled defines a function to call when the effect creation is successful
  127171. * @param onError defines a function to call when the effect creation has failed
  127172. * @returns the new Effect
  127173. */
  127174. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127175. }
  127176. interface Mesh {
  127177. /**
  127178. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127179. * @returns an array of IParticleSystem
  127180. */
  127181. getEmittedParticleSystems(): IParticleSystem[];
  127182. /**
  127183. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127184. * @returns an array of IParticleSystem
  127185. */
  127186. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127187. }
  127188. /**
  127189. * @hidden
  127190. */
  127191. export var _IDoNeedToBeInTheBuild: number;
  127192. }
  127193. declare module BABYLON {
  127194. /** Defines the 4 color options */
  127195. export enum PointColor {
  127196. /** color value */
  127197. Color = 2,
  127198. /** uv value */
  127199. UV = 1,
  127200. /** random value */
  127201. Random = 0,
  127202. /** stated value */
  127203. Stated = 3
  127204. }
  127205. /**
  127206. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127207. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  127208. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127209. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127210. *
  127211. * Full documentation here : TO BE ENTERED
  127212. */
  127213. export class PointsCloudSystem implements IDisposable {
  127214. /**
  127215. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127216. * Example : var p = SPS.particles[i];
  127217. */
  127218. particles: CloudPoint[];
  127219. /**
  127220. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127221. */
  127222. nbParticles: number;
  127223. /**
  127224. * This a counter for your own usage. It's not set by any SPS functions.
  127225. */
  127226. counter: number;
  127227. /**
  127228. * The PCS name. This name is also given to the underlying mesh.
  127229. */
  127230. name: string;
  127231. /**
  127232. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127233. */
  127234. mesh: Mesh;
  127235. /**
  127236. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127237. * Please read :
  127238. */
  127239. vars: any;
  127240. /**
  127241. * @hidden
  127242. */
  127243. _size: number;
  127244. private _scene;
  127245. private _promises;
  127246. private _positions;
  127247. private _indices;
  127248. private _normals;
  127249. private _colors;
  127250. private _uvs;
  127251. private _indices32;
  127252. private _positions32;
  127253. private _colors32;
  127254. private _uvs32;
  127255. private _updatable;
  127256. private _isVisibilityBoxLocked;
  127257. private _alwaysVisible;
  127258. private _groups;
  127259. private _groupCounter;
  127260. private _computeParticleColor;
  127261. private _computeParticleTexture;
  127262. private _computeParticleRotation;
  127263. private _computeBoundingBox;
  127264. private _isReady;
  127265. /**
  127266. * Creates a PCS (Points Cloud System) object
  127267. * @param name (String) is the PCS name, this will be the underlying mesh name
  127268. * @param pointSize (number) is the size for each point
  127269. * @param scene (Scene) is the scene in which the PCS is added
  127270. * @param options defines the options of the PCS e.g.
  127271. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127272. */
  127273. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127274. updatable?: boolean;
  127275. });
  127276. /**
  127277. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127278. * If no points were added to the PCS, the returned mesh is just a single point.
  127279. * @returns a promise for the created mesh
  127280. */
  127281. buildMeshAsync(): Promise<Mesh>;
  127282. /**
  127283. * @hidden
  127284. */
  127285. private _buildMesh;
  127286. private _addParticle;
  127287. private _randomUnitVector;
  127288. private _getColorIndicesForCoord;
  127289. private _setPointsColorOrUV;
  127290. private _colorFromTexture;
  127291. private _calculateDensity;
  127292. /**
  127293. * Adds points to the PCS in random positions within a unit sphere
  127294. * @param nb (positive integer) the number of particles to be created from this model
  127295. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127296. * @returns the number of groups in the system
  127297. */
  127298. addPoints(nb: number, pointFunction?: any): number;
  127299. /**
  127300. * Adds points to the PCS from the surface of the model shape
  127301. * @param mesh is any Mesh object that will be used as a surface model for the points
  127302. * @param nb (positive integer) the number of particles to be created from this model
  127303. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127304. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127305. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127306. * @returns the number of groups in the system
  127307. */
  127308. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127309. /**
  127310. * Adds points to the PCS inside the model shape
  127311. * @param mesh is any Mesh object that will be used as a surface model for the points
  127312. * @param nb (positive integer) the number of particles to be created from this model
  127313. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127314. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127315. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127316. * @returns the number of groups in the system
  127317. */
  127318. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127319. /**
  127320. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127321. * This method calls `updateParticle()` for each particle of the SPS.
  127322. * For an animated SPS, it is usually called within the render loop.
  127323. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127324. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127325. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127326. * @returns the PCS.
  127327. */
  127328. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127329. /**
  127330. * Disposes the PCS.
  127331. */
  127332. dispose(): void;
  127333. /**
  127334. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127335. * doc :
  127336. * @returns the PCS.
  127337. */
  127338. refreshVisibleSize(): PointsCloudSystem;
  127339. /**
  127340. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127341. * @param size the size (float) of the visibility box
  127342. * note : this doesn't lock the PCS mesh bounding box.
  127343. * doc :
  127344. */
  127345. setVisibilityBox(size: number): void;
  127346. /**
  127347. * Gets whether the PCS is always visible or not
  127348. * doc :
  127349. */
  127350. /**
  127351. * Sets the PCS as always visible or not
  127352. * doc :
  127353. */
  127354. isAlwaysVisible: boolean;
  127355. /**
  127356. * Tells to `setParticles()` to compute the particle rotations or not
  127357. * Default value : false. The PCS is faster when it's set to false
  127358. * Note : particle rotations are only applied to parent particles
  127359. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127360. */
  127361. computeParticleRotation: boolean;
  127362. /**
  127363. * Tells to `setParticles()` to compute the particle colors or not.
  127364. * Default value : true. The PCS is faster when it's set to false.
  127365. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127366. */
  127367. /**
  127368. * Gets if `setParticles()` computes the particle colors or not.
  127369. * Default value : false. The PCS is faster when it's set to false.
  127370. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127371. */
  127372. computeParticleColor: boolean;
  127373. /**
  127374. * Gets if `setParticles()` computes the particle textures or not.
  127375. * Default value : false. The PCS is faster when it's set to false.
  127376. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127377. */
  127378. computeParticleTexture: boolean;
  127379. /**
  127380. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127381. */
  127382. /**
  127383. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127384. */
  127385. computeBoundingBox: boolean;
  127386. /**
  127387. * This function does nothing. It may be overwritten to set all the particle first values.
  127388. * The PCS doesn't call this function, you may have to call it by your own.
  127389. * doc :
  127390. */
  127391. initParticles(): void;
  127392. /**
  127393. * This function does nothing. It may be overwritten to recycle a particle
  127394. * The PCS doesn't call this function, you can to call it
  127395. * doc :
  127396. * @param particle The particle to recycle
  127397. * @returns the recycled particle
  127398. */
  127399. recycleParticle(particle: CloudPoint): CloudPoint;
  127400. /**
  127401. * Updates a particle : this function should be overwritten by the user.
  127402. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127403. * doc :
  127404. * @example : just set a particle position or velocity and recycle conditions
  127405. * @param particle The particle to update
  127406. * @returns the updated particle
  127407. */
  127408. updateParticle(particle: CloudPoint): CloudPoint;
  127409. /**
  127410. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127411. * This does nothing and may be overwritten by the user.
  127412. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127413. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127414. * @param update the boolean update value actually passed to setParticles()
  127415. */
  127416. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127417. /**
  127418. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127419. * This will be passed three parameters.
  127420. * This does nothing and may be overwritten by the user.
  127421. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127422. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127423. * @param update the boolean update value actually passed to setParticles()
  127424. */
  127425. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127426. }
  127427. }
  127428. declare module BABYLON {
  127429. /**
  127430. * Represents one particle of a points cloud system.
  127431. */
  127432. export class CloudPoint {
  127433. /**
  127434. * particle global index
  127435. */
  127436. idx: number;
  127437. /**
  127438. * The color of the particle
  127439. */
  127440. color: Nullable<Color4>;
  127441. /**
  127442. * The world space position of the particle.
  127443. */
  127444. position: Vector3;
  127445. /**
  127446. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127447. */
  127448. rotation: Vector3;
  127449. /**
  127450. * The world space rotation quaternion of the particle.
  127451. */
  127452. rotationQuaternion: Nullable<Quaternion>;
  127453. /**
  127454. * The uv of the particle.
  127455. */
  127456. uv: Nullable<Vector2>;
  127457. /**
  127458. * The current speed of the particle.
  127459. */
  127460. velocity: Vector3;
  127461. /**
  127462. * The pivot point in the particle local space.
  127463. */
  127464. pivot: Vector3;
  127465. /**
  127466. * Must the particle be translated from its pivot point in its local space ?
  127467. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127468. * Default : false
  127469. */
  127470. translateFromPivot: boolean;
  127471. /**
  127472. * Index of this particle in the global "positions" array (Internal use)
  127473. * @hidden
  127474. */
  127475. _pos: number;
  127476. /**
  127477. * @hidden Index of this particle in the global "indices" array (Internal use)
  127478. */
  127479. _ind: number;
  127480. /**
  127481. * Group this particle belongs to
  127482. */
  127483. _group: PointsGroup;
  127484. /**
  127485. * Group id of this particle
  127486. */
  127487. groupId: number;
  127488. /**
  127489. * Index of the particle in its group id (Internal use)
  127490. */
  127491. idxInGroup: number;
  127492. /**
  127493. * @hidden Particle BoundingInfo object (Internal use)
  127494. */
  127495. _boundingInfo: BoundingInfo;
  127496. /**
  127497. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127498. */
  127499. _pcs: PointsCloudSystem;
  127500. /**
  127501. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127502. */
  127503. _stillInvisible: boolean;
  127504. /**
  127505. * @hidden Last computed particle rotation matrix
  127506. */
  127507. _rotationMatrix: number[];
  127508. /**
  127509. * Parent particle Id, if any.
  127510. * Default null.
  127511. */
  127512. parentId: Nullable<number>;
  127513. /**
  127514. * @hidden Internal global position in the PCS.
  127515. */
  127516. _globalPosition: Vector3;
  127517. /**
  127518. * Creates a Point Cloud object.
  127519. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  127520. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  127521. * @param group (PointsGroup) is the group the particle belongs to
  127522. * @param groupId (integer) is the group identifier in the PCS.
  127523. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  127524. * @param pcs defines the PCS it is associated to
  127525. */
  127526. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  127527. /**
  127528. * get point size
  127529. */
  127530. /**
  127531. * Set point size
  127532. */
  127533. size: Vector3;
  127534. /**
  127535. * Legacy support, changed quaternion to rotationQuaternion
  127536. */
  127537. /**
  127538. * Legacy support, changed quaternion to rotationQuaternion
  127539. */
  127540. quaternion: Nullable<Quaternion>;
  127541. /**
  127542. * Returns a boolean. True if the particle intersects a mesh, else false
  127543. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  127544. * @param target is the object (point or mesh) what the intersection is computed against
  127545. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  127546. * @returns true if it intersects
  127547. */
  127548. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  127549. /**
  127550. * get the rotation matrix of the particle
  127551. * @hidden
  127552. */
  127553. getRotationMatrix(m: Matrix): void;
  127554. }
  127555. /**
  127556. * Represents a group of points in a points cloud system
  127557. * * PCS internal tool, don't use it manually.
  127558. */
  127559. export class PointsGroup {
  127560. /**
  127561. * The group id
  127562. * @hidden
  127563. */
  127564. groupID: number;
  127565. /**
  127566. * image data for group (internal use)
  127567. * @hidden
  127568. */
  127569. _groupImageData: Nullable<ArrayBufferView>;
  127570. /**
  127571. * Image Width (internal use)
  127572. * @hidden
  127573. */
  127574. _groupImgWidth: number;
  127575. /**
  127576. * Image Height (internal use)
  127577. * @hidden
  127578. */
  127579. _groupImgHeight: number;
  127580. /**
  127581. * Custom position function (internal use)
  127582. * @hidden
  127583. */
  127584. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  127585. /**
  127586. * density per facet for surface points
  127587. * @hidden
  127588. */
  127589. _groupDensity: number[];
  127590. /**
  127591. * Only when points are colored by texture carries pointer to texture list array
  127592. * @hidden
  127593. */
  127594. _textureNb: number;
  127595. /**
  127596. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  127597. * PCS internal tool, don't use it manually.
  127598. * @hidden
  127599. */
  127600. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  127601. }
  127602. }
  127603. declare module BABYLON {
  127604. interface Scene {
  127605. /** @hidden (Backing field) */
  127606. _physicsEngine: Nullable<IPhysicsEngine>;
  127607. /**
  127608. * Gets the current physics engine
  127609. * @returns a IPhysicsEngine or null if none attached
  127610. */
  127611. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  127612. /**
  127613. * Enables physics to the current scene
  127614. * @param gravity defines the scene's gravity for the physics engine
  127615. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  127616. * @return a boolean indicating if the physics engine was initialized
  127617. */
  127618. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  127619. /**
  127620. * Disables and disposes the physics engine associated with the scene
  127621. */
  127622. disablePhysicsEngine(): void;
  127623. /**
  127624. * Gets a boolean indicating if there is an active physics engine
  127625. * @returns a boolean indicating if there is an active physics engine
  127626. */
  127627. isPhysicsEnabled(): boolean;
  127628. /**
  127629. * Deletes a physics compound impostor
  127630. * @param compound defines the compound to delete
  127631. */
  127632. deleteCompoundImpostor(compound: any): void;
  127633. /**
  127634. * An event triggered when physic simulation is about to be run
  127635. */
  127636. onBeforePhysicsObservable: Observable<Scene>;
  127637. /**
  127638. * An event triggered when physic simulation has been done
  127639. */
  127640. onAfterPhysicsObservable: Observable<Scene>;
  127641. }
  127642. interface AbstractMesh {
  127643. /** @hidden */
  127644. _physicsImpostor: Nullable<PhysicsImpostor>;
  127645. /**
  127646. * Gets or sets impostor used for physic simulation
  127647. * @see http://doc.babylonjs.com/features/physics_engine
  127648. */
  127649. physicsImpostor: Nullable<PhysicsImpostor>;
  127650. /**
  127651. * Gets the current physics impostor
  127652. * @see http://doc.babylonjs.com/features/physics_engine
  127653. * @returns a physics impostor or null
  127654. */
  127655. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  127656. /** Apply a physic impulse to the mesh
  127657. * @param force defines the force to apply
  127658. * @param contactPoint defines where to apply the force
  127659. * @returns the current mesh
  127660. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127661. */
  127662. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  127663. /**
  127664. * Creates a physic joint between two meshes
  127665. * @param otherMesh defines the other mesh to use
  127666. * @param pivot1 defines the pivot to use on this mesh
  127667. * @param pivot2 defines the pivot to use on the other mesh
  127668. * @param options defines additional options (can be plugin dependent)
  127669. * @returns the current mesh
  127670. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  127671. */
  127672. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  127673. /** @hidden */
  127674. _disposePhysicsObserver: Nullable<Observer<Node>>;
  127675. }
  127676. /**
  127677. * Defines the physics engine scene component responsible to manage a physics engine
  127678. */
  127679. export class PhysicsEngineSceneComponent implements ISceneComponent {
  127680. /**
  127681. * The component name helpful to identify the component in the list of scene components.
  127682. */
  127683. readonly name: string;
  127684. /**
  127685. * The scene the component belongs to.
  127686. */
  127687. scene: Scene;
  127688. /**
  127689. * Creates a new instance of the component for the given scene
  127690. * @param scene Defines the scene to register the component in
  127691. */
  127692. constructor(scene: Scene);
  127693. /**
  127694. * Registers the component in a given scene
  127695. */
  127696. register(): void;
  127697. /**
  127698. * Rebuilds the elements related to this component in case of
  127699. * context lost for instance.
  127700. */
  127701. rebuild(): void;
  127702. /**
  127703. * Disposes the component and the associated ressources
  127704. */
  127705. dispose(): void;
  127706. }
  127707. }
  127708. declare module BABYLON {
  127709. /**
  127710. * A helper for physics simulations
  127711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127712. */
  127713. export class PhysicsHelper {
  127714. private _scene;
  127715. private _physicsEngine;
  127716. /**
  127717. * Initializes the Physics helper
  127718. * @param scene Babylon.js scene
  127719. */
  127720. constructor(scene: Scene);
  127721. /**
  127722. * Applies a radial explosion impulse
  127723. * @param origin the origin of the explosion
  127724. * @param radiusOrEventOptions the radius or the options of radial explosion
  127725. * @param strength the explosion strength
  127726. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127727. * @returns A physics radial explosion event, or null
  127728. */
  127729. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127730. /**
  127731. * Applies a radial explosion force
  127732. * @param origin the origin of the explosion
  127733. * @param radiusOrEventOptions the radius or the options of radial explosion
  127734. * @param strength the explosion strength
  127735. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127736. * @returns A physics radial explosion event, or null
  127737. */
  127738. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  127739. /**
  127740. * Creates a gravitational field
  127741. * @param origin the origin of the explosion
  127742. * @param radiusOrEventOptions the radius or the options of radial explosion
  127743. * @param strength the explosion strength
  127744. * @param falloff possible options: Constant & Linear. Defaults to Constant
  127745. * @returns A physics gravitational field event, or null
  127746. */
  127747. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  127748. /**
  127749. * Creates a physics updraft event
  127750. * @param origin the origin of the updraft
  127751. * @param radiusOrEventOptions the radius or the options of the updraft
  127752. * @param strength the strength of the updraft
  127753. * @param height the height of the updraft
  127754. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  127755. * @returns A physics updraft event, or null
  127756. */
  127757. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  127758. /**
  127759. * Creates a physics vortex event
  127760. * @param origin the of the vortex
  127761. * @param radiusOrEventOptions the radius or the options of the vortex
  127762. * @param strength the strength of the vortex
  127763. * @param height the height of the vortex
  127764. * @returns a Physics vortex event, or null
  127765. * A physics vortex event or null
  127766. */
  127767. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  127768. }
  127769. /**
  127770. * Represents a physics radial explosion event
  127771. */
  127772. class PhysicsRadialExplosionEvent {
  127773. private _scene;
  127774. private _options;
  127775. private _sphere;
  127776. private _dataFetched;
  127777. /**
  127778. * Initializes a radial explosioin event
  127779. * @param _scene BabylonJS scene
  127780. * @param _options The options for the vortex event
  127781. */
  127782. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  127783. /**
  127784. * Returns the data related to the radial explosion event (sphere).
  127785. * @returns The radial explosion event data
  127786. */
  127787. getData(): PhysicsRadialExplosionEventData;
  127788. /**
  127789. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  127790. * @param impostor A physics imposter
  127791. * @param origin the origin of the explosion
  127792. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  127793. */
  127794. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  127795. /**
  127796. * Triggers affecterd impostors callbacks
  127797. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  127798. */
  127799. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  127800. /**
  127801. * Disposes the sphere.
  127802. * @param force Specifies if the sphere should be disposed by force
  127803. */
  127804. dispose(force?: boolean): void;
  127805. /*** Helpers ***/
  127806. private _prepareSphere;
  127807. private _intersectsWithSphere;
  127808. }
  127809. /**
  127810. * Represents a gravitational field event
  127811. */
  127812. class PhysicsGravitationalFieldEvent {
  127813. private _physicsHelper;
  127814. private _scene;
  127815. private _origin;
  127816. private _options;
  127817. private _tickCallback;
  127818. private _sphere;
  127819. private _dataFetched;
  127820. /**
  127821. * Initializes the physics gravitational field event
  127822. * @param _physicsHelper A physics helper
  127823. * @param _scene BabylonJS scene
  127824. * @param _origin The origin position of the gravitational field event
  127825. * @param _options The options for the vortex event
  127826. */
  127827. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  127828. /**
  127829. * Returns the data related to the gravitational field event (sphere).
  127830. * @returns A gravitational field event
  127831. */
  127832. getData(): PhysicsGravitationalFieldEventData;
  127833. /**
  127834. * Enables the gravitational field.
  127835. */
  127836. enable(): void;
  127837. /**
  127838. * Disables the gravitational field.
  127839. */
  127840. disable(): void;
  127841. /**
  127842. * Disposes the sphere.
  127843. * @param force The force to dispose from the gravitational field event
  127844. */
  127845. dispose(force?: boolean): void;
  127846. private _tick;
  127847. }
  127848. /**
  127849. * Represents a physics updraft event
  127850. */
  127851. class PhysicsUpdraftEvent {
  127852. private _scene;
  127853. private _origin;
  127854. private _options;
  127855. private _physicsEngine;
  127856. private _originTop;
  127857. private _originDirection;
  127858. private _tickCallback;
  127859. private _cylinder;
  127860. private _cylinderPosition;
  127861. private _dataFetched;
  127862. /**
  127863. * Initializes the physics updraft event
  127864. * @param _scene BabylonJS scene
  127865. * @param _origin The origin position of the updraft
  127866. * @param _options The options for the updraft event
  127867. */
  127868. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  127869. /**
  127870. * Returns the data related to the updraft event (cylinder).
  127871. * @returns A physics updraft event
  127872. */
  127873. getData(): PhysicsUpdraftEventData;
  127874. /**
  127875. * Enables the updraft.
  127876. */
  127877. enable(): void;
  127878. /**
  127879. * Disables the updraft.
  127880. */
  127881. disable(): void;
  127882. /**
  127883. * Disposes the cylinder.
  127884. * @param force Specifies if the updraft should be disposed by force
  127885. */
  127886. dispose(force?: boolean): void;
  127887. private getImpostorHitData;
  127888. private _tick;
  127889. /*** Helpers ***/
  127890. private _prepareCylinder;
  127891. private _intersectsWithCylinder;
  127892. }
  127893. /**
  127894. * Represents a physics vortex event
  127895. */
  127896. class PhysicsVortexEvent {
  127897. private _scene;
  127898. private _origin;
  127899. private _options;
  127900. private _physicsEngine;
  127901. private _originTop;
  127902. private _tickCallback;
  127903. private _cylinder;
  127904. private _cylinderPosition;
  127905. private _dataFetched;
  127906. /**
  127907. * Initializes the physics vortex event
  127908. * @param _scene The BabylonJS scene
  127909. * @param _origin The origin position of the vortex
  127910. * @param _options The options for the vortex event
  127911. */
  127912. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  127913. /**
  127914. * Returns the data related to the vortex event (cylinder).
  127915. * @returns The physics vortex event data
  127916. */
  127917. getData(): PhysicsVortexEventData;
  127918. /**
  127919. * Enables the vortex.
  127920. */
  127921. enable(): void;
  127922. /**
  127923. * Disables the cortex.
  127924. */
  127925. disable(): void;
  127926. /**
  127927. * Disposes the sphere.
  127928. * @param force
  127929. */
  127930. dispose(force?: boolean): void;
  127931. private getImpostorHitData;
  127932. private _tick;
  127933. /*** Helpers ***/
  127934. private _prepareCylinder;
  127935. private _intersectsWithCylinder;
  127936. }
  127937. /**
  127938. * Options fot the radial explosion event
  127939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127940. */
  127941. export class PhysicsRadialExplosionEventOptions {
  127942. /**
  127943. * The radius of the sphere for the radial explosion.
  127944. */
  127945. radius: number;
  127946. /**
  127947. * The strenth of the explosion.
  127948. */
  127949. strength: number;
  127950. /**
  127951. * The strenght of the force in correspondence to the distance of the affected object
  127952. */
  127953. falloff: PhysicsRadialImpulseFalloff;
  127954. /**
  127955. * Sphere options for the radial explosion.
  127956. */
  127957. sphere: {
  127958. segments: number;
  127959. diameter: number;
  127960. };
  127961. /**
  127962. * Sphere options for the radial explosion.
  127963. */
  127964. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127965. }
  127966. /**
  127967. * Options fot the updraft event
  127968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127969. */
  127970. export class PhysicsUpdraftEventOptions {
  127971. /**
  127972. * The radius of the cylinder for the vortex
  127973. */
  127974. radius: number;
  127975. /**
  127976. * The strenth of the updraft.
  127977. */
  127978. strength: number;
  127979. /**
  127980. * The height of the cylinder for the updraft.
  127981. */
  127982. height: number;
  127983. /**
  127984. * The mode for the the updraft.
  127985. */
  127986. updraftMode: PhysicsUpdraftMode;
  127987. }
  127988. /**
  127989. * Options fot the vortex event
  127990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127991. */
  127992. export class PhysicsVortexEventOptions {
  127993. /**
  127994. * The radius of the cylinder for the vortex
  127995. */
  127996. radius: number;
  127997. /**
  127998. * The strenth of the vortex.
  127999. */
  128000. strength: number;
  128001. /**
  128002. * The height of the cylinder for the vortex.
  128003. */
  128004. height: number;
  128005. /**
  128006. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128007. */
  128008. centripetalForceThreshold: number;
  128009. /**
  128010. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128011. */
  128012. centripetalForceMultiplier: number;
  128013. /**
  128014. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128015. */
  128016. centrifugalForceMultiplier: number;
  128017. /**
  128018. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128019. */
  128020. updraftForceMultiplier: number;
  128021. }
  128022. /**
  128023. * The strenght of the force in correspondence to the distance of the affected object
  128024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128025. */
  128026. export enum PhysicsRadialImpulseFalloff {
  128027. /** Defines that impulse is constant in strength across it's whole radius */
  128028. Constant = 0,
  128029. /** Defines that impulse gets weaker if it's further from the origin */
  128030. Linear = 1
  128031. }
  128032. /**
  128033. * The strength of the force in correspondence to the distance of the affected object
  128034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128035. */
  128036. export enum PhysicsUpdraftMode {
  128037. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128038. Center = 0,
  128039. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128040. Perpendicular = 1
  128041. }
  128042. /**
  128043. * Interface for a physics hit data
  128044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128045. */
  128046. export interface PhysicsHitData {
  128047. /**
  128048. * The force applied at the contact point
  128049. */
  128050. force: Vector3;
  128051. /**
  128052. * The contact point
  128053. */
  128054. contactPoint: Vector3;
  128055. /**
  128056. * The distance from the origin to the contact point
  128057. */
  128058. distanceFromOrigin: number;
  128059. }
  128060. /**
  128061. * Interface for radial explosion event data
  128062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128063. */
  128064. export interface PhysicsRadialExplosionEventData {
  128065. /**
  128066. * A sphere used for the radial explosion event
  128067. */
  128068. sphere: Mesh;
  128069. }
  128070. /**
  128071. * Interface for gravitational field event data
  128072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128073. */
  128074. export interface PhysicsGravitationalFieldEventData {
  128075. /**
  128076. * A sphere mesh used for the gravitational field event
  128077. */
  128078. sphere: Mesh;
  128079. }
  128080. /**
  128081. * Interface for updraft event data
  128082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128083. */
  128084. export interface PhysicsUpdraftEventData {
  128085. /**
  128086. * A cylinder used for the updraft event
  128087. */
  128088. cylinder: Mesh;
  128089. }
  128090. /**
  128091. * Interface for vortex event data
  128092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128093. */
  128094. export interface PhysicsVortexEventData {
  128095. /**
  128096. * A cylinder used for the vortex event
  128097. */
  128098. cylinder: Mesh;
  128099. }
  128100. /**
  128101. * Interface for an affected physics impostor
  128102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128103. */
  128104. export interface PhysicsAffectedImpostorWithData {
  128105. /**
  128106. * The impostor affected by the effect
  128107. */
  128108. impostor: PhysicsImpostor;
  128109. /**
  128110. * The data about the hit/horce from the explosion
  128111. */
  128112. hitData: PhysicsHitData;
  128113. }
  128114. }
  128115. declare module BABYLON {
  128116. /** @hidden */
  128117. export var blackAndWhitePixelShader: {
  128118. name: string;
  128119. shader: string;
  128120. };
  128121. }
  128122. declare module BABYLON {
  128123. /**
  128124. * Post process used to render in black and white
  128125. */
  128126. export class BlackAndWhitePostProcess extends PostProcess {
  128127. /**
  128128. * Linear about to convert he result to black and white (default: 1)
  128129. */
  128130. degree: number;
  128131. /**
  128132. * Creates a black and white post process
  128133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128134. * @param name The name of the effect.
  128135. * @param options The required width/height ratio to downsize to before computing the render pass.
  128136. * @param camera The camera to apply the render pass to.
  128137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128138. * @param engine The engine which the post process will be applied. (default: current engine)
  128139. * @param reusable If the post process can be reused on the same frame. (default: false)
  128140. */
  128141. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128142. }
  128143. }
  128144. declare module BABYLON {
  128145. /**
  128146. * This represents a set of one or more post processes in Babylon.
  128147. * A post process can be used to apply a shader to a texture after it is rendered.
  128148. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128149. */
  128150. export class PostProcessRenderEffect {
  128151. private _postProcesses;
  128152. private _getPostProcesses;
  128153. private _singleInstance;
  128154. private _cameras;
  128155. private _indicesForCamera;
  128156. /**
  128157. * Name of the effect
  128158. * @hidden
  128159. */
  128160. _name: string;
  128161. /**
  128162. * Instantiates a post process render effect.
  128163. * A post process can be used to apply a shader to a texture after it is rendered.
  128164. * @param engine The engine the effect is tied to
  128165. * @param name The name of the effect
  128166. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128167. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128168. */
  128169. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128170. /**
  128171. * Checks if all the post processes in the effect are supported.
  128172. */
  128173. readonly isSupported: boolean;
  128174. /**
  128175. * Updates the current state of the effect
  128176. * @hidden
  128177. */
  128178. _update(): void;
  128179. /**
  128180. * Attaches the effect on cameras
  128181. * @param cameras The camera to attach to.
  128182. * @hidden
  128183. */
  128184. _attachCameras(cameras: Camera): void;
  128185. /**
  128186. * Attaches the effect on cameras
  128187. * @param cameras The camera to attach to.
  128188. * @hidden
  128189. */
  128190. _attachCameras(cameras: Camera[]): void;
  128191. /**
  128192. * Detaches the effect on cameras
  128193. * @param cameras The camera to detatch from.
  128194. * @hidden
  128195. */
  128196. _detachCameras(cameras: Camera): void;
  128197. /**
  128198. * Detatches the effect on cameras
  128199. * @param cameras The camera to detatch from.
  128200. * @hidden
  128201. */
  128202. _detachCameras(cameras: Camera[]): void;
  128203. /**
  128204. * Enables the effect on given cameras
  128205. * @param cameras The camera to enable.
  128206. * @hidden
  128207. */
  128208. _enable(cameras: Camera): void;
  128209. /**
  128210. * Enables the effect on given cameras
  128211. * @param cameras The camera to enable.
  128212. * @hidden
  128213. */
  128214. _enable(cameras: Nullable<Camera[]>): void;
  128215. /**
  128216. * Disables the effect on the given cameras
  128217. * @param cameras The camera to disable.
  128218. * @hidden
  128219. */
  128220. _disable(cameras: Camera): void;
  128221. /**
  128222. * Disables the effect on the given cameras
  128223. * @param cameras The camera to disable.
  128224. * @hidden
  128225. */
  128226. _disable(cameras: Nullable<Camera[]>): void;
  128227. /**
  128228. * Gets a list of the post processes contained in the effect.
  128229. * @param camera The camera to get the post processes on.
  128230. * @returns The list of the post processes in the effect.
  128231. */
  128232. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128233. }
  128234. }
  128235. declare module BABYLON {
  128236. /** @hidden */
  128237. export var extractHighlightsPixelShader: {
  128238. name: string;
  128239. shader: string;
  128240. };
  128241. }
  128242. declare module BABYLON {
  128243. /**
  128244. * 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.
  128245. */
  128246. export class ExtractHighlightsPostProcess extends PostProcess {
  128247. /**
  128248. * The luminance threshold, pixels below this value will be set to black.
  128249. */
  128250. threshold: number;
  128251. /** @hidden */
  128252. _exposure: number;
  128253. /**
  128254. * Post process which has the input texture to be used when performing highlight extraction
  128255. * @hidden
  128256. */
  128257. _inputPostProcess: Nullable<PostProcess>;
  128258. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128259. }
  128260. }
  128261. declare module BABYLON {
  128262. /** @hidden */
  128263. export var bloomMergePixelShader: {
  128264. name: string;
  128265. shader: string;
  128266. };
  128267. }
  128268. declare module BABYLON {
  128269. /**
  128270. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128271. */
  128272. export class BloomMergePostProcess extends PostProcess {
  128273. /** Weight of the bloom to be added to the original input. */
  128274. weight: number;
  128275. /**
  128276. * Creates a new instance of @see BloomMergePostProcess
  128277. * @param name The name of the effect.
  128278. * @param originalFromInput Post process which's input will be used for the merge.
  128279. * @param blurred Blurred highlights post process which's output will be used.
  128280. * @param weight Weight of the bloom to be added to the original input.
  128281. * @param options The required width/height ratio to downsize to before computing the render pass.
  128282. * @param camera The camera to apply the render pass to.
  128283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128284. * @param engine The engine which the post process will be applied. (default: current engine)
  128285. * @param reusable If the post process can be reused on the same frame. (default: false)
  128286. * @param textureType Type of textures used when performing the post process. (default: 0)
  128287. * @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)
  128288. */
  128289. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128290. /** Weight of the bloom to be added to the original input. */
  128291. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128292. }
  128293. }
  128294. declare module BABYLON {
  128295. /**
  128296. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128297. */
  128298. export class BloomEffect extends PostProcessRenderEffect {
  128299. private bloomScale;
  128300. /**
  128301. * @hidden Internal
  128302. */
  128303. _effects: Array<PostProcess>;
  128304. /**
  128305. * @hidden Internal
  128306. */
  128307. _downscale: ExtractHighlightsPostProcess;
  128308. private _blurX;
  128309. private _blurY;
  128310. private _merge;
  128311. /**
  128312. * The luminance threshold to find bright areas of the image to bloom.
  128313. */
  128314. threshold: number;
  128315. /**
  128316. * The strength of the bloom.
  128317. */
  128318. weight: number;
  128319. /**
  128320. * Specifies the size of the bloom blur kernel, relative to the final output size
  128321. */
  128322. kernel: number;
  128323. /**
  128324. * Creates a new instance of @see BloomEffect
  128325. * @param scene The scene the effect belongs to.
  128326. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128327. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128328. * @param bloomWeight The the strength of bloom.
  128329. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128330. * @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)
  128331. */
  128332. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128333. /**
  128334. * Disposes each of the internal effects for a given camera.
  128335. * @param camera The camera to dispose the effect on.
  128336. */
  128337. disposeEffects(camera: Camera): void;
  128338. /**
  128339. * @hidden Internal
  128340. */
  128341. _updateEffects(): void;
  128342. /**
  128343. * Internal
  128344. * @returns if all the contained post processes are ready.
  128345. * @hidden
  128346. */
  128347. _isReady(): boolean;
  128348. }
  128349. }
  128350. declare module BABYLON {
  128351. /** @hidden */
  128352. export var chromaticAberrationPixelShader: {
  128353. name: string;
  128354. shader: string;
  128355. };
  128356. }
  128357. declare module BABYLON {
  128358. /**
  128359. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128360. */
  128361. export class ChromaticAberrationPostProcess extends PostProcess {
  128362. /**
  128363. * The amount of seperation of rgb channels (default: 30)
  128364. */
  128365. aberrationAmount: number;
  128366. /**
  128367. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128368. */
  128369. radialIntensity: number;
  128370. /**
  128371. * 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))
  128372. */
  128373. direction: Vector2;
  128374. /**
  128375. * 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))
  128376. */
  128377. centerPosition: Vector2;
  128378. /**
  128379. * Creates a new instance ChromaticAberrationPostProcess
  128380. * @param name The name of the effect.
  128381. * @param screenWidth The width of the screen to apply the effect on.
  128382. * @param screenHeight The height of the screen to apply the effect on.
  128383. * @param options The required width/height ratio to downsize to before computing the render pass.
  128384. * @param camera The camera to apply the render pass to.
  128385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128386. * @param engine The engine which the post process will be applied. (default: current engine)
  128387. * @param reusable If the post process can be reused on the same frame. (default: false)
  128388. * @param textureType Type of textures used when performing the post process. (default: 0)
  128389. * @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)
  128390. */
  128391. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128392. }
  128393. }
  128394. declare module BABYLON {
  128395. /** @hidden */
  128396. export var circleOfConfusionPixelShader: {
  128397. name: string;
  128398. shader: string;
  128399. };
  128400. }
  128401. declare module BABYLON {
  128402. /**
  128403. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128404. */
  128405. export class CircleOfConfusionPostProcess extends PostProcess {
  128406. /**
  128407. * 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.
  128408. */
  128409. lensSize: number;
  128410. /**
  128411. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128412. */
  128413. fStop: number;
  128414. /**
  128415. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128416. */
  128417. focusDistance: number;
  128418. /**
  128419. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128420. */
  128421. focalLength: number;
  128422. private _depthTexture;
  128423. /**
  128424. * Creates a new instance CircleOfConfusionPostProcess
  128425. * @param name The name of the effect.
  128426. * @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.
  128427. * @param options The required width/height ratio to downsize to before computing the render pass.
  128428. * @param camera The camera to apply the render pass to.
  128429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128430. * @param engine The engine which the post process will be applied. (default: current engine)
  128431. * @param reusable If the post process can be reused on the same frame. (default: false)
  128432. * @param textureType Type of textures used when performing the post process. (default: 0)
  128433. * @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)
  128434. */
  128435. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128436. /**
  128437. * 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.
  128438. */
  128439. depthTexture: RenderTargetTexture;
  128440. }
  128441. }
  128442. declare module BABYLON {
  128443. /** @hidden */
  128444. export var colorCorrectionPixelShader: {
  128445. name: string;
  128446. shader: string;
  128447. };
  128448. }
  128449. declare module BABYLON {
  128450. /**
  128451. *
  128452. * This post-process allows the modification of rendered colors by using
  128453. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128454. *
  128455. * The object needs to be provided an url to a texture containing the color
  128456. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128457. * Use an image editing software to tweak the LUT to match your needs.
  128458. *
  128459. * For an example of a color LUT, see here:
  128460. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128461. * For explanations on color grading, see here:
  128462. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128463. *
  128464. */
  128465. export class ColorCorrectionPostProcess extends PostProcess {
  128466. private _colorTableTexture;
  128467. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128468. }
  128469. }
  128470. declare module BABYLON {
  128471. /** @hidden */
  128472. export var convolutionPixelShader: {
  128473. name: string;
  128474. shader: string;
  128475. };
  128476. }
  128477. declare module BABYLON {
  128478. /**
  128479. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128480. * input texture to perform effects such as edge detection or sharpening
  128481. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128482. */
  128483. export class ConvolutionPostProcess extends PostProcess {
  128484. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128485. kernel: number[];
  128486. /**
  128487. * Creates a new instance ConvolutionPostProcess
  128488. * @param name The name of the effect.
  128489. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128490. * @param options The required width/height ratio to downsize to before computing the render pass.
  128491. * @param camera The camera to apply the render pass to.
  128492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128493. * @param engine The engine which the post process will be applied. (default: current engine)
  128494. * @param reusable If the post process can be reused on the same frame. (default: false)
  128495. * @param textureType Type of textures used when performing the post process. (default: 0)
  128496. */
  128497. constructor(name: string,
  128498. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128499. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128500. /**
  128501. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128502. */
  128503. static EdgeDetect0Kernel: number[];
  128504. /**
  128505. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128506. */
  128507. static EdgeDetect1Kernel: number[];
  128508. /**
  128509. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128510. */
  128511. static EdgeDetect2Kernel: number[];
  128512. /**
  128513. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128514. */
  128515. static SharpenKernel: number[];
  128516. /**
  128517. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128518. */
  128519. static EmbossKernel: number[];
  128520. /**
  128521. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128522. */
  128523. static GaussianKernel: number[];
  128524. }
  128525. }
  128526. declare module BABYLON {
  128527. /**
  128528. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  128529. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  128530. * based on samples that have a large difference in distance than the center pixel.
  128531. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  128532. */
  128533. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  128534. direction: Vector2;
  128535. /**
  128536. * Creates a new instance CircleOfConfusionPostProcess
  128537. * @param name The name of the effect.
  128538. * @param scene The scene the effect belongs to.
  128539. * @param direction The direction the blur should be applied.
  128540. * @param kernel The size of the kernel used to blur.
  128541. * @param options The required width/height ratio to downsize to before computing the render pass.
  128542. * @param camera The camera to apply the render pass to.
  128543. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  128544. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  128545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128546. * @param engine The engine which the post process will be applied. (default: current engine)
  128547. * @param reusable If the post process can be reused on the same frame. (default: false)
  128548. * @param textureType Type of textures used when performing the post process. (default: 0)
  128549. * @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)
  128550. */
  128551. 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);
  128552. }
  128553. }
  128554. declare module BABYLON {
  128555. /** @hidden */
  128556. export var depthOfFieldMergePixelShader: {
  128557. name: string;
  128558. shader: string;
  128559. };
  128560. }
  128561. declare module BABYLON {
  128562. /**
  128563. * Options to be set when merging outputs from the default pipeline.
  128564. */
  128565. export class DepthOfFieldMergePostProcessOptions {
  128566. /**
  128567. * The original image to merge on top of
  128568. */
  128569. originalFromInput: PostProcess;
  128570. /**
  128571. * Parameters to perform the merge of the depth of field effect
  128572. */
  128573. depthOfField?: {
  128574. circleOfConfusion: PostProcess;
  128575. blurSteps: Array<PostProcess>;
  128576. };
  128577. /**
  128578. * Parameters to perform the merge of bloom effect
  128579. */
  128580. bloom?: {
  128581. blurred: PostProcess;
  128582. weight: number;
  128583. };
  128584. }
  128585. /**
  128586. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128587. */
  128588. export class DepthOfFieldMergePostProcess extends PostProcess {
  128589. private blurSteps;
  128590. /**
  128591. * Creates a new instance of DepthOfFieldMergePostProcess
  128592. * @param name The name of the effect.
  128593. * @param originalFromInput Post process which's input will be used for the merge.
  128594. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  128595. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  128596. * @param options The required width/height ratio to downsize to before computing the render pass.
  128597. * @param camera The camera to apply the render pass to.
  128598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128599. * @param engine The engine which the post process will be applied. (default: current engine)
  128600. * @param reusable If the post process can be reused on the same frame. (default: false)
  128601. * @param textureType Type of textures used when performing the post process. (default: 0)
  128602. * @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)
  128603. */
  128604. 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);
  128605. /**
  128606. * Updates the effect with the current post process compile time values and recompiles the shader.
  128607. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  128608. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  128609. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  128610. * @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
  128611. * @param onCompiled Called when the shader has been compiled.
  128612. * @param onError Called if there is an error when compiling a shader.
  128613. */
  128614. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  128615. }
  128616. }
  128617. declare module BABYLON {
  128618. /**
  128619. * Specifies the level of max blur that should be applied when using the depth of field effect
  128620. */
  128621. export enum DepthOfFieldEffectBlurLevel {
  128622. /**
  128623. * Subtle blur
  128624. */
  128625. Low = 0,
  128626. /**
  128627. * Medium blur
  128628. */
  128629. Medium = 1,
  128630. /**
  128631. * Large blur
  128632. */
  128633. High = 2
  128634. }
  128635. /**
  128636. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  128637. */
  128638. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  128639. private _circleOfConfusion;
  128640. /**
  128641. * @hidden Internal, blurs from high to low
  128642. */
  128643. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  128644. private _depthOfFieldBlurY;
  128645. private _dofMerge;
  128646. /**
  128647. * @hidden Internal post processes in depth of field effect
  128648. */
  128649. _effects: Array<PostProcess>;
  128650. /**
  128651. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  128652. */
  128653. focalLength: number;
  128654. /**
  128655. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128656. */
  128657. fStop: number;
  128658. /**
  128659. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128660. */
  128661. focusDistance: number;
  128662. /**
  128663. * 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.
  128664. */
  128665. lensSize: number;
  128666. /**
  128667. * Creates a new instance DepthOfFieldEffect
  128668. * @param scene The scene the effect belongs to.
  128669. * @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.
  128670. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128671. * @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)
  128672. */
  128673. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  128674. /**
  128675. * Get the current class name of the current effet
  128676. * @returns "DepthOfFieldEffect"
  128677. */
  128678. getClassName(): string;
  128679. /**
  128680. * 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.
  128681. */
  128682. depthTexture: RenderTargetTexture;
  128683. /**
  128684. * Disposes each of the internal effects for a given camera.
  128685. * @param camera The camera to dispose the effect on.
  128686. */
  128687. disposeEffects(camera: Camera): void;
  128688. /**
  128689. * @hidden Internal
  128690. */
  128691. _updateEffects(): void;
  128692. /**
  128693. * Internal
  128694. * @returns if all the contained post processes are ready.
  128695. * @hidden
  128696. */
  128697. _isReady(): boolean;
  128698. }
  128699. }
  128700. declare module BABYLON {
  128701. /** @hidden */
  128702. export var displayPassPixelShader: {
  128703. name: string;
  128704. shader: string;
  128705. };
  128706. }
  128707. declare module BABYLON {
  128708. /**
  128709. * DisplayPassPostProcess which produces an output the same as it's input
  128710. */
  128711. export class DisplayPassPostProcess extends PostProcess {
  128712. /**
  128713. * Creates the DisplayPassPostProcess
  128714. * @param name The name of the effect.
  128715. * @param options The required width/height ratio to downsize to before computing the render pass.
  128716. * @param camera The camera to apply the render pass to.
  128717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128718. * @param engine The engine which the post process will be applied. (default: current engine)
  128719. * @param reusable If the post process can be reused on the same frame. (default: false)
  128720. */
  128721. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128722. }
  128723. }
  128724. declare module BABYLON {
  128725. /** @hidden */
  128726. export var filterPixelShader: {
  128727. name: string;
  128728. shader: string;
  128729. };
  128730. }
  128731. declare module BABYLON {
  128732. /**
  128733. * Applies a kernel filter to the image
  128734. */
  128735. export class FilterPostProcess extends PostProcess {
  128736. /** The matrix to be applied to the image */
  128737. kernelMatrix: Matrix;
  128738. /**
  128739. *
  128740. * @param name The name of the effect.
  128741. * @param kernelMatrix The matrix to be applied to the image
  128742. * @param options The required width/height ratio to downsize to before computing the render pass.
  128743. * @param camera The camera to apply the render pass to.
  128744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128745. * @param engine The engine which the post process will be applied. (default: current engine)
  128746. * @param reusable If the post process can be reused on the same frame. (default: false)
  128747. */
  128748. constructor(name: string,
  128749. /** The matrix to be applied to the image */
  128750. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128751. }
  128752. }
  128753. declare module BABYLON {
  128754. /** @hidden */
  128755. export var fxaaPixelShader: {
  128756. name: string;
  128757. shader: string;
  128758. };
  128759. }
  128760. declare module BABYLON {
  128761. /** @hidden */
  128762. export var fxaaVertexShader: {
  128763. name: string;
  128764. shader: string;
  128765. };
  128766. }
  128767. declare module BABYLON {
  128768. /**
  128769. * Fxaa post process
  128770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  128771. */
  128772. export class FxaaPostProcess extends PostProcess {
  128773. /** @hidden */
  128774. texelWidth: number;
  128775. /** @hidden */
  128776. texelHeight: number;
  128777. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128778. private _getDefines;
  128779. }
  128780. }
  128781. declare module BABYLON {
  128782. /** @hidden */
  128783. export var grainPixelShader: {
  128784. name: string;
  128785. shader: string;
  128786. };
  128787. }
  128788. declare module BABYLON {
  128789. /**
  128790. * The GrainPostProcess adds noise to the image at mid luminance levels
  128791. */
  128792. export class GrainPostProcess extends PostProcess {
  128793. /**
  128794. * The intensity of the grain added (default: 30)
  128795. */
  128796. intensity: number;
  128797. /**
  128798. * If the grain should be randomized on every frame
  128799. */
  128800. animated: boolean;
  128801. /**
  128802. * Creates a new instance of @see GrainPostProcess
  128803. * @param name The name of the effect.
  128804. * @param options The required width/height ratio to downsize to before computing the render pass.
  128805. * @param camera The camera to apply the render pass to.
  128806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128807. * @param engine The engine which the post process will be applied. (default: current engine)
  128808. * @param reusable If the post process can be reused on the same frame. (default: false)
  128809. * @param textureType Type of textures used when performing the post process. (default: 0)
  128810. * @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)
  128811. */
  128812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128813. }
  128814. }
  128815. declare module BABYLON {
  128816. /** @hidden */
  128817. export var highlightsPixelShader: {
  128818. name: string;
  128819. shader: string;
  128820. };
  128821. }
  128822. declare module BABYLON {
  128823. /**
  128824. * Extracts highlights from the image
  128825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128826. */
  128827. export class HighlightsPostProcess extends PostProcess {
  128828. /**
  128829. * Extracts highlights from the image
  128830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  128831. * @param name The name of the effect.
  128832. * @param options The required width/height ratio to downsize to before computing the render pass.
  128833. * @param camera The camera to apply the render pass to.
  128834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128835. * @param engine The engine which the post process will be applied. (default: current engine)
  128836. * @param reusable If the post process can be reused on the same frame. (default: false)
  128837. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  128838. */
  128839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128840. }
  128841. }
  128842. declare module BABYLON {
  128843. /** @hidden */
  128844. export var mrtFragmentDeclaration: {
  128845. name: string;
  128846. shader: string;
  128847. };
  128848. }
  128849. declare module BABYLON {
  128850. /** @hidden */
  128851. export var geometryPixelShader: {
  128852. name: string;
  128853. shader: string;
  128854. };
  128855. }
  128856. declare module BABYLON {
  128857. /** @hidden */
  128858. export var geometryVertexShader: {
  128859. name: string;
  128860. shader: string;
  128861. };
  128862. }
  128863. declare module BABYLON {
  128864. /** @hidden */
  128865. interface ISavedTransformationMatrix {
  128866. world: Matrix;
  128867. viewProjection: Matrix;
  128868. }
  128869. /**
  128870. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  128871. */
  128872. export class GeometryBufferRenderer {
  128873. /**
  128874. * Constant used to retrieve the position texture index in the G-Buffer textures array
  128875. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  128876. */
  128877. static readonly POSITION_TEXTURE_TYPE: number;
  128878. /**
  128879. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  128880. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  128881. */
  128882. static readonly VELOCITY_TEXTURE_TYPE: number;
  128883. /**
  128884. * Dictionary used to store the previous transformation matrices of each rendered mesh
  128885. * in order to compute objects velocities when enableVelocity is set to "true"
  128886. * @hidden
  128887. */
  128888. _previousTransformationMatrices: {
  128889. [index: number]: ISavedTransformationMatrix;
  128890. };
  128891. /**
  128892. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  128893. * in order to compute objects velocities when enableVelocity is set to "true"
  128894. * @hidden
  128895. */
  128896. _previousBonesTransformationMatrices: {
  128897. [index: number]: Float32Array;
  128898. };
  128899. /**
  128900. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  128901. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  128902. */
  128903. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  128904. private _scene;
  128905. private _multiRenderTarget;
  128906. private _ratio;
  128907. private _enablePosition;
  128908. private _enableVelocity;
  128909. private _positionIndex;
  128910. private _velocityIndex;
  128911. protected _effect: Effect;
  128912. protected _cachedDefines: string;
  128913. /**
  128914. * Set the render list (meshes to be rendered) used in the G buffer.
  128915. */
  128916. renderList: Mesh[];
  128917. /**
  128918. * Gets wether or not G buffer are supported by the running hardware.
  128919. * This requires draw buffer supports
  128920. */
  128921. readonly isSupported: boolean;
  128922. /**
  128923. * Returns the index of the given texture type in the G-Buffer textures array
  128924. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  128925. * @returns the index of the given texture type in the G-Buffer textures array
  128926. */
  128927. getTextureIndex(textureType: number): number;
  128928. /**
  128929. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128930. */
  128931. /**
  128932. * Sets whether or not objects positions are enabled for the G buffer.
  128933. */
  128934. enablePosition: boolean;
  128935. /**
  128936. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128937. */
  128938. /**
  128939. * Sets wether or not objects velocities are enabled for the G buffer.
  128940. */
  128941. enableVelocity: boolean;
  128942. /**
  128943. * Gets the scene associated with the buffer.
  128944. */
  128945. readonly scene: Scene;
  128946. /**
  128947. * Gets the ratio used by the buffer during its creation.
  128948. * How big is the buffer related to the main canvas.
  128949. */
  128950. readonly ratio: number;
  128951. /** @hidden */
  128952. static _SceneComponentInitialization: (scene: Scene) => void;
  128953. /**
  128954. * Creates a new G Buffer for the scene
  128955. * @param scene The scene the buffer belongs to
  128956. * @param ratio How big is the buffer related to the main canvas.
  128957. */
  128958. constructor(scene: Scene, ratio?: number);
  128959. /**
  128960. * Checks wether everything is ready to render a submesh to the G buffer.
  128961. * @param subMesh the submesh to check readiness for
  128962. * @param useInstances is the mesh drawn using instance or not
  128963. * @returns true if ready otherwise false
  128964. */
  128965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128966. /**
  128967. * Gets the current underlying G Buffer.
  128968. * @returns the buffer
  128969. */
  128970. getGBuffer(): MultiRenderTarget;
  128971. /**
  128972. * Gets the number of samples used to render the buffer (anti aliasing).
  128973. */
  128974. /**
  128975. * Sets the number of samples used to render the buffer (anti aliasing).
  128976. */
  128977. samples: number;
  128978. /**
  128979. * Disposes the renderer and frees up associated resources.
  128980. */
  128981. dispose(): void;
  128982. protected _createRenderTargets(): void;
  128983. private _copyBonesTransformationMatrices;
  128984. }
  128985. }
  128986. declare module BABYLON {
  128987. interface Scene {
  128988. /** @hidden (Backing field) */
  128989. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128990. /**
  128991. * Gets or Sets the current geometry buffer associated to the scene.
  128992. */
  128993. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128994. /**
  128995. * Enables a GeometryBufferRender and associates it with the scene
  128996. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128997. * @returns the GeometryBufferRenderer
  128998. */
  128999. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129000. /**
  129001. * Disables the GeometryBufferRender associated with the scene
  129002. */
  129003. disableGeometryBufferRenderer(): void;
  129004. }
  129005. /**
  129006. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129007. * in several rendering techniques.
  129008. */
  129009. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129010. /**
  129011. * The component name helpful to identify the component in the list of scene components.
  129012. */
  129013. readonly name: string;
  129014. /**
  129015. * The scene the component belongs to.
  129016. */
  129017. scene: Scene;
  129018. /**
  129019. * Creates a new instance of the component for the given scene
  129020. * @param scene Defines the scene to register the component in
  129021. */
  129022. constructor(scene: Scene);
  129023. /**
  129024. * Registers the component in a given scene
  129025. */
  129026. register(): void;
  129027. /**
  129028. * Rebuilds the elements related to this component in case of
  129029. * context lost for instance.
  129030. */
  129031. rebuild(): void;
  129032. /**
  129033. * Disposes the component and the associated ressources
  129034. */
  129035. dispose(): void;
  129036. private _gatherRenderTargets;
  129037. }
  129038. }
  129039. declare module BABYLON {
  129040. /** @hidden */
  129041. export var motionBlurPixelShader: {
  129042. name: string;
  129043. shader: string;
  129044. };
  129045. }
  129046. declare module BABYLON {
  129047. /**
  129048. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129049. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129050. * As an example, all you have to do is to create the post-process:
  129051. * var mb = new BABYLON.MotionBlurPostProcess(
  129052. * 'mb', // The name of the effect.
  129053. * scene, // The scene containing the objects to blur according to their velocity.
  129054. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129055. * camera // The camera to apply the render pass to.
  129056. * );
  129057. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129058. */
  129059. export class MotionBlurPostProcess extends PostProcess {
  129060. /**
  129061. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129062. */
  129063. motionStrength: number;
  129064. /**
  129065. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129066. */
  129067. /**
  129068. * Sets the number of iterations to be used for motion blur quality
  129069. */
  129070. motionBlurSamples: number;
  129071. private _motionBlurSamples;
  129072. private _geometryBufferRenderer;
  129073. /**
  129074. * Creates a new instance MotionBlurPostProcess
  129075. * @param name The name of the effect.
  129076. * @param scene The scene containing the objects to blur according to their velocity.
  129077. * @param options The required width/height ratio to downsize to before computing the render pass.
  129078. * @param camera The camera to apply the render pass to.
  129079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129080. * @param engine The engine which the post process will be applied. (default: current engine)
  129081. * @param reusable If the post process can be reused on the same frame. (default: false)
  129082. * @param textureType Type of textures used when performing the post process. (default: 0)
  129083. * @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)
  129084. */
  129085. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129086. /**
  129087. * Excludes the given skinned mesh from computing bones velocities.
  129088. * 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.
  129089. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129090. */
  129091. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129092. /**
  129093. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129094. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129095. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129096. */
  129097. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129098. /**
  129099. * Disposes the post process.
  129100. * @param camera The camera to dispose the post process on.
  129101. */
  129102. dispose(camera?: Camera): void;
  129103. }
  129104. }
  129105. declare module BABYLON {
  129106. /** @hidden */
  129107. export var refractionPixelShader: {
  129108. name: string;
  129109. shader: string;
  129110. };
  129111. }
  129112. declare module BABYLON {
  129113. /**
  129114. * Post process which applies a refractin texture
  129115. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129116. */
  129117. export class RefractionPostProcess extends PostProcess {
  129118. /** the base color of the refraction (used to taint the rendering) */
  129119. color: Color3;
  129120. /** simulated refraction depth */
  129121. depth: number;
  129122. /** the coefficient of the base color (0 to remove base color tainting) */
  129123. colorLevel: number;
  129124. private _refTexture;
  129125. private _ownRefractionTexture;
  129126. /**
  129127. * Gets or sets the refraction texture
  129128. * Please note that you are responsible for disposing the texture if you set it manually
  129129. */
  129130. refractionTexture: Texture;
  129131. /**
  129132. * Initializes the RefractionPostProcess
  129133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129134. * @param name The name of the effect.
  129135. * @param refractionTextureUrl Url of the refraction texture to use
  129136. * @param color the base color of the refraction (used to taint the rendering)
  129137. * @param depth simulated refraction depth
  129138. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129139. * @param camera The camera to apply the render pass to.
  129140. * @param options The required width/height ratio to downsize to before computing the render pass.
  129141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129142. * @param engine The engine which the post process will be applied. (default: current engine)
  129143. * @param reusable If the post process can be reused on the same frame. (default: false)
  129144. */
  129145. constructor(name: string, refractionTextureUrl: string,
  129146. /** the base color of the refraction (used to taint the rendering) */
  129147. color: Color3,
  129148. /** simulated refraction depth */
  129149. depth: number,
  129150. /** the coefficient of the base color (0 to remove base color tainting) */
  129151. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129152. /**
  129153. * Disposes of the post process
  129154. * @param camera Camera to dispose post process on
  129155. */
  129156. dispose(camera: Camera): void;
  129157. }
  129158. }
  129159. declare module BABYLON {
  129160. /** @hidden */
  129161. export var sharpenPixelShader: {
  129162. name: string;
  129163. shader: string;
  129164. };
  129165. }
  129166. declare module BABYLON {
  129167. /**
  129168. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129169. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129170. */
  129171. export class SharpenPostProcess extends PostProcess {
  129172. /**
  129173. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129174. */
  129175. colorAmount: number;
  129176. /**
  129177. * How much sharpness should be applied (default: 0.3)
  129178. */
  129179. edgeAmount: number;
  129180. /**
  129181. * Creates a new instance ConvolutionPostProcess
  129182. * @param name The name of the effect.
  129183. * @param options The required width/height ratio to downsize to before computing the render pass.
  129184. * @param camera The camera to apply the render pass to.
  129185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129186. * @param engine The engine which the post process will be applied. (default: current engine)
  129187. * @param reusable If the post process can be reused on the same frame. (default: false)
  129188. * @param textureType Type of textures used when performing the post process. (default: 0)
  129189. * @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)
  129190. */
  129191. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129192. }
  129193. }
  129194. declare module BABYLON {
  129195. /**
  129196. * PostProcessRenderPipeline
  129197. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129198. */
  129199. export class PostProcessRenderPipeline {
  129200. private engine;
  129201. private _renderEffects;
  129202. private _renderEffectsForIsolatedPass;
  129203. /**
  129204. * List of inspectable custom properties (used by the Inspector)
  129205. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129206. */
  129207. inspectableCustomProperties: IInspectable[];
  129208. /**
  129209. * @hidden
  129210. */
  129211. protected _cameras: Camera[];
  129212. /** @hidden */
  129213. _name: string;
  129214. /**
  129215. * Gets pipeline name
  129216. */
  129217. readonly name: string;
  129218. /** Gets the list of attached cameras */
  129219. readonly cameras: Camera[];
  129220. /**
  129221. * Initializes a PostProcessRenderPipeline
  129222. * @param engine engine to add the pipeline to
  129223. * @param name name of the pipeline
  129224. */
  129225. constructor(engine: Engine, name: string);
  129226. /**
  129227. * Gets the class name
  129228. * @returns "PostProcessRenderPipeline"
  129229. */
  129230. getClassName(): string;
  129231. /**
  129232. * If all the render effects in the pipeline are supported
  129233. */
  129234. readonly isSupported: boolean;
  129235. /**
  129236. * Adds an effect to the pipeline
  129237. * @param renderEffect the effect to add
  129238. */
  129239. addEffect(renderEffect: PostProcessRenderEffect): void;
  129240. /** @hidden */
  129241. _rebuild(): void;
  129242. /** @hidden */
  129243. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129244. /** @hidden */
  129245. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129246. /** @hidden */
  129247. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129248. /** @hidden */
  129249. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129250. /** @hidden */
  129251. _attachCameras(cameras: Camera, unique: boolean): void;
  129252. /** @hidden */
  129253. _attachCameras(cameras: Camera[], unique: boolean): void;
  129254. /** @hidden */
  129255. _detachCameras(cameras: Camera): void;
  129256. /** @hidden */
  129257. _detachCameras(cameras: Nullable<Camera[]>): void;
  129258. /** @hidden */
  129259. _update(): void;
  129260. /** @hidden */
  129261. _reset(): void;
  129262. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129263. /**
  129264. * Disposes of the pipeline
  129265. */
  129266. dispose(): void;
  129267. }
  129268. }
  129269. declare module BABYLON {
  129270. /**
  129271. * PostProcessRenderPipelineManager class
  129272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129273. */
  129274. export class PostProcessRenderPipelineManager {
  129275. private _renderPipelines;
  129276. /**
  129277. * Initializes a PostProcessRenderPipelineManager
  129278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129279. */
  129280. constructor();
  129281. /**
  129282. * Gets the list of supported render pipelines
  129283. */
  129284. readonly supportedPipelines: PostProcessRenderPipeline[];
  129285. /**
  129286. * Adds a pipeline to the manager
  129287. * @param renderPipeline The pipeline to add
  129288. */
  129289. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129290. /**
  129291. * Attaches a camera to the pipeline
  129292. * @param renderPipelineName The name of the pipeline to attach to
  129293. * @param cameras the camera to attach
  129294. * @param unique if the camera can be attached multiple times to the pipeline
  129295. */
  129296. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129297. /**
  129298. * Detaches a camera from the pipeline
  129299. * @param renderPipelineName The name of the pipeline to detach from
  129300. * @param cameras the camera to detach
  129301. */
  129302. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129303. /**
  129304. * Enables an effect by name on a pipeline
  129305. * @param renderPipelineName the name of the pipeline to enable the effect in
  129306. * @param renderEffectName the name of the effect to enable
  129307. * @param cameras the cameras that the effect should be enabled on
  129308. */
  129309. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129310. /**
  129311. * Disables an effect by name on a pipeline
  129312. * @param renderPipelineName the name of the pipeline to disable the effect in
  129313. * @param renderEffectName the name of the effect to disable
  129314. * @param cameras the cameras that the effect should be disabled on
  129315. */
  129316. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129317. /**
  129318. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129319. */
  129320. update(): void;
  129321. /** @hidden */
  129322. _rebuild(): void;
  129323. /**
  129324. * Disposes of the manager and pipelines
  129325. */
  129326. dispose(): void;
  129327. }
  129328. }
  129329. declare module BABYLON {
  129330. interface Scene {
  129331. /** @hidden (Backing field) */
  129332. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129333. /**
  129334. * Gets the postprocess render pipeline manager
  129335. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129336. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129337. */
  129338. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129339. }
  129340. /**
  129341. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129342. */
  129343. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129344. /**
  129345. * The component name helpfull to identify the component in the list of scene components.
  129346. */
  129347. readonly name: string;
  129348. /**
  129349. * The scene the component belongs to.
  129350. */
  129351. scene: Scene;
  129352. /**
  129353. * Creates a new instance of the component for the given scene
  129354. * @param scene Defines the scene to register the component in
  129355. */
  129356. constructor(scene: Scene);
  129357. /**
  129358. * Registers the component in a given scene
  129359. */
  129360. register(): void;
  129361. /**
  129362. * Rebuilds the elements related to this component in case of
  129363. * context lost for instance.
  129364. */
  129365. rebuild(): void;
  129366. /**
  129367. * Disposes the component and the associated ressources
  129368. */
  129369. dispose(): void;
  129370. private _gatherRenderTargets;
  129371. }
  129372. }
  129373. declare module BABYLON {
  129374. /**
  129375. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129376. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129377. */
  129378. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129379. private _scene;
  129380. private _camerasToBeAttached;
  129381. /**
  129382. * ID of the sharpen post process,
  129383. */
  129384. private readonly SharpenPostProcessId;
  129385. /**
  129386. * @ignore
  129387. * ID of the image processing post process;
  129388. */
  129389. readonly ImageProcessingPostProcessId: string;
  129390. /**
  129391. * @ignore
  129392. * ID of the Fast Approximate Anti-Aliasing post process;
  129393. */
  129394. readonly FxaaPostProcessId: string;
  129395. /**
  129396. * ID of the chromatic aberration post process,
  129397. */
  129398. private readonly ChromaticAberrationPostProcessId;
  129399. /**
  129400. * ID of the grain post process
  129401. */
  129402. private readonly GrainPostProcessId;
  129403. /**
  129404. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129405. */
  129406. sharpen: SharpenPostProcess;
  129407. private _sharpenEffect;
  129408. private bloom;
  129409. /**
  129410. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129411. */
  129412. depthOfField: DepthOfFieldEffect;
  129413. /**
  129414. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129415. */
  129416. fxaa: FxaaPostProcess;
  129417. /**
  129418. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129419. */
  129420. imageProcessing: ImageProcessingPostProcess;
  129421. /**
  129422. * Chromatic aberration post process which will shift rgb colors in the image
  129423. */
  129424. chromaticAberration: ChromaticAberrationPostProcess;
  129425. private _chromaticAberrationEffect;
  129426. /**
  129427. * Grain post process which add noise to the image
  129428. */
  129429. grain: GrainPostProcess;
  129430. private _grainEffect;
  129431. /**
  129432. * Glow post process which adds a glow to emissive areas of the image
  129433. */
  129434. private _glowLayer;
  129435. /**
  129436. * Animations which can be used to tweak settings over a period of time
  129437. */
  129438. animations: Animation[];
  129439. private _imageProcessingConfigurationObserver;
  129440. private _sharpenEnabled;
  129441. private _bloomEnabled;
  129442. private _depthOfFieldEnabled;
  129443. private _depthOfFieldBlurLevel;
  129444. private _fxaaEnabled;
  129445. private _imageProcessingEnabled;
  129446. private _defaultPipelineTextureType;
  129447. private _bloomScale;
  129448. private _chromaticAberrationEnabled;
  129449. private _grainEnabled;
  129450. private _buildAllowed;
  129451. /**
  129452. * Gets active scene
  129453. */
  129454. readonly scene: Scene;
  129455. /**
  129456. * Enable or disable the sharpen process from the pipeline
  129457. */
  129458. sharpenEnabled: boolean;
  129459. private _resizeObserver;
  129460. private _hardwareScaleLevel;
  129461. private _bloomKernel;
  129462. /**
  129463. * Specifies the size of the bloom blur kernel, relative to the final output size
  129464. */
  129465. bloomKernel: number;
  129466. /**
  129467. * Specifies the weight of the bloom in the final rendering
  129468. */
  129469. private _bloomWeight;
  129470. /**
  129471. * Specifies the luma threshold for the area that will be blurred by the bloom
  129472. */
  129473. private _bloomThreshold;
  129474. private _hdr;
  129475. /**
  129476. * The strength of the bloom.
  129477. */
  129478. bloomWeight: number;
  129479. /**
  129480. * The strength of the bloom.
  129481. */
  129482. bloomThreshold: number;
  129483. /**
  129484. * The scale of the bloom, lower value will provide better performance.
  129485. */
  129486. bloomScale: number;
  129487. /**
  129488. * Enable or disable the bloom from the pipeline
  129489. */
  129490. bloomEnabled: boolean;
  129491. private _rebuildBloom;
  129492. /**
  129493. * If the depth of field is enabled.
  129494. */
  129495. depthOfFieldEnabled: boolean;
  129496. /**
  129497. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129498. */
  129499. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129500. /**
  129501. * If the anti aliasing is enabled.
  129502. */
  129503. fxaaEnabled: boolean;
  129504. private _samples;
  129505. /**
  129506. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129507. */
  129508. samples: number;
  129509. /**
  129510. * If image processing is enabled.
  129511. */
  129512. imageProcessingEnabled: boolean;
  129513. /**
  129514. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  129515. */
  129516. glowLayerEnabled: boolean;
  129517. /**
  129518. * Gets the glow layer (or null if not defined)
  129519. */
  129520. readonly glowLayer: Nullable<GlowLayer>;
  129521. /**
  129522. * Enable or disable the chromaticAberration process from the pipeline
  129523. */
  129524. chromaticAberrationEnabled: boolean;
  129525. /**
  129526. * Enable or disable the grain process from the pipeline
  129527. */
  129528. grainEnabled: boolean;
  129529. /**
  129530. * @constructor
  129531. * @param name - The rendering pipeline name (default: "")
  129532. * @param hdr - If high dynamic range textures should be used (default: true)
  129533. * @param scene - The scene linked to this pipeline (default: the last created scene)
  129534. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  129535. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  129536. */
  129537. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  129538. /**
  129539. * Get the class name
  129540. * @returns "DefaultRenderingPipeline"
  129541. */
  129542. getClassName(): string;
  129543. /**
  129544. * Force the compilation of the entire pipeline.
  129545. */
  129546. prepare(): void;
  129547. private _hasCleared;
  129548. private _prevPostProcess;
  129549. private _prevPrevPostProcess;
  129550. private _setAutoClearAndTextureSharing;
  129551. private _depthOfFieldSceneObserver;
  129552. private _buildPipeline;
  129553. private _disposePostProcesses;
  129554. /**
  129555. * Adds a camera to the pipeline
  129556. * @param camera the camera to be added
  129557. */
  129558. addCamera(camera: Camera): void;
  129559. /**
  129560. * Removes a camera from the pipeline
  129561. * @param camera the camera to remove
  129562. */
  129563. removeCamera(camera: Camera): void;
  129564. /**
  129565. * Dispose of the pipeline and stop all post processes
  129566. */
  129567. dispose(): void;
  129568. /**
  129569. * Serialize the rendering pipeline (Used when exporting)
  129570. * @returns the serialized object
  129571. */
  129572. serialize(): any;
  129573. /**
  129574. * Parse the serialized pipeline
  129575. * @param source Source pipeline.
  129576. * @param scene The scene to load the pipeline to.
  129577. * @param rootUrl The URL of the serialized pipeline.
  129578. * @returns An instantiated pipeline from the serialized object.
  129579. */
  129580. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  129581. }
  129582. }
  129583. declare module BABYLON {
  129584. /** @hidden */
  129585. export var lensHighlightsPixelShader: {
  129586. name: string;
  129587. shader: string;
  129588. };
  129589. }
  129590. declare module BABYLON {
  129591. /** @hidden */
  129592. export var depthOfFieldPixelShader: {
  129593. name: string;
  129594. shader: string;
  129595. };
  129596. }
  129597. declare module BABYLON {
  129598. /**
  129599. * BABYLON.JS Chromatic Aberration GLSL Shader
  129600. * Author: Olivier Guyot
  129601. * Separates very slightly R, G and B colors on the edges of the screen
  129602. * Inspired by Francois Tarlier & Martins Upitis
  129603. */
  129604. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  129605. /**
  129606. * @ignore
  129607. * The chromatic aberration PostProcess id in the pipeline
  129608. */
  129609. LensChromaticAberrationEffect: string;
  129610. /**
  129611. * @ignore
  129612. * The highlights enhancing PostProcess id in the pipeline
  129613. */
  129614. HighlightsEnhancingEffect: string;
  129615. /**
  129616. * @ignore
  129617. * The depth-of-field PostProcess id in the pipeline
  129618. */
  129619. LensDepthOfFieldEffect: string;
  129620. private _scene;
  129621. private _depthTexture;
  129622. private _grainTexture;
  129623. private _chromaticAberrationPostProcess;
  129624. private _highlightsPostProcess;
  129625. private _depthOfFieldPostProcess;
  129626. private _edgeBlur;
  129627. private _grainAmount;
  129628. private _chromaticAberration;
  129629. private _distortion;
  129630. private _highlightsGain;
  129631. private _highlightsThreshold;
  129632. private _dofDistance;
  129633. private _dofAperture;
  129634. private _dofDarken;
  129635. private _dofPentagon;
  129636. private _blurNoise;
  129637. /**
  129638. * @constructor
  129639. *
  129640. * Effect parameters are as follow:
  129641. * {
  129642. * chromatic_aberration: number; // from 0 to x (1 for realism)
  129643. * edge_blur: number; // from 0 to x (1 for realism)
  129644. * distortion: number; // from 0 to x (1 for realism)
  129645. * grain_amount: number; // from 0 to 1
  129646. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  129647. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  129648. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  129649. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  129650. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  129651. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  129652. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  129653. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  129654. * }
  129655. * Note: if an effect parameter is unset, effect is disabled
  129656. *
  129657. * @param name The rendering pipeline name
  129658. * @param parameters - An object containing all parameters (see above)
  129659. * @param scene The scene linked to this pipeline
  129660. * @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)
  129661. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129662. */
  129663. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  129664. /**
  129665. * Get the class name
  129666. * @returns "LensRenderingPipeline"
  129667. */
  129668. getClassName(): string;
  129669. /**
  129670. * Gets associated scene
  129671. */
  129672. readonly scene: Scene;
  129673. /**
  129674. * Gets or sets the edge blur
  129675. */
  129676. edgeBlur: number;
  129677. /**
  129678. * Gets or sets the grain amount
  129679. */
  129680. grainAmount: number;
  129681. /**
  129682. * Gets or sets the chromatic aberration amount
  129683. */
  129684. chromaticAberration: number;
  129685. /**
  129686. * Gets or sets the depth of field aperture
  129687. */
  129688. dofAperture: number;
  129689. /**
  129690. * Gets or sets the edge distortion
  129691. */
  129692. edgeDistortion: number;
  129693. /**
  129694. * Gets or sets the depth of field distortion
  129695. */
  129696. dofDistortion: number;
  129697. /**
  129698. * Gets or sets the darken out of focus amount
  129699. */
  129700. darkenOutOfFocus: number;
  129701. /**
  129702. * Gets or sets a boolean indicating if blur noise is enabled
  129703. */
  129704. blurNoise: boolean;
  129705. /**
  129706. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  129707. */
  129708. pentagonBokeh: boolean;
  129709. /**
  129710. * Gets or sets the highlight grain amount
  129711. */
  129712. highlightsGain: number;
  129713. /**
  129714. * Gets or sets the highlight threshold
  129715. */
  129716. highlightsThreshold: number;
  129717. /**
  129718. * Sets the amount of blur at the edges
  129719. * @param amount blur amount
  129720. */
  129721. setEdgeBlur(amount: number): void;
  129722. /**
  129723. * Sets edge blur to 0
  129724. */
  129725. disableEdgeBlur(): void;
  129726. /**
  129727. * Sets the amout of grain
  129728. * @param amount Amount of grain
  129729. */
  129730. setGrainAmount(amount: number): void;
  129731. /**
  129732. * Set grain amount to 0
  129733. */
  129734. disableGrain(): void;
  129735. /**
  129736. * Sets the chromatic aberration amount
  129737. * @param amount amount of chromatic aberration
  129738. */
  129739. setChromaticAberration(amount: number): void;
  129740. /**
  129741. * Sets chromatic aberration amount to 0
  129742. */
  129743. disableChromaticAberration(): void;
  129744. /**
  129745. * Sets the EdgeDistortion amount
  129746. * @param amount amount of EdgeDistortion
  129747. */
  129748. setEdgeDistortion(amount: number): void;
  129749. /**
  129750. * Sets edge distortion to 0
  129751. */
  129752. disableEdgeDistortion(): void;
  129753. /**
  129754. * Sets the FocusDistance amount
  129755. * @param amount amount of FocusDistance
  129756. */
  129757. setFocusDistance(amount: number): void;
  129758. /**
  129759. * Disables depth of field
  129760. */
  129761. disableDepthOfField(): void;
  129762. /**
  129763. * Sets the Aperture amount
  129764. * @param amount amount of Aperture
  129765. */
  129766. setAperture(amount: number): void;
  129767. /**
  129768. * Sets the DarkenOutOfFocus amount
  129769. * @param amount amount of DarkenOutOfFocus
  129770. */
  129771. setDarkenOutOfFocus(amount: number): void;
  129772. private _pentagonBokehIsEnabled;
  129773. /**
  129774. * Creates a pentagon bokeh effect
  129775. */
  129776. enablePentagonBokeh(): void;
  129777. /**
  129778. * Disables the pentagon bokeh effect
  129779. */
  129780. disablePentagonBokeh(): void;
  129781. /**
  129782. * Enables noise blur
  129783. */
  129784. enableNoiseBlur(): void;
  129785. /**
  129786. * Disables noise blur
  129787. */
  129788. disableNoiseBlur(): void;
  129789. /**
  129790. * Sets the HighlightsGain amount
  129791. * @param amount amount of HighlightsGain
  129792. */
  129793. setHighlightsGain(amount: number): void;
  129794. /**
  129795. * Sets the HighlightsThreshold amount
  129796. * @param amount amount of HighlightsThreshold
  129797. */
  129798. setHighlightsThreshold(amount: number): void;
  129799. /**
  129800. * Disables highlights
  129801. */
  129802. disableHighlights(): void;
  129803. /**
  129804. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  129805. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  129806. */
  129807. dispose(disableDepthRender?: boolean): void;
  129808. private _createChromaticAberrationPostProcess;
  129809. private _createHighlightsPostProcess;
  129810. private _createDepthOfFieldPostProcess;
  129811. private _createGrainTexture;
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /** @hidden */
  129816. export var ssao2PixelShader: {
  129817. name: string;
  129818. shader: string;
  129819. };
  129820. }
  129821. declare module BABYLON {
  129822. /** @hidden */
  129823. export var ssaoCombinePixelShader: {
  129824. name: string;
  129825. shader: string;
  129826. };
  129827. }
  129828. declare module BABYLON {
  129829. /**
  129830. * Render pipeline to produce ssao effect
  129831. */
  129832. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  129833. /**
  129834. * @ignore
  129835. * The PassPostProcess id in the pipeline that contains the original scene color
  129836. */
  129837. SSAOOriginalSceneColorEffect: string;
  129838. /**
  129839. * @ignore
  129840. * The SSAO PostProcess id in the pipeline
  129841. */
  129842. SSAORenderEffect: string;
  129843. /**
  129844. * @ignore
  129845. * The horizontal blur PostProcess id in the pipeline
  129846. */
  129847. SSAOBlurHRenderEffect: string;
  129848. /**
  129849. * @ignore
  129850. * The vertical blur PostProcess id in the pipeline
  129851. */
  129852. SSAOBlurVRenderEffect: string;
  129853. /**
  129854. * @ignore
  129855. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129856. */
  129857. SSAOCombineRenderEffect: string;
  129858. /**
  129859. * The output strength of the SSAO post-process. Default value is 1.0.
  129860. */
  129861. totalStrength: number;
  129862. /**
  129863. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  129864. */
  129865. maxZ: number;
  129866. /**
  129867. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  129868. */
  129869. minZAspect: number;
  129870. private _samples;
  129871. /**
  129872. * Number of samples used for the SSAO calculations. Default value is 8
  129873. */
  129874. samples: number;
  129875. private _textureSamples;
  129876. /**
  129877. * Number of samples to use for antialiasing
  129878. */
  129879. textureSamples: number;
  129880. /**
  129881. * Ratio object used for SSAO ratio and blur ratio
  129882. */
  129883. private _ratio;
  129884. /**
  129885. * Dynamically generated sphere sampler.
  129886. */
  129887. private _sampleSphere;
  129888. /**
  129889. * Blur filter offsets
  129890. */
  129891. private _samplerOffsets;
  129892. private _expensiveBlur;
  129893. /**
  129894. * If bilateral blur should be used
  129895. */
  129896. expensiveBlur: boolean;
  129897. /**
  129898. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  129899. */
  129900. radius: number;
  129901. /**
  129902. * The base color of the SSAO post-process
  129903. * The final result is "base + ssao" between [0, 1]
  129904. */
  129905. base: number;
  129906. /**
  129907. * Support test.
  129908. */
  129909. static readonly IsSupported: boolean;
  129910. private _scene;
  129911. private _depthTexture;
  129912. private _normalTexture;
  129913. private _randomTexture;
  129914. private _originalColorPostProcess;
  129915. private _ssaoPostProcess;
  129916. private _blurHPostProcess;
  129917. private _blurVPostProcess;
  129918. private _ssaoCombinePostProcess;
  129919. /**
  129920. * Gets active scene
  129921. */
  129922. readonly scene: Scene;
  129923. /**
  129924. * @constructor
  129925. * @param name The rendering pipeline name
  129926. * @param scene The scene linked to this pipeline
  129927. * @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 }
  129928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129929. */
  129930. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129931. /**
  129932. * Get the class name
  129933. * @returns "SSAO2RenderingPipeline"
  129934. */
  129935. getClassName(): string;
  129936. /**
  129937. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129938. */
  129939. dispose(disableGeometryBufferRenderer?: boolean): void;
  129940. private _createBlurPostProcess;
  129941. /** @hidden */
  129942. _rebuild(): void;
  129943. private _bits;
  129944. private _radicalInverse_VdC;
  129945. private _hammersley;
  129946. private _hemisphereSample_uniform;
  129947. private _generateHemisphere;
  129948. private _createSSAOPostProcess;
  129949. private _createSSAOCombinePostProcess;
  129950. private _createRandomTexture;
  129951. /**
  129952. * Serialize the rendering pipeline (Used when exporting)
  129953. * @returns the serialized object
  129954. */
  129955. serialize(): any;
  129956. /**
  129957. * Parse the serialized pipeline
  129958. * @param source Source pipeline.
  129959. * @param scene The scene to load the pipeline to.
  129960. * @param rootUrl The URL of the serialized pipeline.
  129961. * @returns An instantiated pipeline from the serialized object.
  129962. */
  129963. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129964. }
  129965. }
  129966. declare module BABYLON {
  129967. /** @hidden */
  129968. export var ssaoPixelShader: {
  129969. name: string;
  129970. shader: string;
  129971. };
  129972. }
  129973. declare module BABYLON {
  129974. /**
  129975. * Render pipeline to produce ssao effect
  129976. */
  129977. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129978. /**
  129979. * @ignore
  129980. * The PassPostProcess id in the pipeline that contains the original scene color
  129981. */
  129982. SSAOOriginalSceneColorEffect: string;
  129983. /**
  129984. * @ignore
  129985. * The SSAO PostProcess id in the pipeline
  129986. */
  129987. SSAORenderEffect: string;
  129988. /**
  129989. * @ignore
  129990. * The horizontal blur PostProcess id in the pipeline
  129991. */
  129992. SSAOBlurHRenderEffect: string;
  129993. /**
  129994. * @ignore
  129995. * The vertical blur PostProcess id in the pipeline
  129996. */
  129997. SSAOBlurVRenderEffect: string;
  129998. /**
  129999. * @ignore
  130000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130001. */
  130002. SSAOCombineRenderEffect: string;
  130003. /**
  130004. * The output strength of the SSAO post-process. Default value is 1.0.
  130005. */
  130006. totalStrength: number;
  130007. /**
  130008. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130009. */
  130010. radius: number;
  130011. /**
  130012. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130013. * Must not be equal to fallOff and superior to fallOff.
  130014. * Default value is 0.0075
  130015. */
  130016. area: number;
  130017. /**
  130018. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130019. * Must not be equal to area and inferior to area.
  130020. * Default value is 0.000001
  130021. */
  130022. fallOff: number;
  130023. /**
  130024. * The base color of the SSAO post-process
  130025. * The final result is "base + ssao" between [0, 1]
  130026. */
  130027. base: number;
  130028. private _scene;
  130029. private _depthTexture;
  130030. private _randomTexture;
  130031. private _originalColorPostProcess;
  130032. private _ssaoPostProcess;
  130033. private _blurHPostProcess;
  130034. private _blurVPostProcess;
  130035. private _ssaoCombinePostProcess;
  130036. private _firstUpdate;
  130037. /**
  130038. * Gets active scene
  130039. */
  130040. readonly scene: Scene;
  130041. /**
  130042. * @constructor
  130043. * @param name - The rendering pipeline name
  130044. * @param scene - The scene linked to this pipeline
  130045. * @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 }
  130046. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130047. */
  130048. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130049. /**
  130050. * Get the class name
  130051. * @returns "SSAORenderingPipeline"
  130052. */
  130053. getClassName(): string;
  130054. /**
  130055. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130056. */
  130057. dispose(disableDepthRender?: boolean): void;
  130058. private _createBlurPostProcess;
  130059. /** @hidden */
  130060. _rebuild(): void;
  130061. private _createSSAOPostProcess;
  130062. private _createSSAOCombinePostProcess;
  130063. private _createRandomTexture;
  130064. }
  130065. }
  130066. declare module BABYLON {
  130067. /** @hidden */
  130068. export var standardPixelShader: {
  130069. name: string;
  130070. shader: string;
  130071. };
  130072. }
  130073. declare module BABYLON {
  130074. /**
  130075. * Standard rendering pipeline
  130076. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130077. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130078. */
  130079. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130080. /**
  130081. * Public members
  130082. */
  130083. /**
  130084. * Post-process which contains the original scene color before the pipeline applies all the effects
  130085. */
  130086. originalPostProcess: Nullable<PostProcess>;
  130087. /**
  130088. * Post-process used to down scale an image x4
  130089. */
  130090. downSampleX4PostProcess: Nullable<PostProcess>;
  130091. /**
  130092. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130093. */
  130094. brightPassPostProcess: Nullable<PostProcess>;
  130095. /**
  130096. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130097. */
  130098. blurHPostProcesses: PostProcess[];
  130099. /**
  130100. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130101. */
  130102. blurVPostProcesses: PostProcess[];
  130103. /**
  130104. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130105. */
  130106. textureAdderPostProcess: Nullable<PostProcess>;
  130107. /**
  130108. * Post-process used to create volumetric lighting effect
  130109. */
  130110. volumetricLightPostProcess: Nullable<PostProcess>;
  130111. /**
  130112. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130113. */
  130114. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130115. /**
  130116. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130117. */
  130118. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130119. /**
  130120. * Post-process used to merge the volumetric light effect and the real scene color
  130121. */
  130122. volumetricLightMergePostProces: Nullable<PostProcess>;
  130123. /**
  130124. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130125. */
  130126. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130127. /**
  130128. * Base post-process used to calculate the average luminance of the final image for HDR
  130129. */
  130130. luminancePostProcess: Nullable<PostProcess>;
  130131. /**
  130132. * Post-processes used to create down sample post-processes in order to get
  130133. * the average luminance of the final image for HDR
  130134. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130135. */
  130136. luminanceDownSamplePostProcesses: PostProcess[];
  130137. /**
  130138. * Post-process used to create a HDR effect (light adaptation)
  130139. */
  130140. hdrPostProcess: Nullable<PostProcess>;
  130141. /**
  130142. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130143. */
  130144. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130145. /**
  130146. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130147. */
  130148. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130149. /**
  130150. * Post-process used to merge the final HDR post-process and the real scene color
  130151. */
  130152. hdrFinalPostProcess: Nullable<PostProcess>;
  130153. /**
  130154. * Post-process used to create a lens flare effect
  130155. */
  130156. lensFlarePostProcess: Nullable<PostProcess>;
  130157. /**
  130158. * Post-process that merges the result of the lens flare post-process and the real scene color
  130159. */
  130160. lensFlareComposePostProcess: Nullable<PostProcess>;
  130161. /**
  130162. * Post-process used to create a motion blur effect
  130163. */
  130164. motionBlurPostProcess: Nullable<PostProcess>;
  130165. /**
  130166. * Post-process used to create a depth of field effect
  130167. */
  130168. depthOfFieldPostProcess: Nullable<PostProcess>;
  130169. /**
  130170. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130171. */
  130172. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130173. /**
  130174. * Represents the brightness threshold in order to configure the illuminated surfaces
  130175. */
  130176. brightThreshold: number;
  130177. /**
  130178. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130179. */
  130180. blurWidth: number;
  130181. /**
  130182. * Sets if the blur for highlighted surfaces must be only horizontal
  130183. */
  130184. horizontalBlur: boolean;
  130185. /**
  130186. * Gets the overall exposure used by the pipeline
  130187. */
  130188. /**
  130189. * Sets the overall exposure used by the pipeline
  130190. */
  130191. exposure: number;
  130192. /**
  130193. * Texture used typically to simulate "dirty" on camera lens
  130194. */
  130195. lensTexture: Nullable<Texture>;
  130196. /**
  130197. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130198. */
  130199. volumetricLightCoefficient: number;
  130200. /**
  130201. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130202. */
  130203. volumetricLightPower: number;
  130204. /**
  130205. * Used the set the blur intensity to smooth the volumetric lights
  130206. */
  130207. volumetricLightBlurScale: number;
  130208. /**
  130209. * Light (spot or directional) used to generate the volumetric lights rays
  130210. * The source light must have a shadow generate so the pipeline can get its
  130211. * depth map
  130212. */
  130213. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130214. /**
  130215. * For eye adaptation, represents the minimum luminance the eye can see
  130216. */
  130217. hdrMinimumLuminance: number;
  130218. /**
  130219. * For eye adaptation, represents the decrease luminance speed
  130220. */
  130221. hdrDecreaseRate: number;
  130222. /**
  130223. * For eye adaptation, represents the increase luminance speed
  130224. */
  130225. hdrIncreaseRate: number;
  130226. /**
  130227. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130228. */
  130229. /**
  130230. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130231. */
  130232. hdrAutoExposure: boolean;
  130233. /**
  130234. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130235. */
  130236. lensColorTexture: Nullable<Texture>;
  130237. /**
  130238. * The overall strengh for the lens flare effect
  130239. */
  130240. lensFlareStrength: number;
  130241. /**
  130242. * Dispersion coefficient for lens flare ghosts
  130243. */
  130244. lensFlareGhostDispersal: number;
  130245. /**
  130246. * Main lens flare halo width
  130247. */
  130248. lensFlareHaloWidth: number;
  130249. /**
  130250. * Based on the lens distortion effect, defines how much the lens flare result
  130251. * is distorted
  130252. */
  130253. lensFlareDistortionStrength: number;
  130254. /**
  130255. * Configures the blur intensity used for for lens flare (halo)
  130256. */
  130257. lensFlareBlurWidth: number;
  130258. /**
  130259. * Lens star texture must be used to simulate rays on the flares and is available
  130260. * in the documentation
  130261. */
  130262. lensStarTexture: Nullable<Texture>;
  130263. /**
  130264. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130265. * flare effect by taking account of the dirt texture
  130266. */
  130267. lensFlareDirtTexture: Nullable<Texture>;
  130268. /**
  130269. * Represents the focal length for the depth of field effect
  130270. */
  130271. depthOfFieldDistance: number;
  130272. /**
  130273. * Represents the blur intensity for the blurred part of the depth of field effect
  130274. */
  130275. depthOfFieldBlurWidth: number;
  130276. /**
  130277. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130278. */
  130279. /**
  130280. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130281. */
  130282. motionStrength: number;
  130283. /**
  130284. * Gets wether or not the motion blur post-process is object based or screen based.
  130285. */
  130286. /**
  130287. * Sets wether or not the motion blur post-process should be object based or screen based
  130288. */
  130289. objectBasedMotionBlur: boolean;
  130290. /**
  130291. * List of animations for the pipeline (IAnimatable implementation)
  130292. */
  130293. animations: Animation[];
  130294. /**
  130295. * Private members
  130296. */
  130297. private _scene;
  130298. private _currentDepthOfFieldSource;
  130299. private _basePostProcess;
  130300. private _fixedExposure;
  130301. private _currentExposure;
  130302. private _hdrAutoExposure;
  130303. private _hdrCurrentLuminance;
  130304. private _motionStrength;
  130305. private _isObjectBasedMotionBlur;
  130306. private _floatTextureType;
  130307. private _camerasToBeAttached;
  130308. private _ratio;
  130309. private _bloomEnabled;
  130310. private _depthOfFieldEnabled;
  130311. private _vlsEnabled;
  130312. private _lensFlareEnabled;
  130313. private _hdrEnabled;
  130314. private _motionBlurEnabled;
  130315. private _fxaaEnabled;
  130316. private _motionBlurSamples;
  130317. private _volumetricLightStepsCount;
  130318. private _samples;
  130319. /**
  130320. * @ignore
  130321. * Specifies if the bloom pipeline is enabled
  130322. */
  130323. BloomEnabled: boolean;
  130324. /**
  130325. * @ignore
  130326. * Specifies if the depth of field pipeline is enabed
  130327. */
  130328. DepthOfFieldEnabled: boolean;
  130329. /**
  130330. * @ignore
  130331. * Specifies if the lens flare pipeline is enabed
  130332. */
  130333. LensFlareEnabled: boolean;
  130334. /**
  130335. * @ignore
  130336. * Specifies if the HDR pipeline is enabled
  130337. */
  130338. HDREnabled: boolean;
  130339. /**
  130340. * @ignore
  130341. * Specifies if the volumetric lights scattering effect is enabled
  130342. */
  130343. VLSEnabled: boolean;
  130344. /**
  130345. * @ignore
  130346. * Specifies if the motion blur effect is enabled
  130347. */
  130348. MotionBlurEnabled: boolean;
  130349. /**
  130350. * Specifies if anti-aliasing is enabled
  130351. */
  130352. fxaaEnabled: boolean;
  130353. /**
  130354. * Specifies the number of steps used to calculate the volumetric lights
  130355. * Typically in interval [50, 200]
  130356. */
  130357. volumetricLightStepsCount: number;
  130358. /**
  130359. * Specifies the number of samples used for the motion blur effect
  130360. * Typically in interval [16, 64]
  130361. */
  130362. motionBlurSamples: number;
  130363. /**
  130364. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130365. */
  130366. samples: number;
  130367. /**
  130368. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130369. * @constructor
  130370. * @param name The rendering pipeline name
  130371. * @param scene The scene linked to this pipeline
  130372. * @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)
  130373. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130374. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130375. */
  130376. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130377. private _buildPipeline;
  130378. private _createDownSampleX4PostProcess;
  130379. private _createBrightPassPostProcess;
  130380. private _createBlurPostProcesses;
  130381. private _createTextureAdderPostProcess;
  130382. private _createVolumetricLightPostProcess;
  130383. private _createLuminancePostProcesses;
  130384. private _createHdrPostProcess;
  130385. private _createLensFlarePostProcess;
  130386. private _createDepthOfFieldPostProcess;
  130387. private _createMotionBlurPostProcess;
  130388. private _getDepthTexture;
  130389. private _disposePostProcesses;
  130390. /**
  130391. * Dispose of the pipeline and stop all post processes
  130392. */
  130393. dispose(): void;
  130394. /**
  130395. * Serialize the rendering pipeline (Used when exporting)
  130396. * @returns the serialized object
  130397. */
  130398. serialize(): any;
  130399. /**
  130400. * Parse the serialized pipeline
  130401. * @param source Source pipeline.
  130402. * @param scene The scene to load the pipeline to.
  130403. * @param rootUrl The URL of the serialized pipeline.
  130404. * @returns An instantiated pipeline from the serialized object.
  130405. */
  130406. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130407. /**
  130408. * Luminance steps
  130409. */
  130410. static LuminanceSteps: number;
  130411. }
  130412. }
  130413. declare module BABYLON {
  130414. /** @hidden */
  130415. export var tonemapPixelShader: {
  130416. name: string;
  130417. shader: string;
  130418. };
  130419. }
  130420. declare module BABYLON {
  130421. /** Defines operator used for tonemapping */
  130422. export enum TonemappingOperator {
  130423. /** Hable */
  130424. Hable = 0,
  130425. /** Reinhard */
  130426. Reinhard = 1,
  130427. /** HejiDawson */
  130428. HejiDawson = 2,
  130429. /** Photographic */
  130430. Photographic = 3
  130431. }
  130432. /**
  130433. * Defines a post process to apply tone mapping
  130434. */
  130435. export class TonemapPostProcess extends PostProcess {
  130436. private _operator;
  130437. /** Defines the required exposure adjustement */
  130438. exposureAdjustment: number;
  130439. /**
  130440. * Creates a new TonemapPostProcess
  130441. * @param name defines the name of the postprocess
  130442. * @param _operator defines the operator to use
  130443. * @param exposureAdjustment defines the required exposure adjustement
  130444. * @param camera defines the camera to use (can be null)
  130445. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130446. * @param engine defines the hosting engine (can be ignore if camera is set)
  130447. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130448. */
  130449. constructor(name: string, _operator: TonemappingOperator,
  130450. /** Defines the required exposure adjustement */
  130451. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130452. }
  130453. }
  130454. declare module BABYLON {
  130455. /** @hidden */
  130456. export var depthVertexShader: {
  130457. name: string;
  130458. shader: string;
  130459. };
  130460. }
  130461. declare module BABYLON {
  130462. /** @hidden */
  130463. export var volumetricLightScatteringPixelShader: {
  130464. name: string;
  130465. shader: string;
  130466. };
  130467. }
  130468. declare module BABYLON {
  130469. /** @hidden */
  130470. export var volumetricLightScatteringPassVertexShader: {
  130471. name: string;
  130472. shader: string;
  130473. };
  130474. }
  130475. declare module BABYLON {
  130476. /** @hidden */
  130477. export var volumetricLightScatteringPassPixelShader: {
  130478. name: string;
  130479. shader: string;
  130480. };
  130481. }
  130482. declare module BABYLON {
  130483. /**
  130484. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130485. */
  130486. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130487. private _volumetricLightScatteringPass;
  130488. private _volumetricLightScatteringRTT;
  130489. private _viewPort;
  130490. private _screenCoordinates;
  130491. private _cachedDefines;
  130492. /**
  130493. * If not undefined, the mesh position is computed from the attached node position
  130494. */
  130495. attachedNode: {
  130496. position: Vector3;
  130497. };
  130498. /**
  130499. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130500. */
  130501. customMeshPosition: Vector3;
  130502. /**
  130503. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130504. */
  130505. useCustomMeshPosition: boolean;
  130506. /**
  130507. * If the post-process should inverse the light scattering direction
  130508. */
  130509. invert: boolean;
  130510. /**
  130511. * The internal mesh used by the post-process
  130512. */
  130513. mesh: Mesh;
  130514. /**
  130515. * @hidden
  130516. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  130517. */
  130518. useDiffuseColor: boolean;
  130519. /**
  130520. * Array containing the excluded meshes not rendered in the internal pass
  130521. */
  130522. excludedMeshes: AbstractMesh[];
  130523. /**
  130524. * Controls the overall intensity of the post-process
  130525. */
  130526. exposure: number;
  130527. /**
  130528. * Dissipates each sample's contribution in range [0, 1]
  130529. */
  130530. decay: number;
  130531. /**
  130532. * Controls the overall intensity of each sample
  130533. */
  130534. weight: number;
  130535. /**
  130536. * Controls the density of each sample
  130537. */
  130538. density: number;
  130539. /**
  130540. * @constructor
  130541. * @param name The post-process name
  130542. * @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)
  130543. * @param camera The camera that the post-process will be attached to
  130544. * @param mesh The mesh used to create the light scattering
  130545. * @param samples The post-process quality, default 100
  130546. * @param samplingModeThe post-process filtering mode
  130547. * @param engine The babylon engine
  130548. * @param reusable If the post-process is reusable
  130549. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  130550. */
  130551. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  130552. /**
  130553. * Returns the string "VolumetricLightScatteringPostProcess"
  130554. * @returns "VolumetricLightScatteringPostProcess"
  130555. */
  130556. getClassName(): string;
  130557. private _isReady;
  130558. /**
  130559. * Sets the new light position for light scattering effect
  130560. * @param position The new custom light position
  130561. */
  130562. setCustomMeshPosition(position: Vector3): void;
  130563. /**
  130564. * Returns the light position for light scattering effect
  130565. * @return Vector3 The custom light position
  130566. */
  130567. getCustomMeshPosition(): Vector3;
  130568. /**
  130569. * Disposes the internal assets and detaches the post-process from the camera
  130570. */
  130571. dispose(camera: Camera): void;
  130572. /**
  130573. * Returns the render target texture used by the post-process
  130574. * @return the render target texture used by the post-process
  130575. */
  130576. getPass(): RenderTargetTexture;
  130577. private _meshExcluded;
  130578. private _createPass;
  130579. private _updateMeshScreenCoordinates;
  130580. /**
  130581. * Creates a default mesh for the Volumeric Light Scattering post-process
  130582. * @param name The mesh name
  130583. * @param scene The scene where to create the mesh
  130584. * @return the default mesh
  130585. */
  130586. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  130587. }
  130588. }
  130589. declare module BABYLON {
  130590. interface Scene {
  130591. /** @hidden (Backing field) */
  130592. _boundingBoxRenderer: BoundingBoxRenderer;
  130593. /** @hidden (Backing field) */
  130594. _forceShowBoundingBoxes: boolean;
  130595. /**
  130596. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  130597. */
  130598. forceShowBoundingBoxes: boolean;
  130599. /**
  130600. * Gets the bounding box renderer associated with the scene
  130601. * @returns a BoundingBoxRenderer
  130602. */
  130603. getBoundingBoxRenderer(): BoundingBoxRenderer;
  130604. }
  130605. interface AbstractMesh {
  130606. /** @hidden (Backing field) */
  130607. _showBoundingBox: boolean;
  130608. /**
  130609. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  130610. */
  130611. showBoundingBox: boolean;
  130612. }
  130613. /**
  130614. * Component responsible of rendering the bounding box of the meshes in a scene.
  130615. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  130616. */
  130617. export class BoundingBoxRenderer implements ISceneComponent {
  130618. /**
  130619. * The component name helpfull to identify the component in the list of scene components.
  130620. */
  130621. readonly name: string;
  130622. /**
  130623. * The scene the component belongs to.
  130624. */
  130625. scene: Scene;
  130626. /**
  130627. * Color of the bounding box lines placed in front of an object
  130628. */
  130629. frontColor: Color3;
  130630. /**
  130631. * Color of the bounding box lines placed behind an object
  130632. */
  130633. backColor: Color3;
  130634. /**
  130635. * Defines if the renderer should show the back lines or not
  130636. */
  130637. showBackLines: boolean;
  130638. /**
  130639. * @hidden
  130640. */
  130641. renderList: SmartArray<BoundingBox>;
  130642. private _colorShader;
  130643. private _vertexBuffers;
  130644. private _indexBuffer;
  130645. private _fillIndexBuffer;
  130646. private _fillIndexData;
  130647. /**
  130648. * Instantiates a new bounding box renderer in a scene.
  130649. * @param scene the scene the renderer renders in
  130650. */
  130651. constructor(scene: Scene);
  130652. /**
  130653. * Registers the component in a given scene
  130654. */
  130655. register(): void;
  130656. private _evaluateSubMesh;
  130657. private _activeMesh;
  130658. private _prepareRessources;
  130659. private _createIndexBuffer;
  130660. /**
  130661. * Rebuilds the elements related to this component in case of
  130662. * context lost for instance.
  130663. */
  130664. rebuild(): void;
  130665. /**
  130666. * @hidden
  130667. */
  130668. reset(): void;
  130669. /**
  130670. * Render the bounding boxes of a specific rendering group
  130671. * @param renderingGroupId defines the rendering group to render
  130672. */
  130673. render(renderingGroupId: number): void;
  130674. /**
  130675. * In case of occlusion queries, we can render the occlusion bounding box through this method
  130676. * @param mesh Define the mesh to render the occlusion bounding box for
  130677. */
  130678. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  130679. /**
  130680. * Dispose and release the resources attached to this renderer.
  130681. */
  130682. dispose(): void;
  130683. }
  130684. }
  130685. declare module BABYLON {
  130686. /** @hidden */
  130687. export var depthPixelShader: {
  130688. name: string;
  130689. shader: string;
  130690. };
  130691. }
  130692. declare module BABYLON {
  130693. /**
  130694. * This represents a depth renderer in Babylon.
  130695. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130696. */
  130697. export class DepthRenderer {
  130698. private _scene;
  130699. private _depthMap;
  130700. private _effect;
  130701. private readonly _storeNonLinearDepth;
  130702. private readonly _clearColor;
  130703. /** Get if the depth renderer is using packed depth or not */
  130704. readonly isPacked: boolean;
  130705. private _cachedDefines;
  130706. private _camera;
  130707. /**
  130708. * Specifiess that the depth renderer will only be used within
  130709. * the camera it is created for.
  130710. * This can help forcing its rendering during the camera processing.
  130711. */
  130712. useOnlyInActiveCamera: boolean;
  130713. /** @hidden */
  130714. static _SceneComponentInitialization: (scene: Scene) => void;
  130715. /**
  130716. * Instantiates a depth renderer
  130717. * @param scene The scene the renderer belongs to
  130718. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130719. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130720. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130721. */
  130722. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130723. /**
  130724. * Creates the depth rendering effect and checks if the effect is ready.
  130725. * @param subMesh The submesh to be used to render the depth map of
  130726. * @param useInstances If multiple world instances should be used
  130727. * @returns if the depth renderer is ready to render the depth map
  130728. */
  130729. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130730. /**
  130731. * Gets the texture which the depth map will be written to.
  130732. * @returns The depth map texture
  130733. */
  130734. getDepthMap(): RenderTargetTexture;
  130735. /**
  130736. * Disposes of the depth renderer.
  130737. */
  130738. dispose(): void;
  130739. }
  130740. }
  130741. declare module BABYLON {
  130742. interface Scene {
  130743. /** @hidden (Backing field) */
  130744. _depthRenderer: {
  130745. [id: string]: DepthRenderer;
  130746. };
  130747. /**
  130748. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  130749. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  130750. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130751. * @returns the created depth renderer
  130752. */
  130753. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  130754. /**
  130755. * Disables a depth renderer for a given camera
  130756. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  130757. */
  130758. disableDepthRenderer(camera?: Nullable<Camera>): void;
  130759. }
  130760. /**
  130761. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  130762. * in several rendering techniques.
  130763. */
  130764. export class DepthRendererSceneComponent implements ISceneComponent {
  130765. /**
  130766. * The component name helpfull to identify the component in the list of scene components.
  130767. */
  130768. readonly name: string;
  130769. /**
  130770. * The scene the component belongs to.
  130771. */
  130772. scene: Scene;
  130773. /**
  130774. * Creates a new instance of the component for the given scene
  130775. * @param scene Defines the scene to register the component in
  130776. */
  130777. constructor(scene: Scene);
  130778. /**
  130779. * Registers the component in a given scene
  130780. */
  130781. register(): void;
  130782. /**
  130783. * Rebuilds the elements related to this component in case of
  130784. * context lost for instance.
  130785. */
  130786. rebuild(): void;
  130787. /**
  130788. * Disposes the component and the associated ressources
  130789. */
  130790. dispose(): void;
  130791. private _gatherRenderTargets;
  130792. private _gatherActiveCameraRenderTargets;
  130793. }
  130794. }
  130795. declare module BABYLON {
  130796. /** @hidden */
  130797. export var outlinePixelShader: {
  130798. name: string;
  130799. shader: string;
  130800. };
  130801. }
  130802. declare module BABYLON {
  130803. /** @hidden */
  130804. export var outlineVertexShader: {
  130805. name: string;
  130806. shader: string;
  130807. };
  130808. }
  130809. declare module BABYLON {
  130810. interface Scene {
  130811. /** @hidden */
  130812. _outlineRenderer: OutlineRenderer;
  130813. /**
  130814. * Gets the outline renderer associated with the scene
  130815. * @returns a OutlineRenderer
  130816. */
  130817. getOutlineRenderer(): OutlineRenderer;
  130818. }
  130819. interface AbstractMesh {
  130820. /** @hidden (Backing field) */
  130821. _renderOutline: boolean;
  130822. /**
  130823. * Gets or sets a boolean indicating if the outline must be rendered as well
  130824. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  130825. */
  130826. renderOutline: boolean;
  130827. /** @hidden (Backing field) */
  130828. _renderOverlay: boolean;
  130829. /**
  130830. * Gets or sets a boolean indicating if the overlay must be rendered as well
  130831. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  130832. */
  130833. renderOverlay: boolean;
  130834. }
  130835. /**
  130836. * This class is responsible to draw bothe outline/overlay of meshes.
  130837. * It should not be used directly but through the available method on mesh.
  130838. */
  130839. export class OutlineRenderer implements ISceneComponent {
  130840. /**
  130841. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  130842. */
  130843. private static _StencilReference;
  130844. /**
  130845. * The name of the component. Each component must have a unique name.
  130846. */
  130847. name: string;
  130848. /**
  130849. * The scene the component belongs to.
  130850. */
  130851. scene: Scene;
  130852. /**
  130853. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  130854. */
  130855. zOffset: number;
  130856. private _engine;
  130857. private _effect;
  130858. private _cachedDefines;
  130859. private _savedDepthWrite;
  130860. /**
  130861. * Instantiates a new outline renderer. (There could be only one per scene).
  130862. * @param scene Defines the scene it belongs to
  130863. */
  130864. constructor(scene: Scene);
  130865. /**
  130866. * Register the component to one instance of a scene.
  130867. */
  130868. register(): void;
  130869. /**
  130870. * Rebuilds the elements related to this component in case of
  130871. * context lost for instance.
  130872. */
  130873. rebuild(): void;
  130874. /**
  130875. * Disposes the component and the associated ressources.
  130876. */
  130877. dispose(): void;
  130878. /**
  130879. * Renders the outline in the canvas.
  130880. * @param subMesh Defines the sumesh to render
  130881. * @param batch Defines the batch of meshes in case of instances
  130882. * @param useOverlay Defines if the rendering is for the overlay or the outline
  130883. */
  130884. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  130885. /**
  130886. * Returns whether or not the outline renderer is ready for a given submesh.
  130887. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  130888. * @param subMesh Defines the submesh to check readyness for
  130889. * @param useInstances Defines wheter wee are trying to render instances or not
  130890. * @returns true if ready otherwise false
  130891. */
  130892. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130893. private _beforeRenderingMesh;
  130894. private _afterRenderingMesh;
  130895. }
  130896. }
  130897. declare module BABYLON {
  130898. /**
  130899. * Class used to manage multiple sprites of different sizes on the same spritesheet
  130900. * @see http://doc.babylonjs.com/babylon101/sprites
  130901. */
  130902. export class SpritePackedManager extends SpriteManager {
  130903. /** defines the packed manager's name */
  130904. name: string;
  130905. /**
  130906. * Creates a new sprite manager from a packed sprite sheet
  130907. * @param name defines the manager's name
  130908. * @param imgUrl defines the sprite sheet url
  130909. * @param capacity defines the maximum allowed number of sprites
  130910. * @param scene defines the hosting scene
  130911. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  130912. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  130913. * @param samplingMode defines the smapling mode to use with spritesheet
  130914. * @param fromPacked set to true; do not alter
  130915. */
  130916. constructor(
  130917. /** defines the packed manager's name */
  130918. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  130919. }
  130920. }
  130921. declare module BABYLON {
  130922. /**
  130923. * Defines the list of states available for a task inside a AssetsManager
  130924. */
  130925. export enum AssetTaskState {
  130926. /**
  130927. * Initialization
  130928. */
  130929. INIT = 0,
  130930. /**
  130931. * Running
  130932. */
  130933. RUNNING = 1,
  130934. /**
  130935. * Done
  130936. */
  130937. DONE = 2,
  130938. /**
  130939. * Error
  130940. */
  130941. ERROR = 3
  130942. }
  130943. /**
  130944. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130945. */
  130946. export abstract class AbstractAssetTask {
  130947. /**
  130948. * Task name
  130949. */ name: string;
  130950. /**
  130951. * Callback called when the task is successful
  130952. */
  130953. onSuccess: (task: any) => void;
  130954. /**
  130955. * Callback called when the task is not successful
  130956. */
  130957. onError: (task: any, message?: string, exception?: any) => void;
  130958. /**
  130959. * Creates a new AssetsManager
  130960. * @param name defines the name of the task
  130961. */
  130962. constructor(
  130963. /**
  130964. * Task name
  130965. */ name: string);
  130966. private _isCompleted;
  130967. private _taskState;
  130968. private _errorObject;
  130969. /**
  130970. * Get if the task is completed
  130971. */
  130972. readonly isCompleted: boolean;
  130973. /**
  130974. * Gets the current state of the task
  130975. */
  130976. readonly taskState: AssetTaskState;
  130977. /**
  130978. * Gets the current error object (if task is in error)
  130979. */
  130980. readonly errorObject: {
  130981. message?: string;
  130982. exception?: any;
  130983. };
  130984. /**
  130985. * Internal only
  130986. * @hidden
  130987. */
  130988. _setErrorObject(message?: string, exception?: any): void;
  130989. /**
  130990. * Execute the current task
  130991. * @param scene defines the scene where you want your assets to be loaded
  130992. * @param onSuccess is a callback called when the task is successfully executed
  130993. * @param onError is a callback called if an error occurs
  130994. */
  130995. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130996. /**
  130997. * Execute the current task
  130998. * @param scene defines the scene where you want your assets to be loaded
  130999. * @param onSuccess is a callback called when the task is successfully executed
  131000. * @param onError is a callback called if an error occurs
  131001. */
  131002. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131003. /**
  131004. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131005. * This can be used with failed tasks that have the reason for failure fixed.
  131006. */
  131007. reset(): void;
  131008. private onErrorCallback;
  131009. private onDoneCallback;
  131010. }
  131011. /**
  131012. * Define the interface used by progress events raised during assets loading
  131013. */
  131014. export interface IAssetsProgressEvent {
  131015. /**
  131016. * Defines the number of remaining tasks to process
  131017. */
  131018. remainingCount: number;
  131019. /**
  131020. * Defines the total number of tasks
  131021. */
  131022. totalCount: number;
  131023. /**
  131024. * Defines the task that was just processed
  131025. */
  131026. task: AbstractAssetTask;
  131027. }
  131028. /**
  131029. * Class used to share progress information about assets loading
  131030. */
  131031. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131032. /**
  131033. * Defines the number of remaining tasks to process
  131034. */
  131035. remainingCount: number;
  131036. /**
  131037. * Defines the total number of tasks
  131038. */
  131039. totalCount: number;
  131040. /**
  131041. * Defines the task that was just processed
  131042. */
  131043. task: AbstractAssetTask;
  131044. /**
  131045. * Creates a AssetsProgressEvent
  131046. * @param remainingCount defines the number of remaining tasks to process
  131047. * @param totalCount defines the total number of tasks
  131048. * @param task defines the task that was just processed
  131049. */
  131050. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131051. }
  131052. /**
  131053. * Define a task used by AssetsManager to load meshes
  131054. */
  131055. export class MeshAssetTask extends AbstractAssetTask {
  131056. /**
  131057. * Defines the name of the task
  131058. */
  131059. name: string;
  131060. /**
  131061. * Defines the list of mesh's names you want to load
  131062. */
  131063. meshesNames: any;
  131064. /**
  131065. * Defines the root url to use as a base to load your meshes and associated resources
  131066. */
  131067. rootUrl: string;
  131068. /**
  131069. * Defines the filename of the scene to load from
  131070. */
  131071. sceneFilename: string;
  131072. /**
  131073. * Gets the list of loaded meshes
  131074. */
  131075. loadedMeshes: Array<AbstractMesh>;
  131076. /**
  131077. * Gets the list of loaded particle systems
  131078. */
  131079. loadedParticleSystems: Array<IParticleSystem>;
  131080. /**
  131081. * Gets the list of loaded skeletons
  131082. */
  131083. loadedSkeletons: Array<Skeleton>;
  131084. /**
  131085. * Gets the list of loaded animation groups
  131086. */
  131087. loadedAnimationGroups: Array<AnimationGroup>;
  131088. /**
  131089. * Callback called when the task is successful
  131090. */
  131091. onSuccess: (task: MeshAssetTask) => void;
  131092. /**
  131093. * Callback called when the task is successful
  131094. */
  131095. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131096. /**
  131097. * Creates a new MeshAssetTask
  131098. * @param name defines the name of the task
  131099. * @param meshesNames defines the list of mesh's names you want to load
  131100. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131101. * @param sceneFilename defines the filename of the scene to load from
  131102. */
  131103. constructor(
  131104. /**
  131105. * Defines the name of the task
  131106. */
  131107. name: string,
  131108. /**
  131109. * Defines the list of mesh's names you want to load
  131110. */
  131111. meshesNames: any,
  131112. /**
  131113. * Defines the root url to use as a base to load your meshes and associated resources
  131114. */
  131115. rootUrl: string,
  131116. /**
  131117. * Defines the filename of the scene to load from
  131118. */
  131119. sceneFilename: string);
  131120. /**
  131121. * Execute the current task
  131122. * @param scene defines the scene where you want your assets to be loaded
  131123. * @param onSuccess is a callback called when the task is successfully executed
  131124. * @param onError is a callback called if an error occurs
  131125. */
  131126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131127. }
  131128. /**
  131129. * Define a task used by AssetsManager to load text content
  131130. */
  131131. export class TextFileAssetTask extends AbstractAssetTask {
  131132. /**
  131133. * Defines the name of the task
  131134. */
  131135. name: string;
  131136. /**
  131137. * Defines the location of the file to load
  131138. */
  131139. url: string;
  131140. /**
  131141. * Gets the loaded text string
  131142. */
  131143. text: string;
  131144. /**
  131145. * Callback called when the task is successful
  131146. */
  131147. onSuccess: (task: TextFileAssetTask) => void;
  131148. /**
  131149. * Callback called when the task is successful
  131150. */
  131151. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131152. /**
  131153. * Creates a new TextFileAssetTask object
  131154. * @param name defines the name of the task
  131155. * @param url defines the location of the file to load
  131156. */
  131157. constructor(
  131158. /**
  131159. * Defines the name of the task
  131160. */
  131161. name: string,
  131162. /**
  131163. * Defines the location of the file to load
  131164. */
  131165. url: string);
  131166. /**
  131167. * Execute the current task
  131168. * @param scene defines the scene where you want your assets to be loaded
  131169. * @param onSuccess is a callback called when the task is successfully executed
  131170. * @param onError is a callback called if an error occurs
  131171. */
  131172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131173. }
  131174. /**
  131175. * Define a task used by AssetsManager to load binary data
  131176. */
  131177. export class BinaryFileAssetTask extends AbstractAssetTask {
  131178. /**
  131179. * Defines the name of the task
  131180. */
  131181. name: string;
  131182. /**
  131183. * Defines the location of the file to load
  131184. */
  131185. url: string;
  131186. /**
  131187. * Gets the lodaded data (as an array buffer)
  131188. */
  131189. data: ArrayBuffer;
  131190. /**
  131191. * Callback called when the task is successful
  131192. */
  131193. onSuccess: (task: BinaryFileAssetTask) => void;
  131194. /**
  131195. * Callback called when the task is successful
  131196. */
  131197. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131198. /**
  131199. * Creates a new BinaryFileAssetTask object
  131200. * @param name defines the name of the new task
  131201. * @param url defines the location of the file to load
  131202. */
  131203. constructor(
  131204. /**
  131205. * Defines the name of the task
  131206. */
  131207. name: string,
  131208. /**
  131209. * Defines the location of the file to load
  131210. */
  131211. url: string);
  131212. /**
  131213. * Execute the current task
  131214. * @param scene defines the scene where you want your assets to be loaded
  131215. * @param onSuccess is a callback called when the task is successfully executed
  131216. * @param onError is a callback called if an error occurs
  131217. */
  131218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131219. }
  131220. /**
  131221. * Define a task used by AssetsManager to load images
  131222. */
  131223. export class ImageAssetTask extends AbstractAssetTask {
  131224. /**
  131225. * Defines the name of the task
  131226. */
  131227. name: string;
  131228. /**
  131229. * Defines the location of the image to load
  131230. */
  131231. url: string;
  131232. /**
  131233. * Gets the loaded images
  131234. */
  131235. image: HTMLImageElement;
  131236. /**
  131237. * Callback called when the task is successful
  131238. */
  131239. onSuccess: (task: ImageAssetTask) => void;
  131240. /**
  131241. * Callback called when the task is successful
  131242. */
  131243. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131244. /**
  131245. * Creates a new ImageAssetTask
  131246. * @param name defines the name of the task
  131247. * @param url defines the location of the image to load
  131248. */
  131249. constructor(
  131250. /**
  131251. * Defines the name of the task
  131252. */
  131253. name: string,
  131254. /**
  131255. * Defines the location of the image to load
  131256. */
  131257. url: string);
  131258. /**
  131259. * Execute the current task
  131260. * @param scene defines the scene where you want your assets to be loaded
  131261. * @param onSuccess is a callback called when the task is successfully executed
  131262. * @param onError is a callback called if an error occurs
  131263. */
  131264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131265. }
  131266. /**
  131267. * Defines the interface used by texture loading tasks
  131268. */
  131269. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131270. /**
  131271. * Gets the loaded texture
  131272. */
  131273. texture: TEX;
  131274. }
  131275. /**
  131276. * Define a task used by AssetsManager to load 2D textures
  131277. */
  131278. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131279. /**
  131280. * Defines the name of the task
  131281. */
  131282. name: string;
  131283. /**
  131284. * Defines the location of the file to load
  131285. */
  131286. url: string;
  131287. /**
  131288. * Defines if mipmap should not be generated (default is false)
  131289. */
  131290. noMipmap?: boolean | undefined;
  131291. /**
  131292. * Defines if texture must be inverted on Y axis (default is false)
  131293. */
  131294. invertY?: boolean | undefined;
  131295. /**
  131296. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131297. */
  131298. samplingMode: number;
  131299. /**
  131300. * Gets the loaded texture
  131301. */
  131302. texture: Texture;
  131303. /**
  131304. * Callback called when the task is successful
  131305. */
  131306. onSuccess: (task: TextureAssetTask) => void;
  131307. /**
  131308. * Callback called when the task is successful
  131309. */
  131310. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131311. /**
  131312. * Creates a new TextureAssetTask object
  131313. * @param name defines the name of the task
  131314. * @param url defines the location of the file to load
  131315. * @param noMipmap defines if mipmap should not be generated (default is false)
  131316. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131317. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131318. */
  131319. constructor(
  131320. /**
  131321. * Defines the name of the task
  131322. */
  131323. name: string,
  131324. /**
  131325. * Defines the location of the file to load
  131326. */
  131327. url: string,
  131328. /**
  131329. * Defines if mipmap should not be generated (default is false)
  131330. */
  131331. noMipmap?: boolean | undefined,
  131332. /**
  131333. * Defines if texture must be inverted on Y axis (default is false)
  131334. */
  131335. invertY?: boolean | undefined,
  131336. /**
  131337. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131338. */
  131339. samplingMode?: number);
  131340. /**
  131341. * Execute the current task
  131342. * @param scene defines the scene where you want your assets to be loaded
  131343. * @param onSuccess is a callback called when the task is successfully executed
  131344. * @param onError is a callback called if an error occurs
  131345. */
  131346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131347. }
  131348. /**
  131349. * Define a task used by AssetsManager to load cube textures
  131350. */
  131351. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131352. /**
  131353. * Defines the name of the task
  131354. */
  131355. name: string;
  131356. /**
  131357. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131358. */
  131359. url: string;
  131360. /**
  131361. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131362. */
  131363. extensions?: string[] | undefined;
  131364. /**
  131365. * Defines if mipmaps should not be generated (default is false)
  131366. */
  131367. noMipmap?: boolean | undefined;
  131368. /**
  131369. * Defines the explicit list of files (undefined by default)
  131370. */
  131371. files?: string[] | undefined;
  131372. /**
  131373. * Gets the loaded texture
  131374. */
  131375. texture: CubeTexture;
  131376. /**
  131377. * Callback called when the task is successful
  131378. */
  131379. onSuccess: (task: CubeTextureAssetTask) => void;
  131380. /**
  131381. * Callback called when the task is successful
  131382. */
  131383. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131384. /**
  131385. * Creates a new CubeTextureAssetTask
  131386. * @param name defines the name of the task
  131387. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131388. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131389. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131390. * @param files defines the explicit list of files (undefined by default)
  131391. */
  131392. constructor(
  131393. /**
  131394. * Defines the name of the task
  131395. */
  131396. name: string,
  131397. /**
  131398. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131399. */
  131400. url: string,
  131401. /**
  131402. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131403. */
  131404. extensions?: string[] | undefined,
  131405. /**
  131406. * Defines if mipmaps should not be generated (default is false)
  131407. */
  131408. noMipmap?: boolean | undefined,
  131409. /**
  131410. * Defines the explicit list of files (undefined by default)
  131411. */
  131412. files?: string[] | undefined);
  131413. /**
  131414. * Execute the current task
  131415. * @param scene defines the scene where you want your assets to be loaded
  131416. * @param onSuccess is a callback called when the task is successfully executed
  131417. * @param onError is a callback called if an error occurs
  131418. */
  131419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131420. }
  131421. /**
  131422. * Define a task used by AssetsManager to load HDR cube textures
  131423. */
  131424. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131425. /**
  131426. * Defines the name of the task
  131427. */
  131428. name: string;
  131429. /**
  131430. * Defines the location of the file to load
  131431. */
  131432. url: string;
  131433. /**
  131434. * Defines the desired size (the more it increases the longer the generation will be)
  131435. */
  131436. size: number;
  131437. /**
  131438. * Defines if mipmaps should not be generated (default is false)
  131439. */
  131440. noMipmap: boolean;
  131441. /**
  131442. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131443. */
  131444. generateHarmonics: boolean;
  131445. /**
  131446. * 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)
  131447. */
  131448. gammaSpace: boolean;
  131449. /**
  131450. * Internal Use Only
  131451. */
  131452. reserved: boolean;
  131453. /**
  131454. * Gets the loaded texture
  131455. */
  131456. texture: HDRCubeTexture;
  131457. /**
  131458. * Callback called when the task is successful
  131459. */
  131460. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131461. /**
  131462. * Callback called when the task is successful
  131463. */
  131464. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131465. /**
  131466. * Creates a new HDRCubeTextureAssetTask object
  131467. * @param name defines the name of the task
  131468. * @param url defines the location of the file to load
  131469. * @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.
  131470. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131471. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131472. * @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)
  131473. * @param reserved Internal use only
  131474. */
  131475. constructor(
  131476. /**
  131477. * Defines the name of the task
  131478. */
  131479. name: string,
  131480. /**
  131481. * Defines the location of the file to load
  131482. */
  131483. url: string,
  131484. /**
  131485. * Defines the desired size (the more it increases the longer the generation will be)
  131486. */
  131487. size: number,
  131488. /**
  131489. * Defines if mipmaps should not be generated (default is false)
  131490. */
  131491. noMipmap?: boolean,
  131492. /**
  131493. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131494. */
  131495. generateHarmonics?: boolean,
  131496. /**
  131497. * 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)
  131498. */
  131499. gammaSpace?: boolean,
  131500. /**
  131501. * Internal Use Only
  131502. */
  131503. reserved?: boolean);
  131504. /**
  131505. * Execute the current task
  131506. * @param scene defines the scene where you want your assets to be loaded
  131507. * @param onSuccess is a callback called when the task is successfully executed
  131508. * @param onError is a callback called if an error occurs
  131509. */
  131510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131511. }
  131512. /**
  131513. * Define a task used by AssetsManager to load Equirectangular cube textures
  131514. */
  131515. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  131516. /**
  131517. * Defines the name of the task
  131518. */
  131519. name: string;
  131520. /**
  131521. * Defines the location of the file to load
  131522. */
  131523. url: string;
  131524. /**
  131525. * Defines the desired size (the more it increases the longer the generation will be)
  131526. */
  131527. size: number;
  131528. /**
  131529. * Defines if mipmaps should not be generated (default is false)
  131530. */
  131531. noMipmap: boolean;
  131532. /**
  131533. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131534. * but the standard material would require them in Gamma space) (default is true)
  131535. */
  131536. gammaSpace: boolean;
  131537. /**
  131538. * Gets the loaded texture
  131539. */
  131540. texture: EquiRectangularCubeTexture;
  131541. /**
  131542. * Callback called when the task is successful
  131543. */
  131544. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  131545. /**
  131546. * Callback called when the task is successful
  131547. */
  131548. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  131549. /**
  131550. * Creates a new EquiRectangularCubeTextureAssetTask object
  131551. * @param name defines the name of the task
  131552. * @param url defines the location of the file to load
  131553. * @param size defines the desired size (the more it increases the longer the generation will be)
  131554. * If the size is omitted this implies you are using a preprocessed cubemap.
  131555. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131556. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  131557. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  131558. * (default is true)
  131559. */
  131560. constructor(
  131561. /**
  131562. * Defines the name of the task
  131563. */
  131564. name: string,
  131565. /**
  131566. * Defines the location of the file to load
  131567. */
  131568. url: string,
  131569. /**
  131570. * Defines the desired size (the more it increases the longer the generation will be)
  131571. */
  131572. size: number,
  131573. /**
  131574. * Defines if mipmaps should not be generated (default is false)
  131575. */
  131576. noMipmap?: boolean,
  131577. /**
  131578. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  131579. * but the standard material would require them in Gamma space) (default is true)
  131580. */
  131581. gammaSpace?: boolean);
  131582. /**
  131583. * Execute the current task
  131584. * @param scene defines the scene where you want your assets to be loaded
  131585. * @param onSuccess is a callback called when the task is successfully executed
  131586. * @param onError is a callback called if an error occurs
  131587. */
  131588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131589. }
  131590. /**
  131591. * This class can be used to easily import assets into a scene
  131592. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  131593. */
  131594. export class AssetsManager {
  131595. private _scene;
  131596. private _isLoading;
  131597. protected _tasks: AbstractAssetTask[];
  131598. protected _waitingTasksCount: number;
  131599. protected _totalTasksCount: number;
  131600. /**
  131601. * Callback called when all tasks are processed
  131602. */
  131603. onFinish: (tasks: AbstractAssetTask[]) => void;
  131604. /**
  131605. * Callback called when a task is successful
  131606. */
  131607. onTaskSuccess: (task: AbstractAssetTask) => void;
  131608. /**
  131609. * Callback called when a task had an error
  131610. */
  131611. onTaskError: (task: AbstractAssetTask) => void;
  131612. /**
  131613. * Callback called when a task is done (whatever the result is)
  131614. */
  131615. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  131616. /**
  131617. * Observable called when all tasks are processed
  131618. */
  131619. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  131620. /**
  131621. * Observable called when a task had an error
  131622. */
  131623. onTaskErrorObservable: Observable<AbstractAssetTask>;
  131624. /**
  131625. * Observable called when all tasks were executed
  131626. */
  131627. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  131628. /**
  131629. * Observable called when a task is done (whatever the result is)
  131630. */
  131631. onProgressObservable: Observable<IAssetsProgressEvent>;
  131632. /**
  131633. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  131634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  131635. */
  131636. useDefaultLoadingScreen: boolean;
  131637. /**
  131638. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  131639. * when all assets have been downloaded.
  131640. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  131641. */
  131642. autoHideLoadingUI: boolean;
  131643. /**
  131644. * Creates a new AssetsManager
  131645. * @param scene defines the scene to work on
  131646. */
  131647. constructor(scene: Scene);
  131648. /**
  131649. * Add a MeshAssetTask to the list of active tasks
  131650. * @param taskName defines the name of the new task
  131651. * @param meshesNames defines the name of meshes to load
  131652. * @param rootUrl defines the root url to use to locate files
  131653. * @param sceneFilename defines the filename of the scene file
  131654. * @returns a new MeshAssetTask object
  131655. */
  131656. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  131657. /**
  131658. * Add a TextFileAssetTask to the list of active tasks
  131659. * @param taskName defines the name of the new task
  131660. * @param url defines the url of the file to load
  131661. * @returns a new TextFileAssetTask object
  131662. */
  131663. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  131664. /**
  131665. * Add a BinaryFileAssetTask to the list of active tasks
  131666. * @param taskName defines the name of the new task
  131667. * @param url defines the url of the file to load
  131668. * @returns a new BinaryFileAssetTask object
  131669. */
  131670. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  131671. /**
  131672. * Add a ImageAssetTask to the list of active tasks
  131673. * @param taskName defines the name of the new task
  131674. * @param url defines the url of the file to load
  131675. * @returns a new ImageAssetTask object
  131676. */
  131677. addImageTask(taskName: string, url: string): ImageAssetTask;
  131678. /**
  131679. * Add a TextureAssetTask to the list of active tasks
  131680. * @param taskName defines the name of the new task
  131681. * @param url defines the url of the file to load
  131682. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131683. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  131684. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131685. * @returns a new TextureAssetTask object
  131686. */
  131687. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  131688. /**
  131689. * Add a CubeTextureAssetTask to the list of active tasks
  131690. * @param taskName defines the name of the new task
  131691. * @param url defines the url of the file to load
  131692. * @param extensions defines the extension to use to load the cube map (can be null)
  131693. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131694. * @param files defines the list of files to load (can be null)
  131695. * @returns a new CubeTextureAssetTask object
  131696. */
  131697. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  131698. /**
  131699. *
  131700. * Add a HDRCubeTextureAssetTask to the list of active tasks
  131701. * @param taskName defines the name of the new task
  131702. * @param url defines the url of the file to load
  131703. * @param size defines the size you want for the cubemap (can be null)
  131704. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131705. * @param generateHarmonics defines if you want to automatically generate (true by default)
  131706. * @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)
  131707. * @param reserved Internal use only
  131708. * @returns a new HDRCubeTextureAssetTask object
  131709. */
  131710. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  131711. /**
  131712. *
  131713. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  131714. * @param taskName defines the name of the new task
  131715. * @param url defines the url of the file to load
  131716. * @param size defines the size you want for the cubemap (can be null)
  131717. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  131718. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  131719. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  131720. * @returns a new EquiRectangularCubeTextureAssetTask object
  131721. */
  131722. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  131723. /**
  131724. * Remove a task from the assets manager.
  131725. * @param task the task to remove
  131726. */
  131727. removeTask(task: AbstractAssetTask): void;
  131728. private _decreaseWaitingTasksCount;
  131729. private _runTask;
  131730. /**
  131731. * Reset the AssetsManager and remove all tasks
  131732. * @return the current instance of the AssetsManager
  131733. */
  131734. reset(): AssetsManager;
  131735. /**
  131736. * Start the loading process
  131737. * @return the current instance of the AssetsManager
  131738. */
  131739. load(): AssetsManager;
  131740. /**
  131741. * Start the loading process as an async operation
  131742. * @return a promise returning the list of failed tasks
  131743. */
  131744. loadAsync(): Promise<void>;
  131745. }
  131746. }
  131747. declare module BABYLON {
  131748. /**
  131749. * Wrapper class for promise with external resolve and reject.
  131750. */
  131751. export class Deferred<T> {
  131752. /**
  131753. * The promise associated with this deferred object.
  131754. */
  131755. readonly promise: Promise<T>;
  131756. private _resolve;
  131757. private _reject;
  131758. /**
  131759. * The resolve method of the promise associated with this deferred object.
  131760. */
  131761. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  131762. /**
  131763. * The reject method of the promise associated with this deferred object.
  131764. */
  131765. readonly reject: (reason?: any) => void;
  131766. /**
  131767. * Constructor for this deferred object.
  131768. */
  131769. constructor();
  131770. }
  131771. }
  131772. declare module BABYLON {
  131773. /**
  131774. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  131775. */
  131776. export class MeshExploder {
  131777. private _centerMesh;
  131778. private _meshes;
  131779. private _meshesOrigins;
  131780. private _toCenterVectors;
  131781. private _scaledDirection;
  131782. private _newPosition;
  131783. private _centerPosition;
  131784. /**
  131785. * Explodes meshes from a center mesh.
  131786. * @param meshes The meshes to explode.
  131787. * @param centerMesh The mesh to be center of explosion.
  131788. */
  131789. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  131790. private _setCenterMesh;
  131791. /**
  131792. * Get class name
  131793. * @returns "MeshExploder"
  131794. */
  131795. getClassName(): string;
  131796. /**
  131797. * "Exploded meshes"
  131798. * @returns Array of meshes with the centerMesh at index 0.
  131799. */
  131800. getMeshes(): Array<Mesh>;
  131801. /**
  131802. * Explodes meshes giving a specific direction
  131803. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  131804. */
  131805. explode(direction?: number): void;
  131806. }
  131807. }
  131808. declare module BABYLON {
  131809. /**
  131810. * Class used to help managing file picking and drag'n'drop
  131811. */
  131812. export class FilesInput {
  131813. /**
  131814. * List of files ready to be loaded
  131815. */
  131816. static readonly FilesToLoad: {
  131817. [key: string]: File;
  131818. };
  131819. /**
  131820. * Callback called when a file is processed
  131821. */
  131822. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  131823. private _engine;
  131824. private _currentScene;
  131825. private _sceneLoadedCallback;
  131826. private _progressCallback;
  131827. private _additionalRenderLoopLogicCallback;
  131828. private _textureLoadingCallback;
  131829. private _startingProcessingFilesCallback;
  131830. private _onReloadCallback;
  131831. private _errorCallback;
  131832. private _elementToMonitor;
  131833. private _sceneFileToLoad;
  131834. private _filesToLoad;
  131835. /**
  131836. * Creates a new FilesInput
  131837. * @param engine defines the rendering engine
  131838. * @param scene defines the hosting scene
  131839. * @param sceneLoadedCallback callback called when scene is loaded
  131840. * @param progressCallback callback called to track progress
  131841. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  131842. * @param textureLoadingCallback callback called when a texture is loading
  131843. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  131844. * @param onReloadCallback callback called when a reload is requested
  131845. * @param errorCallback callback call if an error occurs
  131846. */
  131847. 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);
  131848. private _dragEnterHandler;
  131849. private _dragOverHandler;
  131850. private _dropHandler;
  131851. /**
  131852. * Calls this function to listen to drag'n'drop events on a specific DOM element
  131853. * @param elementToMonitor defines the DOM element to track
  131854. */
  131855. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  131856. /**
  131857. * Release all associated resources
  131858. */
  131859. dispose(): void;
  131860. private renderFunction;
  131861. private drag;
  131862. private drop;
  131863. private _traverseFolder;
  131864. private _processFiles;
  131865. /**
  131866. * Load files from a drop event
  131867. * @param event defines the drop event to use as source
  131868. */
  131869. loadFiles(event: any): void;
  131870. private _processReload;
  131871. /**
  131872. * Reload the current scene from the loaded files
  131873. */
  131874. reload(): void;
  131875. }
  131876. }
  131877. declare module BABYLON {
  131878. /**
  131879. * Defines the root class used to create scene optimization to use with SceneOptimizer
  131880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131881. */
  131882. export class SceneOptimization {
  131883. /**
  131884. * Defines the priority of this optimization (0 by default which means first in the list)
  131885. */
  131886. priority: number;
  131887. /**
  131888. * Gets a string describing the action executed by the current optimization
  131889. * @returns description string
  131890. */
  131891. getDescription(): string;
  131892. /**
  131893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131894. * @param scene defines the current scene where to apply this optimization
  131895. * @param optimizer defines the current optimizer
  131896. * @returns true if everything that can be done was applied
  131897. */
  131898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131899. /**
  131900. * Creates the SceneOptimization object
  131901. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131902. * @param desc defines the description associated with the optimization
  131903. */
  131904. constructor(
  131905. /**
  131906. * Defines the priority of this optimization (0 by default which means first in the list)
  131907. */
  131908. priority?: number);
  131909. }
  131910. /**
  131911. * Defines an optimization used to reduce the size of render target textures
  131912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131913. */
  131914. export class TextureOptimization extends SceneOptimization {
  131915. /**
  131916. * Defines the priority of this optimization (0 by default which means first in the list)
  131917. */
  131918. priority: number;
  131919. /**
  131920. * 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
  131921. */
  131922. maximumSize: number;
  131923. /**
  131924. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131925. */
  131926. step: number;
  131927. /**
  131928. * Gets a string describing the action executed by the current optimization
  131929. * @returns description string
  131930. */
  131931. getDescription(): string;
  131932. /**
  131933. * Creates the TextureOptimization object
  131934. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131935. * @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
  131936. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131937. */
  131938. constructor(
  131939. /**
  131940. * Defines the priority of this optimization (0 by default which means first in the list)
  131941. */
  131942. priority?: number,
  131943. /**
  131944. * 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
  131945. */
  131946. maximumSize?: number,
  131947. /**
  131948. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131949. */
  131950. step?: number);
  131951. /**
  131952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131953. * @param scene defines the current scene where to apply this optimization
  131954. * @param optimizer defines the current optimizer
  131955. * @returns true if everything that can be done was applied
  131956. */
  131957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131958. }
  131959. /**
  131960. * Defines an optimization used to increase or decrease the rendering resolution
  131961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131962. */
  131963. export class HardwareScalingOptimization extends SceneOptimization {
  131964. /**
  131965. * Defines the priority of this optimization (0 by default which means first in the list)
  131966. */
  131967. priority: number;
  131968. /**
  131969. * Defines the maximum scale to use (2 by default)
  131970. */
  131971. maximumScale: number;
  131972. /**
  131973. * Defines the step to use between two passes (0.5 by default)
  131974. */
  131975. step: number;
  131976. private _currentScale;
  131977. private _directionOffset;
  131978. /**
  131979. * Gets a string describing the action executed by the current optimization
  131980. * @return description string
  131981. */
  131982. getDescription(): string;
  131983. /**
  131984. * Creates the HardwareScalingOptimization object
  131985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131986. * @param maximumScale defines the maximum scale to use (2 by default)
  131987. * @param step defines the step to use between two passes (0.5 by default)
  131988. */
  131989. constructor(
  131990. /**
  131991. * Defines the priority of this optimization (0 by default which means first in the list)
  131992. */
  131993. priority?: number,
  131994. /**
  131995. * Defines the maximum scale to use (2 by default)
  131996. */
  131997. maximumScale?: number,
  131998. /**
  131999. * Defines the step to use between two passes (0.5 by default)
  132000. */
  132001. step?: number);
  132002. /**
  132003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132004. * @param scene defines the current scene where to apply this optimization
  132005. * @param optimizer defines the current optimizer
  132006. * @returns true if everything that can be done was applied
  132007. */
  132008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132009. }
  132010. /**
  132011. * Defines an optimization used to remove shadows
  132012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132013. */
  132014. export class ShadowsOptimization extends SceneOptimization {
  132015. /**
  132016. * Gets a string describing the action executed by the current optimization
  132017. * @return description string
  132018. */
  132019. getDescription(): string;
  132020. /**
  132021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132022. * @param scene defines the current scene where to apply this optimization
  132023. * @param optimizer defines the current optimizer
  132024. * @returns true if everything that can be done was applied
  132025. */
  132026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132027. }
  132028. /**
  132029. * Defines an optimization used to turn post-processes off
  132030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132031. */
  132032. export class PostProcessesOptimization extends SceneOptimization {
  132033. /**
  132034. * Gets a string describing the action executed by the current optimization
  132035. * @return description string
  132036. */
  132037. getDescription(): string;
  132038. /**
  132039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132040. * @param scene defines the current scene where to apply this optimization
  132041. * @param optimizer defines the current optimizer
  132042. * @returns true if everything that can be done was applied
  132043. */
  132044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132045. }
  132046. /**
  132047. * Defines an optimization used to turn lens flares off
  132048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132049. */
  132050. export class LensFlaresOptimization extends SceneOptimization {
  132051. /**
  132052. * Gets a string describing the action executed by the current optimization
  132053. * @return description string
  132054. */
  132055. getDescription(): string;
  132056. /**
  132057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132058. * @param scene defines the current scene where to apply this optimization
  132059. * @param optimizer defines the current optimizer
  132060. * @returns true if everything that can be done was applied
  132061. */
  132062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132063. }
  132064. /**
  132065. * Defines an optimization based on user defined callback.
  132066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132067. */
  132068. export class CustomOptimization extends SceneOptimization {
  132069. /**
  132070. * Callback called to apply the custom optimization.
  132071. */
  132072. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132073. /**
  132074. * Callback called to get custom description
  132075. */
  132076. onGetDescription: () => string;
  132077. /**
  132078. * Gets a string describing the action executed by the current optimization
  132079. * @returns description string
  132080. */
  132081. getDescription(): string;
  132082. /**
  132083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132084. * @param scene defines the current scene where to apply this optimization
  132085. * @param optimizer defines the current optimizer
  132086. * @returns true if everything that can be done was applied
  132087. */
  132088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132089. }
  132090. /**
  132091. * Defines an optimization used to turn particles off
  132092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132093. */
  132094. export class ParticlesOptimization extends SceneOptimization {
  132095. /**
  132096. * Gets a string describing the action executed by the current optimization
  132097. * @return description string
  132098. */
  132099. getDescription(): string;
  132100. /**
  132101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132102. * @param scene defines the current scene where to apply this optimization
  132103. * @param optimizer defines the current optimizer
  132104. * @returns true if everything that can be done was applied
  132105. */
  132106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132107. }
  132108. /**
  132109. * Defines an optimization used to turn render targets off
  132110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132111. */
  132112. export class RenderTargetsOptimization extends SceneOptimization {
  132113. /**
  132114. * Gets a string describing the action executed by the current optimization
  132115. * @return description string
  132116. */
  132117. getDescription(): string;
  132118. /**
  132119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132120. * @param scene defines the current scene where to apply this optimization
  132121. * @param optimizer defines the current optimizer
  132122. * @returns true if everything that can be done was applied
  132123. */
  132124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132125. }
  132126. /**
  132127. * Defines an optimization used to merge meshes with compatible materials
  132128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132129. */
  132130. export class MergeMeshesOptimization extends SceneOptimization {
  132131. private static _UpdateSelectionTree;
  132132. /**
  132133. * Gets or sets a boolean which defines if optimization octree has to be updated
  132134. */
  132135. /**
  132136. * Gets or sets a boolean which defines if optimization octree has to be updated
  132137. */
  132138. static UpdateSelectionTree: boolean;
  132139. /**
  132140. * Gets a string describing the action executed by the current optimization
  132141. * @return description string
  132142. */
  132143. getDescription(): string;
  132144. private _canBeMerged;
  132145. /**
  132146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132147. * @param scene defines the current scene where to apply this optimization
  132148. * @param optimizer defines the current optimizer
  132149. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132150. * @returns true if everything that can be done was applied
  132151. */
  132152. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132153. }
  132154. /**
  132155. * Defines a list of options used by SceneOptimizer
  132156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132157. */
  132158. export class SceneOptimizerOptions {
  132159. /**
  132160. * Defines the target frame rate to reach (60 by default)
  132161. */
  132162. targetFrameRate: number;
  132163. /**
  132164. * Defines the interval between two checkes (2000ms by default)
  132165. */
  132166. trackerDuration: number;
  132167. /**
  132168. * Gets the list of optimizations to apply
  132169. */
  132170. optimizations: SceneOptimization[];
  132171. /**
  132172. * Creates a new list of options used by SceneOptimizer
  132173. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132174. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132175. */
  132176. constructor(
  132177. /**
  132178. * Defines the target frame rate to reach (60 by default)
  132179. */
  132180. targetFrameRate?: number,
  132181. /**
  132182. * Defines the interval between two checkes (2000ms by default)
  132183. */
  132184. trackerDuration?: number);
  132185. /**
  132186. * Add a new optimization
  132187. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132188. * @returns the current SceneOptimizerOptions
  132189. */
  132190. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132191. /**
  132192. * Add a new custom optimization
  132193. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132194. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132195. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132196. * @returns the current SceneOptimizerOptions
  132197. */
  132198. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132199. /**
  132200. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132201. * @param targetFrameRate defines the target frame rate (60 by default)
  132202. * @returns a SceneOptimizerOptions object
  132203. */
  132204. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132205. /**
  132206. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132207. * @param targetFrameRate defines the target frame rate (60 by default)
  132208. * @returns a SceneOptimizerOptions object
  132209. */
  132210. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132211. /**
  132212. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132213. * @param targetFrameRate defines the target frame rate (60 by default)
  132214. * @returns a SceneOptimizerOptions object
  132215. */
  132216. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132217. }
  132218. /**
  132219. * Class used to run optimizations in order to reach a target frame rate
  132220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132221. */
  132222. export class SceneOptimizer implements IDisposable {
  132223. private _isRunning;
  132224. private _options;
  132225. private _scene;
  132226. private _currentPriorityLevel;
  132227. private _targetFrameRate;
  132228. private _trackerDuration;
  132229. private _currentFrameRate;
  132230. private _sceneDisposeObserver;
  132231. private _improvementMode;
  132232. /**
  132233. * Defines an observable called when the optimizer reaches the target frame rate
  132234. */
  132235. onSuccessObservable: Observable<SceneOptimizer>;
  132236. /**
  132237. * Defines an observable called when the optimizer enables an optimization
  132238. */
  132239. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132240. /**
  132241. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132242. */
  132243. onFailureObservable: Observable<SceneOptimizer>;
  132244. /**
  132245. * Gets a boolean indicating if the optimizer is in improvement mode
  132246. */
  132247. readonly isInImprovementMode: boolean;
  132248. /**
  132249. * Gets the current priority level (0 at start)
  132250. */
  132251. readonly currentPriorityLevel: number;
  132252. /**
  132253. * Gets the current frame rate checked by the SceneOptimizer
  132254. */
  132255. readonly currentFrameRate: number;
  132256. /**
  132257. * Gets or sets the current target frame rate (60 by default)
  132258. */
  132259. /**
  132260. * Gets or sets the current target frame rate (60 by default)
  132261. */
  132262. targetFrameRate: number;
  132263. /**
  132264. * Gets or sets the current interval between two checks (every 2000ms by default)
  132265. */
  132266. /**
  132267. * Gets or sets the current interval between two checks (every 2000ms by default)
  132268. */
  132269. trackerDuration: number;
  132270. /**
  132271. * Gets the list of active optimizations
  132272. */
  132273. readonly optimizations: SceneOptimization[];
  132274. /**
  132275. * Creates a new SceneOptimizer
  132276. * @param scene defines the scene to work on
  132277. * @param options defines the options to use with the SceneOptimizer
  132278. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132279. * @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)
  132280. */
  132281. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132282. /**
  132283. * Stops the current optimizer
  132284. */
  132285. stop(): void;
  132286. /**
  132287. * Reset the optimizer to initial step (current priority level = 0)
  132288. */
  132289. reset(): void;
  132290. /**
  132291. * Start the optimizer. By default it will try to reach a specific framerate
  132292. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132293. */
  132294. start(): void;
  132295. private _checkCurrentState;
  132296. /**
  132297. * Release all resources
  132298. */
  132299. dispose(): void;
  132300. /**
  132301. * Helper function to create a SceneOptimizer with one single line of code
  132302. * @param scene defines the scene to work on
  132303. * @param options defines the options to use with the SceneOptimizer
  132304. * @param onSuccess defines a callback to call on success
  132305. * @param onFailure defines a callback to call on failure
  132306. * @returns the new SceneOptimizer object
  132307. */
  132308. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132309. }
  132310. }
  132311. declare module BABYLON {
  132312. /**
  132313. * Class used to serialize a scene into a string
  132314. */
  132315. export class SceneSerializer {
  132316. /**
  132317. * Clear cache used by a previous serialization
  132318. */
  132319. static ClearCache(): void;
  132320. /**
  132321. * Serialize a scene into a JSON compatible object
  132322. * @param scene defines the scene to serialize
  132323. * @returns a JSON compatible object
  132324. */
  132325. static Serialize(scene: Scene): any;
  132326. /**
  132327. * Serialize a mesh into a JSON compatible object
  132328. * @param toSerialize defines the mesh to serialize
  132329. * @param withParents defines if parents must be serialized as well
  132330. * @param withChildren defines if children must be serialized as well
  132331. * @returns a JSON compatible object
  132332. */
  132333. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132334. }
  132335. }
  132336. declare module BABYLON {
  132337. /**
  132338. * Class used to host texture specific utilities
  132339. */
  132340. export class TextureTools {
  132341. /**
  132342. * Uses the GPU to create a copy texture rescaled at a given size
  132343. * @param texture Texture to copy from
  132344. * @param width defines the desired width
  132345. * @param height defines the desired height
  132346. * @param useBilinearMode defines if bilinear mode has to be used
  132347. * @return the generated texture
  132348. */
  132349. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132350. }
  132351. }
  132352. declare module BABYLON {
  132353. /**
  132354. * This represents the different options available for the video capture.
  132355. */
  132356. export interface VideoRecorderOptions {
  132357. /** Defines the mime type of the video. */
  132358. mimeType: string;
  132359. /** Defines the FPS the video should be recorded at. */
  132360. fps: number;
  132361. /** Defines the chunk size for the recording data. */
  132362. recordChunckSize: number;
  132363. /** The audio tracks to attach to the recording. */
  132364. audioTracks?: MediaStreamTrack[];
  132365. }
  132366. /**
  132367. * This can help with recording videos from BabylonJS.
  132368. * This is based on the available WebRTC functionalities of the browser.
  132369. *
  132370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132371. */
  132372. export class VideoRecorder {
  132373. private static readonly _defaultOptions;
  132374. /**
  132375. * Returns whether or not the VideoRecorder is available in your browser.
  132376. * @param engine Defines the Babylon Engine.
  132377. * @returns true if supported otherwise false.
  132378. */
  132379. static IsSupported(engine: Engine): boolean;
  132380. private readonly _options;
  132381. private _canvas;
  132382. private _mediaRecorder;
  132383. private _recordedChunks;
  132384. private _fileName;
  132385. private _resolve;
  132386. private _reject;
  132387. /**
  132388. * True when a recording is already in progress.
  132389. */
  132390. readonly isRecording: boolean;
  132391. /**
  132392. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132393. * @param engine Defines the BabylonJS Engine you wish to record.
  132394. * @param options Defines options that can be used to customize the capture.
  132395. */
  132396. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132397. /**
  132398. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132399. */
  132400. stopRecording(): void;
  132401. /**
  132402. * Starts recording the canvas for a max duration specified in parameters.
  132403. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132404. * If null no automatic download will start and you can rely on the promise to get the data back.
  132405. * @param maxDuration Defines the maximum recording time in seconds.
  132406. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132407. * @return A promise callback at the end of the recording with the video data in Blob.
  132408. */
  132409. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132410. /**
  132411. * Releases internal resources used during the recording.
  132412. */
  132413. dispose(): void;
  132414. private _handleDataAvailable;
  132415. private _handleError;
  132416. private _handleStop;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * Class containing a set of static utilities functions for screenshots
  132422. */
  132423. export class ScreenshotTools {
  132424. /**
  132425. * Captures a screenshot of the current rendering
  132426. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132427. * @param engine defines the rendering engine
  132428. * @param camera defines the source camera
  132429. * @param size This parameter can be set to a single number or to an object with the
  132430. * following (optional) properties: precision, width, height. If a single number is passed,
  132431. * it will be used for both width and height. If an object is passed, the screenshot size
  132432. * will be derived from the parameters. The precision property is a multiplier allowing
  132433. * rendering at a higher or lower resolution
  132434. * @param successCallback defines the callback receives a single parameter which contains the
  132435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132436. * src parameter of an <img> to display it
  132437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132438. * Check your browser for supported MIME types
  132439. */
  132440. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132441. /**
  132442. * Captures a screenshot of the current rendering
  132443. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132444. * @param engine defines the rendering engine
  132445. * @param camera defines the source camera
  132446. * @param size This parameter can be set to a single number or to an object with the
  132447. * following (optional) properties: precision, width, height. If a single number is passed,
  132448. * it will be used for both width and height. If an object is passed, the screenshot size
  132449. * will be derived from the parameters. The precision property is a multiplier allowing
  132450. * rendering at a higher or lower resolution
  132451. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132452. * Check your browser for supported MIME types
  132453. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132454. * to the src parameter of an <img> to display it
  132455. */
  132456. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132457. /**
  132458. * Generates an image screenshot from the specified camera.
  132459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132460. * @param engine The engine to use for rendering
  132461. * @param camera The camera to use for rendering
  132462. * @param size This parameter can be set to a single number or to an object with the
  132463. * following (optional) properties: precision, width, height. If a single number is passed,
  132464. * it will be used for both width and height. If an object is passed, the screenshot size
  132465. * will be derived from the parameters. The precision property is a multiplier allowing
  132466. * rendering at a higher or lower resolution
  132467. * @param successCallback The callback receives a single parameter which contains the
  132468. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132469. * src parameter of an <img> to display it
  132470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132471. * Check your browser for supported MIME types
  132472. * @param samples Texture samples (default: 1)
  132473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132474. * @param fileName A name for for the downloaded file.
  132475. */
  132476. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132477. /**
  132478. * Generates an image screenshot from the specified camera.
  132479. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132480. * @param engine The engine to use for rendering
  132481. * @param camera The camera to use for rendering
  132482. * @param size This parameter can be set to a single number or to an object with the
  132483. * following (optional) properties: precision, width, height. If a single number is passed,
  132484. * it will be used for both width and height. If an object is passed, the screenshot size
  132485. * will be derived from the parameters. The precision property is a multiplier allowing
  132486. * rendering at a higher or lower resolution
  132487. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132488. * Check your browser for supported MIME types
  132489. * @param samples Texture samples (default: 1)
  132490. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132491. * @param fileName A name for for the downloaded file.
  132492. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132493. * to the src parameter of an <img> to display it
  132494. */
  132495. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132496. /**
  132497. * Gets height and width for screenshot size
  132498. * @private
  132499. */
  132500. private static _getScreenshotSize;
  132501. }
  132502. }
  132503. declare module BABYLON {
  132504. /**
  132505. * Interface for a data buffer
  132506. */
  132507. export interface IDataBuffer {
  132508. /**
  132509. * Reads bytes from the data buffer.
  132510. * @param byteOffset The byte offset to read
  132511. * @param byteLength The byte length to read
  132512. * @returns A promise that resolves when the bytes are read
  132513. */
  132514. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  132515. /**
  132516. * The byte length of the buffer.
  132517. */
  132518. readonly byteLength: number;
  132519. }
  132520. /**
  132521. * Utility class for reading from a data buffer
  132522. */
  132523. export class DataReader {
  132524. /**
  132525. * The data buffer associated with this data reader.
  132526. */
  132527. readonly buffer: IDataBuffer;
  132528. /**
  132529. * The current byte offset from the beginning of the data buffer.
  132530. */
  132531. byteOffset: number;
  132532. private _dataView;
  132533. private _dataByteOffset;
  132534. /**
  132535. * Constructor
  132536. * @param buffer The buffer to read
  132537. */
  132538. constructor(buffer: IDataBuffer);
  132539. /**
  132540. * Loads the given byte length.
  132541. * @param byteLength The byte length to load
  132542. * @returns A promise that resolves when the load is complete
  132543. */
  132544. loadAsync(byteLength: number): Promise<void>;
  132545. /**
  132546. * Read a unsigned 32-bit integer from the currently loaded data range.
  132547. * @returns The 32-bit integer read
  132548. */
  132549. readUint32(): number;
  132550. /**
  132551. * Read a byte array from the currently loaded data range.
  132552. * @param byteLength The byte length to read
  132553. * @returns The byte array read
  132554. */
  132555. readUint8Array(byteLength: number): Uint8Array;
  132556. /**
  132557. * Read a string from the currently loaded data range.
  132558. * @param byteLength The byte length to read
  132559. * @returns The string read
  132560. */
  132561. readString(byteLength: number): string;
  132562. /**
  132563. * Skips the given byte length the currently loaded data range.
  132564. * @param byteLength The byte length to skip
  132565. */
  132566. skipBytes(byteLength: number): void;
  132567. }
  132568. }
  132569. declare module BABYLON {
  132570. /**
  132571. * A cursor which tracks a point on a path
  132572. */
  132573. export class PathCursor {
  132574. private path;
  132575. /**
  132576. * Stores path cursor callbacks for when an onchange event is triggered
  132577. */
  132578. private _onchange;
  132579. /**
  132580. * The value of the path cursor
  132581. */
  132582. value: number;
  132583. /**
  132584. * The animation array of the path cursor
  132585. */
  132586. animations: Animation[];
  132587. /**
  132588. * Initializes the path cursor
  132589. * @param path The path to track
  132590. */
  132591. constructor(path: Path2);
  132592. /**
  132593. * Gets the cursor point on the path
  132594. * @returns A point on the path cursor at the cursor location
  132595. */
  132596. getPoint(): Vector3;
  132597. /**
  132598. * Moves the cursor ahead by the step amount
  132599. * @param step The amount to move the cursor forward
  132600. * @returns This path cursor
  132601. */
  132602. moveAhead(step?: number): PathCursor;
  132603. /**
  132604. * Moves the cursor behind by the step amount
  132605. * @param step The amount to move the cursor back
  132606. * @returns This path cursor
  132607. */
  132608. moveBack(step?: number): PathCursor;
  132609. /**
  132610. * Moves the cursor by the step amount
  132611. * If the step amount is greater than one, an exception is thrown
  132612. * @param step The amount to move the cursor
  132613. * @returns This path cursor
  132614. */
  132615. move(step: number): PathCursor;
  132616. /**
  132617. * Ensures that the value is limited between zero and one
  132618. * @returns This path cursor
  132619. */
  132620. private ensureLimits;
  132621. /**
  132622. * Runs onchange callbacks on change (used by the animation engine)
  132623. * @returns This path cursor
  132624. */
  132625. private raiseOnChange;
  132626. /**
  132627. * Executes a function on change
  132628. * @param f A path cursor onchange callback
  132629. * @returns This path cursor
  132630. */
  132631. onchange(f: (cursor: PathCursor) => void): PathCursor;
  132632. }
  132633. }
  132634. declare module BABYLON {
  132635. /** @hidden */
  132636. export var blurPixelShader: {
  132637. name: string;
  132638. shader: string;
  132639. };
  132640. }
  132641. declare module BABYLON {
  132642. /** @hidden */
  132643. export var pointCloudVertexDeclaration: {
  132644. name: string;
  132645. shader: string;
  132646. };
  132647. }
  132648. // Mixins
  132649. interface Window {
  132650. mozIndexedDB: IDBFactory;
  132651. webkitIndexedDB: IDBFactory;
  132652. msIndexedDB: IDBFactory;
  132653. webkitURL: typeof URL;
  132654. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  132655. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  132656. WebGLRenderingContext: WebGLRenderingContext;
  132657. MSGesture: MSGesture;
  132658. CANNON: any;
  132659. AudioContext: AudioContext;
  132660. webkitAudioContext: AudioContext;
  132661. PointerEvent: any;
  132662. Math: Math;
  132663. Uint8Array: Uint8ArrayConstructor;
  132664. Float32Array: Float32ArrayConstructor;
  132665. mozURL: typeof URL;
  132666. msURL: typeof URL;
  132667. VRFrameData: any; // WebVR, from specs 1.1
  132668. DracoDecoderModule: any;
  132669. setImmediate(handler: (...args: any[]) => void): number;
  132670. }
  132671. interface HTMLCanvasElement {
  132672. requestPointerLock(): void;
  132673. msRequestPointerLock?(): void;
  132674. mozRequestPointerLock?(): void;
  132675. webkitRequestPointerLock?(): void;
  132676. /** Track wether a record is in progress */
  132677. isRecording: boolean;
  132678. /** Capture Stream method defined by some browsers */
  132679. captureStream(fps?: number): MediaStream;
  132680. }
  132681. interface CanvasRenderingContext2D {
  132682. msImageSmoothingEnabled: boolean;
  132683. }
  132684. interface MouseEvent {
  132685. mozMovementX: number;
  132686. mozMovementY: number;
  132687. webkitMovementX: number;
  132688. webkitMovementY: number;
  132689. msMovementX: number;
  132690. msMovementY: number;
  132691. }
  132692. interface Navigator {
  132693. mozGetVRDevices: (any: any) => any;
  132694. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132695. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132696. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  132697. webkitGetGamepads(): Gamepad[];
  132698. msGetGamepads(): Gamepad[];
  132699. webkitGamepads(): Gamepad[];
  132700. }
  132701. interface HTMLVideoElement {
  132702. mozSrcObject: any;
  132703. }
  132704. interface Math {
  132705. fround(x: number): number;
  132706. imul(a: number, b: number): number;
  132707. }
  132708. interface WebGLRenderingContext {
  132709. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  132710. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  132711. vertexAttribDivisor(index: number, divisor: number): void;
  132712. createVertexArray(): any;
  132713. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  132714. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  132715. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  132716. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  132717. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  132718. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  132719. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  132720. // Queries
  132721. createQuery(): WebGLQuery;
  132722. deleteQuery(query: WebGLQuery): void;
  132723. beginQuery(target: number, query: WebGLQuery): void;
  132724. endQuery(target: number): void;
  132725. getQueryParameter(query: WebGLQuery, pname: number): any;
  132726. getQuery(target: number, pname: number): any;
  132727. MAX_SAMPLES: number;
  132728. RGBA8: number;
  132729. READ_FRAMEBUFFER: number;
  132730. DRAW_FRAMEBUFFER: number;
  132731. UNIFORM_BUFFER: number;
  132732. HALF_FLOAT_OES: number;
  132733. RGBA16F: number;
  132734. RGBA32F: number;
  132735. R32F: number;
  132736. RG32F: number;
  132737. RGB32F: number;
  132738. R16F: number;
  132739. RG16F: number;
  132740. RGB16F: number;
  132741. RED: number;
  132742. RG: number;
  132743. R8: number;
  132744. RG8: number;
  132745. UNSIGNED_INT_24_8: number;
  132746. DEPTH24_STENCIL8: number;
  132747. MIN: number;
  132748. MAX: number;
  132749. /* Multiple Render Targets */
  132750. drawBuffers(buffers: number[]): void;
  132751. readBuffer(src: number): void;
  132752. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  132753. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  132754. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  132755. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  132756. // Occlusion Query
  132757. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  132758. ANY_SAMPLES_PASSED: number;
  132759. QUERY_RESULT_AVAILABLE: number;
  132760. QUERY_RESULT: number;
  132761. }
  132762. interface WebGLProgram {
  132763. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  132764. }
  132765. interface EXT_disjoint_timer_query {
  132766. QUERY_COUNTER_BITS_EXT: number;
  132767. TIME_ELAPSED_EXT: number;
  132768. TIMESTAMP_EXT: number;
  132769. GPU_DISJOINT_EXT: number;
  132770. QUERY_RESULT_EXT: number;
  132771. QUERY_RESULT_AVAILABLE_EXT: number;
  132772. queryCounterEXT(query: WebGLQuery, target: number): void;
  132773. createQueryEXT(): WebGLQuery;
  132774. beginQueryEXT(target: number, query: WebGLQuery): void;
  132775. endQueryEXT(target: number): void;
  132776. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  132777. deleteQueryEXT(query: WebGLQuery): void;
  132778. }
  132779. interface WebGLUniformLocation {
  132780. _currentState: any;
  132781. }
  132782. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  132783. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  132784. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  132785. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132786. interface WebGLRenderingContext {
  132787. readonly RASTERIZER_DISCARD: number;
  132788. readonly DEPTH_COMPONENT24: number;
  132789. readonly TEXTURE_3D: number;
  132790. readonly TEXTURE_2D_ARRAY: number;
  132791. readonly TEXTURE_COMPARE_FUNC: number;
  132792. readonly TEXTURE_COMPARE_MODE: number;
  132793. readonly COMPARE_REF_TO_TEXTURE: number;
  132794. readonly TEXTURE_WRAP_R: number;
  132795. readonly HALF_FLOAT: number;
  132796. readonly RGB8: number;
  132797. readonly RED_INTEGER: number;
  132798. readonly RG_INTEGER: number;
  132799. readonly RGB_INTEGER: number;
  132800. readonly RGBA_INTEGER: number;
  132801. readonly R8_SNORM: number;
  132802. readonly RG8_SNORM: number;
  132803. readonly RGB8_SNORM: number;
  132804. readonly RGBA8_SNORM: number;
  132805. readonly R8I: number;
  132806. readonly RG8I: number;
  132807. readonly RGB8I: number;
  132808. readonly RGBA8I: number;
  132809. readonly R8UI: number;
  132810. readonly RG8UI: number;
  132811. readonly RGB8UI: number;
  132812. readonly RGBA8UI: number;
  132813. readonly R16I: number;
  132814. readonly RG16I: number;
  132815. readonly RGB16I: number;
  132816. readonly RGBA16I: number;
  132817. readonly R16UI: number;
  132818. readonly RG16UI: number;
  132819. readonly RGB16UI: number;
  132820. readonly RGBA16UI: number;
  132821. readonly R32I: number;
  132822. readonly RG32I: number;
  132823. readonly RGB32I: number;
  132824. readonly RGBA32I: number;
  132825. readonly R32UI: number;
  132826. readonly RG32UI: number;
  132827. readonly RGB32UI: number;
  132828. readonly RGBA32UI: number;
  132829. readonly RGB10_A2UI: number;
  132830. readonly R11F_G11F_B10F: number;
  132831. readonly RGB9_E5: number;
  132832. readonly RGB10_A2: number;
  132833. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  132834. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  132835. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  132836. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  132837. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  132838. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  132839. 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;
  132840. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  132841. readonly TRANSFORM_FEEDBACK: number;
  132842. readonly INTERLEAVED_ATTRIBS: number;
  132843. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  132844. createTransformFeedback(): WebGLTransformFeedback;
  132845. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  132846. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  132847. beginTransformFeedback(primitiveMode: number): void;
  132848. endTransformFeedback(): void;
  132849. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  132850. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132851. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132852. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  132853. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  132854. }
  132855. interface ImageBitmap {
  132856. readonly width: number;
  132857. readonly height: number;
  132858. close(): void;
  132859. }
  132860. interface WebGLQuery extends WebGLObject {
  132861. }
  132862. declare var WebGLQuery: {
  132863. prototype: WebGLQuery;
  132864. new(): WebGLQuery;
  132865. };
  132866. interface WebGLSampler extends WebGLObject {
  132867. }
  132868. declare var WebGLSampler: {
  132869. prototype: WebGLSampler;
  132870. new(): WebGLSampler;
  132871. };
  132872. interface WebGLSync extends WebGLObject {
  132873. }
  132874. declare var WebGLSync: {
  132875. prototype: WebGLSync;
  132876. new(): WebGLSync;
  132877. };
  132878. interface WebGLTransformFeedback extends WebGLObject {
  132879. }
  132880. declare var WebGLTransformFeedback: {
  132881. prototype: WebGLTransformFeedback;
  132882. new(): WebGLTransformFeedback;
  132883. };
  132884. interface WebGLVertexArrayObject extends WebGLObject {
  132885. }
  132886. declare var WebGLVertexArrayObject: {
  132887. prototype: WebGLVertexArrayObject;
  132888. new(): WebGLVertexArrayObject;
  132889. };
  132890. // Type definitions for WebVR API
  132891. // Project: https://w3c.github.io/webvr/
  132892. // Definitions by: six a <https://github.com/lostfictions>
  132893. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  132894. interface VRDisplay extends EventTarget {
  132895. /**
  132896. * Dictionary of capabilities describing the VRDisplay.
  132897. */
  132898. readonly capabilities: VRDisplayCapabilities;
  132899. /**
  132900. * z-depth defining the far plane of the eye view frustum
  132901. * enables mapping of values in the render target depth
  132902. * attachment to scene coordinates. Initially set to 10000.0.
  132903. */
  132904. depthFar: number;
  132905. /**
  132906. * z-depth defining the near plane of the eye view frustum
  132907. * enables mapping of values in the render target depth
  132908. * attachment to scene coordinates. Initially set to 0.01.
  132909. */
  132910. depthNear: number;
  132911. /**
  132912. * An identifier for this distinct VRDisplay. Used as an
  132913. * association point in the Gamepad API.
  132914. */
  132915. readonly displayId: number;
  132916. /**
  132917. * A display name, a user-readable name identifying it.
  132918. */
  132919. readonly displayName: string;
  132920. readonly isConnected: boolean;
  132921. readonly isPresenting: boolean;
  132922. /**
  132923. * If this VRDisplay supports room-scale experiences, the optional
  132924. * stage attribute contains details on the room-scale parameters.
  132925. */
  132926. readonly stageParameters: VRStageParameters | null;
  132927. /**
  132928. * Passing the value returned by `requestAnimationFrame` to
  132929. * `cancelAnimationFrame` will unregister the callback.
  132930. * @param handle Define the hanle of the request to cancel
  132931. */
  132932. cancelAnimationFrame(handle: number): void;
  132933. /**
  132934. * Stops presenting to the VRDisplay.
  132935. * @returns a promise to know when it stopped
  132936. */
  132937. exitPresent(): Promise<void>;
  132938. /**
  132939. * Return the current VREyeParameters for the given eye.
  132940. * @param whichEye Define the eye we want the parameter for
  132941. * @returns the eye parameters
  132942. */
  132943. getEyeParameters(whichEye: string): VREyeParameters;
  132944. /**
  132945. * Populates the passed VRFrameData with the information required to render
  132946. * the current frame.
  132947. * @param frameData Define the data structure to populate
  132948. * @returns true if ok otherwise false
  132949. */
  132950. getFrameData(frameData: VRFrameData): boolean;
  132951. /**
  132952. * Get the layers currently being presented.
  132953. * @returns the list of VR layers
  132954. */
  132955. getLayers(): VRLayer[];
  132956. /**
  132957. * Return a VRPose containing the future predicted pose of the VRDisplay
  132958. * when the current frame will be presented. The value returned will not
  132959. * change until JavaScript has returned control to the browser.
  132960. *
  132961. * The VRPose will contain the position, orientation, velocity,
  132962. * and acceleration of each of these properties.
  132963. * @returns the pose object
  132964. */
  132965. getPose(): VRPose;
  132966. /**
  132967. * Return the current instantaneous pose of the VRDisplay, with no
  132968. * prediction applied.
  132969. * @returns the current instantaneous pose
  132970. */
  132971. getImmediatePose(): VRPose;
  132972. /**
  132973. * The callback passed to `requestAnimationFrame` will be called
  132974. * any time a new frame should be rendered. When the VRDisplay is
  132975. * presenting the callback will be called at the native refresh
  132976. * rate of the HMD. When not presenting this function acts
  132977. * identically to how window.requestAnimationFrame acts. Content should
  132978. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132979. * asynchronously from other displays and at differing refresh rates.
  132980. * @param callback Define the eaction to run next frame
  132981. * @returns the request handle it
  132982. */
  132983. requestAnimationFrame(callback: FrameRequestCallback): number;
  132984. /**
  132985. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132986. * Repeat calls while already presenting will update the VRLayers being displayed.
  132987. * @param layers Define the list of layer to present
  132988. * @returns a promise to know when the request has been fulfilled
  132989. */
  132990. requestPresent(layers: VRLayer[]): Promise<void>;
  132991. /**
  132992. * Reset the pose for this display, treating its current position and
  132993. * orientation as the "origin/zero" values. VRPose.position,
  132994. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132995. * updated when calling resetPose(). This should be called in only
  132996. * sitting-space experiences.
  132997. */
  132998. resetPose(): void;
  132999. /**
  133000. * The VRLayer provided to the VRDisplay will be captured and presented
  133001. * in the HMD. Calling this function has the same effect on the source
  133002. * canvas as any other operation that uses its source image, and canvases
  133003. * created without preserveDrawingBuffer set to true will be cleared.
  133004. * @param pose Define the pose to submit
  133005. */
  133006. submitFrame(pose?: VRPose): void;
  133007. }
  133008. declare var VRDisplay: {
  133009. prototype: VRDisplay;
  133010. new(): VRDisplay;
  133011. };
  133012. interface VRLayer {
  133013. leftBounds?: number[] | Float32Array | null;
  133014. rightBounds?: number[] | Float32Array | null;
  133015. source?: HTMLCanvasElement | null;
  133016. }
  133017. interface VRDisplayCapabilities {
  133018. readonly canPresent: boolean;
  133019. readonly hasExternalDisplay: boolean;
  133020. readonly hasOrientation: boolean;
  133021. readonly hasPosition: boolean;
  133022. readonly maxLayers: number;
  133023. }
  133024. interface VREyeParameters {
  133025. /** @deprecated */
  133026. readonly fieldOfView: VRFieldOfView;
  133027. readonly offset: Float32Array;
  133028. readonly renderHeight: number;
  133029. readonly renderWidth: number;
  133030. }
  133031. interface VRFieldOfView {
  133032. readonly downDegrees: number;
  133033. readonly leftDegrees: number;
  133034. readonly rightDegrees: number;
  133035. readonly upDegrees: number;
  133036. }
  133037. interface VRFrameData {
  133038. readonly leftProjectionMatrix: Float32Array;
  133039. readonly leftViewMatrix: Float32Array;
  133040. readonly pose: VRPose;
  133041. readonly rightProjectionMatrix: Float32Array;
  133042. readonly rightViewMatrix: Float32Array;
  133043. readonly timestamp: number;
  133044. }
  133045. interface VRPose {
  133046. readonly angularAcceleration: Float32Array | null;
  133047. readonly angularVelocity: Float32Array | null;
  133048. readonly linearAcceleration: Float32Array | null;
  133049. readonly linearVelocity: Float32Array | null;
  133050. readonly orientation: Float32Array | null;
  133051. readonly position: Float32Array | null;
  133052. readonly timestamp: number;
  133053. }
  133054. interface VRStageParameters {
  133055. sittingToStandingTransform?: Float32Array;
  133056. sizeX?: number;
  133057. sizeY?: number;
  133058. }
  133059. interface Navigator {
  133060. getVRDisplays(): Promise<VRDisplay[]>;
  133061. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133062. }
  133063. interface Window {
  133064. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133065. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133066. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133067. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133068. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133069. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133070. }
  133071. interface Gamepad {
  133072. readonly displayId: number;
  133073. }
  133074. type XRSessionMode =
  133075. | "inline"
  133076. | "immersive-vr"
  133077. | "immersive-ar";
  133078. type XRReferenceSpaceType =
  133079. | "viewer"
  133080. | "local"
  133081. | "local-floor"
  133082. | "bounded-floor"
  133083. | "unbounded";
  133084. type XREnvironmentBlendMode =
  133085. | "opaque"
  133086. | "additive"
  133087. | "alpha-blend";
  133088. type XRVisibilityState =
  133089. | "visible"
  133090. | "visible-blurred"
  133091. | "hidden";
  133092. type XRHandedness =
  133093. | "none"
  133094. | "left"
  133095. | "right";
  133096. type XRTargetRayMode =
  133097. | "gaze"
  133098. | "tracked-pointer"
  133099. | "screen";
  133100. type XREye =
  133101. | "none"
  133102. | "left"
  133103. | "right";
  133104. interface XRSpace extends EventTarget {
  133105. }
  133106. interface XRRenderState {
  133107. depthNear?: number;
  133108. depthFar?: number;
  133109. inlineVerticalFieldOfView?: number;
  133110. baseLayer?: XRWebGLLayer;
  133111. }
  133112. interface XRInputSource {
  133113. handedness: XRHandedness;
  133114. targetRayMode: XRTargetRayMode;
  133115. targetRaySpace: XRSpace;
  133116. gripSpace: XRSpace | undefined;
  133117. gamepad: Gamepad | undefined;
  133118. profiles: Array<string>;
  133119. }
  133120. interface XRSession {
  133121. addEventListener: Function;
  133122. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133123. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133124. requestAnimationFrame: Function;
  133125. end(): Promise<void>;
  133126. renderState: XRRenderState;
  133127. inputSources: Array<XRInputSource>;
  133128. }
  133129. interface XRReferenceSpace extends XRSpace {
  133130. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133131. onreset: any;
  133132. }
  133133. interface XRFrame {
  133134. session: XRSession;
  133135. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133136. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133137. }
  133138. interface XRViewerPose extends XRPose {
  133139. views: Array<XRView>;
  133140. }
  133141. interface XRPose {
  133142. transform: XRRigidTransform;
  133143. emulatedPosition: boolean;
  133144. }
  133145. declare var XRWebGLLayer: {
  133146. prototype: XRWebGLLayer;
  133147. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  133148. };
  133149. interface XRWebGLLayer {
  133150. framebuffer: WebGLFramebuffer;
  133151. framebufferWidth: number;
  133152. framebufferHeight: number;
  133153. getViewport: Function;
  133154. }
  133155. interface XRRigidTransform {
  133156. position: DOMPointReadOnly;
  133157. orientation: DOMPointReadOnly;
  133158. matrix: Float32Array;
  133159. inverse: XRRigidTransform;
  133160. }
  133161. interface XRView {
  133162. eye: XREye;
  133163. projectionMatrix: Float32Array;
  133164. transform: XRRigidTransform;
  133165. }
  133166. interface XRInputSourceChangeEvent {
  133167. session: XRSession;
  133168. removed: Array<XRInputSource>;
  133169. added: Array<XRInputSource>;
  133170. }